Source Maps in node_modules package
See original GitHub issueI haven’t had much luck being able to debug/set breakpoints in source compiled with create-scripts and thought my use case may be somewhat unique, so I wanted to ask it here. If it’s something I should take up with VSCode, I will, but I needed to start somewhere.
My setup is VS Code with an app created by create-react-app. I can debug it just fine, and I hit my breakpoints, as expected, so source maps are indeed working. However, I recently moved some of our components out into its own libraries, so they can be published separately and used by multiple apps. So, now they look like (I’ve simplified the example):
app/
package.json
src/
App.js
libA/
components/
package.json
src/
componentA.js
lib/
componentA.js
componentA.js.map
Now, I can only set breakpoints in lib/componentA.js instead of src/componentA.js (pre-compiled source). Is this something that I should be able to get working?
Any direction would be helpful. Thanks in advance!
Edit: perhaps it’s related to https://github.com/facebook/create-react-app/pull/2355 ?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:34 (11 by maintainers)
On going for over a year now. Has anyone got any interest in fixing support for source-map from imported modules? My dev team and I use a private npm registry to split separation of concern into many packages, and i’m positive many many others do too! I imagine this issue has led to many people moving away from CRA.
Also, if you’re looking for a workaround in the meantime, I use customize-cra to inject source-map-loader into my CRA config. Below is a simplified version of the
config-overrides.js
file that I’ve been using for the last few months.If you’re not familiar with customize-cra, here’s how to use the code above:
config-overrides.js
in your project’s root foldernpm i -D github:volune/source-map-loader#fixes immer customize-cra react-app-rewired
scripts
to usereact-app-rewired
instead ofreact-scripts
. Like this: