Skip to content

Commit 2553932

Browse files
authored
fix: only warn on context="module" in runes mode (#13332)
* fix: only warn on context="module" in runes mode * wow
1 parent d6ab12a commit 2553932

File tree

7 files changed

+20
-4
lines changed

7 files changed

+20
-4
lines changed

.changeset/old-planets-kiss.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+
fix: only warn on context="module" in runes mode

packages/svelte/src/compiler/phases/1-parse/read/script.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ export function read_script(parser, start, attributes) {
7474
e.script_invalid_context(attribute);
7575
}
7676

77-
w.script_context_deprecated(attribute);
78-
7977
context = 'module';
8078
}
8179
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,13 @@ export function analyze_component(root, source, options) {
359359

360360
const runes = options.runes ?? Array.from(module.scope.references.keys()).some(is_rune);
361361

362+
if (runes && root.module) {
363+
const context = root.module.attributes.find((attribute) => attribute.name === 'context');
364+
if (context) {
365+
w.script_context_deprecated(context);
366+
}
367+
}
368+
362369
// TODO remove all the ?? stuff, we don't need it now that we're validating the config
363370
/** @type {ComponentAnalysis} */
364371
const analysis = {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<svelte:options runes />
2+
3+
<script context="module">
4+
let num = 2;
5+
</script>

packages/svelte/tests/validator/samples/script-context-module-deprecated/warnings.json renamed to packages/svelte/tests/validator/samples/script-context-module-runes-deprecated/warnings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"message": "`context=\"module\"` is deprecated, use the `module` attribute instead",
55
"start": {
66
"column": 8,
7-
"line": 1
7+
"line": 3
88
},
99
"end": {
1010
"column": 24,
11-
"line": 1
11+
"line": 3
1212
}
1313
}
1414
]

0 commit comments

Comments
 (0)