tl;dr
Is this a bug report?
Yes. Maybe? I think so.
Did you try recovering your dependencies?
Yup - deleted node_modules and yarn.lock, reinstalled with yarn.
yarn --version is 1.7.0.
Which terms did you search for in User Guide?
sourcemaps, source maps, and eject.
(I'm familiar with ejecting (yarn eject) and manually setting devtool in config/webpack.config.prod.js.)
Environment
Environment:
OS: macOS High Sierra 10.13.4
Node: 9.4.0
Yarn: 1.7.0
npm: 5.6.0
Watchman: 4.9.0
Xcode: Not Found
Android Studio: Not Found
Packages: (wanted => installed)
react: ^16.4.1 => 16.4.1
react-dom: ^16.4.1 => 16.4.1
react-scripts: 1.1.4 => 1.1.4
Steps to Reproduce
I've set up an example repo at https://github.com/kenhoff/cra-sourcemap-testing.
If you're using that repo:
git clone [email protected]:kenhoff/cra-sourcemap-testing.git
cd cra-sourcemap-testing
yarn
yarn build
node test-sourcemaps.js -> throws error
Otherwise, setting up from scratch:
npx create-react-app my-sourcemap-testing
cd my-sourcemap-testing
yarn build
- then, test the
build/static/js/main.*.js and build/static/js/main.*.js.map files with sourcemap-validator (https://www.npmjs.com/package/sourcemap-validator)
Expected Behavior
I expected sourcemap-validator to not throw an error, (hypothetically) indicating that the generated sourcemaps are valid.
Actual Behavior
sourcemap-validator and the node test-sourcemaps.js command logs and throws the following error:
[ 'main.a0b7d8d3.js', 'main.a0b7d8d3.js.map' ]
/Users/kenhoff/dev/cra-sourcemap-testing/node_modules/sourcemap-validator/index.js:146
throw new Error(errMsg);
^
Error: Warning: mismatched names
Expected: __webpack_require__ || '__webpack_require__' || '__webpack_require__' || "__webpack_require__" || "__webpack_require__"
Got: function __webpac || function __webpack_ || function __webpack_ || function __webpack_|| function __webpack_
Original Line: function __webpack_require__(moduleId) {
Mapping: 1:21→5:0 "__webpack_require__" in ../webpack/bootstrap e71d967440f2e775571f
at /Users/kenhoff/dev/cra-sourcemap-testing/node_modules/sourcemap-validator/index.js:146:17
at Array.forEach (<anonymous>)
at SourceMapConsumer_eachMapping [as eachMapping] (/Users/kenhoff/dev/cra-sourcemap-testing/node_modules/sourcemap-validator/node_modules/source-map/lib/source-map/source-map-consumer.js:570:10)
at validate (/Users/kenhoff/dev/cra-sourcemap-testing/node_modules/sourcemap-validator/index.js:83:12)
at fs.readdir (/Users/kenhoff/dev/cra-sourcemap-testing/test-sourcemaps.js:11:9)
at FSReqWrap.oncomplete (fs.js:149:20)
Reproducible Demo
I've set up an example repo at https://github.com/kenhoff/cra-sourcemap-testing.
If you're using that repo:
git clone [email protected]:kenhoff/cra-sourcemap-testing.git
cd cra-sourcemap-testing
yarn
yarn build
node test-sourcemaps.js -> throws error
Other notes
- The sourcemaps appear to be valid to my browser (
Chrome Version 67.0.3396.87 (Official Build) (64-bit))
- But, the sourcemaps don't appear to be valid to my Sentry configuration, using the tool here: https://sourcemaps.io/
- Removing the
UglifyJsPlugin from config/webpack.config.prod.js (after ejecting) solves the problem and generates valid sourcemaps, but doesn't minify/uglify the bundled js.
tl;dr
sourcemap-validatorand https://sourcemaps.io/, the sourcemaps generated by CRA are invalid. (This might be a problem with those tools, but I'm not sure). Full error below.UglifyJsPluginfixes the problem and generates valid sourcemaps, but doesn't minify the outputted js bundle.Is this a bug report?
Yes. Maybe? I think so.
Did you try recovering your dependencies?
Yup - deleted
node_modulesandyarn.lock, reinstalled withyarn.yarn --versionis1.7.0.Which terms did you search for in User Guide?
sourcemaps,source maps, andeject.(I'm familiar with ejecting (
yarn eject) and manually settingdevtoolinconfig/webpack.config.prod.js.)Environment
Steps to Reproduce
I've set up an example repo at https://github.com/kenhoff/cra-sourcemap-testing.
If you're using that repo:
git clone [email protected]:kenhoff/cra-sourcemap-testing.gitcd cra-sourcemap-testingyarnyarn buildnode test-sourcemaps.js-> throws errorOtherwise, setting up from scratch:
npx create-react-app my-sourcemap-testingcd my-sourcemap-testingyarn buildbuild/static/js/main.*.jsandbuild/static/js/main.*.js.mapfiles withsourcemap-validator(https://www.npmjs.com/package/sourcemap-validator)Expected Behavior
I expected
sourcemap-validatorto not throw an error, (hypothetically) indicating that the generated sourcemaps are valid.Actual Behavior
sourcemap-validatorand thenode test-sourcemaps.jscommand logs and throws the following error:Reproducible Demo
I've set up an example repo at https://github.com/kenhoff/cra-sourcemap-testing.
If you're using that repo:
git clone [email protected]:kenhoff/cra-sourcemap-testing.gitcd cra-sourcemap-testingyarnyarn buildnode test-sourcemaps.js-> throws errorOther notes
Chrome Version 67.0.3396.87 (Official Build) (64-bit))UglifyJsPluginfromconfig/webpack.config.prod.js(after ejecting) solves the problem and generates valid sourcemaps, but doesn't minify/uglify the bundled js.