I can't see the source in development in a create react app with typescript. it points to bundle.js and not the source. See image attached.
Any ideas how to show source maps?

I struggled with this problem (React 18 TypeScript bootstrapped with CRA) until now.
I had to eject to solve the issue, this is what worked for me:
npm run eject (ensure you've committed before doing this)./config/webpack.config.js edit the following line this way: return {
// ...
devtool: "eval-source-map",
// ...
}
{
"compilerOptions": {
"sourceMap": true,
at div
at Dashboard (webpack-internal:///./src/pages/Dashboard/Dashboard.tsx:55:69)
at Outlet (webpack-internal:///./node_modules/react-router/index.js:856:26)
Since the look of the output bothered me, I've made a dirty console.error override in my App.tsx :
// In your "main" function, for me App.tsx
if (process.env.NODE_ENV !== "production") {
const originalConsoleError = console.error;
console.error = function (...args) {
const modifiedArgs = args.map((arg) => {
if (typeof arg === "string") {
return arg.replace(/webpack-internal:\/\/\//g, "");
}
return arg;
});
originalConsoleError.apply(console, modifiedArgs);
};
}
The output is now cleaner:
at div
at Dashboard (./src/pages/Dashboard/Dashboard.tsx:55:69)
at Outlet (./node_modules/react-router/index.js:856:26)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With