angular-cli: Angular CLI 10.0.0-rc.2 breaks SSR bundleDependencies and generates multiple bundles

🐞 Bug report

Command (mark with an x)

  • [x ] build

Is this a regression?

Yes, the previous version in which this bug was not present was: 10.0.0-rc.0

Description

After updating my project to Angular CLI 10.0.0-rc.2, it seems that its not honoring the "bundleDependencies":true and generating multiple files.

Here’s my angular.json

"server": {
          "builder": "@angular-devkit/build-angular:server",
          "options": {
            "outputPath": "dist-server",
            "main": "src/main.server.ts",
            "tsConfig": "src/tsconfig.server.json"
          },
          "configurations": {
            "production": {
              "optimization": true,
              "outputHashing": "media",
              "sourceMap": false,
              "namedChunks": false,
              "extractLicenses": true,
              "bundleDependencies": true,
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ]
            }
          }
        }

Here’s my tsconfig

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "downlevelIteration": true,
    "outDir": "./dist/out-tsc",
    "sourceMap": false,
    "declaration": false,
    "module": "es2020",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es2015",
    "typeRoots": [
      "./typings",
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  }
}

and here’s tsconfig.server

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "baseUrl": "./",
    "target": "es2016"
},
  "angularCompilerOptions": {
    "entryModule": "app/app.module.server#AppServerModule",
    "enableIvy": true
  },
  "exclude": [
    "main.ts",
    "app/app.module.browser.ts",
    "app/app.component.ts",
    "app/push-notification.component.ts",
    "app/push-notification.module.ts",
    "app/app-routing.module.ts",
    "./**/*.browser.ts",
    "firebase-messaging-sw.ts",
    "polyfills.ts",
...
....
  ]
}

Before the update,

This was my tsconfig file:

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "downlevelIteration": true,
    "outDir": "./dist/out-tsc",
    "sourceMap": false,
    "declaration": false,
    "module": "esnext",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es2015",
    "typeRoots": [
      "./typings",
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  }
}

And tsconfig.server before update

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "baseUrl": "./",
    "module": "commonjs"
  },
  "angularCompilerOptions": {
    "entryModule": "app/app.module.server#AppServerModule",
    "enableIvy": true
  },
  "exclude": [
    "main.ts",
    "app/app.module.browser.ts",
    "app/app.component.ts",
    "app/push-notification.component.ts",
    "app/push-notification.module.ts",
    "app/app-routing.module.ts",
    "./**/*.browser.ts",
    "firebase-messaging-sw.ts",
    "polyfills.ts",
...
....
  ]
}

Downgrading to Angular CLI version 10.0.0-rc.0, fixes the issue.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (1 by maintainers)

Most upvoted comments

  const renderPromise = AppServerModuleNgFactory
    ? /* AoT */ renderModuleFactory(AppServerModuleNgFactory, options)
    : /* dev */ renderModule(AppServerModule, options);

Should be changed to

  const renderPromise = renderModule(AppServerModule, options);

The reasoning for bundling in that issue (#8616) was that the node modules directory was massive both in depth and breadth. This can lead to triggering windows path limitations. This can also be problematic for deployment on such systems since the entire node modules directory needed to be deployed.

With the lazy chunks, neither should be an issue since there is no additional directory depth and the number of files is limited (especially in comparison to the potential thousands of files in the node modules directory).