SFX optimization via rollup #205

Closed
wants to merge 4 commits into
from

Projects

None yet

5 participants

@guybedford
Member

This is a very first attempt for the simplest of scenarios to use rollup for SFX bundles when everything is ES6.

The next stage will be to widen this to any tree via a zebra striping algorithm variation.

@guybedford
Member

To apply this to arbitrary trees:

  1. Apply zebra striping

  2. Within each ES6 layer create a dummy module of its entry points to the layer above of the form:

    import * as A from 'entrypoint-A';
    import * as B from 'entrypoint-B';
    //...
    export {A,B,...}
  3. Optimize the zebra stripe from that dummy module into a single ES6 / System.register module with the dependencies of the stripe itself all set as externals.

  4. Output the dummy module as a new special unique name

  5. Each of the zebra entry points is then output as:

    entry-point-a-optimized.js

    System.register('A', ['dummy-optimized'], function(_export) {
      return {
        setters: [function(module) {
          _export(module.A);
        }],
        execute: function() {}
      };
    });
  6. Repeat for further zebra stripes

If there's only one stripe, we can obviously skip all the above.

@guybedford
Member

This optimization is now functional!

A limitation here is that we need to still handle applying Traceur / Babel in the pipeline which isn't done currently.

One thing that will make this trivial will be separating transpilers out into plugins and then updating this implementation to reflect that.

Waiting on progress there to land this.

@guybedford
Member

This would need to work by re-running the translate hook of the load record in question, and setting a metadata property say outputFormat = 'esm' to indicate to the plugin that it should output ES modules instead of System.register so we can perform these optimizations.

@amcdnl
amcdnl commented Aug 17, 2015

@guybedford do you have any docs for this?

@lookfirst
Contributor

👍

@kuraga
kuraga commented Nov 14, 2015

@rollup @systemjs @guybedford
Any news? Can you help, please? At least which tests should we have here?

@guybedford guybedford new algorithm approach, work in progress
3169ae5
@guybedford
Member

@kuraga this requires the new Babel plugin to work properly, so it will take a little while for things to fall into place still.

@guybedford
Member

Note - we do need to track how many distinct entry point parents a given inlinable module has and that it is inlined by all parents. If a single parent is not going to inline it, then we should not inline at all. In addition there is some cost analysis to be done, as a module loaded by 5 parent entry points and inlined into each of them becomes duplication, so we may even need to attempt optimization, and then be able to do back-tracking if we pass a duplication threshold as a further optimization.

@guybedford
Member

This has been merged into #442 for the 0.15 release.

@guybedford guybedford closed this Jan 1, 2016
@Gheoan Gheoan referenced this pull request in aurelia/skeleton-navigation Jan 7, 2016
Closed

aurelia + webpack #41

@EisenbergEffect

@guybedford Just a question about this. Does this process "erase" the modules? For example, after optimizing in this way, can I still call system.import('foo') or is foo's code present but foo's module identification gone?

@guybedford
Member

@EisenbergEffect it only works on sfx builds, not normal bundles, so only the sfx shell remains, with the optimizations happening internally (sfx modules don't expose their internal modules already).

@EisenbergEffect

I'm not overly familiar with what the sfx builds actually are that's different from normal I guess.

@guybedford
Member

@EisenbergEffect we're renaming sfx builds to jspm build and bundle to jspm bundle. The difference is that a bundle is just a network optimization to concatenate modules into a single file, while a build is a static optimization of the dependency tree turning it into a single module. I'll be posting some examples along with the alpha release this weekend :)

@EisenbergEffect

Gotcha. I think Aurelia apps will continue to use only the bundling, but it may be that the Aurelia library modules and plugins can use jspm build. I'll be interested to see the details on how that works and what the final output is. Thanks!

@kuraga
kuraga commented Jan 8, 2016

SFX build's good for Aurelia's examples (skeleton), isn't it?

@EisenbergEffect

No. Aurelia requires the module id to not be erased in order for things like the router and view location to work.

@paulfalgout paulfalgout referenced this pull request in samccone/The-cost-of-transpiling-es2015-in-2016 Feb 2, 2016
Closed

add jspm #5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment