-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Webpack is producing invalid sourcemaps? #8302
Copy link
Copy link
Closed
Description
tl;dr
- This issue was open before and marked as fixed Webpack isn't producing valid sourcemaps? #7616, but unfortunately, it's still reproducible with the latest version of webpack
- According to https://sourcemaps.io/ and sourcemap-validator, the sourcemaps produced by webpack are invalid
- using
devtool: "source-map", a barebones webpack config, andwebpack@4.23.1 - sample repro repo available at https://github.com/adaniliuk/webpack-sourcemap-testing
(this might be an issue with sourcemap-validator, but the error that it's throwing (in the "current behavior" section below) seems pretty legit)
Bug report
What is the current behavior?
Running webpack with the following config:
const webpack = require('webpack');
const path = require('path');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
devtool: 'source-map'
};- produces
dist/bundle.jsanddist/bundle.js.map. - running those files through
sourcemap-validator(or https://sourcemaps.io/, and consequently Sentry) produces the following error:
/webpack-sourcemap-testing/node_modules/sourcemap-validator/index.js:146
throw new Error(errMsg);
^
Error: Warning: mismatched names
Expected: installedModules || 'installedModules' || 'installedModules' || "installedModules" || "installedModules"
Got: var installedM || var installedMod || var installedMod || var installedMod || var installedMod
Original Line: var installedModules = {};
Mapping: 1:17→2:0 "installedModules" in webpack:///webpack/bootstrap
at /webpack-sourcemap-testing/node_modules/sourcemap-validator/index.js:146:17
at Array.forEach (<anonymous>)
at SourceMapConsumer_eachMapping [as eachMapping] (/webpack-sourcemap-testing/node_modules/sourcemap-validator/node_modules/source-map/lib/source-map/source-map-consumer.js:570:10)
at validate (/webpack-sourcemap-testing/node_modules/sourcemap-validator/index.js:83:12)
at Object.<anonymous> (/webpack-sourcemap-testing/test-sourcemaps.js:6:1)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
If the current behavior is a bug, please provide the steps to reproduce.
Repro repo here: https://github.com/adaniliuk/webpack-sourcemap-testing
Repro instructions for that repo are on the readme.
If starting from scratch, use the following webpack config:
const webpack = require('webpack');
const path = require('path');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
devtool: 'source-map'
};and use sourcemap-validator to test dist/bundle.js for validity.
What is the expected behavior?
webpackproduces valid source maps- so
sourcemap-validatorreads the sourcemap as valid (e.g., not throw an error).
It looks like it might have something to do with some misaligned whitespace, but I'm really not sure.
Other relevant information:
webpack version: 4.23.1
Node.js version: 8.11.3
Operating System: macOS 10.14 (18A391)
Additional tools: sourcemap-validator@1.1.0, yarn@1.9.2
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels