question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

webpack sourcemap include absolute path

See original GitHub issue

Bug 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:closed
  • Created 2 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
sokracommented, Feb 3, 2022

Bug in ContextModule. It should use relative source paths for new OriginalSource, similar to NormalModule

2reactions
cool-little-fishcommented, Feb 17, 2022

yeah, and actually that’s what I am trying to do…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found