这是我得到的构建失败的升华.症状是,当使用shrinksafe进行优化时,我的构建将失败,并显示错误:
[exec] js: "<eval'ed string>#1(Function)#1(eval)", line 127: uncaught JavaScript runtime exception: TypeError: Cannot read property "1" from null
[exec] at <eval'ed string>#1(Function)#1(eval):127
[exec] at <eval'ed string>#1(Function)#1(eval):163
Run Code Online (Sandbox Code Playgroud)
如果我的代码在其nls文件中使用如下模式
"dojo/i18n!./nls/MyResource"
Run Code Online (Sandbox Code Playgroud)
但是,这个构造在很多dojo代码中很常见,它们构建得很干净.所以我通过将一些dojo代码复制到我的模块中进行了实验,发现如果将nls资源加载到dojo/dojo层中,那么我的图层构建正确,如果我在自己的图层中加载了相同的nls资源,那么我们就会失败.
因此,我将dijit/form/_ComboBoxMenuMixin.js复制到我自己的模块以及相应的nls资源.
我有三个测试用例,一个工作,另外两个给出上面的失败.
我的问题:
似乎我需要在"dojo/dojo"层中包含我自己的nls资源,它必须恰好是这一层.当然这不可能是对的吗?我有什么选择?
工作简介:
layers: {
"dojo/dojo" : {
customBase: false,
include: [
"modules/nls/ComboBox",
],
exclude: []
},
"MyLayer" : {
customBase: false,
include: [
"modules/ComboCopy",
],
exclude: []
},
}
Run Code Online (Sandbox Code Playgroud)
失败:同一层中的nls
layers: {
"dojo/dojo" : {
customBase: false,
include: [
],
exclude: []
},
"MyLayer" : {
customBase: false,
include: [
"modules/nls/ComboBox",
"modules/ComboCopy",
],
exclude: []
},
}
Run Code Online (Sandbox Code Playgroud)
失败,在另一个图层名称中加载nls
layers: {
"myNlsLayer" : {
customBase: false,
include: [
"modules/nls/ComboBox",
],
exclude: []
},
"MyLayer" : {
customBase: false,
include: [
"modules/ComboCopy",
],
exclude: []
},
Run Code Online (Sandbox Code Playgroud)
不应将NLS模块指定为包含在图层中.当你的层模块进行处理,所有的NLS依赖将被自动捆绑到相关层与对应于每个可能的区域设置的文件名的后缀.例如,对于一个层MyLayer.js,你也将获得一个MyLayer_en-us.js,MyLayer_es-es.js等等.这使游客只加载他们所需要的语言包.
如果你想强行包括图层中的特定区域(例如,因为你知道所有的访问者只说英语),你可以使用includeLocales属性可以这样做:
layers: {
MyLayer: {
includeLocales: [ 'en-us' ]
}
}
Run Code Online (Sandbox Code Playgroud)
虽然你的第一个人资料可能会出现的工作,这是不可能的,它实际上是在做你的期望,这可能是为什么ShrinkSafe的崩溃.
其他几点说明:
customBase标志仅应用于主dojo/dojo层,意思是"不自动包括默认道场基本模块".您无需将其应用于其他图层.