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

未关闭
#31,331 1 条评论 7 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
typescript, vite

调研方向

使用 ng new、angular.json、tsconfig.json 和 ng serve 重现该问题,然后在浏览器的 Network 工具中检查已提供的 JavaScript。追踪 Vite/esbuild 开发服务器路径如何处理 sourceMap 设置。当 sourceMap false 能阻止应用程序和 node_modules JavaScript 文件中的内联 Base64 映射时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

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
主要语言
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 摘要。