Dojo 1.9在加载语言环境时构建'multipleDefine'错误 [英] Dojo 1.9 build 'multipleDefine' error while loading locale

查看:557
本文介绍了Dojo 1.9在加载语言环境时构建'multipleDefine'错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


错误{src:

我的dojo应用程序在构建之后,在加载应用程序时抛出multipleDefine dojoLoader,info:Object}


消息:multipleDefine


info:Object {pid:dojo,mid:dojo / nls / dojo_en-us,pack:Object,
url:dojo / nls / dojo_en-us.js执行:5 ...}


这是我的个人资料:

  var profile = {
//`basePath`相对于包含此配置文件的目录;在这种情况下,它被设置为
// src /目录,它与加载器配置中`baseUrl`目录的位置相同。 (如果你更改
//这个,你也需要更新run.js.)
basePath:'../src/',

//这是目录中将放置内置软件包的版本目录。发行目录
//本身由`build.sh`定义。你应该不用这个;这是一个可追溯到Dojo
// 0.4的遗留选项。
//如果你这样做,你也需要更新build.sh。
// releaseName:'',

//构建新版本。
action:'release',

//从CSS文件中剪切所有注释和空格,并尽可能地内嵌@imports。
// cssOptimize:'comments',

//排除测试,演示和原始模板文件从构建版本中包含。
mini:true,

//使用Closure Compiler作为JavaScript minifier。这也可以设置为shrinksafe来使用ShrinkSafe,
//尽管ShrinkSafe已被弃用,不推荐。
//如果没有提供,此选项默认为(无压缩)。
optimize:'',

//我们正在构建图层,所以我们还需要设置分隔符来使用它们。
//如果没有提供,则默认为shrinksafe。
// layerOptimize:'closure',
layerOptimize:'',

//将所有对代码中的控制台函数调用。您还可以将此设置为警告,以剥离所有
//但是console.error,以及任何其他真实值来剥除除console.warn和console.error之外的所有内容。
//如果没有提供,默认为正常(除了警告和错误除外)。
stripConsole:'all',

//默认情况下,dojo.js构建中不包含默认选择器引擎,以便使移动版本的
//更小。我们将其添加回来,以避免额外的HTTP请求。还有一个lite选择器可用;如果
//你使用它,你也需要在`app / run.js`中设置`selectorEngine`属性。 (lite引擎是
//只有在不支持IE7和更早版本的情况下才适用)
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,

//构建可以分为多个不同的称为图层的JavaScript文件。这允许应用程序
//延迟加载大部分代码,直到实际需要,同时仍允许将多个模块
//编译为单个文件。
layers:{
//这是主要的加载器模块。这是一个特别的,因为它被视为一个AMD模块,即使
//它实际上只是纯粹的JavaScript。在这个
//模块ID中,构建系统有一些额外的魔力。
'dojo / dojo':{
//除了加载器`dojo / dojo`和加载器配置文件`app / run`之外,我们还包括
// main应用程序app / main和dojo / i18n和dojo / domReady模块,因为虽然它们是
//app / main中的所有条件依赖关系,但我们不想要额外HTTP请求这样的
//小文件。
包括:['dojo / i18n','dojo / domReady','app / main','app / run'],

//默认情况下,构建系统将尝试在`dojo / dojo`层中添加`dojo / main`,它增加了
//一堆我们不想要或需要的东西。我们希望初始脚本的加载速度尽可能地小到
//加载,所以我们将其配置为一个自定义的可引导的基础。
boot:true,
customBase:true
},
},

//为构建系统提供提示允许有条件地删除代码比
//更简单的模块依赖关系可以允许。这对于创建微小的移动版本尤其有用。
//请记住,死代码删除只在支持它的分解器中发生!目前,只有Closure Compiler
//到具有死代码删除的Dojo构建系统。
//可以在
//< http://dojotoolkit.org/reference-guide/dojo/has.html> ;.找到在工具包中使用的has-flags的文档列表。
staticHasFeatures:{
//跟踪&日志API用于调试加载程序,因此我们不需要在构建中。
'dojo-trace-api':0,
'dojo-log-api':0,

//这将导致正常的私有加载程序数据被公开以进行调试。在发布版本中,我们也不需要
//。
'dojo-publish-privates':0,

//这个应用程序是纯AMD,所以摆脱了旧的加载程序。
'dojo-sync-loader':0,

//`dojo-xhr-factory`依赖于我们已经删除的`dojo-sync-loader`。
'dojo-xhr-factory':0,

//我们没有在生产中加载测试,所以我们可以摆脱一些测试嗅探代码。
'dojo-test-sniff':0
}

}

这里是index.html里面的src /


注意: build.sh 负责在
部署到生产时删除isDebug标志。如果你修改这个标志,你将
打破构建!




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

<! - 加载加载器配置脚本。请注意,该模块ID在build.sh中是硬编码的,以便为
提供一个优化的构建,为整个应用程序加载一个脚本。如果您更改此模块的名称或
位置,则还需要更新build.sh。 - >
< script src =app / run.js>< / script>

这是在dist /


$ b $中生成的index.html b

 <!DOCTYPE html> 
< html>
< head>
< meta charset =utf-8>
< link rel =stylesheethref =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>

我检查过,确保dojo / nls / dojo_en-us.js存在,没关系。这个问题没有任何帮助。



任何帮助来解决这个问题,谢谢。

解决方案

我有类似的错误问题


multipleDefine


<当尝试将greensock库包含到我的dojo项目中时,blockquote>



当dojo外的另一个库声明自己的定义函数(在我的例子中是TweenMax),因为它们与dojo加载程序冲突。



解决方案是确保在您的库或脚本中调用dojo加载程序,该脚本使用定义函数。



所以dojo应该是最新的脚本加载到html

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

此问题也可以使用 jQuery UI 和其他库。


My dojo application breaks after building, during loading the app, throwing 'multipleDefine' and giving this error:

Error {src: "dojoLoader", info: Object}

Message: multipleDefine

info: Object {pid: "dojo", mid: "dojo/nls/dojo_en-us", pack: Object, url: "dojo/nls/dojo_en-us.js", executed: 5…}

Here is my profile:

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
}

}

and here is the index.html inside src/

NOTE: build.sh is responsible for removing the "isDebug" flag when deploying to production. If you modify this flag at all, you will break the build!

<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>

this is the generated index.html in dist/

<!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>

I checked to make sure that dojo/nls/dojo_en-us.js exists and it is fine. I am stuck at this point, having no clue!

Any help to fix this problem is appreciated.

解决方案

I had a similar issue with error

multipleDefine

when trying to include greensock library to my dojo project.

The issue appears when another library outside dojo declared its own define function (in my case was TweenMax) as they clash with dojo loader.

A solution is to make sure dojo loader is called after your library or script which use a define function have loaded.

So dojo should be the latest in your script to load in the html head:

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

This problem is also visible using jQuery UI and other libraries.

这篇关于Dojo 1.9在加载语言环境时构建'multipleDefine'错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆