Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(@angular-devkit/build-angular): add experimentalRollupPass #15690

Merged
merged 1 commit into from
Oct 10, 2019

Conversation

filipesilva
Copy link
Contributor

@filipesilva filipesilva commented Sep 26, 2019

In applications that make heavy use of lazy routes and ES2015 libraries, this option can improve bundle sizes. It might also break your bundles in ways we don't understand fully, so please test and report any problems you find.

NOTE: the following are known problems with experimentalRollupPass

  • vendorChunk, commonChunk, namedChunks: these won't work, because by the time webpack sees the chunks, the context of where they came from is lost.
  • webWorkerTsConfig: workers must be imported via a root relative path (e.g.app/search/search.worker) instead of a relative path (/search.worker) because of the same reason as above.
  • loadChildren string syntax: doesn't work because rollup cannot follow the imports.

@filipesilva filipesilva force-pushed the rollup-plugin branch 2 times, most recently from 0bf71ec to 4f31795 Compare September 26, 2019 21:09
@filipesilva filipesilva changed the title feat(@angular-devkit/build-angular): add experimental Rollup concaten… feat(@angular-devkit/build-angular): add experimentalRollupPass Sep 26, 2019
* found in the LICENSE file at https://angular.io/license
*/

// Adapted from https://github.com/erikdesjardins/webpack-rollup-loader/blob/master/index.js
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module resolution logic and base plugin architecture were taken from https://github.com/erikdesjardins/webpack-rollup-loader.

We'll need to either include the original MIT license, or contribute a more general purpose setup back to the original project and use that instead of this modification. I've contacted the author in erikdesjardins/webpack-rollup-loader#25.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved by adding an additional license header crediting the original author and license as of used SHA:

/**
 * @license
 * @author Erik Desjardins
 * Forked as of SHA 10fb020f997a146725963b202d79290c8798a7a0 from https://github.com/erikdesjardins/webpack-rollup-loader.
 * Licensed under a MIT license.
 * See https://github.com/erikdesjardins/webpack-rollup-loader/blob/10fb020f997a146725963b202d79290c8798a7a0/LICENSE for full license.
 */

@filipesilva
Copy link
Contributor Author

In a angular.io I saw a 164 kb total size reduction, of which 160 kb were in the main bundle. The app still seemed to work afterwards.

  • without experimentalRollupPass
kamik@RED-X1C6 MINGW64 /d/work/angular/aio (master)
$ du -ach --max-depth=1 dist-current/*-es2015*.js
8.0K    dist-current/10-es2015.bb774fbfdbb48a910b56.js
8.0K    dist-current/11-es2015.ec8e5e9d098af69706e6.js
4.0K    dist-current/12-es2015.ff447765d4dcc3cdbf3d.js
8.0K    dist-current/13-es2015.dc65283eabf796cbf8ec.js
16K     dist-current/14-es2015.db8ad428e08bac925985.js
92K     dist-current/5-es2015.c78d9a47687395e877ff.js
56K     dist-current/6-es2015.6bba842a651b1f9027de.js
4.0K    dist-current/7-es2015.7fce2a8bfaf0d140d20c.js
12K     dist-current/8-es2015.3387f5b73e6e053ee2ca.js
8.0K    dist-current/9-es2015.c2dc15fbac12f79fc42b.js
572K    dist-current/main-es2015.f9bd029fbcd2b80424ca.js
52K     dist-current/polyfills-es2015.a8a8b190a3d22b96a76b.js
4.0K    dist-current/runtime-es2015.b843df94cdf1ca019c37.js
844K    total
  • with experimentalRollupPass
kamik@RED-X1C6 MINGW64 /d/work/angular/aio (master)
$ du -ach --max-depth=1 dist-rollup/*-es2015*.js
8.0K    dist-rollup/10-es2015.3cc985d7c3319f055730.js
4.0K    dist-rollup/11-es2015.debfc94f984fa6a0fb50.js
8.0K    dist-rollup/12-es2015.9360d138e386d4702d90.js
8.0K    dist-rollup/13-es2015.525c075aff5aa96c53dd.js
8.0K    dist-rollup/14-es2015.36751c7863947ec28913.js
56K     dist-rollup/5-es2015.91b7fdaa30b328609bbe.js
88K     dist-rollup/6-es2015.014f97b73e13561afaf1.js
4.0K    dist-rollup/7-es2015.3ebcfad0d49d1f2c0a1e.js
12K     dist-rollup/8-es2015.19f1ea00491c6b553e39.js
16K     dist-rollup/9-es2015.0d1220debe4e53f393f4.js
412K    dist-rollup/main-es2015.b748da54ea794ed1d0a9.js
52K     dist-rollup/polyfills-es2015.a8a8b190a3d22b96a76b.js
4.0K    dist-rollup/runtime-es2015.5f093ee29eae729ea1b3.js
680K    total

@filipesilva filipesilva added the target: major This PR is targeted for the next major release label Sep 26, 2019
@filipesilva filipesilva requested a review from clydin September 26, 2019 21:53
@filipesilva
Copy link
Contributor Author

Blocking on reaching a resolution to the licensing issue in #15690 (comment).

@filipesilva filipesilva marked this pull request as ready for review September 26, 2019 21:54
@filipesilva filipesilva force-pushed the rollup-plugin branch 2 times, most recently from 299f370 to dd372a7 Compare October 1, 2019 18:00
// Bundle with Rollup
const rollupOptions = {
...options,
input: entryId,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: should we disable treeshaking, such as pure functional calls removals if scripts optimisation is false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't even want to use this if script optimization if false. But I haven't gotten around to further matching options into the rollup pass. I think it makes more sense to do that later after we start getting feedback from its shortcomings. We might have to add a lot of config then.

In applications that make heavy use of lazy routes and ES2015 libraries, this option can improve bundle sizes. It might also break your bundles in ways we don't understand fully, so please test and report any problems you find.

NOTE: the following are known problems with experimentalRollupPass
- vendorChunk, commonChunk, namedChunks: these won't work, because by the time webpack sees the chunks, the context of where they came from is lost.
- webWorkerTsConfig: workers must be imported via a root relative path (e.g.`app/search/search.worker`) instead of a relative path (`/search.worker`) because of the same reason as above.
- loadChildren string syntax: doesn't work because rollup cannot follow the imports.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants