Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/stupid-dancers-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': minor
---

feat: support ES2026 (Explicit Resource Management)
2 changes: 1 addition & 1 deletion packages/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
"@jridgewell/sourcemap-codec": "^1.5.0",
"@sveltejs/acorn-typescript": "^1.0.5",
"@types/estree": "^1.0.5",
"acorn": "^8.12.1",
"acorn": "^8.15.0",
"aria-query": "^5.3.1",
"axobject-query": "^4.1.0",
"clsx": "^2.1.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/svelte/src/compiler/phases/1-parse/acorn.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function parse(source, comments, typescript, is_script) {
ast = parser.parse(source, {
onComment,
sourceType: 'module',
ecmaVersion: 16,
ecmaVersion: 17,
locations: true
});
} finally {
Expand Down Expand Up @@ -84,7 +84,7 @@ export function parse_expression_at(source, comments, typescript, index) {
const ast = parser.parseExpressionAt(source, index, {
onComment,
sourceType: 'module',
ecmaVersion: 16,
ecmaVersion: 17,
locations: true
});

Expand Down
2 changes: 2 additions & 0 deletions packages/svelte/src/compiler/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ export type DeclarationKind =
| 'var'
| 'let'
| 'const'
| 'using'
| 'await using'
| 'function'
| 'import'
| 'param'
Expand Down
6 changes: 4 additions & 2 deletions packages/svelte/src/compiler/utils/builders.js
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,8 @@ export function import_all(as, source) {
return {
type: 'ImportDeclaration',
source: literal(source),
specifiers: [import_namespace(as)]
specifiers: [import_namespace(as)],
attributes: []
};
}

Expand All @@ -636,7 +637,8 @@ export function imports(parts, source) {
type: 'ImportSpecifier',
imported: id(p[0]),
local: id(p[1])
}))
})),
attributes: []
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@
"kind": "let"
},
"specifiers": [],
"source": null
"source": null,
"attributes": []
}
],
"sourceType": "module"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@
"kind": "const"
},
"specifiers": [],
"source": null
"source": null,
"attributes": []
}
],
"sourceType": "module"
Expand Down
8 changes: 8 additions & 0 deletions packages/svelte/tests/runtime-legacy/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import type { CompileOptions } from '#compiler';
import { suite_with_variants, type BaseTest } from '../suite.js';
import { clear } from '../../src/internal/client/reactivity/batch.js';

const NODE_MAJOR_VERSION = parseInt(process.version.split('.')[0].slice(1));

type Assert = typeof import('vitest').assert & {
htmlEqual(a: string, b: string, description?: string): void;
htmlEqualWithOptions(
Expand Down Expand Up @@ -95,6 +97,7 @@ export interface RuntimeTest<Props extends Record<string, any> = Record<string,
expect_unhandled_rejections?: boolean;
withoutNormalizeHtml?: boolean | 'only-strip-comments';
recover?: boolean;
requiredMinimumNodeVersion?: 18 | 20 | 22 | 24;
}

let unhandled_rejection: Error | null = null;
Expand Down Expand Up @@ -127,6 +130,11 @@ export function runtime_suite(runes: boolean) {
return suite_with_variants<RuntimeTest, 'hydrate' | 'ssr' | 'dom', CompileOptions>(
['dom', 'hydrate', 'ssr'],
(variant, config, test_name) => {
const { requiredMinimumNodeVersion } = config;
if (requiredMinimumNodeVersion && NODE_MAJOR_VERSION < requiredMinimumNodeVersion) {
return 'no-test';
}

if (!async_mode && (config.skip_no_async || test_name.startsWith('async-'))) {
return true;
}
Expand Down
11 changes: 11 additions & 0 deletions packages/svelte/tests/runtime-runes/samples/using/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { flushSync } from 'svelte';
import { test } from '../../test';

export default test({
html: '',
requiredMinimumNodeVersion: 24,
test({ assert, target }) {
flushSync();
assert.htmlEqual(target.innerHTML, `<p>connected: true</p><p>disposed: true</p>`);
}
});
18 changes: 18 additions & 0 deletions packages/svelte/tests/runtime-runes/samples/using/main.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<script>
let connected = $state(false);
let disposed = $state(false);

const getConn = () => {
connected = true;
return {
[Symbol.dispose]() {
disposed = true;
}
}
}

using conn = getConn();
</script>

<p>connected: {connected}</p>
<p>disposed: {disposed}</p>
Loading
Loading