on second thoughts

pull/12530/head
Rich Harris 2 years ago
parent 2125dc8d28
commit 70cd2d82ea

@ -65,7 +65,7 @@ export function client_component(source, analysis, options) {
preserve_whitespace: options.preserveWhitespace, preserve_whitespace: options.preserveWhitespace,
public_state: new Map(), public_state: new Map(),
private_state: new Map(), private_state: new Map(),
getters: new Map(), getters: {},
in_constructor: false, in_constructor: false,
// these are set inside the `Fragment` visitor, and cannot be used until then // these are set inside the `Fragment` visitor, and cannot be used until then
@ -583,7 +583,7 @@ export function client_module(analysis, options) {
legacy_reactive_statements: new Map(), legacy_reactive_statements: new Map(),
public_state: new Map(), public_state: new Map(),
private_state: new Map(), private_state: new Map(),
getters: new Map(), getters: {},
in_constructor: false in_constructor: false
}; };

@ -84,7 +84,7 @@ export function serialize_get_binding(node, state) {
return b.call(node); return b.call(node);
} }
const getter = state.getters.get(binding); const getter = state.getters[node.name];
if (getter) { if (getter) {
return typeof getter === 'function' ? getter(node) : getter; return typeof getter === 'function' ? getter(node) : getter;
} }

@ -221,7 +221,7 @@ function serialize_get_binding(node, state) {
); );
} }
const getter = state.getters.get(binding); const getter = state.getters[binding.node.name];
if (getter) { if (getter) {
return typeof getter === 'function' ? getter(node) : getter; return typeof getter === 'function' ? getter(node) : getter;
} }
@ -1988,7 +1988,7 @@ export function server_component(analysis, options) {
namespace: options.namespace, namespace: options.namespace,
preserve_whitespace: options.preserveWhitespace, preserve_whitespace: options.preserveWhitespace,
private_derived: new Map(), private_derived: new Map(),
getters: new Map(), getters: {},
skip_hydration_boundaries: false skip_hydration_boundaries: false
}; };
@ -2300,7 +2300,7 @@ export function server_module(analysis, options) {
// transform state as well as component transform state // transform state as well as component transform state
legacy_reactive_statements: new Map(), legacy_reactive_statements: new Map(),
private_derived: new Map(), private_derived: new Map(),
getters: new Map() getters: {}
}; };
const module = /** @type {import('estree').Program} */ ( const module = /** @type {import('estree').Program} */ (

@ -8,5 +8,5 @@ export interface TransformState {
readonly options: ValidatedModuleCompileOptions; readonly options: ValidatedModuleCompileOptions;
readonly scope: Scope; readonly scope: Scope;
readonly scopes: Map<SvelteNode, Scope>; readonly scopes: Map<SvelteNode, Scope>;
readonly getters: Map<Binding, Expression | ((id: Identifier) => Expression)>; readonly getters: Record<string, Expression | ((id: Identifier) => Expression)>;
} }

Loading…
Cancel
Save