3

I'm writing a Chrome extension using React, and more specifically, using Create React App. If I inspect the popup that the extension generates, look at Sources, and click on any of the js files, Chrome says "Source Map detected". If I click on "More", it says that "Associated files should be added to the file tree. You can debug these resolved source files as regular JavaScript files.". But I don't see the source files anywhere in the source tree. What do I need to do to be able to view them?

I've tried to add the source maps to the web_accessible_resources property of manifest.json (as per Do source maps work for Chrome extensions?), but that didn't work. Also tried the changes recommended in the top answer of chrome 72 changes sourcemap behaviour - making some changes to webpack.config.js and manifest.json - but that didn't work either.

Nicolas Trahan
  • 615
  • 2
  • 6
  • 13

1 Answers1

0

Are you working with workspaces?

https://developers.google.com/web/tools/chrome-devtools/workspaces/

BTW, create react app don't generate all the sourceMaps by default.

Could you check the file

node_modules/react-scripts/config/webpack.config.js

Search there for the sourceMap and sourceMaps, and see if that is ok for you. You can copy that file like "_original", and then set sourceMaps: true,

in all ocurrences. After that, completely stop the app, and then start it again.

Is that working now?

To verify which sourceMap is working or not, add the sources to workspaces and check for the green dot: https://developers.google.com/web/tools/chrome-devtools/workspaces/

zurcacielos
  • 1,495
  • 2
  • 9
  • 7
  • No, I'm not using workspaces. I'm building the app first and running the output folder in Chrome as an unpacked extension. Which means that it's running in "production", and according to the CRA docs, source maps are supposed to be generated in production (see GENERATE_SOURCEMAP in https://create-react-app.dev/docs/advanced-configuration/). That doesn't mean that all source maps will be generated? – Nicolas Trahan Nov 30 '19 at 19:09
  • Also, I don't want to have to modify webpack.config.js - I'd rather give up on source maps. A big reason (for me at least) for using Create React App in the first place is to not have to configure webpack manually. – Nicolas Trahan Nov 30 '19 at 19:09