rename to compatibility.componentApi

pull/12370/head
Rich Harris 2 years ago
parent 862c6d0b29
commit 70ceb47ac4

@ -16,7 +16,7 @@
## component_api_invalid_new
> Attempted to instantiate %component% with `new %name%`, which is no longer valid in Svelte 5. If this component is not under your control, set the `compatibility.legacyComponent` compiler option to keep it working. See https://svelte-5-preview.vercel.app/docs/breaking-changes#components-are-no-longer-classes for more information
> Attempted to instantiate %component% with `new %name%`, which is no longer valid in Svelte 5. If this component is not under your control, set the `compatibility.componentApi` compiler option to `4` to keep it working. See https://svelte-5-preview.vercel.app/docs/breaking-changes#components-are-no-longer-classes for more information
## each_key_duplicate

@ -390,7 +390,7 @@ export function analyze_component(root, source, options) {
? true
: (runes ? false : !!options.accessors) ||
// because $set method needs accessors
!!options.compatibility?.legacyComponent,
options.compatibility?.componentApi === 4,
reactive_statements: new Map(),
binding_groups: new Map(),
slot_names: new Map(),

@ -259,7 +259,7 @@ export function client_component(source, analysis, options) {
}
}
if (options.compatibility.legacyComponent) {
if (options.compatibility.componentApi === 4) {
component_returned_object.push(
b.init('$set', b.id('$.update_legacy_props')),
b.init(
@ -450,7 +450,7 @@ export function client_component(source, analysis, options) {
body.unshift(b.imports([], 'svelte/internal/disclose-version'));
}
if (options.compatibility.legacyComponent) {
if (options.compatibility.componentApi === 4) {
body.unshift(b.imports([['createClassComponent', '$$_createClassComponent']], 'svelte/legacy'));
component_block.body.unshift(
b.if(

@ -2148,7 +2148,7 @@ export function server_component(analysis, options) {
should_inject_props ? [b.id('$$payload'), b.id('$$props')] : [b.id('$$payload')],
component_block
);
if (options.compatibility.legacyComponent) {
if (options.compatibility.componentApi === 4) {
body.unshift(b.imports([['render', '$$_render']], 'svelte/server'));
body.push(
component_function,

@ -154,9 +154,9 @@ export interface CompileOptions extends ModuleCompileOptions {
* Applies a transformation so that the default export of Svelte files can still be instantiated the same way as in Svelte 4
* as a class when compiling for the browser (as though using `createClassComponent(MyComponent, {...})` from `svelte/legacy`)
* or as an object with a `.render(...)` method when compiling for the server
* @default false
* @default 5
*/
legacyComponent?: boolean;
componentApi?: 4 | 5;
};
/**
* An initial sourcemap that will be merged into the final output sourcemap.

@ -79,11 +79,11 @@ export const validate_component_options =
immutable: deprecate(w.options_deprecated_immutable, boolean(false)),
legacy: removed(
'The legacy option has been removed. If you are using this because of legacy.componentApi, use compatibility.legacyComponent instead'
'The legacy option has been removed. If you are using this because of legacy.componentApi, use compatibility.componentApi instead'
),
compatibility: object({
legacyComponent: boolean(false)
componentApi: list([4, 5])
}),
loopGuardTimeout: warn_removed(w.options_removed_loop_guard_timeout),

@ -41,7 +41,7 @@ export function bubble_event($$props, event) {
}
/**
* Used to simulate `$on` on a component instance when `compatibility.legacyComponent` is `true`
* Used to simulate `$on` on a component instance when `compatibility.componentApi === 4`
* @param {Record<string, any>} $$props
* @param {string} event_name
* @param {Function} event_callback
@ -53,7 +53,7 @@ export function add_legacy_event_listener($$props, event_name, event_callback) {
}
/**
* Used to simulate `$set` on a component instance when `compatibility.legacyComponent` is `true`.
* Used to simulate `$set` on a component instance when `compatibility.componentApi === 4`.
* Needs component accessors so that it can call the setter of the prop. Therefore doesn't
* work for updating props in `$$props` or `$$restProps`.
* @this {Record<string, any>}

@ -76,14 +76,14 @@ export function component_api_changed(parent, method, component) {
}
/**
* Attempted to instantiate %component% with `new %name%`, which is no longer valid in Svelte 5. If this component is not under your control, set the `compatibility.legacyComponent` compiler option to keep it working. See https://svelte-5-preview.vercel.app/docs/breaking-changes#components-are-no-longer-classes for more information
* Attempted to instantiate %component% with `new %name%`, which is no longer valid in Svelte 5. If this component is not under your control, set the `compatibility.componentApi` compiler option to `4` to keep it working. See https://svelte-5-preview.vercel.app/docs/breaking-changes#components-are-no-longer-classes for more information
* @param {string} component
* @param {string} name
* @returns {never}
*/
export function component_api_invalid_new(component, name) {
if (DEV) {
const error = new Error(`component_api_invalid_new\nAttempted to instantiate ${component} with \`new ${name}\`, which is no longer valid in Svelte 5. If this component is not under your control, set the \`compatibility.legacyComponent\` compiler option to keep it working. See https://svelte-5-preview.vercel.app/docs/breaking-changes#components-are-no-longer-classes for more information`);
const error = new Error(`component_api_invalid_new\nAttempted to instantiate ${component} with \`new ${name}\`, which is no longer valid in Svelte 5. If this component is not under your control, set the \`compatibility.componentApi\` compiler option to \`4\` to keep it working. See https://svelte-5-preview.vercel.app/docs/breaking-changes#components-are-no-longer-classes for more information`);
error.name = 'Svelte error';
throw error;

@ -4,7 +4,7 @@ import { test } from '../../test';
export default test({
compileOptions: {
compatibility: {
legacyComponent: true
componentApi: 4
}
},
html: '<button>0</button>',

@ -3,7 +3,7 @@ import { test } from '../../test';
export default test({
compileOptions: {
compatibility: {
legacyComponent: true
componentApi: 4
}
},

@ -813,9 +813,9 @@ declare module 'svelte/compiler' {
* Applies a transformation so that the default export of Svelte files can still be instantiated the same way as in Svelte 4
* as a class when compiling for the browser (as though using `createClassComponent(MyComponent, {...})` from `svelte/legacy`)
* or as an object with a `.render(...)` method when compiling for the server
* @default false
* @default 5
*/
legacyComponent?: boolean;
componentApi?: 4 | 5;
};
/**
* An initial sourcemap that will be merged into the final output sourcemap.
@ -2636,9 +2636,9 @@ declare module 'svelte/types/compiler/interfaces' {
* Applies a transformation so that the default export of Svelte files can still be instantiated the same way as in Svelte 4
* as a class when compiling for the browser (as though using `createClassComponent(MyComponent, {...})` from `svelte/legacy`)
* or as an object with a `.render(...)` method when compiling for the server
* @default false
* @default 5
*/
legacyComponent?: boolean;
componentApi?: 4 | 5;
};
/**
* An initial sourcemap that will be merged into the final output sourcemap.

Loading…
Cancel
Save