angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

bug [email protected]: ng build --prod include all compiler in final bundle

Open sandangel opened this issue 8 years ago • 6 comments

Versions

<!--
Output from: `ng --version`.
If nothing, output from: `node --version` and `npm --version`.
  Windows (7/8/10). Linux (incl. distribution). macOS (El Capitan? Sierra?)
-->
$ ng version

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/

Angular CLI: 6.0.0-beta.5
Node: 8.10.0
OS: win32 x64
Angular: 5.2.8
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, service-worker

@angular/cdk: 5.2.4
@angular/cli: 6.0.0-beta.5
@angular/flex-layout: 5.0.0-beta.13
@angular/material: 5.2.4
@angular-devkit/build-optimizer: 0.4.5
@angular-devkit/core: 0.4.5
@angular-devkit/schematics: 0.4.5
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 6.0.0-beta.5
@schematics/angular: 0.4.5
@schematics/package-update: 0.4.5
typescript: 2.6.2
webpack-bundle-analyzer: 2.11.1
webpack: 4.0.1

Windows 10, yarn 1.5.1, npm 5.7.1, node 8.10.0

Repro steps

I can only provide the stats.json file generated by this command:

ng build --prod --sm --output-hashing=false --stats-json

angular 1.7.3: stats.txt

angular 6.0.0-beta5: https://ufile.io/0p2ke

Observed behavior

<!-- Normally this includes a stack trace and some more information. -->

angular/cli 1.7.3 image

angular/cli 6.0.0-beta5 image

Desired behavior

No compiler in final bundle when build with --prod

Mention any other details that might be useful (optional)

sandangel avatar Mar 09 '18 08:03 sandangel

Hi, I'm seeing the same issue.

Angular CLI: 6.0.0-beta.5 Node: 9.5.0 OS: darwin x64 Angular: 6.0.0-beta.7 ... animations, common, compiler, compiler-cli, core, forms ... http, language-service, platform-browser ... platform-browser-dynamic, router angular/cli: 6.0.0-beta.5 angular-devkit/build-optimizer: 0.4.5 angular-devkit/core: 0.4.5 angular-devkit/schematics: 0.4.5 ngtools/json-schema: 1.2.0 ngtools/webpack: 6.0.0-beta.5 schematics/angular: 0.4.5 schematics/package-update: 0.4.5 typescript: 2.6.2 webpack: 4.0.1

ng build --prod

chunk {main} main.js, main.js.map (main) 778 kB [initial] [rendered] chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 224 kB [initial] [rendered] chunk {runtime} runtime.js, runtime.js.map (runtime) 5.09 kB [entry] [rendered] chunk {scripts} scripts.js, scripts.js.map (scripts) 293 kB [rendered] chunk {styles} styles.js, styles.js.map (styles) 424 kB [initial] [rendered] chunk {vendor} vendor.js, vendor.js.map (vendor) 5.27 MB [initial] [rendered]

But Running ng build --target=production seems to be good :

chunk {scripts} scripts.7919ccceb3b0018336c0.js (scripts) 288 kB [rendered] chunk {0} runtime.5f9d33fb31487f0fdbf1.js (runtime) 1.05 kB [entry] [rendered] chunk {1} styles.3b9328888a1ada1ada41.css (styles) 313 kB [initial] [rendered] chunk {2} polyfills.f0578259d90544bd90ad.js (polyfills) 59.1 kB [initial] [rendered] chunk {3} main.37c0d0a04c33ab0e7152.js (main) 1.9 MB [initial] [rendered]

omahjoub avatar Mar 09 '18 11:03 omahjoub

Yes. In our refactoring of flags we removed the old parsing code and thus --prod was removed (as it was a weird alias case), and we forgot to put it back as a special flag. This will be addressed in the next beta.

For now you can use the long form --target=production.

hansl avatar Mar 09 '18 18:03 hansl

It does not work for me

 #ng build --target=production
Project 'production' could not be found in workspace.
Error: Project 'production' could not be found in workspace.

code2nguyen avatar Apr 23 '18 21:04 code2nguyen

@code2nguyen I too faced similar issue but when I changed prod to production in angular.json file I was able to build using ng build --prod

angular.json

         "configurations": {
            "production": {  //<---- changed from `prod` to `production`
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ]
            }
          }

hope it helps you.

candidJ avatar May 07 '18 15:05 candidJ

Thanks for reporting this issue. This issue is now obsolete due to changes in the recent releases. Please update to the most recent Angular CLI version.

If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.

alan-agius4 avatar Feb 05 '19 12:02 alan-agius4

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.