Skip to content

Angular Linker fails for 'PlatformLocation' with Yarn Berry PnP, requiring JIT compiler #30385

Open
@laxsuryavanshi

Description

@laxsuryavanshi

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

No

Description

When building an Angular application using Yarn Berry with Plug'n'Play (PnP) enabled, I encounter an error indicating that the PlatformLocation injectable needs to be compiled using the JIT compiler because @angular/compiler is not available.

I am looking for a solution that allows us to continue using Yarn PnP without resorting to including @angular/compiler in the production build or disabling PnP.

Steps to reproduce the issue

  • ng new trackr --prefix trackr --routing --server-routing --skip-install --ssr --strict --style scss --package-manager yarn
  • Set "packageManager": "[email protected]" in package.json
  • yarn install
  • yarn build

Please provide a link to a minimal reproduction of the bug

https://github.com/laxsuryavanshi/ybng

Please provide the exception or error you saw

Application bundle generation failed. [4.326 seconds]

✘ [ERROR] An error occurred while extracting routes.

The injectable 'PlatformLocation' 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.

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 19.2.13
Node: 22.11.0
Package Manager: yarn 4.9.1
OS: darwin arm64

Angular: 19.2.13
... cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router, ssr

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1902.13 (cli-only)
@angular-devkit/build-angular   19.2.13
@angular-devkit/core            19.2.13 (cli-only)
@angular-devkit/schematics      19.2.13 (cli-only)
@schematics/angular             19.2.13 (cli-only)
rxjs                            7.8.2
typescript                      5.7.3
zone.js                         0.15.1

Anything else?

NodeJS 22.11.0
Yarn 4.9.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions