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

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

Closed
FrancescoBorzi opened this issue Aug 16, 2018 · 6 comments
Closed

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

FrancescoBorzi opened this issue Aug 16, 2018 · 6 comments
Labels
area: devkit/build-angular needs: more info Reporter must clarify the issue
Milestone

Comments

@FrancescoBorzi
Copy link

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.

@clydin
Copy link
Member

clydin commented 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.

@clydin clydin added needs: more info Reporter must clarify the issue area: devkit/build-angular labels Aug 16, 2018
@ngbot ngbot bot added this to the needsTriage milestone Aug 16, 2018
@FrancescoBorzi
Copy link
Author

@clydin there is nothing about aot in my angular.json (neither specifically enable or disable it) so shouldn't I assume that it's enabled by default when using --prod or not?

@alan-agius4
Copy link
Collaborator

Unless specified in your angular.json it will be false even if you use --prod As basically --prod implies to pick the prod build configuration that you have specified in your angular.json

The --prod will compile in AOT, when in your angular.json you have aot: true under your production configuration.

 "configurations": {
            "production": {
                  ...
                 "aot": true
            }
}

This flag is set by default to true, when you use ng new

@FrancescoBorzi
Copy link
Author

According to what you are saying, then what's written here is wrong:

https://angular.io/guide/aot-compiler#angular-compilation

@clydin
Copy link
Member

clydin commented Aug 17, 2018

It’s correct for new projects which by default have the aot option enabled in their production configuration.

@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 Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: devkit/build-angular needs: more info Reporter must clarify the issue
Projects
None yet
Development

No branches or pull requests

3 participants