From 06887b30b3f65d43f46c47cd0a11910a46507c83 Mon Sep 17 00:00:00 2001 From: Youri van Mill Date: Wed, 21 Aug 2024 16:22:06 +0200 Subject: [PATCH 1/2] chore: remove top level await requirement (#9) --- playground/pinia-example/vite.config.ts | 3 - playground/vue-router/vite.config.ts | 3 - src/plugin/transformEntrypoint.ts | 120 +++++++++++++----------- 3 files changed, 63 insertions(+), 63 deletions(-) diff --git a/playground/pinia-example/vite.config.ts b/playground/pinia-example/vite.config.ts index d6c1267..7ee56ed 100644 --- a/playground/pinia-example/vite.config.ts +++ b/playground/pinia-example/vite.config.ts @@ -13,7 +13,4 @@ export default defineConfig({ '@': fileURLToPath(new URL('./src', import.meta.url)), }, }, - build: { - target: [ 'es2022', 'edge89', 'firefox89', 'chrome89', 'safari15' ], - }, }) diff --git a/playground/vue-router/vite.config.ts b/playground/vue-router/vite.config.ts index d6c1267..7ee56ed 100644 --- a/playground/vue-router/vite.config.ts +++ b/playground/vue-router/vite.config.ts @@ -13,7 +13,4 @@ export default defineConfig({ '@': fileURLToPath(new URL('./src', import.meta.url)), }, }, - build: { - target: [ 'es2022', 'edge89', 'firefox89', 'chrome89', 'safari15' ], - }, }) diff --git a/src/plugin/transformEntrypoint.ts b/src/plugin/transformEntrypoint.ts index becd683..8834dc7 100644 --- a/src/plugin/transformEntrypoint.ts +++ b/src/plugin/transformEntrypoint.ts @@ -21,66 +21,72 @@ export function transformEntrypoint(code: string, ssr: boolean, ssrBuild: boolea ExportDefaultDeclaration(path) { path.replaceWithMultiple( [ - t.variableDeclaration( - 'const', - [ - t.variableDeclarator( - t.objectPattern([ - t.objectProperty( - t.identifier('app'), - t.identifier('app'), - false, - true - ), - t.objectProperty( - t.identifier('router'), - t.identifier('router'), - false, - true - ) - ]), - t.awaitExpression( - t.callExpression( - t.identifier('vueSSR'), - [ ...path.node.declaration.arguments, t.identifier(ssrBuild ? 'true' : 'false') ] - ) - ), - ), - ] - ), - t.expressionStatement( - t.callExpression( - t.memberExpression( - t.callExpression( - t.memberExpression( - t.identifier('router'), - t.identifier('isReady') - ), - [] - ), - t.identifier('then') + t.callExpression( + t.memberExpression( + t.callExpression( + t.identifier('vueSSR'), + [ ...path.node.declaration.arguments, t.identifier(ssrBuild ? 'true' : 'false') ] ), - [ - t.arrowFunctionExpression( - [], - t.blockStatement( - [ - t.expressionStatement( - t.callExpression( - t.memberExpression( - t.identifier('app'), - t.identifier('mount') + t.identifier('then') + ), + [ + t.arrowFunctionExpression( + [ + t.objectPattern([ + t.objectProperty( + t.identifier('app'), + t.identifier('app'), + false, + true + ), + t.objectProperty( + t.identifier('router'), + t.identifier('router'), + false, + true + ), + ]), + ], + t.blockStatement( + [ + t.expressionStatement( + t.callExpression( + t.memberExpression( + t.callExpression( + t.memberExpression( + t.identifier('router'), + t.identifier('isReady') + ), + [] ), - [ - t.stringLiteral('#app') - ] - ) - ), - ] - ) + t.identifier('then') + ), + [ + t.arrowFunctionExpression( + [], + t.blockStatement( + [ + t.expressionStatement( + t.callExpression( + t.memberExpression( + t.identifier('app'), + t.identifier('mount') + ), + [ + t.stringLiteral('#app') + ] + ) + ), + ] + ) + ) + ] + ) + ) + ] ) - ] - ) + ) + ] ) ] ) From 0a202535e911a6d90193954cae289e5164148457 Mon Sep 17 00:00:00 2001 From: Youri van Mill Date: Wed, 21 Aug 2024 16:22:58 +0200 Subject: [PATCH 2/2] release: v0.12.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b9bcca6..cb3c73a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vite-plugin-vue-ssr", - "version": "0.12.1", + "version": "0.12.2", "packageManager": "pnpm@9.6.0", "type": "module", "license": "MIT",