Angular v19 prerender uses the wrong package.json

Đang mở
#29,787 3 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
38/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
angular, node.js, typescript
Lĩnh vực
backend, build-system

Hướng nghiên cứu

Bắt đầu với entry point AngularNodeAppEngine từ @angular/ssr/node và các import trong src/package.json được nêu trong báo cáo, sau đó theo dõi cách angular.json gọi server output và prerendering thông qua src/server.ts. Xác minh rằng việc phân giải diễn ra từ dist thay vì src, và rằng thiết lập prerender: false được ghi rõ trong tài liệu sẽ ngăn prerendering.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
  }
}
Ngôn ngữ chính
TypeScript
Star
27k
Fork
11.8k
Merge trung bình
16 giờ 35 phút
Pull request đã merge (30 ngày)
176

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của angular/angular-cli

Tất cả issue của angular/angular-cli

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.