From f584bcec19ee83e0ba5e3235d2758b5038a44c4b Mon Sep 17 00:00:00 2001 From: Menci Date: Sun, 10 Dec 2023 17:38:09 +0800 Subject: [PATCH] fix: build break --- src/index.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index 8679447..db30d61 100644 --- a/src/index.ts +++ b/src/index.ts @@ -26,7 +26,7 @@ export default function topLevelAwait(options?: Options): Plugin { let buildTarget: ViteTarget; let minify: boolean; - const buildRawTarget = async (code: string) => { + const buildRawTarget = async (code: string) => { return ( await esbuild.transform(code, { minify, @@ -34,7 +34,7 @@ export default function topLevelAwait(options?: Options): Plugin { format: "esm" }) ).code as string; - } + }; return { name: "vite-plugin-top-level-await", @@ -87,10 +87,10 @@ export default function topLevelAwait(options?: Options): Plugin { Object.keys(bundleChunks).map(async moduleName => { if (!bundleInfo[moduleName].transformNeeded) { if (buildTarget !== "esnext") { - (bundle[moduleName] as OutputChunk).code = buildRawTarget(bundleChunks[moduleName]); + (bundle[moduleName] as OutputChunk).code = await buildRawTarget(bundleChunks[moduleName]); } - return - }; + return; + } const newAst = transformModule( bundleChunks[moduleName],