Command
test
Is this a regression?
The previous version in which this bug was not present was
No response
Description
The @angular/build:unit-test builder does not correctly handle local library dependencies installed via symlinks.
When a test target library imports another local library through a symlinked dependency, the test execution fails.
Attempting to enable symlink preservation using preserveSymlinks is not possible because this option is not supported by the @angular/build:unit-test schema.
Minimal Reproduction
Steps to reproduce
-
Create a local library package-b.
-
Create another local library package-a that imports and uses a reference exported by package-b.
-
Build both libraries.
-
Create a separate Angular workspace.
-
Inside this workspace, create a third library package-c.
-
Link the built versions of package-a and package-b into the new workspace node_modules using symlinks.
-
Update package-c to import and use a reference from package-a.
-
Add a unit test for package-c.
-
Run:
using the @angular/build:unit-test builder.
- The test execution fails.
Exception or Error
Error: Failed to resolve import "package-a" from "../../path/to/real/dist/package-b/fesm2022/package-b.mjs". Does the file exist?
Workaround
Developers are forced to manually alter tsconfig.spec.json to map internal node_modules paths to circumvent Vite's deep path resolution:
"compilerOptions": {
"paths": {
"package-a": ["../../node_modules/package-a"],
"package-b": ["../../node_modules/package-b"]
}
}
Your Environment
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI : 22.0.4
Angular : 22.0.2
Node.js : 24.16.0
Package Manager : npm 11.13.0
Operating System : linux x64
┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build │ 22.0.4 │ ^22.0.4 │
│ @angular/cli │ 22.0.4 │ ^22.0.4 │
│ @angular/common │ 22.0.2 │ ^22.0.0 │
│ @angular/compiler │ 22.0.2 │ ^22.0.0 │
│ @angular/compiler-cli │ 22.0.2 │ ^22.0.0 │
│ @angular/core │ 22.0.2 │ ^22.0.0 │
│ @angular/forms │ 22.0.2 │ ^22.0.0 │
│ @angular/localize │ 22.0.2 │ ^22.0.2 │
│ @angular/platform-browser │ 22.0.2 │ ^22.0.0 │
│ @angular/router │ 22.0.2 │ ^22.0.0 │
│ ng-packagr │ 22.0.0 │ ^22.0.0 │
│ rxjs │ 7.8.2 │ ~7.8.0 │
│ typescript │ 6.0.3 │ ~6.0.2 │
│ vitest │ 4.1.9 │ ^4.0.8 │
└───────────────────────────┴───────────────────┴───────────────────┘
Anything else relevant?
No response
Command
test
Is this a regression?
The previous version in which this bug was not present was
No response
Description
The
@angular/build:unit-testbuilder does not correctly handle local library dependencies installed via symlinks.When a test target library imports another local library through a symlinked dependency, the test execution fails.
Attempting to enable symlink preservation using
preserveSymlinksis not possible because this option is not supported by the@angular/build:unit-testschema.Minimal Reproduction
Steps to reproduce
Create a local library
package-b.Create another local library
package-athat imports and uses a reference exported bypackage-b.Build both libraries.
Create a separate Angular workspace.
Inside this workspace, create a third library
package-c.Link the built versions of
package-aandpackage-binto the new workspacenode_modulesusing symlinks.Update
package-cto import and use a reference frompackage-a.Add a unit test for
package-c.Run:
ng test package-cusing the
@angular/build:unit-testbuilder.Exception or Error
Workaround
Developers are forced to manually alter tsconfig.spec.json to map internal node_modules paths to circumvent Vite's deep path resolution:
Your Environment
Anything else relevant?
No response