Angular v19 prerender uses the wrong package.json

未關閉
#29,787 3 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
38/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
angular, node.js, typescript

研究方向

從 @angular/ssr/node 中的 AngularNodeAppEngine 進入點和報告中顯示的 src/package.json 匯入開始,接著追蹤 angular.json 如何透過 src/server.ts 呼叫伺服器輸出和 prerendering。確認解析是從 dist 而不是 src 進行,並確認文件所述的 prerender: false 設定會防止 prerendering。

由索引模型根據 Issue 內容生成。

描述

angular/build:application area: @angular/build area: @angular/ssr freq1: low type: bug/fix
Which @angular/* package(s) are the source of the bug?

ssr

Is this a regression?

No

Description

when running an angular app that uses AngularNodeAppEngine from "@angular/ssr/node" and outputMode set to server it reads imports from src/package.json which is set to be used in dist

package.json

"imports": {
    "#configs/*": "./browser/configs/*.js"
}

in the source code the configs folder is live in "src/configs" but copied at build time into "dist/browser/configs"
the same goes for many dynamic imports that assume the app runs inside the dist dir, i.e. the paths may be differ from the corresponding paths in the source code.

The prerender should run the same way as the original app runs i.e. from dist.

another thing, I cannot find an option to totally disable the prerendering as prerender: false now has no effect

Please provide the environment you discovered this bug in (run ng version)
Angular CLI: 19.2.1
Node: 22.12.0
Package Manager: npm 10.9.0
OS: linux x64

Angular: 19.2.1
... animations, build, cli, common, compiler, compiler-cli, core
... forms, platform-browser, platform-browser-dynamic
... platform-server, router, service-worker, ssr

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1902.1
@angular-devkit/core         19.2.1
@angular-devkit/schematics   19.2.1
@angular/cdk                 19.2.2
@angular/material            19.2.2
@schematics/angular          19.2.1
rxjs                         7.8.2
typescript                   5.8.2
zone.js                      0.15.0
    

Anything else?

No response

angular.json
{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "cms-ui": {
      "projectType": "application",
      "schematics": {
        "@schematics/angular:component": {
          "style": "scss"
        }
      },
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular/build:application",
          "options": {
            "outputPath": "dist",
            "index": "src/index.html",
            "browser": "src/main.ts",
            "polyfills": ["zone.js"],
            "tsConfig": "tsconfig.json",
            "inlineStyleLanguage": "scss",
            "assets": [
              "src/favicon.ico",
              "src/assets",
              "src/manifest.webmanifest",
              "src/scripts.mjs",
              "src/configs"
            ],
            "styles": ["src/styles.scss"],
            "scripts": [],
            "server": "src/main.server.ts",
            "outputMode": "server",
            "prerender": false,
            "ssr": {
              "entry": "src/server.ts"
            },
            "serviceWorker": "ngsw-config.json",
            "define": {},
            "namedChunks": true,
            "externalDependencies": ["#configs/*"]
          },
          "configurations": {
            "production": {
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2m"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "2kb"
                }
              ],
              "outputHashing": "all"
            },
            "development": {
              "optimization": false,
              "extractLicenses": false,
              "sourceMap": true
            }
          },
          "defaultConfiguration": "production"
        },
        "serve": {
          "builder": "@angular/build:dev-server",
          "configurations": {
            "production": {
              "buildTarget": "cms-ui:build:production"
            },
            "development": {
              "buildTarget": "cms-ui:build:development"
            }
          },
          "defaultConfiguration": "development"
        },
        "extract-i18n": {
          "builder": "@angular/build:extract-i18n",
          "options": {
            "buildTarget": "cms-ui:build"
          }
        },
        "test": {
          "builder": "@angular/build:karma",
          "options": {
            "polyfills": ["zone.js", "zone.js/testing"],
            "tsConfig": "tsconfig.spec.json",
            "inlineStyleLanguage": "scss",
            "assets": [
              "src/favicon.ico",
              "src/assets",
              "src/manifest.webmanifest",
              "src/scripts.mjs",
              "src/configs"
            ],
            "styles": ["src/styles.scss"],
            "scripts": []
          }
        }
      }
    }
  },
  "cli": {
    "analytics": false
  }
}
主要語言
TypeScript
星號
27k
分支
11.8k
平均合併
16 小時 35 分鐘
30 天內合併 PR
176

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

angular/angular-cli 的其他 Issue

查看 angular/angular-cli 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。