Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi there! Just a suggested improvement, feel free to ignore if you intentionally don't want sourcemaps for whatever reason 😄
I originally got here from this issue. Webpack's source-map-loader allows webpack to ingest sourcemaps from your dependencies and bundle them into the sourcemap for your application itself -- which is nice for debugging in general because if an error comes from within a library you can instantly trace it to the source instead of having to parse through minified output. However, with
react-json-view
installed, thesource-map-loader
logs an annoying warning.Turns out the warning is because of this --
style-loader
has a conditional to add asourceMappingURL
if thesourceMap
configuration option is set. Note that the entireaddStyles.js
source is bundled into the dist when you're usingstyle-loader
(i.e. you can't just turn off thesourceMap
config option -- it's actually off-by-default anyway -- because the whole conditional that checks whether it's on or off is inlined.) Thesource-map-loader
picks up thesourceMappingUrl
text out of this conditional and thinks it's an actual sourcemap comment, not code to maybe add a sourcemap comment.The folks working on
source-map-loader
have seen this issue before -- here's an issue and here's the PR that came out of it. Their solution was to changesource-map-loader
to only parse the lastsourceMappingURL
found in the file (rather than all of them). This helps for most cases, but it doesn't actually help here becausereact-json-view
doesn't have sourcemaps enabled in the built dist at all, so the last/onlysourceMappingURL
is the false positive fromstyle-loader
.So, I propose that we turn on sourcemaps in the built dist. This is a double improvement for people who want to use
source-map-loader
-- they get sourcemaps out ofreact-json-view
and they also get no annoying warning. It shouldn't really have much impact on anyone else since all it does is add a comment to the end of the built output (and include a sourcemap file adjacent to it in thedist
directory).I also removed the
new webpack.optimize.UglifyJsPlugin()
line because it's redundant (the--optimize-minimize
in thepackage.json
script adds it anyway) and was causing me some issues getting the build to work right with the sourcemaps.Let me know what you think 😄