ng serve with esbuild/Vite ignores sourceMap configuration, injecting large inline source maps into all files

Đang mở
#31,331 1 bình luận 7 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
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
typescript, vite
Lĩnh vực
build-system, devtools

Hướng nghiên cứu

Tái hiện vấn đề với ng new, angular.json, tsconfig.json và ng serve, sau đó kiểm tra JavaScript được phân phát trong các công cụ Network của trình duyệt. Truy vết cách đường dẫn máy chủ phát triển Vite/esbuild xử lý thiết lập sourceMap. Được xem là hoàn tất khi sourceMap false ngăn các map Base64 inline trong các tệp JavaScript của ứng dụng và node_modules.

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

Mô tả

area: @angular/build devkit/build-angular:dev-server freq1: low severity3: broken type: bug/fix
Command

serve

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

No response

Description

The development server (ng serve), which uses Vite/esbuild, consistently injects large, inline Base64 source maps into every JavaScript file it serves.

This behavior occurs even when source maps are explicitly disabled in angular.json and/or tsconfig.json. The most problematic aspect is that this transformation is also applied to pre-built, third-party packages from node_modules.

This unnecessarily inflates file sizes (often by 2-3x), which slows down page loads in development and makes debugging in browser DevTools more difficult due to the massive file content. The core issue is that the configuration to disable this behavior is not being respected.

Minimal Reproduction
  1. Create a new Angular project:

    ng new sourcemap-repro
    cd sourcemap-repro
    
  2. In angular.json, modify the configuration for the development server to explicitly disable all source maps. Under projects.sourcemap-repro.architect.build.configurations.development, set the sourceMap option:

    "sourceMap": false
    

    (Alternatively, using a more granular object like {"scripts": false, "styles": false, "vendor": false} also fails to prevent the issue.)

  3. Run the development server:

    ng serve
    
  4. Open the application in a browser and launch the developer tools (e.g., Chrome DevTools).

  5. Navigate to the "Network" tab, refresh the page, and inspect any .js file (e.g., main.js, polyfills.js, or a chunk from @angular/core).

  6. View the "Response" or "Source" for that file.

Expected Behavior:
The served JavaScript files should not contain an inline source map. The file should end without a //# sourceMappingURL=... comment.

Actual Behavior:
Every JavaScript file has a large inline Base64 source map appended to it, directly contradicting the configuration in angular.json.

Exception or Error

Your Environment
Angular CLI: 19.2.14
Node: 20.19.0
Package Manager: npm 10.8.2
OS: darwin arm64

Angular: undefined
...

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1902.15
@angular-devkit/build-angular   19.2.14
@angular-devkit/core            19.2.14
@angular-devkit/schematics      19.2.14
@angular/cli                    19.2.14
@angular/compiler               19.2.14
@angular/compiler-cli           19.2.14
@angular/language-service       19.2.14
@schematics/angular             18.2.11
ng-packagr                      18.2.1
typescript                      5.7.2
zone.js                         0.15.0
Anything else relevant?
Image
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.