Skip to content
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: Ensure sourcemap comments are stripped too #118

Merged
merged 3 commits into from
Jun 3, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/prerender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,19 @@ export function PrerenderPlugin({
let prerenderEntry: OutputChunk | undefined;
for (const output of Object.keys(bundle)) {
// Clean up source maps if the user didn't enable them themselves
if (/\.map$/.test(output) && !userEnabledSourceMaps) {
delete bundle[output];
continue;
if (!userEnabledSourceMaps) {
if (output.endsWith(".map")) {
delete bundle[output];
continue;
}
if (output.endsWith(".js") && bundle[output].type == "chunk") {
(bundle[output] as OutputChunk).code = (bundle[
output
] as OutputChunk).code.replace(/\/\/#\ssourceMappingURL=.*$/, "");
rschristian marked this conversation as resolved.
Show resolved Hide resolved
}
}
if (!/\.js$/.test(output) || bundle[output].type !== "chunk") continue;
if (!output.endsWith(".js") || bundle[output].type !== "chunk")
continue;

await fs.writeFile(
path.join(tmpDir, path.basename(output)),
Expand Down
Loading