[Question] Why using SystemJS to load async feature areas ?
- I'm submitting a ... [ ] bug report [ ] feature request [x] question about the decisions made in the repository
- Question:
Since the release of RC5 and NgModule, you are using System.import to load modules asynchronously. I was just wondering why. Since we are using webpack, is it redundant to have SystemJS ?
- Please tell us about your environment:
Angular version: 2.0.0-rc.5
I also would like to know this. We were using es6-promise-loader before right?
Maybe because is the recommended way by the Angular 2 staff, however since this repo was already working with es6-promise-loader i do wonder why.
Do not confuse System.import with SystemJS. System.import is to have dynamic imports and SystemJS is the Polyfill to allow to do this today. System.import is using ES6 promises, so not much different then what es6-promise-loader does. See here
That does make sense, instead of depending on that loader is best to rely on SystemJS to polyfill the System.import that JS is supposed to have in the future, basically getting ready for the future hoping some day we could drop the SystemJS library used to polyfill the import.
@katallaxie Is that right?
No, I think there are 2 things with the same name : SystemJS.
On one hand, there is the SystemJS that we all know - the module loader - and on the other hand there is the module loader API for ES6, the one we are using here.
I heard about it but I didn't know that they have the same name.
_ I'm not sure but that is what I understand._
@mildful SystemJS wants to harvest the same mechanism as System.import will do. Dynamically load modules. They provide an API based on Promise, which is polyfilled, that emulates this of System.import. What SystemJS and Webpack do in addition, is to produce these modules. So, the goal of SystemJS is, to have System.import work today, in all browsers, and to have the modules produced.
So it is in deed working as a polyfill in this context.
We are using the keywords System.import but it's not related to SystemJS since it's inlined as promises. Webpack 2 gives us this new promise base syntax which allows us to use that rather than our callback style syntax workaround wrapper (es6-promise-loader) require.ensure. Also, note that SystemJS uses the SystemJS global now to be backwards compatible with the future browser loader spec. See guybedford/systemjs-webpack-plugin that will allow SystemJS and Webpack to work together.