Skip to content

Production build using buildOptimizer is broke but works without buildOptimizer (Angular v6/v7) #17255

Closed
@ClemensSchneider

Description

@ClemensSchneider

🐞 bug report

Affected Package

The issue is caused by package @angular-devkit/build-angular (this is my assumption)

Is this a regression?

Hard to tell as build-dependencies changed from Angular v5 to Angular v6 / v7, right?
Building the original v5 application using ng build --prod --build-optimizer=true spit out a working application at least.

Description

Building itself works but when trying to launch the application in the browser, an error is logged to the console:

main.8cc841c62bc65dc4efeb.js:1 Uncaught TypeError: (intermediate value)(intermediate value) is not a function
    at main.8cc841c62bc65dc4efeb.js:1
    at Object.RCq4.e.exports.12.../apply (main.8cc841c62bc65dc4efeb.js:1)
    at i (main.8cc841c62bc65dc4efeb.js:1)
    at main.8cc841c62bc65dc4efeb.js:1
    at main.8cc841c62bc65dc4efeb.js:1
    at main.8cc841c62bc65dc4efeb.js:1
    at Object.RCq4.e.exports.32../lib/Promise (main.8cc841c62bc65dc4efeb.js:1)
    at i (main.8cc841c62bc65dc4efeb.js:1)
    at main.8cc841c62bc65dc4efeb.js:1
    at Object.RCq4.e.exports.1.../callbacks (main.8cc841c62bc65dc4efeb.js:1)

When setting buildOptimizer to false, everything works out as expected (no error is logged and application launches).

🔬 Minimal Reproduction

Check out https://github.com/ClemensSchneider/angular-buildoptimizer-bug/tree/angular7 (or https://github.com/ClemensSchneider/angular-buildoptimizer-bug/tree/angular6 for the Angular v6 version).

Run yarn to install dependencies, then run yarn build to build the production build with buildOptimizer enabled.
Serve the resulting artifacts in dist/build-optimizer-bug with a regular http-server and open the application in the browser. You can see, that it errors out without displaying anything.

Then, turn off buildOptimizer in angular.json and run yarn build again. Open the resulting artifacts in the browser again and see, that everything works as expected.

🔥 Exception or Error


main.8cc841c62bc65dc4efeb.js:1 Uncaught TypeError: (intermediate value)(intermediate value) is not a function
    at main.8cc841c62bc65dc4efeb.js:1
    at Object.RCq4.e.exports.12.../apply (main.8cc841c62bc65dc4efeb.js:1)
    at i (main.8cc841c62bc65dc4efeb.js:1)
    at main.8cc841c62bc65dc4efeb.js:1
    at main.8cc841c62bc65dc4efeb.js:1
    at main.8cc841c62bc65dc4efeb.js:1
    at Object.RCq4.e.exports.32../lib/Promise (main.8cc841c62bc65dc4efeb.js:1)
    at i (main.8cc841c62bc65dc4efeb.js:1)
    at main.8cc841c62bc65dc4efeb.js:1
    at Object.RCq4.e.exports.1.../callbacks (main.8cc841c62bc65dc4efeb.js:1)

🌍 Your Environment

Angular Version (v7):


Angular CLI: 7.2.1
Node: 8.11.1
OS: win32 x64
Angular: 7.2.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.12.1
@angular-devkit/build-angular     0.12.1
@angular-devkit/build-optimizer   0.12.1
@angular-devkit/build-webpack     0.12.1
@angular-devkit/core              7.2.1
@angular-devkit/schematics        7.2.1
@angular/cli                      7.2.1
@ngtools/webpack                  7.2.1
@schematics/angular               7.2.1
@schematics/update                0.12.1
rxjs                              6.3.3
typescript                        3.2.2
webpack                           4.23.1

Angular Version (v6):


Angular CLI: 6.2.9
Node: 8.11.1
OS: win32 x64
Angular: 6.1.10
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.8.9
@angular-devkit/build-angular     0.8.9
@angular-devkit/build-optimizer   0.8.9
@angular-devkit/build-webpack     0.8.9
@angular-devkit/core              0.8.9
@angular-devkit/schematics        0.8.9
@angular/cli                      6.2.9
@ngtools/webpack                  6.2.9
@schematics/angular               0.8.9
@schematics/update                0.8.9
rxjs                              6.2.2
typescript                        2.9.2
webpack                           4.16.4

Anything else relevant?

The module on which the build optimization chokes is https://www.npmjs.com/package/autobahn

Metadata

Metadata

Assignees

Labels

featureIssue that requests a new featurefreq1: lowOnly reported by a handful of users who observe it rarely

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions