Skip to content

Commit

Permalink
fix: build break
Browse files Browse the repository at this point in the history
  • Loading branch information
Menci committed Dec 10, 2023
1 parent c43ba2b commit f584bce
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ 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,
target: buildTarget as string | string[],
format: "esm"
})
).code as string;
}
};

return {
name: "vite-plugin-top-level-await",
Expand Down Expand Up @@ -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],
Expand Down

0 comments on commit f584bce

Please sign in to comment.