Invalid source maps when building with optimization
See original GitHub issueCurrent Behavior
When building a React App with
"optimization": true,
"sourceMap": true
Most files output the following warning :
WARNING in polyfills.873be10ff174602d11b7.esm.js contains invalid source map
It does NOT happen if optimization is false.
I don’t know if it’s a problem with webpack, angular-cli, or anything else so I open the issue here.
Expected Behavior
All files must generate sourceMap when optimization is true.
Steps to Reproduce
Setup a new workspace with
npx create-nx-workspace --preset=react
In workspace.json, set sourceMap to true in
projects > myApp > targets > build > configuration > production
run nx build --prod
Failure Logs
WARNING in runtime.28c323bf8ee123f67bad.esm.js contains invalid source map
WARNING in polyfills.873be10ff174602d11b7.esm.js contains invalid source map
WARNING in styles.24784bf22071adf4d6c3.esm.js contains invalid source map
Environment
Node : 14.17.6
OS : darwin x64
npm : 6.14.15
nx : Not Found
@nrwl/angular : Not Found
@nrwl/cli : 12.9.0
@nrwl/cypress : 12.9.0
@nrwl/devkit : 12.9.0
@nrwl/eslint-plugin-nx : 12.9.0
@nrwl/express : Not Found
@nrwl/jest : 12.9.0
@nrwl/linter : 12.9.0
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/nx-cloud : Not Found
@nrwl/react : 12.9.0
@nrwl/schematics : Not Found
@nrwl/tao : 12.9.0
@nrwl/web : 12.9.0
@nrwl/workspace : 12.9.0
@nrwl/storybook : 12.9.0
@nrwl/gatsby : Not Found
typescript : 4.3.5
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Building Sentry: Source maps and their problems
Source maps are easy to get wrong. Matching filenames to URLs is complicated for users, and source maps can be insufficient for processing...
Read more >Source map errors — Firefox Source Docs documentation
The source map data can be invalid — either not a JSON file at all, or with an incorrect structure. Typical error messages...
Read more >Source Maps - SurviveJS
Skipping source maps speeds up your build as generating source maps at the best quality can be a complicated ... It's a good...
Read more >Error Messages | Maps JavaScript API - Google Developers
This page describes the error messages that can be returned by the Maps JavaScript API. The Maps JavaScript API writes error and warning...
Read more >Debugging — Emscripten 3.1.26-git (dev) documentation
Emcc strips out most of the debug information from optimized builds by default. ... The -gsource-map option is similar to -g2 but also...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

if you extend nx webpack and manually add sourceMap=true to all TerserPlugin entries, you get valid sourcemaps but it takes way too long (like 14 minutes as opposed to 45 seconds without)
+1 reproduced this on my react project with nx 12.6 and 12.9 cannot generate sourcemaps with
optimization: true`
WARNING in runtime.28c323bf8ee123f67bad.esm.js contains invalid source map
WARNING in main.32f12df25920d591dc11.esm.js contains invalid source map
WARNING in polyfills.8aff3952157e2c8fb9f6.esm.js contains invalid source map
WARNING in styles.f42fd7f76b98fe273020.esm.js contains invalid source map
`