gpt4 book ai didi

javascript - Dojo build 1.7 内置包不起作用

转载 作者:搜寻专家 更新时间:2023-11-01 05:14:20 24 4
gpt4 key购买 nike

我正在开始构建我的项目,但我遇到了一些错误,这些错误无法理解它们发生的原因。

您可以在下面看到 my app.profile.js 文件的内容。我执行"build profile=../../app.profile.js -r" 命令提示符中的这一行,过程完成后我没有收到任何错误。我的问题是,如果我将这些包的发布(构建)版本复制到未构建版本存在的地方,我会收到太多 javascript 错误,例如“Error: multipleDefine”。即使我只复制 dojo、dojox 和 dijit 文件夹,同样的错误也会不断发生。

当我查看两个 js 文件的构建和未构建之间的差异时,(例如 dojo/Deferred)我意识到的唯一差异是:

//built 
define("dojo/Deferred", [
"./_base/lang",
"./promise/CancelError",
"./promise/Promise"
], function(

define([ 
"./_base/lang",
"./promise/CancelError",
"./promise/Promise"
], function(

所以我一开始有点卡住了。我想尽快尝试使用层来减少 http 请求,但我需要一些关于我提到的情况的帮助。任何帮助将不胜感激,谢谢。

应用程序配置文件.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"
]

}

}
};

最佳答案

Dojo 构建器将为每个模块定义添加一个模块标识符,除非您告诉它不要这样做。这会产生multipleDefine 错误

来自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.

在我将 insertAbsMids:false 添加到我的配置文件之前,我遇到了完全相同的问题。

例如:

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" }
]
}

关于javascript - Dojo build 1.7 内置包不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10897480/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com