-
-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “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? Sign in to your account
map.sources converted to absolute paths + other changes #75
Conversation
@michael-ciniawsky sorry for tagging if this is incorrect, but you seem to be the maintainer of this library. Any chance you can take a look at this? I think this would also solve the issue with #51 |
@d3viant0ne Any chance you can take a look at this PR? |
@mlavina it is invalid fix, you should use |
From my understanding source maps are not modules, are source map urls are not meant to follow webpack's logic. Can you explain the benefits of using |
I think this is a nice improvement and would like to see this merged! I'm currently running into this issue: #51 |
@Volune - I found this PR after struggling with multiple different libraries emitting bogus relative paths pointing to source files that didn't exist. I have some concerns about this PR in the context of what I learned about these "missing source" cases. TL;DR - there are three problems I've seen:
I think your PR will do a great job making (1) above better. It will simplify making build pipelines that digest existing sourcemaps. But one nice thing about relative paths is that detecting problems (2) and (3) is easy: just look for But without any relative paths, it will be less obvious which paths have failed to be found. Do you have any ideas for how to identify cases (2) and (3) if all sourcemap paths are non-relative? |
@justingrant I'm not sure I understand all of your cases. For (2) For (3)
|
Hi @Volune, thanks for the quick reply!
Sorry , I was imprecise. "build time" === library build time (first bundling). "run time" === app build time (bundle of library bundles). I think of it as runtime because most of my pipelines have webpack bundling integrated into running the app in development mode.
Yep. I've seen a few examples recently, but the worst offender I've seen is https://github.com/aws-amplify/amplify-js. Here's the sourcemap: https://unpkg.com/aws-amplify@1.1.22/dist/aws-amplify.js.map. You can see the relative paths (grep for
Using amplify-js as an example, its Lerna pipeline builds 10-ish packages from the same set of sibling folders that are symlinked to node_modules. For example, the I'm planning to do a PR to help them fix this, once I figure out exactly how to fix it.
This is helpful, I didn't know about this warning. Is there a webpack config setting needed to show it? I think the real way to fix (2) is to add a warning into the output of |
@Volune - I've got some feedback after using your fork in a few projects. First, this is a huge improvement! It solved almost all of the sourcemap issues in my react app. I'm also seeing sourcemap warnings for the first time, which is very helpful in tracking down problematic dependencies. I assume that the old source-map-loader code wasn't even digging into the sourcemaps deep enough to find those missing files, which is why I wasn't seeing the warnings before. Also, now that I'm seeing warnings, most of my earlier concerns are moot. Thanks so much for building this! Also, with the help of your fork, I was finally able to PR the problematic aws-amplify package to fix most of its sourcemap issues. See aws-amplify/amplify-js#3059. This library still emits a few warnings (see minimal test repo: https://github.com/justingrant/sourcemap-test-relative), but once the questions/issues below are resolved I can PR to fix those warnings too. I've got a few questions/concerns: 1. webpack:/// URL scheme If a sourcemap has URLs using this scheme, your fork will throw a warning, e.g.
AFAIK, by default webpack will emit a Unfortunately I'm not aware of a standard or documentation for the webpack:// URL scheme, so I'm not exactly sure what 2. Unusual URLs from Webpack Webpack itself seems to emit weird, non-standard relative URLs in some sourcemaps, e.g.
How should these be handled by source-map-loader? Currently, these throw URL-scheme warnings in your code because the sourcemaps I have all prepend the webpack:/// prefix to the relative URLs above, but even if we solve the URL scheme issue, I assume we'd run into other errors downstream because they are not real file paths. Given that webpack itself is creating these, I assume we should not throw warnings for them. What do you think? 3. source-map-resolve Today I ran across this package: https://github.com/lydell/source-map-resolve which is used by the snapdragon parser. Does this overlap with what you've built here? Is there anything useful in that package that could be re-used here? |
@Volune - any thoughts re: the questions in my last post? I'm eager to fix the last remaining sourcemap issues in my dependencies but wanted to get your advice first. |
@justingrant I haven't worked on this in a while, so I don't remember everything. In my point of view, If you still use webpack library in a webpack build, here is my opinion for the different cases:
In short for 1. and 2.: either it's in Hope that helps. |
FWIW, applying these changes makes source maps from |
Hi @bebraw @d3viant0ne @SpaceK33z @TheLarkInn - This PR is very helpful and it's been waiting for a maintainer review for 8 months. How can we help it get merged? FWIW, I've been using this fork for 3 months in a customized create-react-app config and it's worked great. |
Any update on this? It would be great to see this loader going into CRA and this PR is blocking that effort. Thanks! |
May 2020, just wanted to see if there is any update on this. |
Fixed in the master |
Whoo-hoo! Thanks @evilebottnawi! This will unblock using source-map-loader in create-react-app which will help a lot of developers. |
@justingrant 👍 ETA is the next week |
Motivation:
Webpack generates useless paths in sourcemaps when the original sourcemap contains relative paths. For example
{"sources":["../../src/MyComponent.js"]}
will generatewebpack://../../src/MyComponent.js
This PR contains the following changes:
sources
in the returned map are now converted to absolute paths. I added an optionkeepRelativeSources
to prevent this behavior. The behavior is enabled by default because it improves the source map generation by webpack.this.resolve
to resolve the sources path. The reason is that sources are URIs (or paths) not meant to be resolved by webpack. (The first reason wasresolve
fails if the file doesn't actually exist)sourcesContent
value isnull
new Buffer
, add .editorconfig for tabsBy the way, I've got these suggestions while working on this PR:
//#sourceMappingURL=/etc/passwd
)sources
list, for Explore using urls instead of absolute paths in source-map 'sources' array webpack/webpack#8226