question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Webpack AoT build fails

See original GitHub issue

Bug description:

Webpack AoT build fails when ng-bootstrap is in the mix. Several errors like the following appear:

ERROR in ./$$_gendir/~/@ng-bootstrap/ng-bootstrap/alert/alert.ngfactory.ts
Module parse failed: <PATH>\$$_gendir\node_modules\@ng-bootstrap\ng-bootstrap\alert\alert.ngfactory.ts Unexpected token (13:21)
You may need an appropriate loader to handle this file type.
| import * as i2 from '@ng-bootstrap/ng-bootstrap/alert/alert';
| import * as i3 from '@ng-bootstrap/ng-bootstrap/alert/alert-config';
| const styles_NgbAlert:any[] = ([] as any[]);
| export const RenderType_NgbAlert:i0.RendererType2 = i0.ɵcrt({encapsulation:2,styles:styles_NgbAlert,
|     data:{}});
 @ ./$$_gendir/ClientApp/app/app.module.server.ngfactory.ts 10:0-103
 @ ./ClientApp/boot.server.ts

Removing all references to ng-bootstrap resolves the build failure.

Solution proposed in #1381 has no effect. My tsconfig.json:

{
  "compilerOptions": {
    "module": "es2015",
    "moduleResolution": "node",
    "target": "es5",
    "sourceMap": true,
    "noImplicitAny": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "skipDefaultLibCheck": true,
    "skipLibCheck": true,
    "lib": [ "es6", "dom" ],
    "types": [ "webpack-env" ]
  },
  "exclude": [ "bin", "node_modules" ],
  "atom": { "rewriteTsconfig": false }
}

Version info

Angular: 4.3.3

ngtools/webpack: 1.5.5

Webpack: 2.7.0

ng-bootstrap: 1.0.0-alpha.30

Bootstrap: 4.0.0-alpha.6

OS: Win 10

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
alienlikecommented, Aug 25, 2017

I’ve just found the solution! It requires a small tweak to the webpack config provided by the VS2017 template. This will be resolved in the next release of the Microsoft SDK.

https://github.com/aspnet/JavaScriptServices/issues/1168#issuecomment-320026397

0reactions
alienlikecommented, Aug 24, 2017

Reopening this because it’s becoming more urgent that I find a solution. I’ve created a repo to reproduce the issue: https://github.com/alienlike/NgBootstrapAoT. To set this up, I created a brand new project using the Angular template provided by VS 2017 Preview 2. Then I simply added Bootstrap 4 and ng-bootstrap to the project. This causes the AoT build to begin failing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular 8 webpack AOT build failed - Cannot ... - Stack Overflow
In my case, it was ERROR in Cannot read property 'name' of undefined while I was trying to run npm run build in...
Read more >
Webpack AOT build errors - Material Design for Bootstrap
Topic: Webpack AOT build errors ... A question was posed earlier by someone stating that your project throws errors in Jhipster (or any...
Read more >
Angular 8 Webpack Aot Build Failed - Cannot Read ... - ADocLib
Hi, i just tried to migrate to Angular 9 and followed the Instruction. But getting this mistake:ERROR in Cannot read property 'length' of...
Read more >
@ngtools/webpack - npm
Webpack plugin that AoT compiles your Angular components and modules. ... TypeScript files with other TypeScript files in the build.
Read more >
Ahead-of-time (AOT) compilation - Angular
Detect template errors earlier, The AOT compiler detects and reports template binding errors during the build step before users can see them.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found