cache values

config
Rich Harris 1 month ago
parent d20d6042bc
commit 33752a31e0

@ -465,8 +465,10 @@ export function analyze_component(root, source, options) {
}
}
const is_custom_element =
!!options.customElementOptions || options.customElement({ filename: options.filename });
const custom_element_from_option = options.customElement({ filename: options.filename });
const css = options.css({ filename: options.filename });
const custom_element = options.customElementOptions ?? custom_element_from_option;
const is_custom_element = !!options.customElementOptions || custom_element_from_option;
const name = module.scope.generate(options.name ?? component_name);
@ -526,8 +528,8 @@ export function analyze_component(root, source, options) {
needs_props: false,
event_directive_node: null,
uses_event_attributes: false,
custom_element: is_custom_element,
inject_styles: options.css({ filename: options.filename }) === 'injected' || is_custom_element,
custom_element,
inject_styles: css === 'injected' || is_custom_element,
accessors:
is_custom_element ||
(runes ? false : !!options.accessors) ||
@ -683,10 +685,7 @@ export function analyze_component(root, source, options) {
w.options_deprecated_accessors(attribute);
}
if (
attribute.name === 'customElement' &&
!options.customElement({ filename: options.filename })
) {
if (attribute.name === 'customElement' && !custom_element_from_option) {
w.options_missing_custom_element(attribute);
}

@ -595,7 +595,7 @@ export function client_component(analysis, options) {
);
}
const ce = options.customElementOptions ?? options.customElement({ filename: options.filename });
const ce = analysis.custom_element;
if (ce) {
const ce_props = typeof ce === 'boolean' ? {} : ce.props || {};

@ -65,7 +65,7 @@ export function render_stylesheet(source, analysis, options) {
merge_with_preprocessor_map(css, options, css.map.sources[0]);
if (dev && options.css({ filename: options.filename }) === 'injected' && css.code) {
if (dev && analysis.inject_styles && css.code) {
css.code += `\n/*# sourceMappingURL=${css.map.toUrl()} */`;
}

@ -300,11 +300,7 @@ export function server_component(analysis, options) {
const body = [...state.hoisted, ...module.body];
if (
analysis.css.ast !== null &&
options.css({ filename: options.filename }) === 'injected' &&
!options.customElement({ filename: options.filename })
) {
if (analysis.css.ast !== null && analysis.inject_styles && !analysis.custom_element) {
const hash = b.literal(analysis.css.hash);
const code = b.literal(render_stylesheet(analysis.source, analysis, options).code);

Loading…
Cancel
Save