Skip to content

Commit 88d7e05

Browse files
authored
chore: update sandbox to support async SSR (#16787)
* chore: update sandbox to support async SSR * dedupe * fix some stuff * fix * bump devDependencies
1 parent 16e16da commit 88d7e05

File tree

13 files changed

+577
-497
lines changed

13 files changed

+577
-497
lines changed

.changeset/friendly-queens-melt.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte": patch
3+
---
4+
5+
chore: bump some devDependencies

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"@sveltejs/eslint-config": "^8.3.3",
3131
"@svitejs/changesets-changelog-github-compact": "^1.1.0",
3232
"@types/node": "^20.11.5",
33+
"@types/picomatch": "^4.0.2",
3334
"@vitest/coverage-v8": "^2.1.9",
3435
"eslint": "^9.9.1",
3536
"eslint-plugin-lube": "^0.4.3",

packages/svelte/src/compiler/types/index.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,16 @@ export type DeclarationKind =
283283
| 'var'
284284
| 'let'
285285
| 'const'
286+
| 'using'
287+
| 'await using'
286288
| 'function'
287289
| 'import'
288290
| 'param'
289291
| 'rest_param'
290-
| 'synthetic';
292+
| 'synthetic'
293+
// TODO not yet implemented, but needed for TypeScript reasons
294+
| 'using'
295+
| 'await using';
291296

292297
export interface ExpressionMetadata {
293298
/** All the bindings that are referenced eagerly (not inside functions) in this expression */

packages/svelte/src/compiler/utils/builders.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,14 @@ export function prop(kind, key, value, computed = false) {
364364
* @returns {ESTree.PropertyDefinition}
365365
*/
366366
export function prop_def(key, value, computed = false, is_static = false) {
367-
return { type: 'PropertyDefinition', key, value, computed, static: is_static };
367+
return {
368+
type: 'PropertyDefinition',
369+
decorators: [],
370+
key,
371+
value,
372+
computed,
373+
static: is_static
374+
};
368375
}
369376

370377
/**
@@ -565,6 +572,7 @@ function for_builder(init, test, update, body) {
565572
export function method(kind, key, params, body, computed = false, is_static = false) {
566573
return {
567574
type: 'MethodDefinition',
575+
decorators: [],
568576
key,
569577
kind,
570578
value: function_builder(null, params, block(body)),
@@ -610,6 +618,7 @@ function if_builder(test, consequent, alternate) {
610618
export function import_all(as, source) {
611619
return {
612620
type: 'ImportDeclaration',
621+
attributes: [],
613622
source: literal(source),
614623
specifiers: [import_namespace(as)]
615624
};
@@ -623,6 +632,7 @@ export function import_all(as, source) {
623632
export function imports(parts, source) {
624633
return {
625634
type: 'ImportDeclaration',
635+
attributes: [],
626636
source: literal(source),
627637
specifiers: parts.map((p) => ({
628638
type: 'ImportSpecifier',

packages/svelte/tests/parser-legacy/samples/each-block-destructured/output.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@
259259
"kind": "let"
260260
},
261261
"specifiers": [],
262-
"source": null
262+
"source": null,
263+
"attributes": []
263264
}
264265
],
265266
"sourceType": "module"

packages/svelte/tests/parser-legacy/samples/script-context-module-unquoted/output.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@
169169
"kind": "const"
170170
},
171171
"specifiers": [],
172-
"source": null
172+
"source": null,
173+
"attributes": []
173174
}
174175
],
175176
"sourceType": "module"

playgrounds/sandbox/Wrapper.svelte

Lines changed: 0 additions & 9 deletions
This file was deleted.

playgrounds/sandbox/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<script type="module">
1414
import { mount, hydrate, unmount } from 'svelte';
15-
import App from '/Wrapper.svelte';
15+
import App from '/src/App.svelte';
1616

1717
globalThis.delayed = (v, ms = 1000) => {
1818
return new Promise((f) => {

playgrounds/sandbox/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
"start": "node run.js"
1717
},
1818
"devDependencies": {
19-
"@sveltejs/vite-plugin-svelte": "^4.0.0-next.6",
19+
"@sveltejs/vite-plugin-svelte": "^6.2.0",
20+
"@types/node": "^24.5.2",
2021
"polka": "^1.0.0-next.25",
2122
"svelte": "workspace:*",
2223
"tinyglobby": "^0.2.12",
23-
"vite": "^5.4.20",
24-
"vite-plugin-inspect": "^0.8.4"
24+
"vite": "^7.1.5",
25+
"vite-plugin-devtools-json": "^1.0.0",
26+
"vite-plugin-inspect": "^11.3.3"
2527
}
2628
}

playgrounds/sandbox/ssr-dev.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import path from 'node:path';
44
import { fileURLToPath } from 'node:url';
55
import polka from 'polka';
66
import { createServer as createViteServer } from 'vite';
7-
import { render } from 'svelte/server';
87
import './ssr-common.js';
98

109
const PORT = process.env.PORT || '5173';
@@ -23,8 +22,11 @@ polka()
2322
.use(async (req, res) => {
2423
const template = fs.readFileSync(path.resolve(__dirname, 'index.html'), 'utf-8');
2524
const transformed_template = await vite.transformIndexHtml(req.url, template);
25+
26+
const { render } = await vite.ssrLoadModule('svelte/server');
2627
const { default: App } = await vite.ssrLoadModule('/src/App.svelte');
27-
const { head, body } = render(App);
28+
29+
const { head, body } = await render(App);
2830

2931
const html = transformed_template
3032
.replace(`<!--ssr-head-->`, head)

0 commit comments

Comments
 (0)