下午好,
我正在尝试使用r.js优化基于Require.js和Backbone的源代码,但是我在编译期间遇到以下错误:
Tracing dependencies for: main
Cannot optimize network URL, skipping: empty:.js
TypeError: Cannot read property 'normalize' of undefined
In module tree:
main
app
router
views/main_panel/event_details
helpers/template_manager
我的template_manager模块不会尝试访问任何'normalize'属性,所以我真的不明白这是什么意思。 这是我的应用程序的入口点以及require.js配置。
require.config({
paths: {
order: 'libs/requirejs-plugins/order',
text: 'libs/requirejs-plugins/text',
jQuery: 'libs/jquery/jquery',
Underscore: 'libs/underscore/underscore',
Backbone: 'libs/backbone/backbone',
templates: '../templates',
Sync: 'helpers/sync'
}
});
require([
'app',
'event_manager',
'order!https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js',
'order!libs/underscore/underscore-min',
'order!libs/backbone/backbone-min',
'helpers/objects_extension',
'helpers/date_extension',
'helpers/assets'
], function(App){
App.initialize();
});
应用程序本身或多或少遵循this tutorial中的内容。 我的app.build.js文件如下
({
appDir: "../",
baseUrl: "js",
dir: "../app-build",
modules: [
{
name: "main"
}
],
paths: {
order: 'empty:',
text: 'empty:',
jQuery: 'empty:',
Underscore: 'empty:',
Backbone: 'empty:',
templates: '../templates',
Sync: 'helpers/sync'
}
})
感谢您的帮助。
答案 0 :(得分:4)
文本插件需要由加载程序加载才能处理文本! depenencies。 Loader插件作为构建的一部分执行以解析其资源。
所以它应该足以从路径配置中删除文本:“empty:”,并且只留下排除:in,因此它不包含在最终的构建结果中。这假设您在本地可以使用text.js以供优化器读取。