Skip to content

Commit

Permalink
fix: only warn on context="module" in runes mode (#13332)
Browse files Browse the repository at this point in the history
* fix: only warn on context="module" in runes mode

* wow
Rich-Harris authored Sep 19, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent d6ab12a commit 2553932
Showing 7 changed files with 20 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/old-planets-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: only warn on context="module" in runes mode
2 changes: 0 additions & 2 deletions packages/svelte/src/compiler/phases/1-parse/read/script.js
Original file line number Diff line number Diff line change
@@ -74,8 +74,6 @@ export function read_script(parser, start, attributes) {
e.script_invalid_context(attribute);
}

w.script_context_deprecated(attribute);

context = 'module';
}
}
7 changes: 7 additions & 0 deletions packages/svelte/src/compiler/phases/2-analyze/index.js
Original file line number Diff line number Diff line change
@@ -359,6 +359,13 @@ export function analyze_component(root, source, options) {

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

if (runes && root.module) {
const context = root.module.attributes.find((attribute) => attribute.name === 'context');
if (context) {
w.script_context_deprecated(context);
}
}

// TODO remove all the ?? stuff, we don't need it now that we're validating the config
/** @type {ComponentAnalysis} */
const analysis = {
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<svelte:options runes />

<script context="module">
let num = 2;
</script>
Original file line number Diff line number Diff line change
@@ -4,11 +4,11 @@
"message": "`context=\"module\"` is deprecated, use the `module` attribute instead",
"start": {
"column": 8,
"line": 1
"line": 3
},
"end": {
"column": 24,
"line": 1
"line": 3
}
}
]

0 comments on commit 2553932

Please sign in to comment.