-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Closed
Description
Bug Report or Feature Request (mark with an x
)
- [x] bug report -> please search issues before submitting
- [ ] feature request
Versions.
Angular CLI: 1.5.0
Node: 8.6.0
OS: darwin x64
Angular: 5.0.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.5.0
@angular-devkit/build-optimizer: 0.0.32
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.35
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.0
typescript: 2.4.2
webpack: 3.8.1
Repro steps.
If you set up Multiple Apps on angular-cli to share some code between apps and create routes with loadChildren. Some Lazy Modules are bundled even if it's not part of the app.
UPDATE: Here is a repo with my example code
https://github.com/leocaseiro/angular-cli-bug-issue-8321
Desired functionality.
I'd like to be able to do tree-shaking and avoid unnecessary code for some apps while I'm able to share code between apps.
Mention any other details that might be useful.
In my example, if you compile --app app1
or --app app2
both of apps are bundling chunks from the other app.
ng build -a app1
Date: 2017-11-03T00:56:34.672Z
Hash: 67c107e8f2f355ade09e
Time: 16699ms
chunk {for-both-apps.module} for-both-apps.module.23d24b6a1f133c64a0eb.chunk.js () 840 bytes [rendered]
chunk {for-one-only.module} for-one-only.module.c48a9d70cf5bc41775b1.chunk.js () 836 bytes [rendered]
chunk {for-two-only.module} for-two-only.module.e54917a2c951c2254c05.chunk.js () 837 bytes [rendered]
chunk {inline} inline.5c2e62dbc8c09c7d63c6.bundle.js (inline) 1.6 kB [entry] [rendered]
chunk {main} main.5cc16f5560486cefd10c.bundle.js (main) 243 kB [initial] [rendered]
chunk {polyfills} polyfills.ed1fc5df9e729422d99e.bundle.js (polyfills) 61.1 kB [initial] [rendered]
chunk {styles} styles.d41d8cd98f00b204e980.bundle.css (styles) 0 bytes [initial] [rendered]
Note that the chunk
for-two-only.module
is not part of the app2 and the router definition is only used on app1.
What is interesting, is that if you run
ng serve
, it doesn't compile the other LazyModules, like so:
ng serve -a app1
Date: 2017-11-03T00:58:53.910Z
Hash: 107ae163c129cb863c74
Time: 5969ms
chunk {for-both-apps.module} for-both-apps.module.chunk.js () 7.2 kB [rendered]
chunk {for-one-only.module} for-one-only.module.chunk.js () 7.14 kB [rendered]
chunk {inline} inline.bundle.js (inline) 5.79 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 26.7 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 560 kB [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 34.3 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 8.03 MB [initial] [rendered]
webpack: Compiled successfully.
PS: It might be related to #6677
ChrisMoffatt, daonhan, pauldraper, mina-skunk, ttugates and 2 more
Metadata
Metadata
Assignees
Labels
No labels