Skip to content

Commit b984bf0

Browse files
committed
add experimental option
1 parent 00107cb commit b984bf0

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

packages/svelte/src/compiler/phases/2-analyze/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,9 @@ export function analyze_module(ast, options) {
263263
scope,
264264
scopes,
265265
// @ts-expect-error TODO
266-
analysis
266+
analysis,
267+
// @ts-expect-error TODO
268+
options
267269
},
268270
visitors
269271
);

packages/svelte/src/compiler/phases/2-analyze/visitors/AwaitExpression.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,14 @@ export function AwaitExpression(node, context) {
3232
}
3333
}
3434

35-
if (suspend && !context.state.analysis.runes) {
36-
e.legacy_await_invalid(node);
35+
if (suspend) {
36+
if (!context.state.options.experimental.async) {
37+
e.experimental_async(node);
38+
}
39+
40+
if (!context.state.analysis.runes) {
41+
e.legacy_await_invalid(node);
42+
}
3743
}
3844

3945
if (preserve_context) {

packages/svelte/tests/helpers.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ export async function compile_directory(
8686
const compiled = compileModule(text, {
8787
filename: opts.filename,
8888
generate: opts.generate,
89-
dev: opts.dev
89+
dev: opts.dev,
90+
experimental: opts.experimental
9091
});
9192
write(out, compiled.js.code.replace(`v${VERSION}`, 'VERSION'));
9293
} else {

packages/svelte/tests/runtime-legacy/shared.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ async function common_setup(cwd: string, runes: boolean | undefined, config: Run
157157
rootDir: cwd,
158158
dev: force_hmr ? true : undefined,
159159
hmr: force_hmr ? true : undefined,
160+
experimental: {
161+
async: true
162+
},
160163
...config.compileOptions,
161164
immutable: config.immutable,
162165
accessors: 'accessors' in config ? config.accessors : true,

0 commit comments

Comments
 (0)