-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Closed
Description
Command
build
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
angular 12
Description
Since angular 13 shipped with ESM package format only, if we build the project with bundleDependencies=false, it will report an error like this:
require() of ES Module /Users/kame/code/web/node_modules/@angular/core/fesm2015/core.mjs not supported.
I know we can set bundleDependencies=true to make the build work. But I found ssr render performance with all dependencies bundled is worse than unbundled in previous version(angular 12, not sure why).
Minimal Reproduction
Here is the minimal repo to reproduce the issue: https://github.com/ganatan/angular-ssr
Steps to reproduce:
- Clone the repo
- Change "bundleDependencies" option to false for server build in angular.json file
- Run command
npm run build:ssr
- Run
npm run serve:ssr
Exception or Error
node:internal/modules/cjs/loader:979
throw new ERR_REQUIRE_ESM(filename, true);
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/kame/code/github/angular-ssr/node_modules/@angular/common/fesm2015/common.mjs not supported.
Instead change the require of /Users/kame.chen/code/github/angular-ssr/node_modules/@angular/common/fesm2015/common.mjs to a dynamic import() which is available in all CommonJS modules.
at Object.8260 (/Users/kame.chen/code/github/angular-ssr/dist/angular-starter/server/main.js:517:18)
at __webpack_require__ (/Users/kame.chen/code/github/angular-ssr/dist/angular-starter/server/main.js:671:41)
at /Users/kame.chen/code/github/angular-ssr/dist/angular-starter/server/main.js:814:73
at /Users/kame.chen/code/github/angular-ssr/dist/angular-starter/server/main.js:870:3
at Object.<anonymous> (/Users/kame.chen/code/github/angular-ssr/dist/angular-starter/server/main.js:875:12) {
code: 'ERR_REQUIRE_ESM'
Your Environment
Angular CLI: 14.1.3
Node: 16.15.0
Package Manager: npm 8.5.5
OS: darwin x64
Angular: 14.1.3
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router, service-worker
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1401.3
@angular-devkit/build-angular 14.1.3
@angular-devkit/core 14.1.3
@angular-devkit/schematics 14.1.3
@nguniversal/builders 14.1.0
@nguniversal/express-engine 14.1.0
@schematics/angular 14.1.3
rxjs 7.5.6
typescript 4.7.4
Anything else relevant?
No response