Skip to content

Commit 33992ed

Browse files
committed
fix?
1 parent 3e54616 commit 33992ed

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

packages/svelte/src/compiler/phases/3-transform/client/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export interface ParallelizedChunk {
8888
id: Pattern | null;
8989
init: Expression;
9090
}>;
91-
kind: VariableDeclaration['kind'] | null;
91+
kind: 'var' | 'let' | 'const' | null;
9292
/** index in instance body */
9393
position: number;
9494
bindings: Binding[];

packages/svelte/src/compiler/phases/3-transform/client/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export function can_be_parallelized(expression, scope, analysis, bindings) {
5454
NewExpression: stop,
5555
StaticBlock: stop,
5656
Identifier(node, { path }) {
57+
// @ts-expect-error wtf
5758
if (is_reference(node, /** @type {Node} */ (path.at(-1)))) {
5859
references.add(node.name);
5960
}

packages/svelte/src/compiler/phases/3-transform/client/visitors/VariableDeclaration.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ export function VariableDeclaration(node, context) {
4747

4848
continue;
4949
}
50+
const kind = node.kind;
5051
if (
52+
kind !== 'using' && kind !== 'await using' &&
5153
init?.type === 'AwaitExpression' &&
5254
context.state.analysis.instance?.scope === context.state.scope &&
5355
!is_expression_async(init.argument)
@@ -72,16 +74,16 @@ export function VariableDeclaration(node, context) {
7274
};
7375
if (
7476
current_chunk &&
75-
(current_chunk.kind === node.kind || current_chunk.kind === null)
77+
(current_chunk.kind === kind || current_chunk.kind === null)
7678
) {
7779
current_chunk.declarators.push(_declarator);
7880
current_chunk.bindings.push(...bindings);
7981
current_chunk.position = /** @type {Program} */ (parent).body.indexOf(node);
80-
current_chunk.kind = node.kind;
82+
current_chunk.kind = kind;
8183
} else {
8284
/** @type {ParallelizedChunk} */
8385
const chunk = {
84-
kind: node.kind,
86+
kind,
8587
declarators: [_declarator],
8688
position,
8789
bindings
@@ -179,11 +181,13 @@ export function VariableDeclaration(node, context) {
179181
if (rune === '$state' || rune === '$state.raw') {
180182
const state_declarators = [];
181183
const current_chunk = context.state.current_parallelized_chunk;
184+
const kind = node.kind;
182185
const parallelize =
183186
declarator.id.type === 'Identifier' &&
184187
context.state.analysis.instance?.scope === context.state.scope &&
185188
value.type === 'AwaitExpression' &&
186189
!is_expression_async(value.argument) &&
190+
kind !== 'using' && kind !== 'await using' &&
187191
can_be_parallelized(value.argument, context.state.scope, context.state.analysis, [
188192
...(current_chunk?.bindings ?? []),
189193
...bindings
@@ -294,11 +298,11 @@ export function VariableDeclaration(node, context) {
294298
current_chunk.declarators.push(...declarators);
295299
current_chunk.bindings.push(...bindings);
296300
current_chunk.position = position;
297-
current_chunk.kind = node.kind;
301+
current_chunk.kind = kind;
298302
} else {
299303
/** @type {ParallelizedChunk} */
300304
const chunk = {
301-
kind: node.kind,
305+
kind,
302306
declarators,
303307
position,
304308
bindings
@@ -322,13 +326,15 @@ export function VariableDeclaration(node, context) {
322326
context.state.analysis.instance &&
323327
context.state.scope === context.state.analysis.instance.scope &&
324328
// TODO make it work without this
325-
declarator.id.type === 'Identifier'
329+
declarator.id.type === 'Identifier' &&
330+
node.kind !== 'await using' && node.kind !== 'using'
326331
) {
327332
parallelize = can_be_parallelized(value, context.state.scope, context.state.analysis, [
328333
...(current_chunk?.bindings ?? []),
329334
...context.state.scope.get_bindings(declarator)
330335
]);
331336
}
337+
const kind = /** @type {ParallelizedChunk['kind']} */ (node.kind);
332338

333339
/** @type {VariableDeclarator[]} */
334340
const derived_declarators = [];
@@ -428,15 +434,15 @@ export function VariableDeclaration(node, context) {
428434
id,
429435
init: /** @type {Expression} */ (init)
430436
}));
431-
if (current_chunk && (current_chunk.kind === node.kind || current_chunk.kind === null)) {
437+
if (current_chunk && (current_chunk.kind === kind || current_chunk.kind === null)) {
432438
current_chunk.declarators.push(...declarators);
433439
current_chunk.bindings.push(...bindings);
434440
current_chunk.position = position;
435-
current_chunk.kind = node.kind;
441+
current_chunk.kind = kind;
436442
} else {
437443
/** @type {ParallelizedChunk} */
438444
const chunk = {
439-
kind: node.kind,
445+
kind,
440446
declarators,
441447
position,
442448
bindings

0 commit comments

Comments
 (0)