webpack sourcemap include absolute path
See original GitHub issueBug report
What is the current behavior?
If the current behavior is a bug, please provide the steps to reproduce.
https://github.com/xiaoxiangmoe/webpack-source-absolute-path-bug
git clone https://github.com/xiaoxiangmoe/webpack-source-absolute-path-bug.git
cd webpack-source-absolute-path-bug
yarn install && yarn build
see file src/index.js
const foo = Math.random() > 0.5 ? "a" : "b";
const m = require(`./foo/${foo}.js`);
console.log(m);
see file dist/main.js.map.json
line 8
{
"version": 3,
"file": "main.js",
"mappings": "...",
"sources": [
"webpack:///./src/foo/a.js",
"webpack:///./src/foo/b.js",
"webpack:////Users/zhaojinxiang/repos/webpack-sourcemap-bug/src/foo|sync|/^\\.\\/.*\\.js$/",
"webpack:///webpack/bootstrap",
"webpack:///webpack/runtime/hasOwnProperty shorthand",
"webpack:///./src/index.js"
],
}
You can find a absolute file path in line 8
What is the expected behavior?
It should be
{
"version": 3,
"file": "main.js",
"mappings": "...",
"sources": [
"webpack:///./src/foo/a.js",
"webpack:///./src/foo/b.js",
"webpack:///./src/foo|sync|/^\\.\\/.*\\.js$/",
"webpack:///webpack/bootstrap",
"webpack:///webpack/runtime/hasOwnProperty shorthand",
"webpack:///./src/index.js"
],
}
Other relevant information: webpack version: 5.67.0 Node.js version: v16.12.0 Operating System: macos 12.1
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
Webpack: How to get relative path in css sourcemap
The question is, is it possible to shorten the source map to be relative to my project root path? So instead of /Users/xunyang/workspace/ ......
Read more >SourceMapDevToolPlugin - webpack
noSources = false ( boolean ): Prevents the source file content from being included in the source map. publicPath ( string ): Emits...
Read more >Source Maps - SurviveJS
Webpack can generate both inline or separate source map files. The inline ones are included to the emitted bundles and are valuable during...
Read more >配置 | webpack
sourceMapFilename. The filename of the SourceMaps for the JavaScript files. They are inside the output.path directory. [file] ...
Read more >Webpack Configuration · mochapack - GitHub Pages
webpack.config-test.js - example config ... output: { // use absolute paths in sourcemaps (important for debugging via IDE) devtoolModuleFilenameTemplate: ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Bug in
ContextModule
. It should use relative source paths fornew OriginalSource
, similar toNormalModule
yeah, and actually that’s what I am trying to do…