Open DorianGrey opened 7 years ago
/ping @svi3c
I've fixed the mentioned issues, and extracted the shared module declaration and handling to a different PR - https://github.com/flaviait/ng2-jspm-template/pull/41.
The problem: Since we annot roll-up our app to global, we have an increased bundle size of ~400K (from 892K to 1284K).
I'll see if there is a solution to this - although it seems to be a more general problem: Different from e.g. webpack, the resulting bundles are not really linked to each other, thus, completely bundling them might not work in terms of rolling up (that's why I'd moved the code to use bundle
so that System.registerDynamic
takes care of this).
However, the SystemJS runtime would be required anyway - it's used by Angular to load the target module.
Right. I think a different npm script for the alternative module bundling would be great, so we can merge this to the master branch. There is quite a bunch of npm scripts by now, but I'm reducing them step by step issue within #39. Maybe we can even handle this by a simple flag in the config file I'm introducing.
I'm afraid this won't be an easy task, since the parts of the bundling process are rather tightly connected to each other, like here: https://github.com/flaviait/ng2-jspm-template/pull/38/files#diff-b9cfc7f2cdf78a7f4b91a753d10865a2R212
The only valuable thing I can think would be:
The only alternative would be to implement something like the tools in angular-cli already provide: Parsing the source and checking for use of lazy routes. Suppose this would be even more complicated - might be useful with a particular plugin, but these cannot be chained (atm.?) and thus would conflict with plugin-typescript. Kinda... problematic.
Thoughts?
Yes, I'm currently implementing the usage of the JSPM API. Afterwards we may think of a well-suited solution.
... ok, the example itself is simple, but the way to support lazy loading wasn't.
SharedModule
to be able to import them from the lazily loaded modules. Might be required to add even more modules to the shared one.These is still an issue with theFixed in the third commit, as described here.TranslateModule
being used on shared modules or referenced by lazily loaded modules (see https://github.com/ocombe/ng2-translate/issues/232).jspm.browser.js
) to contain only those entries referring to modules which are lazily loaded.build
tobundle
: The lazy module could not have been built in global format (as the app was before), so it was required to push both to the same module format.System.import
, which is only possible with SystemJS or Webpack 2 atm.SystemJS.import
to start as well.Some things to note:
npm
task per bundle. We might consider to use a tool like jspm-bundler to simplify this process, especially since we might not be able to bundle concurrently due to the changes applied tojspm.browser.js
.@svi3c, have fun with reviewing 😄