Skip to content

Commit 775e26d

Browse files
committed
refactor: Skip second loop, delete from bundle earlier
1 parent d1a2486 commit 775e26d

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/prerender.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,11 @@ export function PrerenderPlugin({
221221

222222
let prerenderEntry: OutputChunk | undefined;
223223
for (const output of Object.keys(bundle)) {
224+
// Clean up source maps if the user didn't enable them themselves
225+
if (/\.map$/.test(output) && !userEnabledSourceMaps) {
226+
delete bundle[output];
227+
continue;
228+
}
224229
if (!/\.js$/.test(output) || bundle[output].type !== "chunk") continue;
225230

226231
await fs.writeFile(
@@ -407,14 +412,5 @@ export function PrerenderPlugin({
407412
});
408413
}
409414
},
410-
async writeBundle(_opts, bundle) {
411-
if (!userEnabledSourceMaps) {
412-
Object.keys(bundle)
413-
.filter(f => /\.map$/.test(f))
414-
.forEach(async f => {
415-
fs.rm(path.join(viteConfig.root, viteConfig.build.outDir, f));
416-
});
417-
}
418-
},
419415
};
420416
}

0 commit comments

Comments
 (0)