Repository navigation
Closed
Description
🐞 Bug report
What modules are related to this issue?
- aspnetcore-engine
- builders
- common
- express-engine
- hapi-engine
- module-map-ngfactory-loader
Is this a regression?
I don't know cause i was not using the previous version
Description
Prerendering always creates named chunks. If i run ng run app:build:production everything builds correctly https://prnt.sc/r2dytb , but if i run it with ng run app:prerender:production the lazy loaded modules are still named based on the module name https://prnt.sc/r2dzp1
🔬 Minimal Reproduction
- Create angular app (v9)
ng add @nguniversal/express-engine- create a module to lazy load
- run
ng run app:prerender:production
🌍 Your Environment
Angular CLI: 9.0.2
Node: 12.14.1
OS: win32 x64
Angular: 9.0.1
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.900.2
@angular-devkit/build-angular 0.900.2
@angular-devkit/build-optimizer 0.900.2
@angular-devkit/build-webpack 0.900.2
@angular-devkit/core 9.0.2
@angular-devkit/schematics 9.0.2
@angular/cli 9.0.2
@ngtools/webpack 9.0.2
@nguniversal/builders 9.0.0
@nguniversal/common 9.0.0
@nguniversal/express-engine 9.0.0
@schematics/angular 9.0.2
@schematics/update 0.900.2
rxjs 6.5.4
typescript 3.7.5
webpack 4.41.2
Reacted by Dmytro Tkachenko, Leo Osang, evil-morfar, Wenchen Li, Dennis Martin Herbers, trympet, Uri Shaked, andreasriemer and Lukas Holzer
Reacted by Exocomp and Dennis Martin Herbers
Activity
wagnermaciel commentedon Feb 14, 2020
@alan-agius4 This is interesting because the browser target we are passing to the prerender builder is
app:build:production. See add/index.ts. Do you have any idea why this happens?alan-agius4 commentedon Feb 14, 2020
Will need some debugging, I am also noticing that in one of screenshots sources are emitted while in the other screenshots they are not.
alan-agius4 commentedon Feb 14, 2020
@wagnermaciel I’d start by debugging here: https://github.com/angular/universal/blob/57a0399133ccb7bc43a5024e0c40c7f8fafa6180/modules/builders/src/prerender/index.ts#L31
scurk1415 commentedon Feb 15, 2020
I also noticed that the file sizes are not the same (which they probably should be) so i am guessing that it runs the serverTarget instead of browserTarget.
This is the output for the files if i run it with the serverTarget configuration (https://prnt.sc/r2mwif). Which is close to being the same as on my second screenshot when i ran
app:prerender:productionhttps://prnt.sc/r2dzp1 (based on file size)alan-agius4 commentedon Feb 19, 2020
I looked at this briefly and it seems that this is a bug related to Angular Devkit architect.
Did a small test to confirm
I did a custom builder that calls the browser target;
Executing the above will return the below (Note: while sourceMaps is false, they are still generated)
getTargetOptions { outputPath: 'dist/uni-pre/browser', index: 'src/index.html', main: 'src/main.ts', polyfills: 'src/polyfills.ts', tsConfig: 'tsconfig.app.json', aot: true, assets: [ 'src/favicon.ico', 'src/assets' ], styles: [ 'src/styles.css' ], scripts: [], fileReplacements: [ { replace: 'src/environments/environment.ts', with: 'src/environments/environment.prod.ts' } ], optimization: true, outputHashing: 'all', sourceMap: false, extractCss: true, namedChunks: false, extractLicenses: true, vendorChunk: false, buildOptimizer: true, budgets: [ { type: 'initial', maximumWarning: '2mb', maximumError: '5mb' }, { type: 'anyComponentStyle', maximumWarning: '6kb', maximumError: '10kb' } ] } Generating ES5 bundles for differential loading... ES5 bundle generation complete. chunk {3} polyfills-es5.041738d66a3982520e90.js, polyfills-es5.041738d66a3982520e90.js.map (polyfills-es5) 127 kB [initial] [rendered] chunk {2} polyfills-es2015.db39b23daa8851ccf344.js, polyfills-es2015.db39b23daa8851ccf344.js.map (polyfills) 35.7 kB [initial] [rendered] chunk {0} runtime-es2015.0811dcefd377500b5b1a.js, runtime-es2015.0811dcefd377500b5b1a.js.map (runtime) 1.51 kB [entry] [rendered] chunk {0} runtime-es5.0811dcefd377500b5b1a.js, runtime-es5.0811dcefd377500b5b1a.js.map (runtime) 1.51 kB [entry] [rendered] chunk {1} main-es2015.4da5b65032ea1b50beac.js, main-es2015.4da5b65032ea1b50beac.js.map (main) 27.1 kB [initial] [rendered] chunk {1} main-es5.4da5b65032ea1b50beac.js, main-es5.4da5b65032ea1b50beac.js.map (main) 27.3 kB [initial] [rendered] chunk {5} vendor-es2015.126aaec3f9743611b6ec.js, vendor-es2015.126aaec3f9743611b6ec.js.map (vendor) 215 kB [initial] [rendered] chunk {5} vendor-es5.126aaec3f9743611b6ec.js, vendor-es5.126aaec3f9743611b6ec.js.map (vendor) 260 kB [initial] [rendered] chunk {4} styles.8547d00c5fcaf5c47c33.css, styles.8547d00c5fcaf5c47c33.css.map (styles) 0 bytes [initial] [rendered] Date: 2020-02-19T08:46:11.724Z - Hash: a4caaf1c847b94bf8394 - Time: 24565msThe interesting part is that if we omit calling
context.getTargetOptionsprior tocontext.scheduleTargetthe result is different,.Let update our builder to;
Here's the result;
alan-agius4 commentedon Feb 19, 2020
Transferring to the CLI repo and chiming in @clydin
16 remaining items
alan-agius4 commentedon Apr 16, 2020
Hi all, we didn't forget about this issue.
It's just that it taking more time to find the root cause of the problem.
neo commentedon Apr 16, 2020
Thank you for the update!!
We really appreciate it and all your hard work!!
fix(@angular-devkit/core): workspace reader spread/rest operator usag…
fix(@angular-devkit/core): workspace reader spread/rest operator usag…
markanye commentedon Apr 22, 2020
@alan-agius4 Alan, I rebuilt the 9.1.2 release with your fix and I'm able to produce a prerender build without the maps. Thank you!
scurk1415 commentedon Apr 22, 2020
Thank you guys ♥
denisyilmaz commentedon Apr 22, 2020
is this already released via npm? I updated to Angular CLI 9.1.2 but still get the maps and named chunks with the prerender
alan-agius4 commentedon Apr 22, 2020
denisyilmaz commentedon Apr 22, 2020
Ah, I see. Thanks a lot
neo commentedon Apr 22, 2020
And it just got released! What a speedy release 😆
(cc @denisyilmaz)
Thanks again to @alan-agius4 finding an easy solution to a difficult bug 😂
d2kx commentedon Apr 22, 2020
Can confirm it works!! <3
Nice desu ne
angular-automatic-lock-bot commentedon May 23, 2020
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.
fix(@angular-devkit/core): workspace reader spread/rest operator usag…