-
Notifications
You must be signed in to change notification settings - Fork 920
Source maps generation adds broken intermediate code #1400
New issue
Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “No Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? No Sign in to your account
Comments
Just adding my 2 cents,
It would be nice if we can have the original Vue SFC file being displayed instead of the intermediate files... I may understand why vue-loader decides to add intermediate files in the source map; probably for debugging the vue-loader output itself during internal development. However, seeing that the source map usually only is needed for debugging the consumer source code in the browser dev tool, perhaps don't show the intermediate files? (End-users tend not to put breakpoints in html and css parts of the template)
Thanks for considering. |
Veeery disappointing to not have heard any response whatsoever to this issue for close to 2 months now, after you originally explicitly asked in #1163 to open a new issue, should the problem persist. Not asking for an immediate solution, but a simple "yeah, we're going to look into it" would be nice... |
So... I've just attached a debugger and started stepping through the webpack compilation, source map generation etc.
I.e. this whole thing probably starts with |
Also seeing the intermediate code output. This is breaking debugging entirely for Firefox and in weird ways in Chrome. Chrome debugging seems to find the right code if the .vue file is the first entry in the stack trace, but not if it is isn't (i.e., the .vue file code is calling code in another module that throws an exception). |
I've been investigating this for the past 4 days or so, and it's actually a bit more complicated than that. I don't think So, what I've found is: A single
I don't know the best fix for this, however my current assumption is that if 2-7 included source maps when returning code from the loader, with a source path equivalent to number 1, then there would only be one entry in the So for starters, the return `import mod from ${request}; export default mod; export * from ${request}` Instead, it should do something like this: const sourceMap = generateSourceMapToOriginalFile(etc);
this.callback(null, `import mod from ${request}; export default mod; export * from ${request}`, sourceMap) Same for the templates and custom blocks in that file. That gets rid of 4, 5, and 6. However, I'm guessing the pitcher might go away in the next major version because Webpack added the The Custom blocks are up to your custom block code. That would get rid of 7. Finally, that just leaves the "intermediate representation". The return code It would need to do, loaderContext.callback(null, code, sourceMap) Which gets rid of 2. Then all source maps would point to the same file as 1 (the original), and in theory everything would work. Let me know if I'm incorrect in any of this, I'm new to webpack development! |
That still ends up with a pool of source maps all pointing back at 1, but sharing the same name. Each would clobber whatever was registered under that name previously. And the arbitrary last entrant would 'win'. Webpack concatenates a query string with the first few symbols of the hash fingerprint of a file when it detects a source map name collision, exactly to avoid this problem. Vue loader fails to correctly propagate faked split names (e.g. Vue loader should:
|
The problem is that when a module, any module, is resolved by webpack, it generates a source map. The way Emitting an empty source map would probably work like you said. The relevant Note this line at the end, which is the default for a module: return new OriginalSource(source, identifier);
If all of the intermediate modules have a source map to the original file, I think that the source map generation is smart enough to merge them all. Maybe I'm wrong on that one, I haven't tried. Edit: There is collision detection with |
What is the status with this issue? Will it ever be addressed? What can I do to help move it along? It's very frustrating that Vue template errors can not be mapped to source. When our react native apps have errors in production the Sentry error shows exactly the line in source where the error occurred but for Vue we just get garbage. I think this is the same issue as vuejs/vue-cli#2978. |
Yeah this essentially renders vue unusable. How do you expect people to use an application in production if they can't debug it? I understand there might be fixes in the cases, but they're not guaranteed to work and I would expect this to work out of the box |
Version
15.4.1
Reproduction link
https://github.com/NetMatch/vue-loader-testcase
Steps to reproduce
npm ci
npm run build
dist
folderWhat is expected?
vue-loader
generates source maps for the source Vue SFC file and the constituent template, style and script sections.The
appendExtension
option is honored and the source map lists the constituents asExample.vue.html
,Example.vue.css
andExample.vue.js
.What is actually happening?
vue-loader
generates source maps for intermediate stages of generated JS code rather than the original sources of the template, style and JS sections.The
appendExtension
option is not honored. All generated files are generated under theExample.vue
name and are disambiguated by adding part of their content hash as a suffixed query string.Same issue as in #1163 where the root cause was claimed to be Babel and should have been resolved with latest versions of all build tools. However, the test case presented here uses the latest versions of Webpack and vue-loader and doesn't even use Babel at all. And still has this problem.
The text was updated successfully, but these errors were encountered: