admin管理员组文章数量:1405374
I have implemented requirejs across a multipage web application, which works fine but now I am trying to use r.js to create a single file of 'all' the modules except any of the third party libraries and frameworks such as jquery etc...
the broken down build file (build.js) looks like this:
({
baseUrl: "../",
out: "main-v0.1.js", //"charts-v0.1.js",
include: [
"bi/jquery/jquery.ui.autoplete",
"bi/jquery/jquery.uibobox",
"bi/ui/investmentselector"
],
wrap: true,
exclude: [
'jquery', 'jqueryui', 'jcanvas', 'jqtools', 'prettyphoto', 'cssSandpaper', 'knockout', 'datatables', 'handlebars'
],
preserveLicenseComments: false,
optimize: "none", // "uglify", "uglify2"
paths: {
handlebars : 'lib/handlebars',
/*hb runtime : 'lib/handlebars.runtime',*/
jquery : 'lib/jquery-1.9.1',
jqueryui : 'lib/jquery.ui/jquery-ui-1.10.3.min',
jcanvas : 'lib/jcanvas.min',
jqtools : 'lib/jquery.tools/jquery.tools.min',
prettyphoto : 'lib/jquery/jquery.prettyphoto-3.1.5.min',
BI : 'bi/BI',
sliderconnect : 'bi/charts/slider-connect',
cssSandpaper : 'lib/csssandpaper/cssSandpaper',
csstransform : 'bi/enhance/csstransform',
knockout : 'lib/knockout-2.2.1',
datatables : 'lib/jquery/jquery.dataTables',
// jquery ui widgets
uibobox : 'bi/jquery/jquery.uibobox',
uiautoplete : 'bi/jquery/jquery.ui.autoplete'
}
})
The jquery.ui.autoplete.js and jquery.uibobox.js files are custom jqueryui widgets without any define() wrapped around them. The module investmentselector.js (broken down) looks like this...
define(['jquery',
'bi/templates/investmentselector.js',
'bi/jquery/datatables/investmentselector.js',
'lib/JSLinq/JSLINQ.js',
'uibobox', 'uiautoplete'], function ($, tmp, datatables, jsLinq, uibobox, uiautoplete) {
'use strict';
var methods = {
// ... code
};
return methods;
});
what I am getting when I run r.js to build the single file named 'main-v0.1.js' is this...
Tracing dependencies for: D:/Files/Trunk/BestInvest.Select.Website/js/build/main
-v0.1.js
Error: Error: Module loading did not plete for: bi/ui/investmentselector, uic
ombobox, uiautoplete
The following modules share the same URL. This could be a misconfiguration if th
at URL only has one anonymous module in it:
D:/Files/Trunk/BestInvest.Select.Website/js/bi/jquery/jquery.ui.autoplete.js:
uiautoplete, bi/jquery/jquery.ui.autoplete
D:/Files/Trunk/BestInvest.Select.Website/js/bi/jquery/jquery.uibobox.js: uic
ombobox, bi/jquery/jquery.uibobox
at Function.build.checkForErrors (D:\Files\Trunk\BestInvest.Select.Website\j
s\build\r.js:27237:19)
Any ideas as to what is going on?
FYI the widget code (broken down again) looks like this...
$.widget("bi.bibobox", {
_create: function () {
// ...code
},
_destroy: function () { }
});
and...
$.widget("bi.biautoplete", {
_create: function () {
// ...code
},
_destroy: function () { }
});
Any help on this would be greatful, Thanks!
I have implemented requirejs across a multipage web application, which works fine but now I am trying to use r.js to create a single file of 'all' the modules except any of the third party libraries and frameworks such as jquery etc...
the broken down build file (build.js) looks like this:
({
baseUrl: "../",
out: "main-v0.1.js", //"charts-v0.1.js",
include: [
"bi/jquery/jquery.ui.autoplete",
"bi/jquery/jquery.ui.bobox",
"bi/ui/investmentselector"
],
wrap: true,
exclude: [
'jquery', 'jqueryui', 'jcanvas', 'jqtools', 'prettyphoto', 'cssSandpaper', 'knockout', 'datatables', 'handlebars'
],
preserveLicenseComments: false,
optimize: "none", // "uglify", "uglify2"
paths: {
handlebars : 'lib/handlebars',
/*hb runtime : 'lib/handlebars.runtime',*/
jquery : 'lib/jquery-1.9.1',
jqueryui : 'lib/jquery.ui/jquery-ui-1.10.3.min',
jcanvas : 'lib/jcanvas.min',
jqtools : 'lib/jquery.tools/jquery.tools.min',
prettyphoto : 'lib/jquery/jquery.prettyphoto-3.1.5.min',
BI : 'bi/BI',
sliderconnect : 'bi/charts/slider-connect',
cssSandpaper : 'lib/csssandpaper/cssSandpaper',
csstransform : 'bi/enhance/csstransform',
knockout : 'lib/knockout-2.2.1',
datatables : 'lib/jquery/jquery.dataTables',
// jquery ui widgets
uibobox : 'bi/jquery/jquery.ui.bobox',
uiautoplete : 'bi/jquery/jquery.ui.autoplete'
}
})
The jquery.ui.autoplete.js and jquery.ui.bobox.js files are custom jqueryui widgets without any define() wrapped around them. The module investmentselector.js (broken down) looks like this...
define(['jquery',
'bi/templates/investmentselector.js',
'bi/jquery/datatables/investmentselector.js',
'lib/JSLinq/JSLINQ.js',
'uibobox', 'uiautoplete'], function ($, tmp, datatables, jsLinq, uibobox, uiautoplete) {
'use strict';
var methods = {
// ... code
};
return methods;
});
what I am getting when I run r.js to build the single file named 'main-v0.1.js' is this...
Tracing dependencies for: D:/Files/Trunk/BestInvest.Select.Website/js/build/main
-v0.1.js
Error: Error: Module loading did not plete for: bi/ui/investmentselector, uic
ombobox, uiautoplete
The following modules share the same URL. This could be a misconfiguration if th
at URL only has one anonymous module in it:
D:/Files/Trunk/BestInvest.Select.Website/js/bi/jquery/jquery.ui.autoplete.js:
uiautoplete, bi/jquery/jquery.ui.autoplete
D:/Files/Trunk/BestInvest.Select.Website/js/bi/jquery/jquery.ui.bobox.js: uic
ombobox, bi/jquery/jquery.ui.bobox
at Function.build.checkForErrors (D:\Files\Trunk\BestInvest.Select.Website\j
s\build\r.js:27237:19)
Any ideas as to what is going on?
FYI the widget code (broken down again) looks like this...
$.widget("bi.bibobox", {
_create: function () {
// ...code
},
_destroy: function () { }
});
and...
$.widget("bi.biautoplete", {
_create: function () {
// ...code
},
_destroy: function () { }
});
Any help on this would be greatful, Thanks!
Share Improve this question asked Mar 21, 2014 at 15:03 quintonquinton 4391 gold badge8 silver badges14 bronze badges1 Answer
Reset to default 9Your include
option uses the full paths to your module instead of using the abbreviated names you've established in paths
. Use the names you have in paths
:
include: [
"uibobox",
"uiautoplete",
"bi/ui/investmentselector"
]
I've not seen another name defined for the last one so I've left it as-is. Generally, you don't want to have something like foo: "path/to/foo"
in your paths
and sometimes use foo
sometimes path/to/foo
when referring to the module in dependencies. You always want to use foo
, everywhere. Here, r.js
sees uibobox
(to take one example) and resolves its path through paths
. It sees "bi/jquery/jquery.ui.bobox"
in include
and resolves it by just adding the .js
and it points to the same file as the first case. Then it realizes that it has two modules pointing to the same file and can't process the file because ultimately the file needs to be associated with just one module.
I also notice that your define
call lists some of the dependencies with the .js
extension. This goes against the remended practice of not specifying the extension. And having sometimes the extension, sometimes not, could cause issues like what I've explained above.
本文标签:
版权声明:本文标题:javascript - single dependency across multiple modules - r.js "the following module share the same URL" - Stac 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744266540a2597973.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论