gpt4 book ai didi

javascript - 是否可以使用 RequireJS 加载自定义 dojo 构建?

转载 作者:行者123 更新时间:2023-11-28 06:54:08 24 4
gpt4 key购买 nike

正在开发一个使用 RequireJS 的项目,并使用 Require 而不是 Dojo 加载器加载 dojo/dijit/dojox/dgrid。

我正在尝试优化 javascript 以减少 http 调用,而 RequireJS 优化器似乎无法优化 Dojo 模块。

是否可以创建一个 Dojo 自定义构建,然后使用 RequireJS 加载它?我已经尝试了一些构建,但还无法让它工作。我尝试的最后一个 Dojo 构建配置(成功运行)是:

var profile = {
basePath: '../src/',
action: 'release',
cssOptimize: 'comments',
mini: true,
optimize: 'closure',
layerOptimize: 'closure',

packages: [
'dgrid',
'dijit',
'dojo',
'dojox',
'put-selector',
'xstyle'
],

stripConsole: 'all',
selectorEngine: 'lite',

layers: {
'dojo/dojo': {
boot: false,
customBase: true,
include: [
'dojo/_base/array',
'dojo/_base/declare',
'dojo/_base/fx',
'dojo/_base/lang',
'dojo/_base/window',
'dojo/_base/xhr',
'dojo/aspect',
'dojo/cache',
'dojo/Deferred',
//'dojo/dojo',
'dojo/dom-class',
'dojo/dom-construct',
'dojo/dom-geometry',
'dojo/dom-style',
'dojo/dom',
'dojo/fx',
'dojo/has',
'dojo/keys',
'dojo/mouse',
'dojo/on',
'dojo/promise/all',
'dojo/query',
'dojo/request/registry',
'dojo/request/util',
'dojo/sniff',
'dojo/string',
'dojo/store/Cache',
'dojo/store/JsonRest',
'dojo/store/Memory',
'dojo/store/Observable',
'dojo/store/util/QueryResults',
'dojo/topic',
'dojo/when',
'dojox/uuid/generateRandomUuid',
'put-selector/put',
]
},
'dijit/dijit': {
include: [
'dijit/_TemplatedMixin',
'dijit/_Widget',
'dijit/dijit',
'dijit/form/CheckBox',
//'dijit/form/DateTextBox', // For some reason including this module causes the Dojo build to fail?
//'dijit/form/FilteringSelect', // For some reason including this module causes the Dojo build to fail?
//'dijit/form/MappedTextBox', // For some reason including this module causes the Dojo build to fail?
'dijit/form/TextBox',
'dijit/Menu',
'dijit/MenuItem',
'dijit/Tooltip',
]
},
'dgrid/dgrid': {
include: [
'dgrid/CellSelection', // Set the cell selection model
'dgrid/ColumnSet', //Adds frozen column capabilities.
'dgrid/Editor',
//'dgrid/extensions/ColumnHider', // For some reason including this module causes the Dojo build to fail?
'dgrid/extensions/ColumnReorder',
'dgrid/extensions/ColumnResizer',
'dgrid/extensions/CompoundColumns',
'dgrid/Grid',
'dgrid/Keyboard',
'dgrid/OnDemandGrid',
'dgrid/Tree',
'dgrid/util/misc',
'dgrid/util/touch',
]
},

},

staticHasFeatures: {
'config-deferredInstrumentation': 0,
'config-dojo-loader-catches': 0,
'config-tlmSiblingOfDojo': 0,
'dojo-amd-factory-scan': 0,
'dojo-combo-api': 0,
'dojo-config-api': 1,
'dojo-config-require': 0,
'dojo-debug-messages': 0,
'dojo-dom-ready-api': 1,
'dojo-firebug': 0,
'dojo-guarantee-console': 1,
'dojo-has-api': 1,
'dojo-inject-api': 1,
'dojo-loader': 0,
'dojo-log-api': 0,
'dojo-modulePaths': 0,
'dojo-moduleUrl': 0,
'dojo-publish-privates': 0,
'dojo-requirejs-api': 0,
'dojo-sniff': 1,
'dojo-sync-loader': 0,
'dojo-test-sniff': 0,
'dojo-timeout-api': 0,
'dojo-trace-api': 0,
'dojo-undef-api': 0,
'dojo-v1x-i18n-Api': 1,
'dom': 1,
'host-browser': 1,
'extend-dojo': 1
},

}

但是,当我尝试在 require 中加载优化层文件时,它会返回这个相当神秘的错误,并且应用程序不会加载:

Failed to load root module. Details: has.add is not a function

此外,如果我包含上面用注释标记的一些模块,将会导致 Dojo 构建失败。有什么想法吗?

有可能实现这个功能吗?目前我们只能使用 dgrid,所以如果这不起作用,唯一的选择就是删除 RequireJS。

提前致谢!

最佳答案

您需要使用source version Dojo 工具包的一部分。 AMD 模块的内置副本在加载程序之间不兼容。

关于javascript - 是否可以使用 RequireJS 加载自定义 dojo 构建?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32701679/

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