-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Webpack isn't producing valid sourcemaps? #7616
Description
tl;dr
- According to https://sourcemaps.io/ and
sourcemap-validator, the sourcemaps produced by webpack are invalid - using
devtool: "source-map", a barebones webpack config, andVersion: webpack 4.12.2 - sample repro repo available at https://github.com/kenhoff/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. - those files are able to be used in Chrome dev tools with source mappings 👍
- but running those files through
sourcemap-validator(or https://sourcemaps.io/, and consequently Sentry) produces the following error:
/Users/kenhoff/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 /Users/kenhoff/node_modules/sourcemap-validator/index.js:146:17
at Array.forEach (<anonymous>)
at SourceMapConsumer_eachMapping [as eachMapping] (/Users/kenhoff/node_modules/sourcemap-validator/node_modules/source-map/lib/source-map/source-map-consumer.js:570:10)
at validate (/Users/kenhoff/node_modules/sourcemap-validator/index.js:83:12)
at Object.<anonymous> (/Users/kenhoff/dev/webpack-sourcemap-testing/test-sourcemaps.js:6:1)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
If the current behavior is a bug, please provide the steps to reproduce.
Repro repo here: https://github.com/kenhoff/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?
Expected behavior is for sourcemap-validator to read 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: Version: webpack 4.12.2
Node.js version: v9.4.0
Operating System: macOS 10.13.4
Additional tools: none