Bug Report or Feature Request (mark with an x)
- [x] bug report -> please search issues before submitting
- [ ] feature request
Versions.
Angular CLI: 1.5.0
Node: 8.7.0
OS: darwin x64
Angular: 5.0.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.5.0
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.35
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.3
typescript: 2.4.2
webpack: 3.8.1
Repro steps.
npm i -g @angular/cli@1.5.0
ng new esnext
cd esnext
# Set tsconfig.json target value as "es2015"
ng serve --prod
# Open browser and observe error
ng serve --prod --build-optimizer=false
# Open browser and observe working application
The log given by the failure.
main.3e29c45be9527f2aa1bf.bundle.js:1 ERROR TypeError: Cannot read property '_moduleDoBootstrap' of undefined
at e.donePromise.then (main.3e29c45be9527f2aa1bf.bundle.js:1)
at e.invoke (polyfills.ad37cd45a71cb38eee76.bundle.js:1)
at Object.onInvoke (main.3e29c45be9527f2aa1bf.bundle.js:1)
at e.invoke (polyfills.ad37cd45a71cb38eee76.bundle.js:1)
at r.run (polyfills.ad37cd45a71cb38eee76.bundle.js:1)
at polyfills.ad37cd45a71cb38eee76.bundle.js:1
at e.invokeTask (polyfills.ad37cd45a71cb38eee76.bundle.js:1)
at Object.onInvokeTask (main.3e29c45be9527f2aa1bf.bundle.js:1)
at e.invokeTask (polyfills.ad37cd45a71cb38eee76.bundle.js:1)
at r.runTask (polyfills.ad37cd45a71cb38eee76.bundle.js:1)
Desired functionality.
No error with build optimizer enabled.
Mention any other details that might be useful.
The issue was originally posted in #7797 (comment). I discovered that it is caused by build optimizer and not JIT mode, so creating separate issue for tracking purpose.
I traced it down back to this line. Changing amount of passed to 1 fixes the problem. It is probably a bug in UglifyJS after all, but I don't have enough expertise to trace it down and report correctly in their repo. Maybe somebody else can take it from here.
Relevant code snippet from exception:
bootstrapModuleFactory(e, t) {
const n = function(e) {
let t;
return t = "noop" === e ? new Lr : ("zone.js" === e ? void 0 : e) || new Dr({
enableLongStackTrace: Z()
})
}(t ? t.ngZone : void 0);
return n.run(()=>{
const t = jn.create([{
provide: Dr,
useValue: n
}], this.injector)
, r = e.create(t)
, o = r.injector.get(Wn, null);
if (!o)
throw new Error("No ErrorHandler. Is platform module (BrowserModule) included?");
return r.onDestroy(()=>K(this._modules, r)),
n.runOutsideAngular(()=>n.onError.subscribe({
next: e=>{
o.handleError(e)
}
})),
function(e, t, n) {
try {
const n = (()=>{
const e = r.injector.get(dr);
return e.runInitializers(),
exception here -> e.donePromise.then(()=>(this._moduleDoBootstrap(r),
r))
}
)();
return R(n) ? n.catch(n=>{
throw t.runOutsideAngular(()=>e.handleError(n)),
n
}
) : n
} catch (n) {
throw t.runOutsideAngular(()=>e.handleError(n)),
n
}
}(o, n)
}
)
}
Bug Report or Feature Request (mark with an
x)Versions.
Repro steps.
The log given by the failure.
Desired functionality.
No error with build optimizer enabled.
Mention any other details that might be useful.
The issue was originally posted in #7797 (comment). I discovered that it is caused by build optimizer and not JIT mode, so creating separate issue for tracking purpose.
I traced it down back to this line. Changing amount of passed to 1 fixes the problem. It is probably a bug in UglifyJS after all, but I don't have enough expertise to trace it down and report correctly in their repo. Maybe somebody else can take it from here.
Relevant code snippet from exception: