-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Description
Command
test
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
with @angular-devkit/build-angular:karma
Description
Our project is a large enterprise application.
After migrating the test builder from @angular-devkit/build-angular:karma
to esbuild-based @angular/build:karma
, a significant number of our tests fail. The tests were all passing with the previous Webpack-based builder.
The primary errors are starting with TypeError: Cannot read properties of undefined (reading 'ɵmod')
and are followed by TypeError: Cannot read properties of undefined (reading '__ngAsyncComponentMetadataFn__')
which seems to be caused by stricter module and dependency resolution in the new builder.
This issue documents the patterns that were tolerated by the Webpack builder, but cause the esbuild builder to fail, making the migration very difficult for large-scale applications.
The production build of our app itself with ESBuild is working as expected with no issues after migration.
Minimal Reproduction
Have not been able to reproduce it in another repository
Exception or Error
1) Chrome Headless 138.0.0.0 (Mac OS 10.15.7) Component should do something FAILED
TypeError: Cannot read properties of undefined (reading 'ɵmod')
at getNgModuleDef (node_modules/@angular/core/fesm2022/core.mjs:1608:23)
at isNgModule (node_modules/@angular/core/fesm2022/core.mjs:16500:12)
at DepsTracker.computeNgModuleScope (node_modules/@angular/core/fesm2022/core.mjs:16682:13)
at DepsTracker.getNgModuleScope (node_modules/@angular/core/fesm2022/core.mjs:16637:24)
at DepsTracker.computeNgModuleScope (node_modules/@angular/core/fesm2022/core.mjs:16657:36)
at DepsTracker.getNgModuleScope (node_modules/@angular/core/fesm2022/core.mjs:16637:24)
at DepsTracker.computeNgModuleScope (node_modules/@angular/core/fesm2022/core.mjs:16657:36)
at DepsTracker.getNgModuleScope (node_modules/@angular/core/fesm2022/core.mjs:16637:24)
at transitiveScopesFor (node_modules/@angular/core/fesm2022/core.mjs:33185:33)
2) TypeError: Cannot read properties of undefined (reading '__ngAsyncComponentMetadataFn__')
at getAsyncClassMetadataFn (node_modules/@angular/core/fesm2022/core.mjs:20777:10)
at TestBedCompiler.maybeRegisterComponentWithAsyncMetadata (node_modules/@angular/core/fesm2022/testing.mjs:1235:29)
at TestBedCompiler.queueType (node_modules/@angular/core/fesm2022/testing.mjs:1243:10)
at TestBedCompiler.queueTypeArray (node_modules/@angular/core/fesm2022/testing.mjs:1224:14)
at queueTypesFromModulesArrayRecur (node_modules/@angular/core/fesm2022/testing.mjs:1305:16)
at queueTypesFromModulesArrayRecur (node_modules/@angular/core/fesm2022/testing.mjs:1306:11)
at queueTypesFromModulesArrayRecur (node_modules/@angular/core/fesm2022/testing.mjs:1306:11)
at TestBedCompiler.queueTypesFromModulesArray (node_modules/@angular/core/fesm2022/testing.mjs:1332:5)
at TestBedCompiler.configureTestingModule (node_modules/@angular/core/fesm2022/testing.mjs:839:12)
at _TestBedImpl.configureTestingModule (node_modules/@angular/core/fesm2022/testing.mjs:1955:19)
Your Environment
Angular CLI: 19.2.15
Node: 22.17.1
Package Manager: npm 10.9.2
OS: darwin arm64
Angular: 19.2.14
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.1902.15
@angular-devkit/core 19.2.15
@angular-devkit/schematics 19.2.15
@angular-devkit/schematics-cli 19.2.15
@angular/build 19.2.15
@angular/cdk 19.2.18
@angular/cdk-experimental 19.2.18
@angular/cli 19.2.15
@angular/material 19.2.18
@angular/material-experimental 19.2.18
@angular/material-moment-adapter 19.2.18
@schematics/angular 19.2.15
ng-packagr 19.2.2
rxjs 7.8.2
typescript 5.8.3
zone.js 0.15.1
Anything else relevant?
No response