Support sourcemaps for client-only code? #5202
Replies: 8 comments 14 replies
-
I will definitely be looking into how we can optimize to allow sourcemaps in the browser without the server portions being included. It's strange though because at that point it's not a true sourcemap, but more of a partial-sourcemap. |
Beta Was this translation helpful? Give feedback.
-
The compiler makes 2 passes. One for the server build and the other for client. Each one includes the from remix/packages/remix-dev/compiler.ts Line 300 in e6e6e1c from remix/packages/remix-dev/compiler.ts Line 339 in e6e6e1c |
Beta Was this translation helpful? Give feedback.
-
But the sourcemap is not going to still show the loader/action code of each route? Because that's the source code used to create both the server and browser build. |
Beta Was this translation helpful? Give feedback.
-
Ah, I see what you mean. Yeah, I just checked the sourcemap generated for the route and "sourcesContent" includes the entire source of the file, not just the stripped/client version. I supposed you could post-process the sourcemap and simply hide all the code that's not supposed to be on the client (replace each line with a blank to preserve line numbers). You'd only need to do that on the production build. |
Beta Was this translation helpful? Give feedback.
-
Hmm. Why is this closed? It’s still an issue although there is a warning now that you probably shouldn’t expose your source map on production. I want to fix this so it post-processes the map file and strips server code from the route. |
Beta Was this translation helpful? Give feedback.
-
Converting this to a Proposal discussion, as per our Development Process. |
Beta Was this translation helpful? Give feedback.
-
What I actually would want, I think, is the server sourcemap and the client sourcemap to be in different files, so that I can have the server sourcemap available for Node stacktraces in logs but block it from being accessible by browsers, while client sourcemaps are accessible by browsers to help with debugging. |
Beta Was this translation helpful? Give feedback.
-
For anyone following: #8613 |
Beta Was this translation helpful? Give feedback.
-
Due to a security issue, sourcemaps were made opt-in: #350
Luckily for me all my code is open source anyway so I can just enable them. But I think there's probably a lot of value for people who don't want their server-side source to be visible but want client-side sourcemaps. What are the chances we could get an option (or a default) that adds sourcemaps but only for the client-side code?
I'm not even sure how possible that would be, but if it were possible to have sourcemaps for my modules that somehow magically doesn't include any server code that would be a stellar default I think.
Beta Was this translation helpful? Give feedback.
All reactions