-
-
Notifications
You must be signed in to change notification settings - Fork 255
Angular2 usage #432
Comments
There are two 'polyfill' type dependencies for angular2 - zone.js and reflect-metadata If reflect-metadata can be automatically added that would be ideal. The same thing needs to happen with zone.js, but that's a little trickier as it patches a ton of browser APIs and thus really needs to be loaded first. These two approaches work for me till its automatic -
import 'zone.js'
import 'reflect-metadata' note that zone.js is (vexingly) the name of the npm module as well as the file... |
Thanks for the update - unfortunately override dependencies only apply to globals, because the spec doesn't provide the ability to add extra deps to existing ES6 modules. There is a new aliases feature exactly to allow this sort of thing via an override though, but it isn't implemented in overrides yet. One way to cheat would be to find a global higher in the angular tree than the part that needs these modules that we can shim, but it doesn't look like there are any files that could equally be globals in the tree unfortunately. Would be nice to at least document this somewhere for users otherwise so that it is clear as it seems to be a common catch at the moment. Will leave this issue open for now as well. |
see also robwormald/fix-me-rob@54e1d7e @guybedford we can add the appropriate config into the package.json in the distribution - so if you can let me know what the ideal config should look like, i'll add it into angular2. It's generated from this template - While we're at it: Some form of an es6 polyfill is needed - some of the ES6 Array methods are present in the commonJS source - Array.fill is the one that blows up for anyone who's reading. The traceur/babel runtimes satisfy this, but they don't necessarily get included when consuming the commonjs source. |
@robwormald Not sure if i can post this question here but after doing the above fix (like i did previously by manually including it) i indeed still see the following error:
How would i go about fixing this? How would i force commonjs to include a runtime like bable/traceur without doing it manually? |
@schippie That's the error you get when you don't include/import the es6-shim because TypeScript doesn't polyfill like traceur does. Read through this: https://gist.github.com/robwormald/429e01c6d802767441ec |
@johnlindquist his comment here disappeared pointing me towards the github link. And my comments over there disappeared as well, which is really weird. |
@schippie that discussion was happening over here: systemjs/systemjs#434 (comment) - don't worry, i've lost track too :D I'm seeing the same thing as @jimthedev over here systemjs/systemjs#434 (comment), looking into it now.... |
@jimthedev err, that's a big DUHHH on my part. presumably you're using TypeScript, and of course bundling isn't supported directly yet. The error message I'd seen previously while doing this mistakenly has changed, so it threw me for a bit of loop. Part of the reason I use a "virtual" directory here (app/) is that it means its trivial to change the location SystemJS pulls your source in from - so I've been using the TSC compiler to compile TS -> ES6 to /temp, and then mapping app/ to temp/ - then when you build (using traceur) everything works nicely. Bit of a faff workaround, but only temporary. |
@robwormald Ah. Makes total sense. Thanks. I'll keep an eye out for direct
|
/cc @robwormald
When installing Angular2 it still seems necessary to separately import and include
reflect-metadata
via:And then:
Ideally Angular2 would contain this reference in its override. It's probably as simple as adding
reflect-metadata
as a dependency and a shim, but it would be good to know the right way to do this.The text was updated successfully, but these errors were encountered: