Skip to content

Commit

Permalink
Merge branch 'main' of github.com:yooouuri/vite-plugin-vue-ssr into a…
Browse files Browse the repository at this point in the history
…dd-h3
  • Loading branch information
yooouuri committed Dec 12, 2024
2 parents b2237f5 + 0a20253 commit 0574d52
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 64 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite-plugin-vue-ssr",
"version": "0.12.1",
"version": "0.12.2",
"packageManager": "[email protected]",
"type": "module",
"license": "MIT",
Expand Down
3 changes: 0 additions & 3 deletions playground/pinia-example/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,4 @@ export default defineConfig({
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
build: {
target: [ 'es2022', 'edge89', 'firefox89', 'chrome89', 'safari15' ],
},
})
3 changes: 0 additions & 3 deletions playground/vue-router/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,4 @@ export default defineConfig({
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
build: {
target: [ 'es2022', 'edge89', 'firefox89', 'chrome89', 'safari15' ],
},
})
120 changes: 63 additions & 57 deletions src/plugin/transformEntrypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
]
)
),
]
)
)
]
)
)
]
)
]
)
)
]
)
]
)
Expand Down

0 comments on commit 0574d52

Please sign in to comment.