-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix] ssr remove css map #6744
[fix] ssr remove css map #6744
Conversation
This makes me nervous. Is there anything else this might be breaking, even if other official Svelte tooling doesn't use this? Do browsers use these CSS sourcemaps? |
This comment has been minimized.
This comment has been minimized.
There was a thread about it in the maintainers chat. But in short, the only way someone could access the sourcemap is when there's a bundler plugin that extracts the inline css sourcemap after compiling the svelte component in SSR. And I can't think of a reason someone wants to do that, especially that the official way to get the css sourcemap is via AFAIK, the sourcemap can't be leaked in any other ways than mentioned above. And if the generated code isn't following semver, it should be safe to make the change.
That PR won't help with this though since it would still do code replacements and mess with the code in the css sourcemap. |
Closing in favour of a new |
Tried making the I'm thinking something like |
Yeah, it looks like that option was added in #5584, but not documented. We should probably add it to the documentation. Regarding the API for the new option, I wonder if just on / off is enough. E.g. Rollup lets you choose between inline, separate file, hidden (which I don't quite understand the description of), or off: https://rollupjs.org/guide/en/#outputsourcemap |
I'm not sure if on/off could work since in SSR we might want to have JS sourcemaps, but no CSS sourcemaps. Currently in SSR, CSS sourcemaps are always inlined by Svelte, even before the bundler step, which feels a bit weird but I'm not familiar with sourcemaps enough to justify. I might go with the |
I was saying that even for js vs css just turning them on vs off might not be enough because maybe you'd need to decide inline vs external for each one. But actually, I'm not sure my thought was correct because now I'm remembering that I think the idea is that the plugins pass along the sourcemap via the Rollup API and then it's Rollup that would decide inline vs external at the end after collecting and merging all the source maps (I think) This isn't a problem on the client-side because the CSS is extracted out into separate files. I wonder if we could do that on the server-side as well. Though that might have to be a v4 thing if we did it since I think it'd be a breaking change |
Ah gotcha. Yeah I too haven't wrapped my head around how we would handle sourcemaps in the server-side. In the meantime, I'll try to get an simple but agnostic option to remove this specific sourcemap use-case. |
Fixes sveltejs/kit#720.
The inline sourcemap's
sourcesContent
was interfering with Vite's production replacement, since they are applied near the end of the build process (after svelte has been compiled). So we remove the sourcemap instead since it wasn't actually being used.REPL to show css map issue. (Compile to
ssr
)See sveltejs/kit#720 (comment) for more info.
Before submitting the PR, please make sure you do the following
[feat]
,[fix]
,[chore]
, or[docs]
.Tests
npm test
and lint the project withnpm run lint