question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Different build results with --prod vs --prod --aot

See original GitHub issue

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

If I’m not mistaken, the Ahead of Time Compilation is currently enabled by default in ng build when run with --prod (as the documentation says).

However, apparently running ng build --prod and ng build --prod --aot leads to different results for me.

➜ ng build --prod --aot 10% building modules 3/3 modules 0 activeWarning: Can’t resolve all parameters for SpecificContentService in /path/to/specific-content.service.ts: ([object Object], ?). This will become an error in Angular v6.x 11% building modules 16/19 modules 3 active …path/to/src/assets/scss/main.scssWarning: Can’t resolve all parameters for SpecificContentService in /path/to/specific-content.service.ts: ([object Object], ?). This will become an error in Angular v6.x Warning: Can’t resolve all parameters for SpecificContentService in /path/to/specific-content.service.ts: ([object Object], ?). This will become an error in Angular v6.x Date: 2018-08-16T13:42:36.042Z Hash: 9af835d2f0354778401c Time: 45325ms chunk {main} main.js, main.js.map (main) 2.36 MB [initial] [rendered] chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 251 kB [initial] [rendered] chunk {runtime} runtime.js, runtime.js.map (runtime) 5.22 kB [entry] [rendered] chunk {styles} styles.js, styles.js.map (styles) 425 kB [initial] [rendered] chunk {vendor} vendor.js, vendor.js.map (vendor) 8.91 MB [initial] [rendered]

➜ ng build --prod

Date: 2018-08-16T13:45:37.414Z Hash: d950717427a9e25c7306 Time: 21065ms chunk {main} main.js, main.js.map (main) 878 kB [initial] [rendered] chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 251 kB [initial] [rendered] chunk {runtime} runtime.js, runtime.js.map (runtime) 5.22 kB [entry] [rendered] chunk {styles} styles.js, styles.js.map (styles) 425 kB [initial] [rendered] chunk {vendor} vendor.js, vendor.js.map (vendor) 7.29 MB [initial] [rendered]

As you can notice from the output, not only the bundle sizes are different but I even got warnings when using --prod --aot that I normally don’t get.

Command (mark with an x)

- [ ] new
- [x] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

Angular CLI: 6.1.3 Node: 8.10.0 OS: linux x64 Angular: 6.1.2 … animations, common, compiler, compiler-cli, core, forms … http, language-service, platform-browser … platform-browser-dynamic, router

Package Version

@angular-devkit/architect 0.7.3 @angular-devkit/build-angular 0.6.8 @angular-devkit/build-optimizer 0.6.8 @angular-devkit/core 0.7.3 @angular-devkit/schematics 0.7.3 @angular/cli 6.1.3 @ngtools/webpack 6.0.8 @schematics/angular 0.7.3 @schematics/update 0.7.3 rxjs 6.2.2 typescript 2.9.2 webpack 4.8.3

Repro steps

Run an Angular project with ng build --prod and compare its console output with ng build --prod --aot.

Desired functionality

The behaviour should be the same.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
clydincommented, Aug 16, 2018

--prod is an alias for --configuration=production and will use the settings defined within the production configuration for the project. If aot is not enabled within the configuration it will not enabled when build is run with the --prod option. If the aot option is in fact enabled within the production configuration, please provide the project’s angular.json file for further analysis.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 8, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AngularCli build and server --aot vs --prod - Stack Overflow
--prod is prod build (this will be smaller) --aot is ahead of time compilation. · Yeah but what does prod do that isn't...
Read more >
Angular Dev vs Prod Build - Medium
Development build produces source map files whereas production builds not. ... AOT compilation means angular component and templates are ...
Read more >
What's the difference between ng build - aot flag - Reddit
Hey, what's the difference between building for production with --aot flag and without it ? Is there any performance boost…
Read more >
Angular dev build vs prod build - YouTube
In this video we will discuss the differences between a development build and a production build in angular.Healthy diet is very important ...
Read more >
Ahead-of-time (AOT) compilation - Angular
Fewer asynchronous requests, The compiler inlines external HTML templates and CSS style sheets within the application JavaScript, eliminating separate ajax ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found