Dojo构建1.7内置程序包不起作用 [英] Dojo build 1.7 built packages does not work
问题描述
您可以在下面看到我的app.profile.js
文件的内容。我从命令提示符执行
build profile = .. / .. / app.profile.js -r
这行,进程后没有错误已经完成了。我的问题是如果我将这些软件包的版本(内置)复制到存在未完成版本的位置,我会收到太多的JavaScript错误,如 Error:multipleDefine
。即使我只复制dojo,dojox和dijit文件夹,同样的错误仍然发生。
当我查看两个js文件的构建和未构建之间的区别(例如dojo / Deferred)时,我意识到的唯一区别是:
//内建
define(dojo / Deferred,[
./_base/lang,
./promise/CancelError,
./promise/Promise
],function(
define([
./_base/lang,
./promise/取消错误,
./promise/Promise
],函数(
所以我一开始就有点困惑,我想尝试使用图层来尽可能地减少http请求,但是我需要一些关于我提到的情况的帮助,任何帮助将不胜感激,谢谢。 >
app.profile.js:
var profile = {
basePath:..,
layerOptimize:shrinksafe.keepLines,
optimize:shrinksafe,
releaseDir :./release,
hasReport:true,
packages:[
{
name:dojo,
location:./ dojo
},
{
名称:dijit,
位置:./dijit
},
{
name:app,
location:./app
},
{
name:dtk,
location :./dtk
},
{
名称:dojox,
位置:./dojox
}
],
层:{
app / layers / core:{
include:[
dojo / _base / declare,
dtk / core / ILifeCycle,
dtk / core / AppConfig,
dtk / core / TopicContext,
dtk / core / NavigationContext,
doj o / require,
dojo / _base / Deferred,
dojo / DeferredList,
dojo / _base / lang
]
},
app / layers / appcontext:{
include:[
dtk / core / AppContext
],
exclude:[
层/核心
]
}
}
};
Dojo构建器将向每个模块添加一个模块标识符定义,除非你告诉它不要。这可以产生 multipleDefine错误。
从建立者文档:
insertAbsMids(default = undefined) p>
- [truthy] 导致转换确保每个AMD定义
应用程序包含一个模块标识符参数。
- [falsy]
转换对定义
应用程序中的模块标识符参数没有任何作用。特别是,一个错误的值不会导致
转换去除
源代码中存在的模块标识符参数。
< blockquote>
我正在完全相同的问题,直到我添加了 insertAbsMids :false 到我的个人资料。
例如:
var profile = {
basePath :./,
releaseDir:release,
action:release,
layerOptimize:shrinksafe,
optimize:shrinksafe
css优化:comments,
mini:false,
insertAbsMids:false,
包:[
{name:dijit,location: djit},
{name:dojox,location:dojox},
{name:dojo,location:dojo}
]
}
I'm at the beginning of building my project and I get some errors that couldn't realize why they are being occured.
You can see contents of
my app.profile.js
file below. I execute"build profile=../../app.profile.js -r"
this line from command prompt and I get no error after the process is done. My problem is if I copy the release(built) version of these packages to the place where the unbuilt versions exist, I get too many javascript errors like "Error: multipleDefine
". Even if I copy only dojo, dojox and dijit folders, same errors are keep occuring.When I look the differences between built and unbuilt of two js files, (for example dojo/Deferred) the only difference I realize is this:
//built define("dojo/Deferred", [ "./_base/lang", "./promise/CancelError", "./promise/Promise" ], function(
define([ "./_base/lang", "./promise/CancelError", "./promise/Promise" ], function(
So I'm a little bit stucked at the beginning. I want to try using layers to reduce http requests as soon as possible but I need some help about the situation I mentioned. Any help will be greatly appreciated, thanks.
app.profile.js:
var profile = { basePath: "..", layerOptimize: "shrinksafe.keepLines", optimize: "shrinksafe", releaseDir: "./release", hasReport: true, packages: [ { name: "dojo", location: "./dojo" }, { name: "dijit", location: "./dijit" }, { name: "app", location: "./app" }, { name: "dtk", location: "./dtk" }, { name: "dojox", location: "./dojox" } ], layers: { "app/layers/core": { include: [ "dojo/_base/declare", "dtk/core/ILifeCycle", "dtk/core/AppConfig", "dtk/core/TopicContext", "dtk/core/NavigationContext", "dojo/require", "dojo/_base/Deferred", "dojo/DeferredList", "dojo/_base/lang" ] }, "app/layers/appcontext": { include: [ "dtk/core/AppContext" ], exclude: [ "app/layers/core" ] } } };
解决方案The Dojo builder will add a module identifier to every module definition unless you tell it not to. This can produce the multipleDefine error.
From the builder documentation:
insertAbsMids (default = undefined)
- [truthy] Causes the transform to ensure that every AMD define application includes a module identifier argument.
- [falsy] The transform does nothing to the module identifier argument in define applications. In particular, a falsy value doe not cause the transform to remove a module identifier argument that exists in the source code.
I was having exactly the same problem until I added insertAbsMids:false to my profile.
eg:
var profile = { basePath: "./", releaseDir: "release", action: "release", layerOptimize: "shrinksafe", optimize: "shrinksafe", cssOptimize: "comments", mini: false, insertAbsMids: false, packages: [ { name: "dijit", location :"dijit" }, { name: "dojox", location :"dojox" }, { name: "dojo", location :"dojo" } ] }
这篇关于Dojo构建1.7内置程序包不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!