From ae0d52d9990b48b0bd8a6e2cd6c97182a11c5a8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Tue, 25 Mar 2025 16:41:12 +0900 Subject: [PATCH] refactor: avoid assigning to bundle object (#4647) --- src/node/plugin.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/node/plugin.ts b/src/node/plugin.ts index 219c18b6..748c4da4 100644 --- a/src/node/plugin.ts +++ b/src/node/plugin.ts @@ -366,15 +366,12 @@ export async function createVitePressPlugin( pageToHashMap![chunk.name.toLowerCase()] = hash // inject another chunk with the content stripped - bundle[name + '-lean'] = { - ...chunk, + this.emitFile({ + type: 'asset', + name: name + '-lean', fileName: chunk.fileName.replace(/\.js$/, '.lean.js'), - preliminaryFileName: chunk.preliminaryFileName.replace( - /\.js$/, - '.lean.js' - ), - code: chunk.code.replace(staticStripRE, `""`) - } + source: chunk.code.replace(staticStripRE, `""`) + }) // remove static markers from original code chunk.code = chunk.code.replace(staticRestoreRE, '')