New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting undefined when creating a global function variable in a file loaded via require.js #69
Comments
Hmm, I'm not sure I fully understand the setup. Are you loading http://cdn.sockjs.org/sockjs-0.3.4.js directly from the CDN in a require statement? And what goes wrong? Could you quote the relevant output of buildProduction and describe the problem with it? |
I'm loading the sockjs module from a static file via reuirejs paths. When building, I get no errors, but when running the code in a browser I get: It all works running in the browser before using the builder. |
I couldn't reproduce the issue. Please provide more details:
|
app/main.js This is in the main.js file, that is loaded via data-main when loading requirejs (version 2.1.6): require.config({
baseUrl: 'app',
enforceDefine: false,
paths: {
jquery: '../vendor/jquery/jquery-1.8.3.min',
underscore: '../vendor/lodash/lodash.custom.min',
backbone: '../vendor/backbone/backbone-min',
sockjs: '../vendor/sockjs/sockjs-0.3.4',
text: '../vendor/text/text'
},
shim: {
backbone: {
// Dependencies to be loaded before backbone.js
deps: ['underscore', 'jquery'],
// Once loaded, use the global 'Backbone' as the module value
exports: 'Backbone'
}
}
}); |
Unfortunately I still cannot get it to fail in a reduced version where only SockJS is loaded: https://github.com/One-com/assetgraph-builder/tree/master/test/buildProduction/issue69 Perhaps it only happens when backbone and the other vendor scripts are added to the mix. Could you share a little more of your code? Maybe the main |
This issue is still relevant. I see error messages that are similar in some of the TodoMVC apps. I have rebased the issue69 branch onto master and will see if I can figure out the root cause. Since I see the same issues in non-AMD projects I suspect the minification process to be the culprit |
Hopefully this will be fixed with 5.0.0 now that we delegate to r.js for bundling. Please reopen if that's not the case. |
I'm using the sockjs-client module in a backbone+require.js setup.
(Sockjs-client on GH: https://github.com/sockjs/sockjs-client)
Source file: http://cdn.sockjs.org/sockjs-0.3.4.js
This part on line 30 seemed to be the problem:
And avoiding being global by adding a 'var' in front helped:
The text was updated successfully, but these errors were encountered: