-->

道场1.9构建“multipleDefine”错误而载入区域(Dojo 1.9 build '

2019-09-03 21:52发布

建设,加载应用程序时,抛出“multipleDefine”,给这个错误后,我的道场应用程序中断:

错误{SRC: “dojoLoader” 信息:对象}

消息:multipleDefine

信息:对象{PID: “道场”,中期 “道场/ NLS / dojo_en-US”,包:对象,网址: “道场/ NLS / dojo_en-us.js”,执行:5 ...}

这是我的个人资料:

var profile = {
// `basePath` is relative to the directory containing this profile file; in this case, it is being set to the
// src/ directory, which is the same place as the `baseUrl` directory in the loader configuration. (If you change
// this, you will also need to update run.js.)
basePath: '../src/',

// This is the directory within the release directory where built packages will be placed. The release directory
// itself is defined by `build.sh`. You should probably not use this; it is a legacy option dating back to Dojo
// 0.4.
// If you do use this, you will need to update build.sh, too.
// releaseName: '',

// Builds a new release.
action: 'release',

// Strips all comments and whitespace from CSS files and inlines @imports where possible.
//cssOptimize: 'comments',

// Excludes tests, demos, and original template files from being included in the built version.
mini: true,

// Uses Closure Compiler as the JavaScript minifier. This can also be set to "shrinksafe" to use ShrinkSafe,
// though ShrinkSafe is deprecated and not recommended.
// This option defaults to "" (no compression) if not provided.
optimize: '',

// We're building layers, so we need to set the minifier to use for those, too.
// This defaults to "shrinksafe" if not provided.
//layerOptimize: 'closure',
layerOptimize: '',

// Strips all calls to console functions within the code. You can also set this to "warn" to strip everything
// but console.error, and any other truthy value to strip everything but console.warn and console.error.
// This defaults to "normal" (strip all but warn and error) if not provided.
stripConsole: 'all',

// The default selector engine is not included by default in a dojo.js build in order to make mobile builds
// smaller. We add it back here to avoid that extra HTTP request. There is also a "lite" selector available; if
// you use that, you will need to set the `selectorEngine` property in `app/run.js`, too. (The "lite" engine is
// only suitable if you are not supporting IE7 and earlier.)
selectorEngine: 'acme',


//localeList:"en-gb,en-us,de-de,es-es,fr-fr,it-it,pt-br,ko-kr,zh-tw,zh-cn,ja-jp",

// Builds can be split into multiple different JavaScript files called "layers". This allows applications to
// defer loading large sections of code until they are actually required while still allowing multiple modules to
// be compiled into a single file.
layers: {
    // This is the main loader module. It is a little special because it is treated like an AMD module even though
    // it is actually just plain JavaScript. There is some extra magic in the build system specifically for this
    // module ID.
    'dojo/dojo': {
        // In addition to the loader `dojo/dojo` and the loader configuration file `app/run`, we are also including
        // the main application `app/main` and the `dojo/i18n` and `dojo/domReady` modules because, while they are
        // all conditional dependencies in `app/main`, we do not want to have to make extra HTTP requests for such
        // tiny files.
        include: [ 'dojo/i18n', 'dojo/domReady', 'app/main', 'app/run' ],

        // By default, the build system will try to include `dojo/main` in the built `dojo/dojo` layer, which adds
        // a bunch of stuff we do not want or need. We want the initial script load to be as small and quick to
        // load as possible, so we configure it as a custom, bootable base.
        boot: true,
        customBase: true
    },
},

// Providing hints to the build system allows code to be conditionally removed on a more granular level than
// simple module dependencies can allow. This is especially useful for creating tiny mobile builds.
// Keep in mind that dead code removal only happens in minifiers that support it! Currently, only Closure Compiler
// to the Dojo build system with dead code removal.
// A documented list of has-flags in use within the toolkit can be found at
// <http://dojotoolkit.org/reference-guide/dojo/has.html>.
staticHasFeatures: {
    // The trace & log APIs are used for debugging the loader, so we do not need them in the build.
    'dojo-trace-api': 0,
    'dojo-log-api': 0,

    // This causes normally private loader data to be exposed for debugging. In a release build, we do not need
    // that either.
    'dojo-publish-privates': 0,

    // This application is pure AMD, so get rid of the legacy loader.
    'dojo-sync-loader': 0,

    // `dojo-xhr-factory` relies on `dojo-sync-loader`, which we have removed.
    'dojo-xhr-factory': 0,

    // We are not loading tests in production, so we can get rid of some test sniffing code.
    'dojo-test-sniff': 0
}

}

这里是内部SRC中的index.html /

注: build.sh负责部署到生产时删除“isDebug”标志。 如果你在所有修改这个标志,你会打破建立!

<script data-dojo-config="async: 1, tlmSiblingOfDojo: 0, locale:'en_US', isDebug: 1" src="dojo/dojo.js"></script>

<!-- Load the loader configuration script. Note that this module ID is hard-coded in build.sh in order to provide
     an optimised build that loads as few as one script for the entire application. If you change the name or
     location of this module, you will need to update build.sh too. -->
<script src="app/run.js"></script>

这是在蒸馏水生成的index.html /

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <link rel="stylesheet" href="app/resources/app.css">
    </head>
    <body class="claro">
        <script data-dojo-config=
            "async: 1, tlmSiblingOfDojo: 0, locale:'en_US', deps:['app/run']" 
            src="dojo/dojo.js"></script>
    </body>
</html>

我检查,以确保道场/ NLS / dojo_en-us.js存在,它是好的。 我被困在这一点上,没有线索!

任何有助于解决这个问题表示赞赏。

Answer 1:

您可以发布您需要run.js? 你需要“道场/ _base /配置”呢?

[只注意到了同样的错误,因为我忘了;)]

从文档:

需要注意的dojoConfig和道场/ _base /配置之间的区别是很重要的。 dojoConfig纯粹是为了输入目的,这是我们如何通信的配置参数,加载程序和模块。 在引导过程中,道场/ _base /配置是从这些参数用于通过模块后面的代码查找填充。



Answer 2:

我有错误的类似问题

multipleDefine

当试图包括使用GreenSock库我的道场项目。

当外界道场另一个库宣布自己出现问题define功能(在我的情况是TweenMax),因为他们对阵道场装载机。

一个解决方案是让它们使用资料库或脚本之后肯定道场程序叫define函数已加载。

所以道场应该是最新的脚本在HTML载入head

<head>
    <script src="yourLibrary.js"></script>
    <script src="dojo/dojo.js"></script>
</head>

这个问题也可见使用jQuery UI的和其他库。



Answer 3:

有一个关于这个装载机文档中说明(在此响应的时间反正)。

multipleDefine
AMD定义了被称为引用已经被定义的模块。 这个问题的最常见的原因是通过HTML文档中的元素加载模块。 使用装载机; 不使用的元素。 第二个最常见的原因是通过显式的模块标识符来定义; 不这样做,无论是。

https://dojotoolkit.org/reference-guide/1.10/loader/amd.html

许多图书馆现在实行UMD将基本上尝试自动检测AMD加载器的存在。 例如,引导程序 - 流行前端框架 - 实现了UMD。

下面这个例子就可以了(注意,引导将在全球范围加载):

<script src="path/to/bootstrap.js"></script><!--UMD packaged library-->
<script src="path/to/dojo/dojo.js"></script><!--then dojo loader-->

但第二例中将无法正常工作,因为UMD代码将检测AMD加载器,并用它来注册自己。 这将触发multipleDefine误差按文档。

<script src="path/to/dojo/dojo.js"></script><!--dojo loader first-->
<script src="path/to/bootstrap.js"></script><!--then UMD library-->

如果要加载库全球使用上面第一个例子并加载它bofore道场装载机。 如果要加载库作为AMD模块,使用装载机。



文章来源: Dojo 1.9 build 'multipleDefine' error while loading locale