Angular esbuild @angular/compiler missing from bundle file

93 Views Asked by At

I have a shell application that works with https://single-spa.js.org/docs/api/ and https://github.com/systemjs/systemjs to run its various micro-frontends.

Now I have a brand new Angular application and I've wanted to make it worked with the new builder esbuild.

Run npm run build and end up with a main.js file. When I then try to run this file, it produces an error:

Uncaught Error: The injectable '_G' needs to be compiled using the JIT compiler, but '@angular/compiler' is not available. The injectable is part of a library that has been partially compiled. However, the Angular Linker has not processed the library such that JIT compilation is used as fallback.

Ideally, the library is processed using the Angular Linker to become fully AOT compiled. Alternatively, the JIT compiler should be loaded by bootstrapping using '@angular/platform-browser-dynamic' or '@angular/platform-server', or manually provide the compiler with 'import "@angular/compiler";' before bootstrapping.

Shouldn't the bundled file include the @angular/compiler library ?

Edit: Included package.json

  "dependencies": {
    "@angular-architects/ngrx-toolkit": "^0.1.2",
    "@angular/animations": "^17.2.0",
    "@angular/common": "^17.2.0",
    "@angular/compiler": "^17.2.0",
    "@angular/core": "^17.2.0",
    "@angular/elements": "^17.3.0",
    "@angular/forms": "^17.2.0",
    "@angular/platform-browser": "^17.2.0",
    "@angular/platform-browser-dynamic": "^17.2.0",
    "@angular/router": "^17.2.0",
    "@ngrx/signals": "^17.1.1",
    "@ngrx/store": "^17.1.1",
    "@ngrx/store-devtools": "^17.1.1",
    "@signicat/pubsub": "^2.0.0",
    "esbuild": "^0.20.2",
    "esbuild-plugin-manifest": "^1.0.3",
    "rxjs": "~7.8.0",
    "single-spa": "^6.0.1",
    "single-spa-angular": "^9.0.1",
    "tslib": "^2.3.0",
    "zone.js": "~0.14.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^17.2.3",
    "@angular/cli": "^17.2.3",
    "@angular/compiler-cli": "^17.2.0",
    "@types/jasmine": "~5.1.0",
    "jasmine-core": "~5.1.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.2.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.1.0",
    "typescript": "~5.3.2"
  }
1

There are 1 best solutions below

0
Akshay Goud On

Try

npm install @angular/compiler

or

yarn add @angular/compiler 

Clear Cache and Reinstall Dependencies

npm cache clean --force
npm install

or

yarn cache clean
yarn install