Angular 6 - Prod build fails with property 'call' of undefined in runtime.js
"dependencies": { "@angular/animations": "^6.0.0", "@angular/cdk": "^6.2.1", "@angular/common": "^6.0.0", "@angular/compiler": "^6.0.0", "@angular/core": "^6.0.0", "@angular/forms": "^6.0.0", "@angular/http": "^6.0.0", "@angular/material": "^6.2.1", "@angular/platform-browser": "^6.0.0", "@angular/platform-browser-dynamic": "^6.0.0", "@angular/router": "^6.0.0", "@fnando/sparkline": "^0.3.7", "@types/socket.io": "^1.4.34", "core-js": "^2.5.4", "countup.js-angular2": "^6.0.0", "d3": "^5.3.0", "d3-cloud": "^1.2.5", "hammerjs": "^2.0.8", "isobject": "^3.0.1", "js-base64": "^2.4.3", "leaflet": "^1.3.1", "leaflet.markercluster": "^1.3.0", "progressbar.js": "^1.0.1", "rxjs": "^6.0.0", "scrollmonitor": "^1.2.4", "simplebar": "^2.6.1", "socket.io": "^2.1.1", "zone.js": "^0.8.26" }, "devDependencies": { "@angular-devkit/build-angular": "^0.6.7", "@angular/cli": "^6.0.7", "@angular/compiler-cli": "^6.0.3", "@angular/language-service": "^6.0.3", "@types/jasmine": "^2.8.8", "@types/jasminewd2": "~2.0.3", "@types/node": "~8.9.4", "codelyzer": "~4.2.1", "jasmine-core": "~2.99.1", "jasmine-spec-reporter": "~4.2.1", "karma": "~1.7.1", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "^1.4.3", "karma-jasmine": "~1.1.1", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "^5.3.2", "ts-node": "~5.0.1", "tslint": "~5.9.1", "typescript": "~2.7.2" }
ng build - Everything works fine
ng build --prod (with or without --aot) - Running fails with the following error:
runtime.a66f828dca56eeb90e02.js:1 Uncaught TypeError: Cannot read property 'call' of undefined at p (code snippet: return r[e].call(n.exports,n,n.exports,p),n.l=!0, ... [following])
Working with cli 6.0.7. Same error with cli 6.0.0.
I got the same error but I just killed my ng serve and started serving again. it worked!
I know it's not the solution but my prod ng build --prod build's too successful.
Fixed via https://github.com/angular/angular-cli/pull/11488, we shouldn't have a dependency on 4.10.2 in our latest versions anymore.
Try for this..
ng build --prod --optimization=false
edit3: Updating to Angular 7 RC fixed it. See my other comment below.
I have this issue even with the latest dependencies. Turning off optimization fixes it. This started happening when I moved a large (non-angular) library outside of my project, bundled it with webpack, and added it as dependency to my application.
edit1: I have a suspicion it has something to do with reflect-metadata that my bundled library depends on due to class-transformer
edit2: I'm not so sure about that suspicion now because the angular compiler itself relies on reflect-metadata. The core-js polyfill provides it's own reflect metadata functionality so maybe there's a conflict but I doubt that's an issue for AOT because a comment in my pollyfill.ts says it can be removed for AOT. Removing it didn't solve the issue.
package.json:
"dependencies": {
"@angular/animations": "^6.1.9",
"@angular/common": "^6.1.9",
"@angular/compiler": "^6.1.9",
"@angular/core": "^6.1.9",
"@angular/forms": "^6.1.9",
"@angular/http": "^6.1.9",
"@angular/platform-browser": "^6.1.9",
"@angular/platform-browser-dynamic": "^6.1.9",
"@angular/router": "^6.1.9",
"rxjs": "^6.3.3",
"rxjs-compat": "^6.3.3",
...
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.8.4",
"@angular-devkit/build-ng-packagr": "^0.8.4",
"@angular/cli": "^6.2.4",
"@angular/compiler-cli": "^6.1.9",
"@angular/language-service": "^6.1.9",
"@angularclass/hmr": "^2.1.3",
"lerna": "^3.4.0",
"ts-node": "~7.0.0",
"tslib": "^1.7.1",
"typescript": "~2.9.2",
...
},
"resolutions": {
"typescript": "~2.9.2",
"reflect-metadata": "0.1.12"
}
yarn.lock
[email protected], reflect-metadata@^0.1.10, reflect-metadata@^0.1.2:
version "0.1.12"
webpack@^4.15.1:
version "4.20.2"
Encouraging news. Updating to angular version 7.0.0-rc0 and corresponding versions for @angular-devkit and @angular/cli fixed it! :)
package.json
"dependencies": {
"@angular/animations": "^7.0.0-rc.0",
"@angular/common": "^7.0.0-rc.0",
"@angular/compiler": "^7.0.0-rc.0",
"@angular/core": "^7.0.0-rc.0",
"@angular/forms": "^7.0.0-rc.0",
"@angular/http": "^7.0.0-rc.0",
"@angular/platform-browser": "^7.0.0-rc.0",
"@angular/platform-browser-dynamic": "^7.0.0-rc.0",
"@angular/router": "^7.0.0-rc.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.9.0-rc.1",
"@angular-devkit/build-ng-packagr": "^0.9.0-rc.1",
"@angular/cli": "7.0.0-rc.1",
"@angular/compiler-cli": "^7.0.0-rc.0",
"@angular/language-service": "^7.0.0-rc.0",
}
I'm still experiencing this issue as of CLI 7.0.3.
I had similar event-related issues when hovering on plots using plot.ly: `ERROR TypeError: "o[a] is undefined".
As some of you noticed, the --optimization=false is still generating quite a big bundle. It turns out that --build-optimizer=false also solved the problem in my case. But it generates a way smaller bundle than with the full optimization removed so that's great! I haven't found a clear definition of what optimization does but as i understand it, it's super set of parameters including build-optimizer, which removes the dead code through Tree shaking if i understand it right.
Still these are workarounds and the problem has to be fixed to allow all flags to work as expected.
Thank you for the tip, @virgile-hogman, it sounded like a good idea. However, for our project it did not work. The only change that did help, was to remove all optimization, which resized our main bundle from 600 KB to 5 MB.
Angular version was updated today to 7.1.2.
Does anyone have any other ideas?
For info, the issue i had when hovering on plots in prod mode is now solved!
This problem appeared with a fully optimized bundle, consisting of two parameters: optimization (minimizer) + buildOptimizer (tree shaking), which are enabled by default in prod mode, at least with Angular 7.
As stated here a few months ago, I had to turn the buildOptimizer off to make the application work, but now i can also enable it again and i'm convinced the solution came with a fix on the build of angular-plotly.js. At least it's the most rational explanation, as a double minimization (of the underlying plotly.js library) created some strange issues already with the minimizer step alone.
Now i have a fully optimized bundle, so that's great! :)
In short, maybe the cause is different, but check if you don't have some double minimization going on through your third-party dependencies, that could explain some issues with the prod mode.
--build-optimizer=false work for me , --optimization=false didn't work
I had the same issue with the angular-plotly library. The point looked to be the fact that this library was already calling a minified library (plotly.js in that case) and the double minification was the origin of the problem. The new version (1.0) of angular-plotly solved perfectly the issue. I hope that might help somebody...
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.