* breaking: deprecate `context="module"` in favor of `module`
Also reserve a few attributes, which we may or may not use in the future
closes#12637
* fix tests
* one more
* add svelte package to the root so eslint and prettier can use it
* tweak messages
* warn on unknown attributes
* regenerate
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
@ -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.
For more information on reactivity, read the documentation around runes.
## <script context="module">
## <script module>
A `<script>` tag with a `context="module"` attribute runs once when the module first evaluates, rather than for each component instance. Values declared in this block are accessible from a regular `<script>` (and the component markup) but not vice versa.
A `<script>` tag with a `module` attribute runs once when the module first evaluates, rather than for each component instance. Values declared in this block are accessible from a regular `<script>` (and the component markup) but not vice versa.
You can `export` bindings from this block, and they will become exports of the compiled module.
You can `export` bindings from this block, and they will become exports of the compiled module.
You cannot `export default`, since the default export is the component itself.
You cannot `export default`, since the default export is the component itself.
```svelte
```svelte
<scriptcontext="module">
<script module>
let totalComponents = 0;
let totalComponents = 0;
// the export keyword allows this function to imported with e.g.
// the export keyword allows this function to imported with e.g.
@ -50,6 +50,14 @@ HTML restricts where certain elements can appear. In case of a violation the bro
This code will work when the component is rendered on the client (which is why this is a warning rather than an error), but if you use server rendering it will cause hydration to fail.
This code will work when the component is rendered on the client (which is why this is a warning rather than an error), but if you use server rendering it will cause hydration to fail.
## script_context_deprecated
> `context="module"` is deprecated, use the `module` attribute instead
## script_unknown_attribute
> Unrecognized attribute — should be one of `generics`, `lang` or `module`. If this exists for a preprocessor, ensure that the preprocessor removes it
## slot_element_deprecated
## slot_element_deprecated
> Using `<slot>` to render parent content is deprecated. Use `{@render ...}` tags instead
> Using `<slot>` to render parent content is deprecated. Use `{@render ...}` tags instead
e(node,"script_duplicate","A component can have a single top-level `<script>` element and/or a single top-level `<script context=\"module\">` element");
e(node,"script_duplicate","A component can have a single top-level `<script>` element and/or a single top-level `<script module>` element");
@ -769,6 +771,22 @@ export function node_invalid_placement_ssr(node, thing, parent) {
w(node,"node_invalid_placement_ssr",`${thing} is invalid inside \`<${parent}>\`. When rendering this component on the server, the resulting HTML will be modified by the browser, likely resulting in a \`hydration_mismatch\` warning`);
w(node,"node_invalid_placement_ssr",`${thing} is invalid inside \`<${parent}>\`. When rendering this component on the server, the resulting HTML will be modified by the browser, likely resulting in a \`hydration_mismatch\` warning`);
w(node,"script_unknown_attribute","Unrecognized attribute — should be one of `generics`, `lang` or `module`. If this exists for a preprocessor, ensure that the preprocessor removes it");
"Cannot export state from a module if it is reassigned. Either export a function returning the state value or only mutate the state value's properties",
"Cannot export state from a module if it is reassigned. Either export a function returning the state value or only mutate the state value's properties",
"message":"Unrecognized attribute — should be one of `generics`, `lang` or `module`. If this exists for a preprocessor, ensure that the preprocessor removes it",
"message":"Unrecognized attribute — should be one of `generics`, `lang` or `module`. If this exists for a preprocessor, ensure that the preprocessor removes it",
@ -117,3 +117,14 @@ A derived value may be used in other contexts:
## `immutable`
## `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).
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: