angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.77k stars 11.97k forks source link

ES Build Angular - JIT compilation failed for NgModule ƒ DialogModule2() #24770

Closed thaoula closed 1 year ago

thaoula commented 1 year ago

Command

build

Is this a regression?

The previous version in which this bug was not present was

No response

Description

Hi Team,

We are trying to get the esbuild to compile our application and have encountered an other challenge.

The ng build command completes in about 45 seconds but the app does not run and reports the following error in the console-

Unhandled Promise rejection: The NgModule 'DialogModule2' needs to be compiled using the JIT compiler, but '@angular/compiler' is not available.

After trying to debug ... add break points at the points outlined in the stack trace. We see the that DialogModule2 is referencing node_modules/primeng/fesm5/primeng-dialog.js.

FYI - Due to some technical reasons we are stuck using primeng 9.1.0.

Minimal Reproduction

ng build The run app

Exception or Error

instrument.js:108 Unhandled Promise rejection: The NgModule 'DialogModule2' needs to be compiled using the JIT compiler, but '@angular/compiler' is not available.

Your Environment

Angular CLI: 15.2.0
Node: 16.18.1
Package Manager: npm 8.19.2
OS: darwin arm64

Angular: 15.2.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, localize, platform-browser, platform-browser-dynamic
... platform-server, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1502.0
@angular-devkit/build-angular   15.2.0
@angular-devkit/core            15.2.0
@angular-devkit/schematics      15.2.0
@schematics/angular             15.2.0
rxjs                            7.8.0
typescript                      4.8.4

Anything else relevant?

Due to some technical reasons we are stuck using primeng 9.1.0.

alan-agius4 commented 1 year ago

This seems like a bug but we'll need to look at a reproduction to find and fix the problem. Can you setup a minimal repro please?

You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

This might be related to your directory structure so its really important to get an accurate repro to diagnose this.

JoostK commented 1 year ago

The message suggests that the lib hasn't been AOT compiled, which in this case suggests that it hasn't been processed with ngcc.

primeng 9.1.0 is super old and not necessarily compatible with Angular 15, but I wonder if the esbuild builder runs ngcc automatically at all, or has the necessary main fields configuration, which might explain this?

clydin commented 1 year ago

The experimental esbuild-based builder does not provide support for ngcc and requires that all libraries are Ivy-compliant. The next major version of Angular (v16) will be removing ngcc support and as a result there are no current plans to support ngcc with the esbuild-based builder.

angular-automatic-lock-bot[bot] commented 1 year ago

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.