webpack icon indicating copy to clipboard operation
webpack copied to clipboard

[HELP WANTED] Perform source-map audit against webpack

Open TheLarkInn opened this issue 10 years ago • 89 comments

Problem

There are multiple issues that have been filed for numerous different reports of source-maps having issues in chrome.

Work Required

Listed is the canonical specification for source-maps: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit

We would like help (as we cannot make this a priority with current resources) creating every type of sourcemap, and then either manually (or via unit testing) validate that the source-map types that we have configured in place currently (starting at webpack2.1.0-beta.25) and work in Chrome.

Results

This will allow us to:

  • Create unit tests that are sturdier, and a source map validation tool to ensure it works to this specification (if it doesn't already exist).
  • Identify if source-map issues are chrome bugs or webpack bugs.

If there is anyone who would like to tackle this, please comment in the issue, then we can be aware of who is working on it, and how

TheLarkInn avatar Oct 19 '16 19:10 TheLarkInn

Have you looked at https://github.com/mattrobenolt/sourcemap-validator before? I believe in the past they've tried to roughly approximate how well support with the current spec could be captured by their validator.

addyosmani avatar Oct 20 '16 22:10 addyosmani

I made a small (very small) hello world script and passed it through webpack. the resulting sourcemap does not work in chrome.

https://github.com/mattkime/node-test-debuggers

npm install && npm run build && npm run chrome:webpack and you should be able to see the issue - the original 'index.js' file is referenced in the sourcemap but its not displayed in the sources list.

mattkime avatar Oct 21 '16 00:10 mattkime

@addyosmani thank you so much.

@mattkime are you familiar will all the types of sourcemaps you can generate with webpack?

TheLarkInn avatar Oct 21 '16 00:10 TheLarkInn

See https://github.com/webpack/webpack/blob/master/lib/WebpackOptionsApply.js#L200-L232

TheLarkInn avatar Oct 21 '16 01:10 TheLarkInn

@TheLarkInn I am. I guess I should iterate through all the options? I was trying to find the simplest starting point and iterate out through there.

mattkime avatar Oct 21 '16 01:10 mattkime

Yeah id say just one at a time! I haven't tried out the validator that Addy suggested just yet but I would think that could provide a great way to iterate quickly.

TheLarkInn avatar Oct 21 '16 01:10 TheLarkInn

The validator is, um, under documented. I'm not certain what it does or doesn't document.

I gave 'eval-soucre-map' a go and it worked well on my simple test and failed on a complex project.

As mention in the issue description, I'm not sure if i'm looking at webpack or chrome bugs.

While I'm happy to pitch in, I need some guidance to get started on this.

mattkime avatar Oct 21 '16 01:10 mattkime

Ideally we'd find someone on the Google Chrome project that could give us some guidance.


found some very helpful stuff - http://sourcemapper.qfox.nl/ http://www.mattzeunert.com/2016/02/14/how-do-source-maps-work.html

mattkime avatar Oct 21 '16 02:10 mattkime

I did also like this link for some information: http://jlongster.com/On-the-Road-to-Better-Sourcemaps-in-the-Firefox-Developer-Tools

joachimprinzbach avatar Oct 21 '16 06:10 joachimprinzbach

this shows a sourcemap working when loaded via front end and failing when loaded via node https://github.com/mattkime/chrome-devtools-sourcemap-test

while webpack could certainly use a good sourcemap test suite, i'd hold off on pursuing bugs in webpack's sourcemap production until we're certain that chrome works correctly or we find a better standard.

mattkime avatar Oct 21 '16 15:10 mattkime

Sorry I don't have anything productive to add yet beyond an observation, but maybe now that angular 2 is promoting typescript and their angular-cli project is depending on webpack 2, it's possible someone on the angular team will have a better-than-average chance of getting some feedback from the chrome team on this? As angular 2 picks up users, I have to imagine that'll mean a lot of new users wondering why sourcemaps are broken. https://github.com/angular/angular-cli

rob3c avatar Oct 21 '16 15:10 rob3c

verified the problem on chromium and opened a bug. it would be helpful if people could verify the bug on windows and linux. https://bugs.chromium.org/p/chromium/issues/detail?id=658438

would probably help to get a bunch of followers on that bug as well.

mattkime avatar Oct 21 '16 23:10 mattkime

@rob3c I'm working with the team to get some help and feedback. cc @PaulIrish

TheLarkInn avatar Oct 21 '16 23:10 TheLarkInn

@mattkime have you run your test against each sourcemap type. Should we make a chart or checklist?

TheLarkInn avatar Oct 21 '16 23:10 TheLarkInn

@TheLarkInn the bug i submitted to chromium uses babel rather than webpack. the output is a bit simpler but still exposes the flaw.

lets make a new project that makes it easy to iterate over the various sourcemap types, in a similar spirit as https://github.com/mattkime/node-test-debuggers.

i did try a couple of other sourcemap types and found that they may work in a simple example and then fail in a complex setup. My simple test is not sufficient to determine whether a given sourcemap type works in completion.


I should also mention that this might be tied to nodejs version. however, I did check node.js 6.3.1 when the feature was still fresh so i think its a chrome side issue.

just tried chrome v50 which would have been recent when this debugging technique was released. it supports the debugging url but doesn't show the source files.

mattkime avatar Oct 22 '16 00:10 mattkime

@TheLarkInn webpack v1.13, right?

mattkime avatar Oct 22 '16 02:10 mattkime

threw this together, might be rough around the edges - https://github.com/mattkime/webpack-sourcemap-test

prompts you for the devtool you'd like to build with and then creates node and web builds.

mattkime avatar Oct 22 '16 04:10 mattkime

Curious about v2.1.0-beta.25 also

TheLarkInn avatar Oct 22 '16 14:10 TheLarkInn

Nice work btw. I will check this out.

TheLarkInn avatar Oct 22 '16 14:10 TheLarkInn

Curious about v2.1.0-beta.25 also

Haven't double checked but i suspect the problem would be reproduced identically.

eval devtool seems to work but i suspect thats because its not really a sourcemap.

mattkime avatar Oct 22 '16 15:10 mattkime