-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Closed
Description
Which @angular/* package(s) are the source of the bug?
compiler
Is this a regression?
Yes
Description
When including the library typeorm using the default angular.json config with the new application builder there is an ESM interop error with the build system due to typeorm depending on the app-root-path module which uses the CommonJS global constant __dirname.
The documentation refers to CommonJS being compatible with third-party dependencies.
Please provide a link to a minimal reproduction of the bug
https://github.com/synthet1c/angular-typeorm-mvp
Please provide the exception or error you saw
ReferenceError: __dirname is not defined
at node_modules/app-root-path/index.js (/Users/founts/projects/angular-typeorm-mvp/.angular/cache/19.2.4/angular-typeorm-mvp/vite/deps_ssr/typeorm.js:2730:26)
at __require2 (/Users/founts/projects/angular-typeorm-mvp/.angular/cache/19.2.4/angular-typeorm-mvp/vite/deps_ssr/chunk-SOE35BD4.js:47:50)
at node_modules/typeorm/connection/ConnectionOptionsReader.js (/Users/founts/projects/angular-typeorm-mvp/.angular/cache/19.2.4/angular-typeorm-mvp/vite/deps_ssr/typeorm.js:5362:51)
at __require2 (/Users/founts/projects/angular-typeorm-mvp/.angular/cache/19.2.4/angular-typeorm-mvp/vite/deps_ssr/chunk-SOE35BD4.js:47:50)
at node_modules/typeorm/globals.js (/Users/founts/projects/angular-typeorm-mvp/.angular/cache/19.2.4/angular-typeorm-mvp/vite/deps_ssr/typeorm.js:57301:37)
at __require2 (/Users/founts/projects/angular-typeorm-mvp/.angular/cache/19.2.4/angular-typeorm-mvp/vite/deps_ssr/chunk-SOE35BD4.js:47:50)
at node_modules/typeorm/index.js (/Users/founts/projects/angular-typeorm-mvp/.angular/cache/19.2.4/angular-typeorm-mvp/vite/deps_ssr/typeorm.js:59834:26)
at __require2 (/Users/founts/projects/angular-typeorm-mvp/.angular/cache/19.2.4/angular-typeorm-mvp/vite/deps_ssr/chunk-SOE35BD4.js:47:50)
at eval (/Users/founts/projects/angular-typeorm-mvp/.angular/cache/19.2.4/angular-typeorm-mvp/vite/deps_ssr/typeorm.js:60148:28)
at async ESModulesEvaluator.runInlinedModule (file:///Users/founts/projects/angular-typeorm-mvp/node_modules/@angular/build/node_modules/vite/dist/node/module-runner.js:1049:5)
Please provide the environment you discovered this bug in (run ng version)
Angular CLI: 19.2.4
Node: 20.14.0
Package Manager: npm 10.7.0
OS: darwin arm64
Angular: 19.2.3
... common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1902.4
@angular-devkit/build-angular 19.2.4
@angular-devkit/core 19.2.4
@angular-devkit/schematics 19.2.4
@angular/cli 19.2.4
@angular/ssr 19.2.4
@schematics/angular 19.2.4
rxjs 7.8.2
typescript 5.7.3
zone.js 0.15.0
Anything else?
I've attempted to configure custom-webpack builder to shim __dirname but didn't have any luck with that and don't feel it's the right approach as I would lose the benefit of vite.
Metadata
Metadata
Assignees
Labels
No labels