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.

Inconsistent sourcemap dot path behavior

See original GitHub issue

Bug report

What is the current behavior?

When configuring an entry point like this:

module.exports = {
  entry: './path/to/my/entry/file.js',
};

The source map in dev mode will have urls like this: webpack://project-server/./resources/js/MyPage.js

But vue files in the same project have urls like this: webpack://project-server/resources/js/AnotherPage.vue

Notice that the vue paths are not prefixed with ./.

This splits the sources in the dev tool to two separate folder, which makes it hard to find while debugging.

I have tried multiple entry combinations, but could not get this to behave.

For those interested in a workaround, here it is:

  output.devtoolModuleFilenameTemplate = opts => {
      return `webpack://${opts.namespace}/${opts.resourcePath.startsWith('./') ? opts.resourcePath.substr(2) : opts.resourcePath}`;
  };
  output.devtoolFallbackModuleFilenameTemplate = opts => {
      return `webpack://${opts.namespace}/${opts.resourcePath.startsWith('./') ? opts.resourcePath.substr(2) : opts.resourcePath}?${hash}`;
  };

If the current behavior is a bug, please provide the steps to reproduce.

Any simple project with both js and vue will demonstrate the issue. Although just a simple js project will also demonstrate it, as the paths should not contain ./ in them anyway.

What is the expected behavior?

Paths should be normalized (no ./ or ../ in the path), or at least behave in a consistent way across all modules.

I am not entirely sure if paths are not normalized, or if they are actually normalized and this line options.moduleFilenameTemplate || "webpack://[namespace]/[resourcePath]"; in SourceMapDevToolPlugin.js is just too simple.

Even though there is a workaround, I think that this should be fixed for everyone from the ground up.

Other relevant information: webpack version: 5.38.1 Node.js version: 14.5.4 Operating System: Windows 10 Additional tools: webpack-dev-server v4.0.0-beta.3, webpack-cli v4.6.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:23 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
danielgindicommented, Jun 3, 2021

Yes I’ll create something

0reactions
danielgindicommented, Jun 8, 2021

ok then if there is no difference and both are valid we prefer to use ./ and it is our default behaviour

So I understand that you want to preserve this weird behaviour- that’s fine, thank you. I do have a local workaround.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting sourceMap: true generates different content hashes on ...
I think the issue is from the sources array in the sourcemap object. That path is an absolute path, not a relative path,...
Read more >
Source Maps — raven-js 3.4.0 documentation
Source Maps¶. Sentry supports un-minifying JavaScript via Source Maps. This lets you view source code context obtained from stack traces in their original ......
Read more >
TSConfig Reference - Docs on every TSConfig option
The value of extends is a string which contains a path to another configuration file to inherit from. The path may use Node.js...
Read more >
Webpack with Less and Source Map - Weird path behaviour
I have been trying to resolve an issue for a long time with Webpack, Less and Code Map - it seems to all...
Read more >
How I solved and debugged my Webpack issue through trial ...
When webpack bundles your source code, it can become difficult to track down errors and warnings to their original location.
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