diff --git a/.changeset/quick-eagles-sit.md b/.changeset/quick-eagles-sit.md new file mode 100644 index 000000000000..613ea2bd053c --- /dev/null +++ b/.changeset/quick-eagles-sit.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +breaking: deprecate `context="module"` in favor of `module` diff --git a/documentation/docs/02-template-syntax/01-component-fundamentals.md b/documentation/docs/02-template-syntax/01-component-fundamentals.md index debe4828d257..fc81bb24bd8f 100644 --- a/documentation/docs/02-template-syntax/01-component-fundamentals.md +++ b/documentation/docs/02-template-syntax/01-component-fundamentals.md @@ -161,16 +161,16 @@ If you'd like to react to changes to a prop, use the `$derived` or `$effect` run For more information on reactivity, read the documentation around runes. -## <script context="module"> +## <script module> -A ` diff --git a/packages/svelte/tests/compiler-errors/samples/store-autosub-context-module/_config.js b/packages/svelte/tests/compiler-errors/samples/store-autosub-context-module/_config.js index a48923bd4ac9..4983e054197d 100644 --- a/packages/svelte/tests/compiler-errors/samples/store-autosub-context-module/_config.js +++ b/packages/svelte/tests/compiler-errors/samples/store-autosub-context-module/_config.js @@ -3,7 +3,7 @@ import { test } from '../../test'; export default test({ error: { code: 'store_invalid_subscription', - message: 'Cannot reference store value inside ` diff --git a/packages/svelte/tests/migrate/samples/script-context-module/output.svelte b/packages/svelte/tests/migrate/samples/script-context-module/output.svelte new file mode 100644 index 000000000000..e508049d5db1 --- /dev/null +++ b/packages/svelte/tests/migrate/samples/script-context-module/output.svelte @@ -0,0 +1,3 @@ + diff --git a/packages/svelte/tests/parser-modern/samples/options/input.svelte b/packages/svelte/tests/parser-modern/samples/options/input.svelte index 9e8253c50c99..b7ee13b5e519 100644 --- a/packages/svelte/tests/parser-modern/samples/options/input.svelte +++ b/packages/svelte/tests/parser-modern/samples/options/input.svelte @@ -1,6 +1,6 @@ - \ No newline at end of file + export const Widget = { Tooltip }; + diff --git a/packages/svelte/tests/runtime-legacy/samples/component-namespaced/components.svelte b/packages/svelte/tests/runtime-legacy/samples/component-namespaced/components.svelte index 5b9a6c5167a8..3672036a534a 100644 --- a/packages/svelte/tests/runtime-legacy/samples/component-namespaced/components.svelte +++ b/packages/svelte/tests/runtime-legacy/samples/component-namespaced/components.svelte @@ -1,5 +1,5 @@ - \ No newline at end of file + export const Components = { Foo }; + diff --git a/packages/svelte/tests/runtime-legacy/samples/component-slot-fallback-2/store.svelte b/packages/svelte/tests/runtime-legacy/samples/component-slot-fallback-2/store.svelte index e377aaf3149c..ef5dc7e91ae0 100644 --- a/packages/svelte/tests/runtime-legacy/samples/component-slot-fallback-2/store.svelte +++ b/packages/svelte/tests/runtime-legacy/samples/component-slot-fallback-2/store.svelte @@ -1,23 +1,23 @@ - \ No newline at end of file + diff --git a/packages/svelte/tests/runtime-legacy/samples/context-api/Tabs.svelte b/packages/svelte/tests/runtime-legacy/samples/context-api/Tabs.svelte index 6692bb31e962..79cc4e11b1be 100644 --- a/packages/svelte/tests/runtime-legacy/samples/context-api/Tabs.svelte +++ b/packages/svelte/tests/runtime-legacy/samples/context-api/Tabs.svelte @@ -1,6 +1,6 @@ - diff --git a/packages/svelte/tests/runtime-legacy/samples/deconflict-component-name-with-module-global/main.svelte b/packages/svelte/tests/runtime-legacy/samples/deconflict-component-name-with-module-global/main.svelte index a14f3e7a1e7e..9fac58577504 100644 --- a/packages/svelte/tests/runtime-legacy/samples/deconflict-component-name-with-module-global/main.svelte +++ b/packages/svelte/tests/runtime-legacy/samples/deconflict-component-name-with-module-global/main.svelte @@ -1,5 +1,5 @@ - -

{set.has('x')}

\ No newline at end of file +

{set.has('x')}

diff --git a/packages/svelte/tests/runtime-legacy/samples/module-context-export-referenced-in-template/Foo.svelte b/packages/svelte/tests/runtime-legacy/samples/module-context-export-referenced-in-template/Foo.svelte index a0f3258fd671..4750e6253b7a 100644 --- a/packages/svelte/tests/runtime-legacy/samples/module-context-export-referenced-in-template/Foo.svelte +++ b/packages/svelte/tests/runtime-legacy/samples/module-context-export-referenced-in-template/Foo.svelte @@ -1,5 +1,7 @@ - diff --git a/packages/svelte/tests/runtime-legacy/samples/module-context-export/Foo.svelte b/packages/svelte/tests/runtime-legacy/samples/module-context-export/Foo.svelte index c992ceef528d..86f110f48180 100644 --- a/packages/svelte/tests/runtime-legacy/samples/module-context-export/Foo.svelte +++ b/packages/svelte/tests/runtime-legacy/samples/module-context-export/Foo.svelte @@ -1,4 +1,4 @@ - diff --git a/packages/svelte/tests/runtime-legacy/samples/module-context/main.svelte b/packages/svelte/tests/runtime-legacy/samples/module-context/main.svelte index 851d98bea3e0..2e1ae663fb22 100644 --- a/packages/svelte/tests/runtime-legacy/samples/module-context/main.svelte +++ b/packages/svelte/tests/runtime-legacy/samples/module-context/main.svelte @@ -1,5 +1,5 @@ - -

{foo}

\ No newline at end of file +

{foo}

diff --git a/packages/svelte/tests/runtime-legacy/samples/preload/main.svelte b/packages/svelte/tests/runtime-legacy/samples/preload/main.svelte index f7f2adff1874..b285d423fc13 100644 --- a/packages/svelte/tests/runtime-legacy/samples/preload/main.svelte +++ b/packages/svelte/tests/runtime-legacy/samples/preload/main.svelte @@ -1,7 +1,7 @@ - \ No newline at end of file + diff --git a/packages/svelte/tests/runtime-legacy/samples/reactive-import-statement-module/main.svelte b/packages/svelte/tests/runtime-legacy/samples/reactive-import-statement-module/main.svelte index beb2c406d123..18db8a7a3137 100644 --- a/packages/svelte/tests/runtime-legacy/samples/reactive-import-statement-module/main.svelte +++ b/packages/svelte/tests/runtime-legacy/samples/reactive-import-statement-module/main.svelte @@ -1,4 +1,4 @@ - diff --git a/packages/svelte/tests/runtime-legacy/samples/store-imported-module/main.svelte b/packages/svelte/tests/runtime-legacy/samples/store-imported-module/main.svelte index 8710e3d1c6f5..35986d43d53f 100644 --- a/packages/svelte/tests/runtime-legacy/samples/store-imported-module/main.svelte +++ b/packages/svelte/tests/runtime-legacy/samples/store-imported-module/main.svelte @@ -1,4 +1,4 @@ - diff --git a/packages/svelte/tests/runtime-runes/samples/class-state-derived-unowned/main.svelte b/packages/svelte/tests/runtime-runes/samples/class-state-derived-unowned/main.svelte index baa1b4aa8696..898df1d66ce6 100644 --- a/packages/svelte/tests/runtime-runes/samples/class-state-derived-unowned/main.svelte +++ b/packages/svelte/tests/runtime-runes/samples/class-state-derived-unowned/main.svelte @@ -1,4 +1,4 @@ - diff --git a/packages/svelte/tests/runtime-runes/samples/derived-unowned-5/main.svelte b/packages/svelte/tests/runtime-runes/samples/derived-unowned-5/main.svelte index 388986946166..beecbacb695d 100644 --- a/packages/svelte/tests/runtime-runes/samples/derived-unowned-5/main.svelte +++ b/packages/svelte/tests/runtime-runes/samples/derived-unowned-5/main.svelte @@ -1,4 +1,4 @@ - diff --git a/packages/svelte/tests/runtime-runes/samples/derived-unowned/Component.svelte b/packages/svelte/tests/runtime-runes/samples/derived-unowned/Component.svelte index 8946c01d50a6..1790f088c09f 100644 --- a/packages/svelte/tests/runtime-runes/samples/derived-unowned/Component.svelte +++ b/packages/svelte/tests/runtime-runes/samples/derived-unowned/Component.svelte @@ -1,4 +1,4 @@ - diff --git a/packages/svelte/tests/runtime-runes/samples/effect-dependencies/main.svelte b/packages/svelte/tests/runtime-runes/samples/effect-dependencies/main.svelte index 75f5a0cd6ee9..770666289cce 100644 --- a/packages/svelte/tests/runtime-runes/samples/effect-dependencies/main.svelte +++ b/packages/svelte/tests/runtime-runes/samples/effect-dependencies/main.svelte @@ -1,8 +1,8 @@ -
- - + +
{#if things.tab === 'A'} - A + A {:else} B {#each things.list as item} diff --git a/packages/svelte/tests/runtime-runes/samples/element-is-attribute/main.svelte b/packages/svelte/tests/runtime-runes/samples/element-is-attribute/main.svelte index 76aca5fa325f..15d2d521e43d 100644 --- a/packages/svelte/tests/runtime-runes/samples/element-is-attribute/main.svelte +++ b/packages/svelte/tests/runtime-runes/samples/element-is-attribute/main.svelte @@ -1,4 +1,4 @@ - diff --git a/packages/svelte/tests/runtime-runes/samples/non-local-mutation-global-2/child.svelte b/packages/svelte/tests/runtime-runes/samples/non-local-mutation-global-2/child.svelte index 5efb0d11ab36..13de75364752 100644 --- a/packages/svelte/tests/runtime-runes/samples/non-local-mutation-global-2/child.svelte +++ b/packages/svelte/tests/runtime-runes/samples/non-local-mutation-global-2/child.svelte @@ -1,4 +1,4 @@ - diff --git a/packages/svelte/tests/validator/samples/illegal-variable-declaration/errors.json b/packages/svelte/tests/validator/samples/illegal-variable-declaration/errors.json index e0002aaa743e..b5fc2c4f4c2d 100644 --- a/packages/svelte/tests/validator/samples/illegal-variable-declaration/errors.json +++ b/packages/svelte/tests/validator/samples/illegal-variable-declaration/errors.json @@ -1,7 +1,7 @@ [ { "code": "declaration_duplicate_module_import", - "message": "Cannot declare same variable name which is imported inside ` diff --git a/packages/svelte/tests/validator/samples/module-script-reactive-declaration/input.svelte b/packages/svelte/tests/validator/samples/module-script-reactive-declaration/input.svelte index 9df1cd54dd31..2673ab2f9a2b 100644 --- a/packages/svelte/tests/validator/samples/module-script-reactive-declaration/input.svelte +++ b/packages/svelte/tests/validator/samples/module-script-reactive-declaration/input.svelte @@ -1,4 +1,4 @@ - - \ No newline at end of file diff --git a/packages/svelte/tests/validator/samples/reactive-module-const-variable/input.svelte b/packages/svelte/tests/validator/samples/reactive-module-const-variable/input.svelte index c89cc1c1d08b..82fb3aba9b31 100644 --- a/packages/svelte/tests/validator/samples/reactive-module-const-variable/input.svelte +++ b/packages/svelte/tests/validator/samples/reactive-module-const-variable/input.svelte @@ -1,4 +1,4 @@ - diff --git a/packages/svelte/tests/validator/samples/reactive-module-variable-2/input.svelte b/packages/svelte/tests/validator/samples/reactive-module-variable-2/input.svelte index d36d9cf21054..5209154b6f03 100644 --- a/packages/svelte/tests/validator/samples/reactive-module-variable-2/input.svelte +++ b/packages/svelte/tests/validator/samples/reactive-module-variable-2/input.svelte @@ -1,4 +1,4 @@ - diff --git a/packages/svelte/tests/validator/samples/script-context-module-deprecated/warnings.json b/packages/svelte/tests/validator/samples/script-context-module-deprecated/warnings.json new file mode 100644 index 000000000000..739e2b229572 --- /dev/null +++ b/packages/svelte/tests/validator/samples/script-context-module-deprecated/warnings.json @@ -0,0 +1,14 @@ +[ + { + "code": "script_context_deprecated", + "message": "`context=\"module\"` is deprecated, use the `module` attribute instead", + "start": { + "column": 8, + "line": 1 + }, + "end": { + "column": 24, + "line": 1 + } + } +] diff --git a/packages/svelte/tests/validator/samples/silence-warnings-2/input.svelte b/packages/svelte/tests/validator/samples/silence-warnings-2/input.svelte index 275165ffd7a9..251ea1205111 100644 --- a/packages/svelte/tests/validator/samples/silence-warnings-2/input.svelte +++ b/packages/svelte/tests/validator/samples/silence-warnings-2/input.svelte @@ -1,4 +1,4 @@ - diff --git a/packages/svelte/tests/validator/samples/silence-warnings/input.svelte b/packages/svelte/tests/validator/samples/silence-warnings/input.svelte index 4520aed9c13f..a8760fdd19b8 100644 --- a/packages/svelte/tests/validator/samples/silence-warnings/input.svelte +++ b/packages/svelte/tests/validator/samples/silence-warnings/input.svelte @@ -1,4 +1,4 @@ - diff --git a/packages/svelte/tests/validator/samples/unreferenced-variables/input.svelte b/packages/svelte/tests/validator/samples/unreferenced-variables/input.svelte index cebd8619850e..caac6d8bf954 100644 --- a/packages/svelte/tests/validator/samples/unreferenced-variables/input.svelte +++ b/packages/svelte/tests/validator/samples/unreferenced-variables/input.svelte @@ -1,4 +1,4 @@ - diff --git a/sites/svelte-5-preview/src/routes/docs/content/03-appendix/03-deprecations.md b/sites/svelte-5-preview/src/routes/docs/content/03-appendix/03-deprecations.md index e4fdcc86b3e9..0c45bdaab208 100644 --- a/sites/svelte-5-preview/src/routes/docs/content/03-appendix/03-deprecations.md +++ b/sites/svelte-5-preview/src/routes/docs/content/03-appendix/03-deprecations.md @@ -117,3 +117,14 @@ A derived value may be used in other contexts: ## `immutable` The `immutable` compiler option is deprecated. Use runes mode instead, where all state is immutable (which means that assigning to `object.property` won't cause updates for anything that is observing `object` itself, or a different property of it). + +## `context="module"` + +`context="module"` is deprecated, use the new `module` attribute instead: + +```diff +- +```