Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: only warn on context="module" in runes mode #13332

Merged
merged 2 commits into from
Sep 19, 2024
Merged
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/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
Expand Up @@ -74,8 +74,6 @@ export function read_script(parser, start, attributes) {
e.script_invalid_context(attribute);
}

w.script_context_deprecated(attribute);

context = 'module';
}
}
Expand Down
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
Expand Up @@ -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 = {
Expand Down
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
Expand Up @@ -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
}
}
]