-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
CRA generating invalid sourcemaps? #4683
Comments
Oh uglify ... we seriously need to consider whether or not it's stable to use, there's been a ton of problems with the newer version(s). Thanks for this report! While this seemingly only affects source maps, it still worries me. Should we switch to |
I think uglifyjs-webpack-plugin is going to make a switch to terser at some point: webpack-contrib/uglifyjs-webpack-plugin#298 (comment) |
Let's make sure that happens before we cut 2.0 final. |
If it's useful:
Also, I attempted the fix for Any thoughts? Anything else that you'd recommend I try to keep debugging? Thanks so much for all your help! (and for |
That source map evaluator tool's analysis should be taken with a grain of salt. It's only producing correct results with webpack without minification because the source lines are not being transformed. Despite what their documentation states, webpack only offers line-based source maps as opposed to Rollup which has high resolution character-based source maps. webpack-contrib/uglifyjs-webpack-plugin#134 (comment) By definition there are tradeoffs between small minification size and a good debugging experience. Much of the original code no longer exists when minification transformations are performed. https://github.com/fabiosantoscode/terser#source-maps-and-debugging |
We've switched to Terser instead of Uglify. Please re-test this after v2 is released stable. Thanks! |
tl;dr
sourcemap-validator
and 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.UglifyJsPlugin
fixes 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_modules
andyarn.lock
, reinstalled withyarn
.yarn --version
is1.7.0
.Which terms did you search for in User Guide?
sourcemaps
,source maps
, andeject
.(I'm familiar with ejecting (
yarn eject
) and manually settingdevtool
inconfig/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.git
cd cra-sourcemap-testing
yarn
yarn build
node test-sourcemaps.js
-> throws errorOtherwise, setting up from scratch:
npx create-react-app my-sourcemap-testing
cd my-sourcemap-testing
yarn build
build/static/js/main.*.js
andbuild/static/js/main.*.js.map
files withsourcemap-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 thenode test-sourcemaps.js
command 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.git
cd cra-sourcemap-testing
yarn
yarn build
node test-sourcemaps.js
-> throws errorOther notes
Chrome Version 67.0.3396.87 (Official Build) (64-bit)
)UglifyJsPlugin
fromconfig/webpack.config.prod.js
(after ejecting) solves the problem and generates valid sourcemaps, but doesn't minify/uglify the bundled js.The text was updated successfully, but these errors were encountered: