remove absolute file paths embedded in sourcemaps generated by `SourceMapPlugin`
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 50/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- typescript, webpack
- 领域
- build-system
调研方向
Start in packages/repack/src/plugins/SourceMapPlugin.ts, where module names are built into the source map's sources (around lines 92-95) and where the commented-out read of output.devtoolModuleFilenameTemplate sits (around lines 107-108). Check how compiler.options.context is available there and whether the webpack config can be exercised with a small production build. Done means the emitted map no longer contains machine-specific absolute paths, either by honoring the template or by defaulting to paths relative to the context. Agreeing on which of the two options to take first is likely needed with a maintainer.
由索引模型根据 Issue 内容生成。
描述
Description
When building without a dev server (e.g. a release bundle built in CI), SourceMapPlugin names every module in the source map's sources by its absolute path on the build machine, and there's no way to override this.
RepackPlugin always applies SourceMapPlugin, and SourceMapPlugin ignores output.devtoolModuleFilenameTemplate (the line that would read it is commented out)
Why this is a problem
The source map ends up depending on where the build ran, not just on its inputs:
- Non-reproducible builds. On remote-execution or sandboxed build systems (Bazel, Buck, etc.) the absolute path includes a per-job working directory, so the same commit yields a different map on each worker:
/mnt/ci/worker/7/exec/bazel-out/<config>/bin/<target>.runfiles/<workspace>/node_modules/react-native/Libraries/Components/Pressable/Pressable.js - Error-reporting tools show machine-specific paths. Sentry and similar tools display these paths as frame filenames. Because the prefix changes between builds, a single code mapping (stack trace → repository) can't cover them.
The web-oriented default, webpack://[namespace]/[resourcePath], has none of these problems because [resourcePath] is relative to context.
Suggested solution
- Honor
output.devtoolModuleFilenameTemplatewhen set, falling back to the current behavior otherwise. This seems to be what the commented-out code intended or - Default to paths relative to
compiler.options.contextfor production builds. That keeps the map reproducible, and tools can still resolve files by joining with the project root.
Additional context
No response
- 主要语言
- TypeScript
- 星标
- 1.9k
- 派生
- 177
- 平均合并
- 2 天 10 小时
- 30 天内合并 PR
- 23
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
callstack/repack 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
callstack/repack#1515 · 1 条评论 ·
维护者通常 2 天内回复
-
ScriptManager caches the rejected promise when a resolver throws, so loadScript/prefetchScript never retry可能已有人在做 @linhh-phv 于 15 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 35/100
维护者通常 2 天内回复
-
Inlined assets with fractional scales resolve to the wrong variant可能已有人在做 @RaphaelFakhri 于 15 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 25/100
维护者通常 2 天内回复
-
json as string in JS bundle可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 5/5 一周以上 新手友好度 35/100
callstack/repack#1461 · 1 条评论 ·
维护者通常 2 天内回复
-
area:repack type:feature
难度 5/5 一周以上 新手友好度 42/100
callstack/repack#1423 · 1 条评论 ·
维护者通常 2 天内回复
相似的 Issue
-
needs-area-label
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
liberation-data/drivine#615 ·
维护者通常 1 天内回复
-
backend bug ready-for-agent
难度 2/5 1-3 小时 新手友好度 78/100
geolens-io/geolens#3639 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
radius-project/ai-extensions#1196 ·
维护者通常 1 天内回复
-
good first issue
难度 1/5 1-3 小时 新手友好度 88/100