add immutable to transform state

proxied-state-each-blocks
Rich Harris 11 months ago
parent b049cc72cd
commit afd2efa2d7

@ -220,7 +220,8 @@ export function analyze_module(ast, options) {
name: options.filename || 'module', name: options.filename || 'module',
warnings, warnings,
accessors: false, accessors: false,
runes: true runes: true,
immutable: true
}; };
} }
@ -301,6 +302,10 @@ export function analyze_component(root, options) {
const component_name = get_component_name(options.filename ?? 'Component'); const component_name = get_component_name(options.filename ?? 'Component');
const runes =
options.runes ??
Array.from(module.scope.references).some(([name]) => Runes.includes(/** @type {any} */ (name)));
// TODO remove all the ?? stuff, we don't need it now that we're validating the config // TODO remove all the ?? stuff, we don't need it now that we're validating the config
/** @type {import('../types.js').ComponentAnalysis} */ /** @type {import('../types.js').ComponentAnalysis} */
const analysis = { const analysis = {
@ -317,11 +322,8 @@ export function analyze_component(root, options) {
component_name, component_name,
get_css_hash: options.cssHash get_css_hash: options.cssHash
}), }),
runes: runes,
options.runes ?? immutable: runes || options.immutable,
Array.from(module.scope.references).some(([name]) =>
Runes.includes(/** @type {any} */ (name))
),
exports: [], exports: [],
uses_props: false, uses_props: false,
uses_rest_props: false, uses_rest_props: false,

@ -47,6 +47,7 @@ export interface Analysis {
name: string; // TODO should this be filename? it's used in `compileModule` as well as `compile` name: string; // TODO should this be filename? it's used in `compileModule` as well as `compile`
warnings: RawWarning[]; warnings: RawWarning[];
runes: boolean; runes: boolean;
immutable: boolean;
// TODO figure out if we can move this to ComponentAnalysis // TODO figure out if we can move this to ComponentAnalysis
accessors: boolean; accessors: boolean;

Loading…
Cancel
Save