获取依赖项以在requirejs(autobahn和whenjs)中正确加载
Getting dependencies to load correctly in requirejs (autobahn and whenjs)
在过去的几个小时里,我一直被这个问题困住了。我正在尝试让 autobahnjs 和 whenjs 由 requirejs 正确加载。
require.config({
paths: {
angular: '../bower_components/angular/angular',
angularBootstrap: '../bower_components/angular-bootstrap/ui-bootstrap',
bootstrap: '../bower_components/bootstrap/dist/js/bootstrap',
jquery: '../bower_components/jquery/jquery',
chosen: '../bower_components/chosen/chosen.jquery.min',
text: '../bower_components/requirejs-text/text',
autobahn: '../bower_components/autobahnjs/autobahn/autobahn'
},
packages: [
{ name: 'when', location: '../bower_components/when/', main: 'when' }
],
baseUrl: '/bundles/example/app/scripts/',
shim: {
angular : {
exports : 'angular'
},
angularBootstrap: {
deps: ['angular']
},
autobahn: {
deps: ['when']
}
},
priority: [
'angular'
]
});
require
( [
'angular',
'app',
'autobahn',
'angularBootstrap',
'jquery',
'bootstrap',
'chosen',
'controllers/event',
'services/notify'
], function(angular, app) {
// more code here
});
Autobahnjs依赖于whenjs。加载所有文件(并按正确的顺序)。但何时总是未定义的。我完全不知道我做错了什么。我已经尝试了各种方法来解决这个问题。我还有一个bower.json文件,如果这有助于任何人复制问题。提前谢谢。
编辑:Autobahnjs目前不支持AMD。但是,Whenjs确实支持它。
正如您已经注意到的,向AutobahnJS添加requirejs支持存在问题。AutobahnJS内部还有更多为了"方便"而捆绑的嵌入式内容,主要是来自cryptojs的部分。
挑战很简单:如何最好地为所有用户服务,无论他们是否使用什么模块加载器,以及他们是否想要方便(捆绑的东西)或更喜欢将东西分开(并自己管理/加载)。
我不能保证,但我试图优先解决这个问题。但是,对于进一步的讨论,我认为最好的地方是GitHub问题。
这现在已经在 v0.8.0 中实现
相关文章:
- 如何使用url加载程序在webpack中导入多个图像
- 如何在生成下载文件时显示加载动画
- 有没有任何方法可以将控制器从文件加载到ui路由器$stateProvider中
- 无法在通过jQuery的ajax加载的页面中执行javascript
- Emberjs应用程序加载在除Index之外的所有路由上
- 在chrome.tabs.onCreated之后加载HTML页面
- 单击F5时如何停止页面加载
- HTML5音频加载和播放获胜'我不能在iPad上工作
- 跟踪在页面加载时应用内联样式的JavaScript
- 在使用Polymer'加载所有json文件后执行方法;s的核心ajax
- jQuery Lazy加载动画滚动
- Html页面上的多个Base64图像和平滑加载
- 如何创建带有插槽的vue js组件预加载程序
- Webpack/Rect:遵循egghead.io教程,但出现错误:您可能需要一个合适的加载程序来处理此文件类型
- 如何使该数据在所有元素中加载
- Chrome扩展没有't在重新加载之前考虑期权价值
- 使用javascript在Flash中加载外部图像
- Ajax文件加载和<输入>文件加载
- 使用javascript函数在页面初始化后加载jquery
- 获取依赖项以在requirejs(autobahn和whenjs)中正确加载