Conflict when consumer is using Traceur runtime
I am unable to consume DI when I am running my app through Traceur’s runtime:
https://gist.github.com/OliverJAsh/fd5b5edb86d92a34d296
I get the following error:
/Users/Oliver/Development/di-test/node_modules/di/node_modules/traceur/bin/traceur-runtime.js:631
var $__2 = $traceurRuntime.assertObject($traceurRuntime),
^
TypeError: Object #<Object> has no method 'assertObject'
at System.register.__moduleName (/Users/Oliver/Development/di-test/node_modules/di/node_modules/traceur/bin/traceur-runtime.js:631:30)
at Object.<anonymous> (/Users/Oliver/Development/di-test/node_modules/di/node_modules/traceur/bin/traceur-runtime.js:776:3)
at Module._compile (module.js:456:26)
at Module._extensions..js (module.js:474:10)
at Object.Module._extensions..js (/Users/Oliver/Development/di-test/node_modules/traceur/src/node/require.js:69:12)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/Oliver/Development/di-test/node_modules/di/node/index.js:4:1)
When using Traceur for your code as well, you should just compile DI yourself to make sure there is only one version of Traceur.
We need to document this.
@vojtajina Okay, is there an online example of a project consuming a compiled version of DI? I'm not sure how to fit that compilation step into my workflow (currently it's just a matter of requiring DI).
https://github.com/angular/templating compiles its deps.
Just install it with NPM as normally, and reference ./node_modules/di/src/ instead of ./node_modules/dist/amd/
When using Traceur for your code as well, you should just compile DI yourself to make sure there is only one version of Traceur.
I thought the way dependencies work in Node/npm would mitigate this. Surely DI would just use its version of Traceur in isolation? It'd be great to understand the why!
Traceur needs to extend/create globals (in browser or not) to be able to do what it does. Like implement promises and Sets/Maps. If not these would not be spec-compliant (which is sort of the whole point). Also, this (at the end of the day) runs in the browser, where you don't have npm/Node modules. You can hack CommonJS, but that's another story.
Suggestion: instead of compiling di.js at runtime (https://github.com/angular/di.js/blob/d6d42e10727b30d8a9d8d3277fb8a6d40f6ad251/node/index.js), could the compilation not just be done as an npm prepublish script? Not sure if that makes the development cycle more difficult though, although it does mean we don't have to worry about Traceur conflicts.
This is tricky for pre-built libraries that use DI/Traceur used in conjunction with code that uses a different version of Traceur. See angular/benchpress#21.