solid-optimizer 1.0.0-next.8 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/vite.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.mjs","names":["generateMap","generateMap"],"sources":["../src/vite/globals.ts","../src/vite/report.ts","../src/vite/runtime.ts","../src/vite/inject.ts","../src/vite/namespace.ts","../src/vite/refs.ts","../src/vite/usage.ts","../src/vite/index.ts"],"sourcesContent":["/**\n * The global constants every build environment shares, from Vite's `define`\n * and `import.meta.env`.\n */\nimport type { ResolvedConfig } from 'vite';\nimport type { Primitive } from '../value';\n\n/**\n * The `define` entries and `import.meta.env` values that are the same in\n * every build environment, as global constants. A value that differs, like\n * `import.meta.env.SSR`, could make the server and client builds fold, and\n * then inline, differently, so their hydration keys would not match.\n */\nexport function sharedGlobals(\n config: Pick<ResolvedConfig, 'env' | 'define' | 'environments'>,\n): Record<string, Primitive> {\n const globals: Record<string, Primitive> = {};\n for (const [key, value] of Object.entries(config.env)) {\n if (\n key !== 'SSR' &&\n (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean')\n ) {\n globals[`import.meta.env.${key}`] = value;\n }\n }\n const environments = Object.values(config.environments);\n const defines: Record<string, unknown>[] = [];\n if (environments.length > 0) {\n for (const environment of environments) {\n defines.push(environment.define ?? config.define ?? {});\n }\n } else {\n defines.push(config.define ?? {});\n }\n const keys = new Set<string>();\n for (const define of defines) {\n for (const key of Object.keys(define)) {\n keys.add(key);\n }\n }\n for (const key of keys) {\n // Every environment must define the key as the same value.\n let first: { value: Primitive } | undefined;\n let same = true;\n for (const define of defines) {\n const value = defineValue(define[key]);\n first ??= value;\n if (value === undefined || !Object.is(value.value, first?.value)) {\n same = false;\n break;\n }\n }\n if (first !== undefined && same) {\n globals[key] = first.value;\n }\n }\n return globals;\n}\n\n/**\n * The primitive a `define` entry replaces its key with. A string is code,\n * so only one that is a JSON literal counts.\n */\nfunction defineValue(value: unknown): { value: Primitive } | undefined {\n let parsed: unknown = value;\n if (typeof value === 'string') {\n try {\n parsed = JSON.parse(value);\n } catch {\n return undefined;\n }\n }\n if (\n parsed === null ||\n typeof parsed === 'string' ||\n typeof parsed === 'number' ||\n typeof parsed === 'boolean'\n ) {\n return { value: parsed };\n }\n return undefined;\n}\n","/**\n * The report of what the optimizer leaves alone in a build, and why.\n *\n * Each pass records a short reason code for every component call, provider,\n * and memo it does not optimize. The plugin collects them from the final\n * compile of each chunk or module, and prints them grouped by reason.\n */\nimport type { Skip, SkipPass } from '../context';\n\n/** What the optimizer left alone in one build environment. */\nexport interface OptimizerReport {\n /** The Vite environment, like `client` or `ssr`. */\n readonly environment: string;\n readonly skips: readonly Skip[];\n}\n\nexport interface ReasonSummary {\n readonly pass: SkipPass;\n readonly reason: string;\n readonly count: number;\n /** How many times each name was skipped for this reason, most first. */\n readonly names: readonly (readonly [string, number])[];\n}\n\n/**\n * Groups skips by pass and reason, most frequent first.\n */\nexport function summarizeSkips(skips: readonly Skip[]): ReasonSummary[] {\n const groups = new Map<string, { pass: SkipPass; reason: string; names: Map<string, number> }>();\n for (const skip of skips) {\n const key = `${skip.pass}\\0${skip.reason}`;\n const group = groups.get(key) ?? { pass: skip.pass, reason: skip.reason, names: new Map() };\n group.names.set(skip.name, (group.names.get(skip.name) ?? 0) + 1);\n groups.set(key, group);\n }\n const summaries: ReasonSummary[] = [];\n for (const { pass, reason, names } of groups.values()) {\n let count = 0;\n for (const times of names.values()) {\n count += times;\n }\n summaries.push({\n pass,\n reason,\n count,\n names: [...names].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])),\n });\n }\n return summaries.sort(\n (a, b) => b.count - a.count || a.pass.localeCompare(b.pass) || a.reason.localeCompare(b.reason),\n );\n}\n\n/** The most names listed for a reason. */\nconst NAMES_SHOWN = 6;\n\n/**\n * The report as text, one line per reason.\n */\nexport function formatReport(report: OptimizerReport): string {\n const lines = [`solid-optimizer: what stays as written in ${report.environment}`];\n const summaries = summarizeSkips(report.skips);\n if (summaries.length === 0) {\n lines.push(' nothing');\n }\n let reasonWidth = 0;\n for (const summary of summaries) {\n reasonWidth = Math.max(reasonWidth, summary.reason.length);\n }\n for (const summary of summaries) {\n const shown: string[] = [];\n for (const [name, count] of summary.names.slice(0, NAMES_SHOWN)) {\n shown.push(count > 1 ? `${name}×${String(count)}` : name);\n }\n if (summary.names.length > NAMES_SHOWN) {\n shown.push(`${String(summary.names.length - NAMES_SHOWN)} more`);\n }\n lines.push(\n ` ${summary.pass.padEnd(8)} ${summary.reason.padEnd(reasonWidth)} ${String(summary.count).padStart(4)} ${shown.join(', ')}`,\n );\n }\n return lines.join('\\n');\n}\n","/**\n * Keeps Solid's runtime helpers reachable while JSX waits in a bundled chunk.\n *\n * Solid's JSX transform imports helpers like `template` and `insert` from\n * `@solidjs/web`. When the transform runs on a chunk, the bundle is already\n * built, so a new bare import cannot be resolved or bundled anymore. Instead,\n * every module imports the helpers it will need before bundling, and passes\n * them to a marker call. The bundler keeps the call, since it could have side\n * effects, and renames the helpers to whatever they are called in the chunk.\n * The chunk step reads the marker, removes it, and points the lowered code at\n * those names.\n *\n * The marker also records which bindings are Solid's built-in components, so\n * the fold pass still recognizes `Show` after the bundler renamed it.\n */\nimport MagicString from 'magic-string';\nimport { parseSync } from 'oxc-parser';\nimport type {\n ExpressionStatement,\n ImportDeclarationSpecifier,\n ImportSpecifier,\n Node,\n Program,\n} from 'oxc-parser';\nimport { collectParents, forEachChild, parse, unwrap } from '../ast';\nimport type { ScopeAnalysis } from '../scope';\nimport { analyzeScopes, lookup, scopeAt } from '../scope';\n\nexport const MARKER = '__SOLID_OPTIMIZER_KEEP__';\n\n/**\n * The lowered chunk needs a helper that no module in the chunk kept.\n */\nexport class MissingHelperError extends Error {\n override readonly name = 'MissingHelperError';\n}\n\nconst HELPER_PREFIX = 'helper:';\nconst BUILT_IN_PREFIX = 'builtin:';\n\nexport interface EditResult {\n code: string;\n map: string;\n}\n\nfunction generateMap(s: MagicString, filename: string): string {\n return s.generateMap({ source: filename, hires: true, includeContent: true }).toString();\n}\n\nfunction freshName(scopes: ScopeAnalysis, base: string): string {\n let name = base;\n let index = 1;\n while (scopes.names.has(name)) {\n name = `${base}$${String(index)}`;\n index += 1;\n }\n scopes.names.add(name);\n return name;\n}\n\nfunction isAllGenerated(specifiers: readonly ImportDeclarationSpecifier[]): boolean {\n for (const specifier of specifiers) {\n if (!isGeneratedSpecifier(specifier)) {\n return false;\n }\n }\n return true;\n}\n\nfunction hasStatement(functions: readonly { statement: Node }[], statement: Node): boolean {\n for (const entry of functions) {\n if (entry.statement === statement) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Whether an import specifier was added by Solid's JSX transform, which\n * names every helper it imports `_$name`.\n */\nfunction isGeneratedSpecifier(specifier: ImportDeclarationSpecifier): boolean {\n return specifier.type === 'ImportSpecifier' && specifier.local.name.startsWith('_$');\n}\n\nfunction exportedName(specifier: ImportSpecifier): string {\n return specifier.imported.type === 'Literal' ? specifier.imported.value : specifier.imported.name;\n}\n\n/**\n * The helpers Solid's JSX transform imported from `source` into its output.\n * The module's own imports, including type imports, are left out.\n */\nexport function generatedImports(code: string, filename: string, source: string): string[] {\n const program = parse(filename, code);\n const names: string[] = [];\n for (const statement of program.body) {\n if (statement.type !== 'ImportDeclaration' || statement.source.value !== source) {\n continue;\n }\n for (const specifier of statement.specifiers) {\n if (specifier.type === 'ImportSpecifier' && isGeneratedSpecifier(specifier)) {\n names.push(exportedName(specifier));\n }\n }\n }\n return names;\n}\n\nexport interface MarkerOptions {\n /** The module the helpers come from, usually `@solidjs/web`. */\n readonly moduleName: string;\n /** The helpers to keep. */\n readonly helpers: ReadonlySet<string>;\n /** The modules Solid's built-in components come from. */\n readonly moduleSources: readonly string[];\n /** The names of Solid's built-in components. */\n readonly builtIns: ReadonlySet<string>;\n}\n\n/**\n * The functions declared at the top level of a module, with the statement\n * that declares each: `function A() {}`, `const A = () => ...`, and their\n * `export` forms.\n */\nfunction topLevelFunctions(program: Program): { statement: Node; fn: Node }[] {\n const found: { statement: Node; fn: Node }[] = [];\n for (const statement of program.body) {\n const declaration =\n statement.type === 'ExportNamedDeclaration' || statement.type === 'ExportDefaultDeclaration'\n ? statement.declaration\n : statement;\n if (!declaration) {\n continue;\n }\n if (declaration.type === 'FunctionDeclaration') {\n found.push({ statement, fn: declaration });\n } else if (\n declaration.type === 'VariableDeclaration' &&\n declaration.declarations.length === 1\n ) {\n const init = declaration.declarations.at(0)?.init;\n const fn = init ? unwrap(init) : undefined;\n if (fn?.type === 'ArrowFunctionExpression' || fn?.type === 'FunctionExpression') {\n found.push({ statement, fn });\n }\n }\n }\n return found;\n}\n\nfunction containsJSX(node: Node): boolean {\n let found = false;\n const visit = (current: Node): void => {\n if (found) {\n return;\n }\n if (current.type === 'JSXElement' || current.type === 'JSXFragment') {\n found = true;\n return;\n }\n forEachChild(current, visit);\n };\n visit(node);\n return found;\n}\n\n/**\n * Adds the helper imports and the marker calls to a module.\n *\n * Each top-level function with JSX gets its own marker, so a component the\n * bundler drops takes its helpers with it. JSX anywhere else gets a marker\n * at the top level. Returns `undefined` when the module needs no helper.\n */\nexport function addMarker(\n code: string,\n filename: string,\n options: MarkerOptions,\n): EditResult | undefined {\n if (options.helpers.size === 0) {\n return undefined;\n }\n const program = parse(filename, code);\n const scopes = analyzeScopes(program);\n const entries: string[] = [];\n const specifiers: string[] = [];\n for (const helper of options.helpers) {\n const local = freshName(scopes, `__so$${helper}`);\n specifiers.push(`${helper} as ${local}`);\n entries.push(`${JSON.stringify(HELPER_PREFIX + helper)}: ${local}`);\n }\n for (const statement of program.body) {\n if (\n statement.type !== 'ImportDeclaration' ||\n statement.importKind === 'type' ||\n !options.moduleSources.includes(statement.source.value)\n ) {\n continue;\n }\n for (const specifier of statement.specifiers) {\n if (specifier.type !== 'ImportSpecifier' || specifier.importKind === 'type') {\n continue;\n }\n const imported = exportedName(specifier);\n // A built-in that folding left unused stays out, so the bundler can drop it.\n const used = (scopes.root.bindings.get(specifier.local.name)?.references.length ?? 0) > 0;\n if (options.builtIns.has(imported) && used) {\n entries.push(`${JSON.stringify(BUILT_IN_PREFIX + imported)}: ${specifier.local.name}`);\n }\n }\n }\n const call = `${MARKER}({ ${entries.join(', ')} })`;\n const s = new MagicString(code);\n const functions: { statement: Node; fn: Node }[] = [];\n for (const entry of topLevelFunctions(program)) {\n if (containsJSX(entry.fn)) {\n functions.push(entry);\n }\n }\n for (const { fn } of functions) {\n if (\n fn.type !== 'FunctionDeclaration' &&\n fn.type !== 'FunctionExpression' &&\n fn.type !== 'ArrowFunctionExpression'\n ) {\n continue;\n }\n const { body } = fn;\n if (!body) {\n continue;\n }\n if (body.type === 'BlockStatement') {\n s.appendLeft(body.start + 1, `${call};`);\n } else {\n s.prependRight(body.start, `{ ${call}; return `);\n s.appendLeft(body.end, '; }');\n }\n }\n let outside = false;\n for (const statement of program.body) {\n if (!hasStatement(functions, statement) && containsJSX(statement)) {\n outside = true;\n break;\n }\n }\n s.append(\n `\\nimport { ${specifiers.join(', ')} } from ${JSON.stringify(options.moduleName)};\\n` +\n (outside ? `${call};\\n` : ''),\n );\n return { code: s.toString(), map: generateMap(s, filename) };\n}\n\n/**\n * Puts back the parentheses around a comma expression that is the whole of a\n * JSX expression container. Rolldown drops them when it prints a chunk that\n * kept its JSX, and JSX does not allow the result. Returns `undefined` when\n * the chunk has none.\n */\nexport function repairJSXSequences(code: string, filename: string): EditResult | undefined {\n // The chunk does not parse cleanly, which is why this runs, so errors are expected.\n const { program } = parseSync(filename, code, {\n lang: 'jsx',\n sourceType: 'module',\n preserveParens: true,\n });\n const sequences: Node[] = [];\n const visit = (node: Node): void => {\n if (node.type === 'JSXExpressionContainer' && node.expression.type === 'SequenceExpression') {\n sequences.push(node.expression);\n }\n forEachChild(node, visit);\n };\n visit(program);\n if (sequences.length === 0) {\n return undefined;\n }\n const s = new MagicString(code);\n for (const sequence of sequences) {\n s.appendLeft(sequence.start, '(');\n s.prependRight(sequence.end, ')');\n }\n return { code: s.toString(), map: generateMap(s, filename) };\n}\n\nexport interface ChunkRuntime extends EditResult {\n /** The chunk's name for each helper, keyed by the name `@solidjs/web` exports. */\n readonly helpers: ReadonlyMap<string, string>;\n /** The built-in each chunk binding refers to, keyed by the chunk's name for it. */\n readonly builtInAliases: Record<string, string>;\n}\n\nfunction propertyKey(node: Node): string | undefined {\n if (node.type === 'Literal' && typeof node.value === 'string') {\n return node.value;\n }\n if (node.type === 'Identifier') {\n return node.name;\n }\n return undefined;\n}\n\n/**\n * Reads and removes the marker calls of a chunk.\n * Returns `undefined` when the chunk has none.\n */\nexport function readMarkers(code: string, filename: string): ChunkRuntime | undefined {\n if (!code.includes(MARKER)) {\n return undefined;\n }\n const program = parse(filename, code);\n const s = new MagicString(code);\n const helpers = new Map<string, string>();\n const builtInAliases: Record<string, string> = {};\n // A marker is usually a top-level statement. The bundler moves a module\n // into an init function when it has to run lazily, such as a module that\n // a dynamic import pulled into the same chunk, so every statement is searched.\n const markers: ExpressionStatement[] = [];\n const visit = (node: Node): void => {\n if (\n node.type === 'ExpressionStatement' &&\n node.expression.type === 'CallExpression' &&\n node.expression.callee.type === 'Identifier' &&\n node.expression.callee.name === MARKER\n ) {\n markers.push(node);\n return;\n }\n forEachChild(node, visit);\n };\n visit(program);\n for (const statement of markers) {\n s.remove(statement.start, statement.end);\n if (statement.expression.type !== 'CallExpression') {\n continue;\n }\n const argument = statement.expression.arguments.at(0);\n if (argument?.type !== 'ObjectExpression') {\n continue;\n }\n for (const property of argument.properties) {\n if (property.type !== 'Property' || property.value.type !== 'Identifier') {\n continue;\n }\n const key = propertyKey(property.key);\n if (key?.startsWith(HELPER_PREFIX)) {\n helpers.set(key.slice(HELPER_PREFIX.length), property.value.name);\n } else if (key?.startsWith(BUILT_IN_PREFIX)) {\n builtInAliases[property.value.name] = key.slice(BUILT_IN_PREFIX.length);\n }\n }\n }\n if (markers.length === 0) {\n return undefined;\n }\n return {\n code: s.toString(),\n map: generateMap(s, filename),\n helpers,\n builtInAliases,\n };\n}\n\n/**\n * Replaces the helper imports that Solid's JSX transform added to a chunk\n * with the chunk's own names for those helpers.\n */\nexport function linkHelpers(\n code: string,\n filename: string,\n moduleName: string,\n helpers: ReadonlyMap<string, string>,\n): EditResult {\n const program = parse(filename, code);\n const scopes = analyzeScopes(program);\n const parents = collectParents(program);\n const s = new MagicString(code);\n for (const statement of program.body) {\n if (\n statement.type !== 'ImportDeclaration' ||\n statement.source.value !== moduleName ||\n !isAllGenerated(statement.specifiers)\n ) {\n continue;\n }\n for (const specifier of statement.specifiers) {\n if (specifier.type !== 'ImportSpecifier') {\n continue;\n }\n const imported = exportedName(specifier);\n const target = helpers.get(imported);\n if (target === undefined) {\n throw new MissingHelperError(\n `[solid-optimizer] ${filename} needs \"${imported}\" from \"${moduleName}\", but no module in the chunk imports it.`,\n );\n }\n const binding = scopes.root.bindings.get(specifier.local.name);\n const targetBinding = scopes.root.bindings.get(target);\n if (!targetBinding) {\n throw new Error(\n `[solid-optimizer] ${filename} has no top-level \"${target}\" for \"${imported}\".`,\n );\n }\n for (const reference of binding?.references ?? []) {\n if (lookup(scopeAt(scopes, parents, reference), target) !== targetBinding) {\n throw new Error(\n `[solid-optimizer] ${filename} shadows \"${target}\" where the JSX transform uses \"${imported}\".`,\n );\n }\n s.overwrite(reference.start, reference.end, target);\n }\n }\n s.remove(statement.start, statement.end);\n }\n return { code: s.toString(), map: generateMap(s, filename) };\n}\n","/**\n * Copies components from other modules into a module before bundling, so\n * the inline pass can inline them there.\n *\n * In chunk mode, the chunk step inlines any component in the same chunk.\n * It runs after the bundler has split the chunks, so a shared chunk still\n * exports what an inlined component needed, like the runtime's `spread`.\n * Inlining an imported component while its importer is transformed lets\n * the bundler drop the component, and what only it used, before splitting.\n *\n * A copy refers to the bindings of its own module. Imports are imported\n * again by the module they resolve to. A binding the module declares but\n * does not export is exported under an extra name, which `exposeLocals`\n * adds when the module is transformed.\n */\nimport MagicString from 'magic-string';\nimport type { Expression, Node, Program } from 'oxc-parser';\nimport { forEachChild, parse, unwrap } from '../ast';\nimport type { Binding, ScopeAnalysis } from '../scope';\nimport { analyzeScopes } from '../scope';\nimport { MARKER } from './runtime';\nimport type { EditResult } from './runtime';\n\n/**\n * Whether a binding is `const X = createContext(...)`, with `createContext`\n * imported from Solid.\n */\nfunction isContext(\n binding: Binding,\n scopes: ScopeAnalysis,\n moduleSources: readonly string[],\n): boolean {\n const { declaration } = binding;\n if (\n binding.kind !== 'const' ||\n binding.mutated ||\n declaration.type !== 'VariableDeclarator' ||\n !declaration.init\n ) {\n return false;\n }\n const init = unwrap(declaration.init);\n if (init.type !== 'CallExpression' || init.callee.type !== 'Identifier') {\n return false;\n }\n const callee = scopes.references.get(init.callee);\n return (\n callee?.kind === 'import' &&\n callee.imported === 'createContext' &&\n callee.source !== undefined &&\n moduleSources.includes(callee.source)\n );\n}\n\n/** The prefix of the name a module exports a local binding under. */\nexport const LOCAL_EXPORT = '__so_local$';\n\nfunction generateMap(s: MagicString, filename: string): string {\n return s.generateMap({ source: filename, hires: true, includeContent: true }).toString();\n}\n\nfunction isCapitalized(name: string): boolean {\n return /^[A-Z]/.test(name);\n}\n\ninterface TopLevelFunction {\n readonly binding: Binding;\n /** The function, or the arrow or function expression a `const` holds. */\n readonly fn: Node;\n /** The node to copy: the function declaration, or the expression. */\n readonly kind: 'declaration' | 'expression';\n}\n\n/**\n * The function a top-level binding holds: `function A() {}`, or\n * `const A = () => ...`.\n */\nfunction findTopLevelFunction(binding: Binding): TopLevelFunction | undefined {\n const { declaration } = binding;\n if (declaration.type === 'FunctionDeclaration') {\n return { binding, fn: declaration, kind: 'declaration' };\n }\n if (\n declaration.type === 'VariableDeclarator' &&\n binding.kind === 'const' &&\n declaration.id === binding.identifier &&\n declaration.init\n ) {\n const init = unwrap(declaration.init);\n if (init.type === 'ArrowFunctionExpression' || init.type === 'FunctionExpression') {\n return { binding, fn: init, kind: 'expression' };\n }\n }\n return undefined;\n}\n\n/**\n * The binding a top-level alias like `const Button = ButtonRoot` names, or\n * the binding itself when it is not one. Libraries often export a component\n * under such a second name.\n */\nfunction aliasedBinding(binding: Binding): Binding {\n let current = binding;\n for (let depth = 0; depth < 8; depth += 1) {\n const { declaration } = current;\n if (\n declaration.type !== 'VariableDeclarator' ||\n current.kind !== 'const' ||\n current.mutated ||\n declaration.id !== current.identifier ||\n !declaration.init\n ) {\n return current;\n }\n const init = unwrap(declaration.init);\n const target = init.type === 'Identifier' ? current.scope.bindings.get(init.name) : undefined;\n if (!target || target === current || target.mutated) {\n return current;\n }\n current = target;\n }\n return current;\n}\n\n/**\n * Where a module re-exports `exportName` from, like\n * `export { t as Separator } from './chunk.jsx'`, or `undefined` when it\n * does not re-export it by name.\n */\nexport function readReexport(\n code: string,\n filename: string,\n exportName: string,\n): { source: string; imported: string } | undefined {\n const program = parse(filename, code);\n for (const statement of program.body) {\n if (\n statement.type !== 'ExportNamedDeclaration' ||\n !statement.source ||\n statement.exportKind === 'type'\n ) {\n continue;\n }\n for (const specifier of statement.specifiers) {\n const exported =\n specifier.exported.type === 'Identifier'\n ? specifier.exported.name\n : specifier.exported.value;\n const local =\n specifier.local.type === 'Identifier' ? specifier.local.name : specifier.local.value;\n if (exported === exportName && specifier.exportKind !== 'type') {\n return { source: statement.source.value, imported: local };\n }\n }\n }\n return undefined;\n}\n\nfunction addDeclared(\n exports: Map<string, Binding>,\n declarators: readonly { id: { type: string; name?: string } }[],\n bindings: ReadonlyMap<string, Binding>,\n): void {\n for (const declarator of declarators) {\n const binding =\n declarator.id.type === 'Identifier' && declarator.id.name !== undefined\n ? bindings.get(declarator.id.name)\n : undefined;\n if (binding !== undefined) {\n exports.set(binding.name, binding);\n }\n }\n}\n\n/**\n * The names a module exports, each with the top-level binding it exports.\n */\nfunction collectExports(program: Program, scopes: ScopeAnalysis): Map<string, Binding> {\n const exports = new Map<string, Binding>();\n const { bindings } = scopes.root;\n for (const statement of program.body) {\n if (statement.type === 'ExportNamedDeclaration' && !statement.source) {\n const { declaration } = statement;\n if (declaration?.type === 'FunctionDeclaration' && declaration.id) {\n const binding = bindings.get(declaration.id.name);\n if (binding) {\n exports.set(declaration.id.name, binding);\n }\n } else if (declaration?.type === 'VariableDeclaration') {\n addDeclared(exports, declaration.declarations, bindings);\n }\n for (const specifier of statement.specifiers) {\n const local = specifier.local.type === 'Identifier' ? specifier.local.name : undefined;\n const exported =\n specifier.exported.type === 'Identifier'\n ? specifier.exported.name\n : specifier.exported.value;\n const binding = local === undefined ? undefined : bindings.get(local);\n if (binding) {\n exports.set(exported, binding);\n }\n }\n } else if (statement.type === 'ExportDefaultDeclaration') {\n const { declaration } = statement;\n if (declaration.type === 'FunctionDeclaration' && declaration.id) {\n const binding = bindings.get(declaration.id.name);\n if (binding) {\n exports.set('default', binding);\n }\n } else if (declaration.type === 'Identifier') {\n const binding = bindings.get(declaration.name);\n if (binding) {\n exports.set('default', binding);\n }\n }\n }\n }\n return exports;\n}\n\n/**\n * The top-level bindings a function refers to, other than itself.\n */\nfunction outerBindings(fn: Node, self: Binding, scopes: ScopeAnalysis): Map<Node, Binding> {\n const outer = new Map<Node, Binding>();\n for (const [reference, binding] of scopes.references) {\n if (\n binding &&\n binding !== self &&\n binding.scope === scopes.root &&\n reference.start >= fn.start &&\n reference.end <= fn.end\n ) {\n outer.set(reference, binding);\n }\n }\n return outer;\n}\n\n/**\n * Exports the top-level bindings that the module's exported components\n * refer to but the module does not export, under an extra name. A copy of\n * such a component in another module imports them from here.\n */\nexport function exposeLocals(code: string, filename: string): EditResult | undefined {\n const program = parse(filename, code);\n const scopes = analyzeScopes(program);\n const exports = collectExports(program, scopes);\n const exported = new Set(exports.values());\n const needed = new Set<Binding>();\n for (const [name, binding] of exports) {\n const component =\n isCapitalized(binding.name) || name === 'default' ? findTopLevelFunction(binding) : undefined;\n if (!component) {\n continue;\n }\n for (const outer of outerBindings(component.fn, binding, scopes).values()) {\n if (outer.kind !== 'import' && !exported.has(outer)) {\n needed.add(outer);\n }\n }\n }\n if (needed.size === 0) {\n return undefined;\n }\n const s = new MagicString(code);\n const specifiers: string[] = [];\n for (const binding of needed) {\n specifiers.push(`${binding.name} as ${LOCAL_EXPORT}${binding.name}`);\n }\n s.append(`\\nexport { ${specifiers.join(', ')} };\\n`);\n return { code: s.toString(), map: generateMap(s, filename) };\n}\n\n/** A binding a copied component needs from its own module's scope. */\nexport type Dependency =\n /** An import of that module, imported again by the module it resolves to. */\n | { readonly kind: 'import'; readonly source: string; readonly imported: string }\n /** A binding that module exports, imported from it under this name. */\n | { readonly kind: 'export'; readonly exported: string; readonly context: boolean };\n\nexport interface ExportedComponent {\n /** Each top-level binding the component refers to, by its name in the module. */\n readonly dependencies: ReadonlyMap<string, Dependency>;\n /**\n * The component's declaration under `name`, with each dependency renamed\n * as `rename` gives it.\n */\n readonly copy: (name: string, rename: ReadonlyMap<string, string>) => string;\n /**\n * Whether the component only returns a call of another component of its\n * module, like `(props) => <Icon {...props}><path /></Icon>`.\n */\n readonly wrapsLocal: boolean;\n}\n\n/**\n * Whether a function returns JSX whose root calls a component declared at\n * the top of its own module. A context's provider does not count, since the\n * provider pass can remove it from a copy.\n */\nfunction returnsLocalCall(\n fn: TopLevelFunction['fn'],\n scopes: ScopeAnalysis,\n moduleSources: readonly string[],\n): boolean {\n if (\n fn.type !== 'FunctionDeclaration' &&\n fn.type !== 'FunctionExpression' &&\n fn.type !== 'ArrowFunctionExpression'\n ) {\n return false;\n }\n const { body } = fn;\n if (!body) {\n return false;\n }\n let root: Expression | null | undefined;\n if (body.type === 'BlockStatement') {\n const last = body.body.at(-1);\n root = last?.type === 'ReturnStatement' ? last.argument : undefined;\n } else {\n root = body;\n }\n if (!root) {\n return false;\n }\n const inner = unwrap(root);\n if (inner.type !== 'JSXElement' || inner.openingElement.name.type !== 'JSXIdentifier') {\n return false;\n }\n const binding = scopes.references.get(inner.openingElement.name);\n return (\n binding !== undefined &&\n binding.scope === scopes.root &&\n binding.kind !== 'import' &&\n !isContext(binding, scopes, moduleSources)\n );\n}\n\n/**\n * Reads the component a module exports under `exportName`, from the module\n * as the bundler loaded it. `undefined` when that export is not a function\n * component, or it refers to a top-level binding the module cannot export.\n */\nexport function readExportedComponent(\n code: string,\n filename: string,\n exportName: string,\n moduleSources: readonly string[],\n): ExportedComponent | undefined {\n const program = parse(filename, code);\n const scopes = analyzeScopes(program);\n const exports = collectExports(program, scopes);\n const named = exports.get(exportName);\n const binding = named ? aliasedBinding(named) : undefined;\n const component = binding ? findTopLevelFunction(binding) : undefined;\n if (!binding || !component) {\n return undefined;\n }\n const exportNames = new Map<Binding, string>();\n for (const [name, exported] of exports) {\n if (!exportNames.has(exported)) {\n exportNames.set(exported, name);\n }\n }\n\n const outer = outerBindings(component.fn, binding, scopes);\n const dependencies = new Map<string, Dependency>();\n for (const dependency of outer.values()) {\n if (dependencies.has(dependency.name)) {\n continue;\n }\n if (dependency.kind === 'import') {\n if (dependency.source === undefined || dependency.imported === undefined) {\n return undefined;\n }\n dependencies.set(dependency.name, {\n kind: 'import',\n source: dependency.source,\n imported: dependency.imported,\n });\n continue;\n }\n // A local binding is exported under its extra name, which `exposeLocals` added.\n const name = exportNames.get(dependency);\n if (name === undefined) {\n return undefined;\n }\n dependencies.set(dependency.name, {\n kind: 'export',\n exported: name,\n context: isContext(dependency, scopes, moduleSources),\n });\n }\n\n // The helper markers in the copy belong to the module it comes from.\n const markers: Node[] = [];\n const findMarkers = (node: Node): void => {\n if (\n node.type === 'ExpressionStatement' &&\n node.expression.type === 'CallExpression' &&\n node.expression.callee.type === 'Identifier' &&\n node.expression.callee.name === MARKER\n ) {\n markers.push(node);\n return;\n }\n forEachChild(node, findMarkers);\n };\n findMarkers(component.fn);\n\n const copy = (name: string, rename: ReadonlyMap<string, string>): string => {\n const s = new MagicString(code);\n for (const [reference, dependency] of outer) {\n const renamed = rename.get(dependency.name);\n if (renamed !== undefined && renamed !== dependency.name) {\n s.overwrite(reference.start, reference.end, renamed);\n }\n }\n for (const marker of markers) {\n s.remove(marker.start, marker.end);\n }\n if (\n component.kind === 'declaration' &&\n component.fn.type === 'FunctionDeclaration' &&\n component.fn.id\n ) {\n s.overwrite(component.fn.id.start, component.fn.id.end, name);\n return s.slice(component.fn.start, component.fn.end);\n }\n return `const ${name} = ${s.slice(component.fn.start, component.fn.end)};`;\n };\n return { dependencies, copy, wrapsLocal: returnsLocalCall(component.fn, scopes, moduleSources) };\n}\n","/**\n * Rewrites JSX tags that read a member of a namespace import, like\n * `<Button.Root>` with `import * as Button from '...'`, to a named import.\n *\n * A bundler resolves `Button.Root` in code to the export it reads, and\n * drops the namespace. In a JSX tag name it does not, so a module that\n * keeps its JSX through bundling would make the bundle build a namespace\n * object with every export of the module.\n */\nimport MagicString from 'magic-string';\nimport { collectParents, parse } from '../ast';\nimport { analyzeScopes } from '../scope';\nimport type { EditResult } from './runtime';\n\nexport function nameNamespaceTags(code: string, filename: string): EditResult | undefined {\n const program = parse(filename, code);\n const scopes = analyzeScopes(program);\n const parents = collectParents(program);\n const s = new MagicString(code);\n const names = new Set(scopes.names);\n const imports: string[] = [];\n for (const binding of scopes.root.bindings.values()) {\n const statement = parents.get(binding.declaration);\n if (\n binding.kind !== 'import' ||\n binding.imported !== '*' ||\n binding.source === undefined ||\n statement?.type !== 'ImportDeclaration' ||\n statement.importKind === 'type'\n ) {\n continue;\n }\n // One local name for each member, shared by its opening and closing tags.\n const locals = new Map<string, string>();\n for (const reference of binding.references) {\n const member = parents.get(reference);\n if (\n reference.type !== 'JSXIdentifier' ||\n member?.type !== 'JSXMemberExpression' ||\n member.object !== reference\n ) {\n continue;\n }\n const { name } = member.property;\n let local = locals.get(name);\n if (local === undefined) {\n local = `${binding.name}$${name}`;\n for (let index = 1; names.has(local); index += 1) {\n local = `${binding.name}$${name}$${String(index)}`;\n }\n names.add(local);\n locals.set(name, local);\n imports.push(`import { ${name} as ${local} } from ${JSON.stringify(binding.source)};`);\n }\n s.overwrite(member.start, member.end, local);\n }\n }\n if (imports.length === 0) {\n return undefined;\n }\n s.prepend(`${imports.join('\\n')}\\n`);\n return {\n code: s.toString(),\n map: s.generateMap({ source: filename, hires: true, includeContent: true }).toString(),\n };\n}\n","/**\n * Keeps a `ref` that names a variable working through bundling.\n *\n * Solid's JSX transform turns `<input ref={el} />` into code that assigns\n * the element to `el`. In chunk mode the JSX reaches the bundler before that\n * code exists, so the bundler only sees `el` read. A `let el` that nothing\n * else writes to then looks like it is always `undefined`, and the bundler\n * folds its reads, like `el ? el.value : ''`, to the `undefined` branch.\n *\n * Before bundling, `ref={el}` becomes `ref={__SO_REF__(el, (v) => (el = v))}`,\n * which shows the bundler the write. The bundler renames both uses of `el`\n * alike. Before the chunk is lowered, the call becomes `ref={el}` again, so\n * the JSX transform writes the same code it would have.\n */\nimport type { CallExpression, JSXAttribute, Node } from 'oxc-parser';\nimport MagicString from 'magic-string';\nimport { forEachChild, parse } from '../ast';\nimport { analyzeScopes } from '../scope';\nimport type { EditResult } from './runtime';\n\nexport const REF_MARKER = '__SO_REF__';\n\nfunction generateMap(s: MagicString, filename: string): string {\n return s.generateMap({ source: filename, hires: true, includeContent: true }).toString();\n}\n\nfunction isRefAttribute(node: Node): node is JSXAttribute {\n return (\n node.type === 'JSXAttribute' && node.name.type === 'JSXIdentifier' && node.name.name === 'ref'\n );\n}\n\n/**\n * Wraps each `ref` whose value is a `let` or `var` binding, so the bundler\n * sees it written. `undefined` when there is none.\n */\nexport function protectRefs(code: string, filename: string): EditResult | undefined {\n if (!code.includes('ref')) {\n return undefined;\n }\n const program = parse(filename, code);\n const scopes = analyzeScopes(program);\n const s = new MagicString(code);\n const visit = (node: Node): void => {\n if (isRefAttribute(node) && node.value?.type === 'JSXExpressionContainer') {\n const { expression } = node.value;\n const binding =\n expression.type === 'Identifier' ? scopes.references.get(expression) : undefined;\n if (\n expression.type === 'Identifier' &&\n (binding?.kind === 'let' || binding?.kind === 'var')\n ) {\n const { name } = expression;\n s.overwrite(\n expression.start,\n expression.end,\n `${REF_MARKER}(${name}, (__so_ref) => (${name} = __so_ref))`,\n );\n }\n }\n forEachChild(node, visit);\n };\n visit(program);\n return s.hasChanged() ? { code: s.toString(), map: generateMap(s, filename) } : undefined;\n}\n\n/**\n * Turns each wrapped `ref` back into its variable. `undefined` when there\n * is none.\n */\nexport function restoreRefs(code: string, filename: string): EditResult | undefined {\n if (!code.includes(REF_MARKER)) {\n return undefined;\n }\n const program = parse(filename, code);\n const s = new MagicString(code);\n const visit = (node: Node): void => {\n if (isRefAttribute(node) && node.value?.type === 'JSXExpressionContainer') {\n const { expression } = node.value;\n if (isMarkerCall(expression)) {\n const target = expression.arguments.at(0);\n if (target?.type === 'Identifier') {\n s.overwrite(expression.start, expression.end, target.name);\n }\n }\n }\n forEachChild(node, visit);\n };\n visit(program);\n return s.hasChanged() ? { code: s.toString(), map: generateMap(s, filename) } : undefined;\n}\n\nfunction isMarkerCall(node: Node): node is CallExpression {\n return (\n node.type === 'CallExpression' &&\n node.callee.type === 'Identifier' &&\n node.callee.name === REF_MARKER\n );\n}\n","/**\n * Which modules use each export of the app, read from the files on disk.\n *\n * A component copied into the module that uses it is only smaller overall\n * when the original goes away, which takes that module being its only user.\n * The index answers that from the whole module graph, so it does not depend\n * on the order the bundler transforms modules in, and a server build and its\n * client build make the same decisions.\n *\n * Anything the index cannot follow counts as another use: a re-export, a\n * dynamic import, a namespace used as a value, or a use inside the module\n * that declares the export.\n */\nimport type { Node, Program } from 'oxc-parser';\nimport { collectParents, forEachChild, parse } from '../ast';\nimport type { Parents } from '../ast';\nimport type { Binding, ScopeAnalysis } from '../scope';\nimport { analyzeScopes } from '../scope';\n\nexport interface UsageIndex {\n /**\n * How many modules use `exportName` of `module`, counting `user`, when\n * they only use it as JSX tags. `0` when anything else uses it, which\n * keeps it whoever copies it. `absorbed` holds, by module, the exported\n * components that were copied into `user` and leave their module, so the\n * uses inside them count as uses in `user`.\n */\n users(\n module: string,\n exportName: string,\n user: string,\n absorbed: ReadonlyMap<string, ReadonlySet<string>>,\n ): number;\n}\n\nexport interface UsageHost {\n /** The id `source` resolves to from `importer`, or `undefined` outside the app. */\n resolve(source: string, importer: string): Promise<string | undefined>;\n /** The code of a module, or `undefined` when it cannot be read. */\n read(id: string): Promise<string | undefined>;\n}\n\n/** The name a use counts under when it is not inside an exported declaration. */\nconst UNEXPORTED = '';\n\ninterface ExportUsage {\n /**\n * The modules that use the export as a JSX tag, each with the export\n * names of the top-level declarations the uses sit in.\n */\n readonly importers: Map<string, Set<string>>;\n /** Whether anything uses it other than as a tag. */\n other: boolean;\n}\n\nconst SCRIPT = /\\.[mc]?[jt]sx?$/;\n\nclass Usage implements UsageIndex {\n private readonly exports = new Map<string, ExportUsage>();\n\n /** Modules any of whose exports can be used in a way the index does not follow. */\n private readonly opaque = new Set<string>();\n\n /** The modules each module imports. */\n readonly imports = new Map<string, readonly string[]>();\n\n /** Whether `from` imports `to`, directly or through other modules. */\n private reaches(from: string, to: string): boolean {\n const seen = new Set<string>();\n const stack = [from];\n for (let id = stack.pop(); id !== undefined; id = stack.pop()) {\n if (id === to) {\n return true;\n }\n if (!seen.has(id)) {\n seen.add(id);\n stack.push(...(this.imports.get(id) ?? []));\n }\n }\n return false;\n }\n\n private entry(module: string, name: string): ExportUsage {\n const key = `${module}\\0${name}`;\n let usage = this.exports.get(key);\n if (!usage) {\n usage = { importers: new Map(), other: false };\n this.exports.set(key, usage);\n }\n return usage;\n }\n\n tag(module: string, name: string, importer: string, containers: readonly string[]): void {\n const { importers } = this.entry(module, name);\n const known = importers.get(importer) ?? new Set();\n for (const container of containers) {\n known.add(container);\n }\n importers.set(importer, known);\n }\n\n other(module: string, name: string): void {\n this.entry(module, name).other = true;\n }\n\n all(module: string): void {\n this.opaque.add(module);\n }\n\n users(\n module: string,\n exportName: string,\n user: string,\n absorbed: ReadonlyMap<string, ReadonlySet<string>>,\n ): number {\n if (this.opaque.has(module)) {\n return 0;\n }\n const usage = this.exports.get(`${module}\\0${exportName}`);\n if (!usage || usage.other || usage.importers.size === 0) {\n return 0;\n }\n const users = new Set([user]);\n for (const [importer, containers] of usage.importers) {\n const moved = absorbed.get(importer);\n users.add(hasEvery(containers, moved) ? user : importer);\n }\n // A module the component's module imports never gets a copy of it, so\n // the original stays for it.\n for (const id of users) {\n if (this.reaches(module, id)) {\n return 0;\n }\n }\n return users.size;\n }\n}\n\nfunction hasEvery(names: Iterable<string>, set: ReadonlySet<string> | undefined): boolean {\n for (const name of names) {\n if (set?.has(name) !== true) {\n return false;\n }\n }\n return true;\n}\n\nfunction isTagName(reference: Node, parents: Parents): boolean {\n const parent = parents.get(reference);\n return parent?.type === 'JSXOpeningElement' && parent.name === reference;\n}\n\nfunction isClosingTagName(reference: Node, parents: Parents): boolean {\n const parent = parents.get(reference);\n return parent?.type === 'JSXClosingElement' && parent.name === reference;\n}\n\n/** The names a declaration exported with `export` declares. */\nfunction declaredNames(declaration: Node | null | undefined): string[] {\n if (declaration?.type === 'FunctionDeclaration' && declaration.id) {\n return [declaration.id.name];\n }\n if (declaration?.type === 'VariableDeclaration') {\n const names: string[] = [];\n for (const declarator of declaration.declarations) {\n if (declarator.id.type === 'Identifier') {\n names.push(declarator.id.name);\n }\n }\n return names;\n }\n return [];\n}\n\n/** The top-level bindings a module exports, each with its export names. */\nfunction exportedBindings(program: Program, scopes: ScopeAnalysis): Map<Binding, string[]> {\n const exported = new Map<Binding, string[]>();\n const add = (local: string, name: string): void => {\n const binding = scopes.root.bindings.get(local);\n if (binding) {\n exported.set(binding, [...(exported.get(binding) ?? []), name]);\n }\n };\n for (const statement of program.body) {\n if (statement.type === 'ExportNamedDeclaration' && !statement.source) {\n for (const name of declaredNames(statement.declaration)) {\n add(name, name);\n }\n for (const specifier of statement.specifiers) {\n if (specifier.local.type === 'Identifier') {\n add(\n specifier.local.name,\n specifier.exported.type === 'Identifier'\n ? specifier.exported.name\n : specifier.exported.value,\n );\n }\n }\n } else if (statement.type === 'ExportDefaultDeclaration') {\n const { declaration } = statement;\n if (declaration.type === 'FunctionDeclaration' && declaration.id) {\n add(declaration.id.name, 'default');\n } else if (declaration.type === 'Identifier') {\n add(declaration.name, 'default');\n }\n }\n }\n return exported;\n}\n\n/**\n * Records how a module uses what it imports, and the uses of its own\n * exports inside it.\n */\nfunction recordModule(\n usage: Usage,\n id: string,\n program: Program,\n targets: ReadonlyMap<string, string>,\n): void {\n const scopes = analyzeScopes(program);\n const parents = collectParents(program);\n\n // A module that uses its own export keeps it, whoever else copies it.\n const exported = exportedBindings(program, scopes);\n // The export names of the top-level declaration a use sits in.\n const findContainers = (reference: Node): string[] => {\n let node: Node = reference;\n let parent = parents.get(node);\n while (parent && parent.type !== 'Program') {\n node = parent;\n parent = parents.get(node);\n }\n const declaration =\n (node.type === 'ExportNamedDeclaration' || node.type === 'ExportDefaultDeclaration') &&\n node.declaration\n ? node.declaration\n : node;\n const bindings: (Binding | undefined)[] = [];\n if (declaration.type === 'FunctionDeclaration' && declaration.id) {\n bindings.push(scopes.root.bindings.get(declaration.id.name));\n } else if (declaration.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations) {\n if (\n declarator.id.type === 'Identifier' &&\n reference.start >= declarator.start &&\n reference.end <= declarator.end\n ) {\n bindings.push(scopes.root.bindings.get(declarator.id.name));\n }\n }\n }\n const names: string[] = [];\n for (const binding of bindings) {\n if (binding) {\n names.push(...(exported.get(binding) ?? []));\n }\n }\n return names.length > 0 ? names : [UNEXPORTED];\n };\n\n const record = (binding: Binding, target: string): void => {\n const imported = binding.imported ?? '*';\n for (const reference of binding.references) {\n if (isClosingTagName(reference, parents)) {\n continue;\n }\n if (imported !== '*') {\n if (isTagName(reference, parents)) {\n usage.tag(target, imported, id, findContainers(reference));\n } else {\n usage.other(target, imported);\n }\n continue;\n }\n // `<Ns.Member>` and `Ns.member` use one export. Anything else may use any.\n const member = parents.get(reference);\n if (member?.type === 'JSXMemberExpression' && member.object === reference) {\n if (isTagName(member, parents)) {\n usage.tag(target, member.property.name, id, findContainers(reference));\n } else {\n usage.other(target, member.property.name);\n }\n } else if (\n member?.type === 'MemberExpression' &&\n member.object === reference &&\n !member.computed &&\n member.property.type === 'Identifier'\n ) {\n usage.other(target, member.property.name);\n } else {\n usage.all(target);\n }\n }\n };\n for (const binding of scopes.root.bindings.values()) {\n if (binding.kind === 'import' && binding.source !== undefined) {\n const target = targets.get(binding.source);\n if (target !== undefined) {\n record(binding, target);\n }\n }\n }\n\n // Re-exports pass an export on, which the index does not follow.\n for (const statement of program.body) {\n if (statement.type === 'ExportAllDeclaration') {\n const target = targets.get(statement.source.value);\n if (target !== undefined) {\n usage.all(target);\n }\n } else if (statement.type === 'ExportNamedDeclaration' && statement.source) {\n const target = targets.get(statement.source.value);\n for (const specifier of statement.specifiers) {\n const name =\n specifier.local.type === 'Identifier' ? specifier.local.name : specifier.local.value;\n if (target !== undefined) {\n usage.other(target, name);\n }\n }\n }\n }\n\n for (const [binding, names] of exported) {\n let used = false;\n for (const reference of binding.references) {\n const parent = parents.get(reference);\n if (\n parent?.type !== 'ExportSpecifier' &&\n parent?.type !== 'ExportDefaultDeclaration' &&\n !isClosingTagName(reference, parents)\n ) {\n used = true;\n break;\n }\n }\n if (used) {\n for (const name of names) {\n usage.other(id, name);\n }\n }\n }\n}\n\n/** The import specifiers a module loads, statically or with `import()`. */\nfunction collectSpecifiers(program: Program): { static: Set<string>; dynamic: Set<string> } {\n const statics = new Set<string>();\n const dynamics = new Set<string>();\n for (const statement of program.body) {\n if (\n (statement.type === 'ImportDeclaration' && statement.importKind !== 'type') ||\n ((statement.type === 'ExportNamedDeclaration' || statement.type === 'ExportAllDeclaration') &&\n statement.source &&\n statement.exportKind !== 'type')\n ) {\n const value = statement.source?.value;\n if (value !== undefined) {\n statics.add(value);\n }\n }\n }\n const visit = (node: Node): void => {\n if (\n node.type === 'ImportExpression' &&\n node.source.type === 'Literal' &&\n typeof node.source.value === 'string'\n ) {\n dynamics.add(node.source.value);\n }\n forEachChild(node, visit);\n };\n visit(program);\n return { static: statics, dynamic: dynamics };\n}\n\n/**\n * Reads every module reachable from `entries` and records how each export\n * is used.\n */\nexport async function buildUsageIndex(\n entries: readonly string[],\n host: UsageHost,\n): Promise<UsageIndex> {\n const usage = new Usage();\n // An entry's exports are its public API.\n for (const entry of entries) {\n usage.all(entry);\n }\n const seen = new Set<string>();\n let frontier: string[] = [];\n for (const id of entries) {\n if (SCRIPT.test(id.replace(/\\?.*$/, ''))) {\n frontier.push(id);\n }\n }\n while (frontier.length > 0) {\n for (const id of frontier) {\n seen.add(id);\n }\n async function readModule(id: string): Promise<string[]> {\n const code = await host.read(id);\n let program: Program;\n try {\n program = parse(id.replace(/\\?.*$/, ''), code ?? '');\n } catch {\n return [];\n }\n const { static: statics, dynamic } = collectSpecifiers(program);\n const targets = new Map<string, string>();\n async function resolveSource(source: string): Promise<void> {\n const target = await host.resolve(source, id);\n if (target !== undefined) {\n targets.set(source, target);\n }\n }\n const resolving: Promise<void>[] = [];\n for (const source of [...statics, ...dynamic]) {\n resolving.push(resolveSource(source));\n }\n await Promise.all(resolving);\n // A module loaded with `import()` is used as a whole.\n for (const source of dynamic) {\n const target = targets.get(source);\n if (target !== undefined) {\n usage.all(target);\n }\n }\n recordModule(usage, id, program, targets);\n usage.imports.set(id, [...targets.values()]);\n return [...targets.values()];\n }\n const reading: Promise<string[]>[] = [];\n for (const id of frontier) {\n reading.push(readModule(id));\n }\n // oxlint-disable-next-line no-await-in-loop\n const next = await Promise.all(reading);\n frontier = [];\n for (const id of new Set(next.flat())) {\n if (!seen.has(id) && SCRIPT.test(id.replace(/\\?.*$/, ''))) {\n frontier.push(id);\n }\n }\n }\n return usage;\n}\n","/**\n * `solid-optimizer/vite`: `@solidjs/vite-plugin` with the optimizer built in.\n *\n * It takes the same options as `@solidjs/vite-plugin`, plus `optimizer`, and\n * returns the official plugins with the optimizer wired in. It runs in one of\n * two modes.\n *\n * - Chunk mode keeps JSX through bundling. Each chunk is optimized as a whole\n * and then lowered by Solid's JSX transform, so a component inlines into\n * any other component in the same chunk. It applies to client builds that\n * do not hydrate.\n * - Module mode optimizes each module before the official plugin lowers it.\n * It applies everywhere else. A server build and its client build chunk\n * differently, and hydration needs both to render the same tree, so\n * hydrating builds only optimize within a module.\n */\nimport { readFile } from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\nimport { gzipSync } from 'node:zlib';\nimport remapping from '@jridgewell/remapping';\nimport MagicString from 'magic-string';\nimport type * as SolidCompiler from '@solidjs/compiler';\nimport type { Options as SolidPluginOptions } from '@solidjs/vite-plugin';\nimport solidPlugin from '@solidjs/vite-plugin';\nimport type { Node, Program } from 'oxc-parser';\nimport type { Plugin, ResolvedConfig, Rollup } from 'vite';\nimport { createFilter, minifySync, transformWithOxc } from 'vite';\nimport type { CompileOptions, CompileResult, ModuleConstants } from '../compile';\nimport { compile, readModuleConstants } from '../compile';\nimport { collectParents, forEachChild, isIntrinsicTag, parse } from '../ast';\nimport { analyzeScopes } from '../scope';\nimport { CONTEXT_SAFE_PRIMITIVES } from '../provider';\nimport type { ImportedConstants } from '../constants';\nimport { runtimeImportSources } from '../constants';\nimport type { Primitive } from '../value';\nimport { sharedGlobals } from './globals';\nimport type { Skip } from '../context';\nimport type { OptimizerReport } from './report';\nimport { formatReport } from './report';\nimport { exposeLocals, readExportedComponent, readReexport } from './inject';\nimport { nameNamespaceTags } from './namespace';\nimport { protectRefs, restoreRefs } from './refs';\nimport type { UsageIndex } from './usage';\nimport { buildUsageIndex } from './usage';\nimport {\n MARKER,\n MissingHelperError,\n addMarker,\n generatedImports,\n linkHelpers,\n readMarkers,\n repairJSXSequences,\n} from './runtime';\n\nexport interface OptimizerOptions extends Pick<\n CompileOptions,\n 'fold' | 'inline' | 'alwaysInline' | 'contexts' | 'memos' | 'conditionals' | 'maxPasses'\n> {\n /**\n * Where the optimizer runs.\n *\n * - `auto` uses chunk mode for client builds that do not hydrate, and module mode otherwise.\n * - `module` optimizes each module on its own.\n *\n * @default 'auto'\n */\n mode?: 'auto' | 'module';\n /**\n * Also optimize while serving, in module mode.\n *\n * @default false\n */\n dev?: boolean;\n /**\n * Report what the optimizer leaves alone in each build, and why: each\n * component call that stays a call, each provider that stays, and each\n * memo that stays. `true` prints the report. A function receives it\n * instead, once per build environment.\n *\n * @default false\n */\n report?: boolean | ((report: OptimizerReport) => void);\n /**\n * Packages whose components can be copied into the modules that use\n * them, like `['@kobalte/core']`. A package has to publish its JSX, as\n * most Solid libraries do through the `solid` export condition. A copy\n * lets the bundler drop the original, and the runtime code only it used,\n * even when the package lands in another chunk.\n *\n * @default []\n */\n packages?: readonly string[];\n}\n\nexport type { OptimizerReport } from './report';\n\nexport interface Options extends Partial<SolidPluginOptions> {\n /** Set to `false` to use `@solidjs/vite-plugin` as it is. */\n optimizer?: OptimizerOptions | false;\n}\n\ntype Compiler = typeof SolidCompiler;\ntype JSXOptions = SolidCompiler.TransformOptions;\n\nconst DEFAULT_MODULE_NAME = '@solidjs/web';\n\nconst JSX_MODULE = /\\.[mc]?[jt]sx$/i;\n\n/**\n * Helpers the JSX transform picks between for the same attribute. Inlining\n * can turn one form into the other: a style object that was a prop becomes a\n * literal, which the transform writes one property at a time. A module that\n * needs one keeps the other too.\n */\nconst RELATED_HELPERS: Readonly<Record<string, readonly string[]>> = {\n style: ['setStyleProperty'],\n setStyleProperty: ['style'],\n};\n\nfunction withRelated(helpers: readonly string[]): Set<string> {\n const result = new Set(helpers);\n for (const helper of helpers) {\n for (const related of RELATED_HELPERS[helper] ?? []) {\n result.add(related);\n }\n }\n return result;\n}\n\nconst LAZY_PLACEHOLDER = /\"__SOLID_LAZY_MODULE__:([^\"]+)\"/g;\n\n/**\n * The common kinds of attribute: a class, any other attribute, events, and\n * children. Inlining a component turns a spread onto an element into\n * attributes like these, in a module that may not use their helpers itself.\n * A `ref` can come through a spread too, and a link with a dynamic attribute\n * claims its element. A rarer kind, like `style`, can still need a helper no\n * module imports. The chunk is then lowered without optimizing it.\n */\nconst ATTRIBUTE_SAMPLE = `const a = () => 0;\nexport const Sample = () => (\n <div class={a()} id={a()} onClick={a()} onScroll={a()}>\n {a()}\n <a href=\"/\" title={a()} ref={a} />\n </div>\n);`;\n\n/** The references that are the name of a JSX tag. */\nfunction findTags(references: readonly Node[], parents: ReturnType<typeof collectParents>): Node[] {\n const tags: Node[] = [];\n for (const reference of references) {\n const parent = parents.get(reference);\n if (\n (parent?.type === 'JSXOpeningElement' || parent?.type === 'JSXClosingElement') &&\n parent.name === reference\n ) {\n tags.push(reference);\n }\n }\n return tags;\n}\n\nfunction findSkipReason(\n skipped: readonly { name: string; reason: string }[],\n name: string,\n): string | undefined {\n for (const entry of skipped) {\n if (entry.name === name) {\n return entry.reason;\n }\n }\n return undefined;\n}\n\nfunction hasSpreadAttribute(attributes: readonly { type: string }[]): boolean {\n for (const attribute of attributes) {\n if (attribute.type === 'JSXSpreadAttribute') {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Whether the code spreads anything onto an intrinsic element, or onto\n * `<Dynamic>`, which becomes one once its `component` is known.\n */\nfunction spreadsOntoElement(code: string, filename: string): boolean {\n if (!code.includes('...')) {\n return false;\n }\n let found = false;\n const visit = (node: Node): void => {\n if (found) {\n return;\n }\n if (\n node.type === 'JSXOpeningElement' &&\n node.name.type === 'JSXIdentifier' &&\n (isIntrinsicTag(node.name.name) || node.name.name === 'Dynamic') &&\n hasSpreadAttribute(node.attributes)\n ) {\n found = true;\n return;\n }\n forEachChild(node, visit);\n };\n visit(parse(filename, code));\n return found;\n}\n\n/** A chunk optimized and lowered one way, ready to be compared with another. */\ninterface ChunkCandidate {\n readonly optimized: CompileResult;\n readonly lowered: SolidCompiler.TransformResult;\n readonly linked: { code: string; map: string };\n}\n\n/**\n * How many bytes a chunk takes once minified and gzipped. Minifying drops\n * the runtime code nothing calls anymore, which is what the comparison is\n * for, so it counts even when the build does not minify.\n */\nfunction shippedSize(candidate: ChunkCandidate, filename: string): number {\n const minified = minifySync(filename, candidate.linked.code, {\n module: true,\n compress: true,\n mangle: true,\n });\n return gzipSync(minified.code).length;\n}\n\n/** Whether a module, or the module of a copy's key, is in `node_modules`. */\nfunction isPackageModule(id: string): boolean {\n return stripQuery(id).replaceAll('\\\\', '/').includes('/node_modules/');\n}\n\nfunction loadCompiler(): Compiler {\n // Use the compiler `@solidjs/vite-plugin` uses, so both lower JSX the same way.\n const require = createRequire(import.meta.url);\n const pluginRequire = createRequire(require.resolve('@solidjs/vite-plugin'));\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return pluginRequire('@solidjs/compiler') as Compiler;\n}\n\nfunction stripQuery(id: string): string {\n return id.replace(/\\?.*$/, '');\n}\n\n/**\n * Chains the maps of each step into one, or `null` when the build writes no\n * source maps, since chaining the maps of a large chunk takes a while.\n */\nfunction combineMaps(wanted: boolean, maps: (string | null | undefined)[]): string | null {\n const present: string[] = [];\n for (const map of maps) {\n if (typeof map === 'string') {\n present.push(map);\n }\n }\n if (!wanted || present.length === 0) {\n return null;\n }\n return remapping(present.reverse(), () => null).toString();\n}\n\n/**\n * The local name of each value a module imports, keyed by its source and\n * the name it is imported as: an export name, `default`, or `*`.\n */\nfunction importedNames(program: Program): Map<string, string> {\n const names = new Map<string, string>();\n for (const statement of program.body) {\n if (statement.type !== 'ImportDeclaration' || statement.importKind === 'type') {\n continue;\n }\n for (const specifier of statement.specifiers) {\n let imported = '*';\n if (specifier.type === 'ImportDefaultSpecifier') {\n imported = 'default';\n } else if (specifier.type === 'ImportSpecifier') {\n imported =\n specifier.imported.type === 'Identifier'\n ? specifier.imported.name\n : specifier.imported.value;\n }\n const typeOnly = specifier.type === 'ImportSpecifier' && specifier.importKind === 'type';\n if (!typeOnly) {\n names.set(`${statement.source.value}\\0${imported}`, specifier.local.name);\n }\n }\n }\n return names;\n}\n\n/**\n * A key for a module in the build environment of `context`. The server and\n * client builds transform the same module into different code.\n */\nfunction environmentKey(context: { environment?: { name: string } }, id: string): string {\n return `${context.environment?.name ?? ''}\\0${id}`;\n}\n\nfunction isClient(context: { environment?: { config: { consumer: string } } }): boolean {\n return context.environment?.config.consumer === 'client';\n}\n\nexport default function solidOptimizer(options: Options = {}): Plugin[] {\n const { optimizer: optimizerOption, ...solidOptions } = options;\n const plugins = solidPlugin(solidOptions);\n if (optimizerOption === false) {\n return plugins;\n }\n const optimizer = optimizerOption ?? {};\n const moduleName = solidOptions.solid?.moduleName ?? DEFAULT_MODULE_NAME;\n const moduleSources = [...new Set(['solid-js', DEFAULT_MODULE_NAME, moduleName])];\n const builtIns = new Set(\n solidOptions.solid?.builtIns ?? [\n 'For',\n 'Show',\n 'Switch',\n 'Match',\n 'Loading',\n 'Reveal',\n 'Portal',\n 'Repeat',\n 'Dynamic',\n 'Errored',\n ],\n );\n const compileOptions: CompileOptions = {\n fold: optimizer.fold,\n inline: optimizer.inline,\n alwaysInline: optimizer.alwaysInline,\n contexts: optimizer.contexts,\n memos: optimizer.memos,\n conditionals: optimizer.conditionals,\n maxPasses: optimizer.maxPasses,\n builtIns: [...builtIns],\n moduleSources,\n report: optimizer.report !== undefined && optimizer.report !== false,\n };\n\n /** What the final compile of each chunk or module left alone, by environment. */\n const skips = new Map<string, Skip[]>();\n const addSkips = (\n context: { environment?: { name: string } },\n list?: readonly Skip[],\n module?: string,\n ): void => {\n // A package's own modules are compiled too, but what they leave alone\n // is not something the app can change. A call of a package's component\n // in the app is still reported, from the app's module.\n if (!list || (module !== undefined && isPackageModule(module))) {\n return;\n }\n const environment = context.environment?.name ?? 'client';\n const entries = skips.get(environment) ?? [];\n entries.push(...list);\n skips.set(environment, entries);\n };\n\n let config: ResolvedConfig | undefined;\n /** The `define` entries and `import.meta.env` values every environment shares. */\n let globals: Record<string, Primitive> = {};\n let compiler: Compiler | undefined;\n let filter: ((id: string) => boolean) | undefined;\n const getCompiler = (): Compiler => {\n compiler ??= loadCompiler();\n return compiler;\n };\n\n const isBuild = (): boolean => config?.command === 'build';\n /** Whether the output needs source maps: while serving, or when the build writes them. */\n const wantsMaps = (): boolean => !isBuild() || Boolean(config?.build.sourcemap);\n\n /**\n * The JSX options the official plugin passes for a posture, so the\n * lowering here matches it. Mirrors `getSolidOptions` in `@solidjs/vite-plugin`.\n */\n const jsxOptions = (isSsr: boolean): JSXOptions => {\n let posture: Pick<JSXOptions, 'generate' | 'hydratable'>;\n if (solidOptions.start && !solidOptions.ssr) {\n posture = { generate: isSsr ? 'ssr' : 'dom', hydratable: false };\n } else if (solidOptions.ssr) {\n posture = { generate: isSsr ? 'ssr' : 'dom', hydratable: true };\n } else {\n posture = { generate: 'dom', hydratable: false };\n }\n const dev = solidOptions.dev === true || (solidOptions.dev !== false && !isBuild());\n const names = dev || solidOptions.observe === true;\n const { sourceNames, ...rest } = solidOptions.solid ?? {};\n let resolvedNames: JSXOptions['sourceNames'] = false;\n if (typeof sourceNames === 'boolean') {\n resolvedNames = sourceNames;\n } else if (sourceNames !== undefined || names) {\n const components = sourceNames?.components ?? names;\n const bindings = sourceNames?.bindings ?? names;\n resolvedNames = components || bindings ? { components, bindings } : false;\n }\n return { ...posture, dev, sourceNames: resolvedNames, ...rest };\n };\n\n let sampleHelpers: string[] | undefined;\n /** The helpers the JSX transform uses for attributes in chunk mode. */\n const attributeHelpers = (): string[] => {\n sampleHelpers ??= generatedImports(\n getCompiler().transform(ATTRIBUTE_SAMPLE, { ...jsxOptions(false), filename: 'sample.jsx' })\n .code,\n 'sample.jsx',\n moduleName,\n );\n return sampleHelpers;\n };\n\n /**\n * Whether client builds keep JSX until chunks are rendered.\n */\n const chunkMode = (): boolean => {\n if (!isBuild() || (optimizer.mode ?? 'auto') !== 'auto') {\n return false;\n }\n // A Babel pass or backend has to see the modules, which chunk mode skips.\n if (solidOptions.babel || solidOptions.compiler === 'babel') {\n return false;\n }\n const client = jsxOptions(false);\n return client.generate === 'dom' && client.hydratable !== true;\n };\n\n const isJSXModule = (id: string): boolean => {\n filter ??= createFilter(solidOptions.include, solidOptions.exclude, {\n resolve: config?.root,\n });\n return filter(id) && JSX_MODULE.test(stripQuery(id));\n };\n\n /** Modules that keep their JSX, which the bundler must parse as JSX. */\n const preserved = new Set<string>();\n\n /**\n * What each module imports and the constants it exports, by module id,\n * once read in full. A module whose constants needed a module with JSX\n * that could not be loaded, to avoid a cycle, is not kept, since another\n * transform may load it.\n *\n * A read in progress is never shared. It can wait for a module with JSX,\n * and a read that waited for it would wait for that module too, without\n * the cycle checks knowing. Two reads of modules that import each other\n * would also wait for each other.\n */\n const moduleConstants = new Map<string, ConstantsResult>();\n\n interface ConstantsResult {\n readonly constants: ModuleConstants | undefined;\n /** Whether a module with JSX was left out to avoid a cycle. */\n readonly partial: boolean;\n }\n\n /**\n * The module an import resolves to, when its constants can be read, and\n * whether it has JSX. Dependencies are skipped to keep the build fast.\n */\n async function resolveConstantModule(\n context: Rollup.PluginContext,\n specifier: string,\n importer: string,\n ): Promise<{ id: string; jsx: boolean } | undefined> {\n if (moduleSources.includes(specifier)) {\n return undefined;\n }\n const resolved = await context.resolve(specifier, importer);\n if (!resolved || resolved.external || resolved.id.includes('/node_modules/')) {\n return undefined;\n }\n return { id: resolved.id, jsx: isJSXModule(resolved.id) };\n }\n\n /**\n * The code of a module with JSX to read constants from, as this plugin's\n * transform returns it. `transform` is the module whose transform waits for\n * it, which the cycle checks are about. `undefined` when that could wait\n * for itself.\n */\n async function loadJSXModule(\n context: Rollup.PluginContext,\n transform: string,\n target: string,\n ): Promise<string | undefined> {\n return chunkMode() && isClient(context)\n ? loadModule(context, transform, target)\n : loadRecorded(context, transform, target);\n }\n\n /**\n * The constants of the modules `code` imports, keyed by import specifier.\n *\n * Each module is read as the bundler loads it, after every plugin has\n * transformed it. A module with JSX is read from this plugin's own output\n * for it, unless its transform could be waiting for `transform`.\n */\n async function importedConstants(\n context: Rollup.PluginContext,\n imports: readonly string[],\n importer: string,\n visiting: ReadonlySet<string>,\n transform: string,\n ): Promise<{ constants: ImportedConstants; partial: boolean }> {\n let partial = false;\n async function readImport(\n specifier: string,\n ): Promise<readonly [string, Readonly<Record<string, Primitive>>] | undefined> {\n const target = await resolveConstantModule(context, specifier, importer);\n if (target === undefined || visiting.has(target.id)) {\n return undefined;\n }\n const result = await readConstants(context, target, visiting, transform);\n partial ||= result.partial;\n if (!result.constants || Object.keys(result.constants.exports).length === 0) {\n return undefined;\n }\n return [specifier, result.constants.exports] as const;\n }\n const reading = [];\n for (const specifier of imports) {\n reading.push(readImport(specifier));\n }\n const entries = await Promise.all(reading);\n const constants: Record<string, Readonly<Record<string, Primitive>>> = {};\n for (const entry of entries) {\n if (entry !== undefined) {\n constants[entry[0]] = entry[1];\n }\n }\n return { constants, partial };\n }\n\n async function readConstants(\n context: Rollup.PluginContext,\n target: { id: string; jsx: boolean },\n visiting: ReadonlySet<string>,\n transform: string,\n ): Promise<ConstantsResult> {\n const { id } = target;\n const known = moduleConstants.get(id);\n if (known) {\n return known;\n }\n const result = await (async (): Promise<ConstantsResult> => {\n let code: string | null | undefined;\n if (target.jsx) {\n code = await loadJSXModule(context, transform, id);\n if (code === undefined) {\n return { constants: undefined, partial: true };\n }\n } else {\n ({ code } = await context.load({ id }));\n }\n if (code === null) {\n return { constants: undefined, partial: false };\n }\n // Loaded code is JavaScript, whatever the module was written in, and keeps its JSX.\n const filename = `${stripQuery(id)}.${target.jsx ? 'jsx' : 'js'}`;\n try {\n const own = readModuleConstants(code, { filename, globalConstants: globals });\n if (own.imports.length === 0) {\n return { constants: own, partial: false };\n }\n const imported = await importedConstants(\n context,\n own.imports,\n id,\n new Set([...visiting, id]),\n transform,\n );\n return {\n constants: readModuleConstants(code, {\n filename,\n importedConstants: imported.constants,\n globalConstants: globals,\n }),\n partial: imported.partial,\n };\n } catch (error) {\n // A module the parser rejects fails its own transform, with a better error.\n if (error instanceof SyntaxError) {\n return { constants: undefined, partial: false };\n }\n throw error;\n }\n })();\n if (!result.partial) {\n moduleConstants.set(id, result);\n }\n return result;\n }\n\n /**\n * The compile options for a module, with the constants of its imports.\n */\n async function moduleOptions(\n context: Rollup.PluginContext,\n code: string,\n id: string,\n ): Promise<CompileOptions> {\n const filename = stripQuery(id);\n // The dev server cannot give back the code of a loaded module.\n if (optimizer.fold === false || !isBuild()) {\n return { ...compileOptions, filename, sourceMap: wantsMaps() };\n }\n const { imports } = readModuleConstants(code, { filename });\n const imported = await importedConstants(context, imports, filename, new Set([filename]), id);\n return {\n ...compileOptions,\n filename,\n sourceMap: wantsMaps(),\n importedConstants: imported.constants,\n globalConstants: globals,\n };\n }\n\n async function resolveLazyModuleUrls(\n context: Rollup.TransformPluginContext,\n code: string,\n importer: string,\n ): Promise<string> {\n const root = config?.root ?? process.cwd();\n let result = code;\n for (const match of code.matchAll(LAZY_PLACEHOLDER)) {\n const specifier = match.at(1);\n if (specifier === undefined) {\n continue;\n }\n // oxlint-disable-next-line no-await-in-loop\n const resolved = await context.resolve(specifier, importer);\n if (resolved) {\n const queryIndex = resolved.id.indexOf('?');\n const file = queryIndex === -1 ? resolved.id : resolved.id.slice(0, queryIndex);\n const query = queryIndex === -1 ? '' : resolved.id.slice(queryIndex);\n const relative = path.relative(root, file).split(path.sep).join('/') + query;\n result = result.replace(match[0], JSON.stringify(relative));\n }\n }\n return result;\n }\n\n /** The modules each transform waits for, so two never wait for each other. */\n const waiting = new Map<string, Set<string>>();\n\n /** Whether the transform of `from` waits, directly or not, for `to`. */\n const waitsFor = (from: string, to: string): boolean => {\n const seen = new Set<string>();\n const stack = [from];\n for (let current = stack.pop(); current !== undefined; current = stack.pop()) {\n if (current === to) {\n return true;\n }\n if (!seen.has(current)) {\n seen.add(current);\n stack.push(...(waiting.get(current) ?? []));\n }\n }\n return false;\n };\n\n /**\n * The code of a module with JSX, as the bundler loads it. `undefined`\n * when that module's transform waits for the importer, which would then\n * wait for it in turn.\n */\n async function loadModule(\n context: Rollup.PluginContext,\n importer: string,\n target: string,\n ): Promise<string | undefined> {\n if (waitsFor(target, importer)) {\n return undefined;\n }\n const targets = waiting.get(importer) ?? new Set<string>();\n targets.add(target);\n waiting.set(importer, targets);\n try {\n const info = await context.load({ id: target });\n return info.code ?? undefined;\n } finally {\n targets.delete(target);\n }\n }\n\n /**\n * The code of each module with JSX as this plugin's module step returned\n * it, before Solid's JSX transform lowers it. In module mode, an importer\n * copies components from it.\n */\n const recorded = new Map<string, string>();\n\n /**\n * Whether components can be copied from a module: one of the app's, or\n * one of a package listed in `optimizer.packages`.\n */\n const isCopyable = (id: string): boolean => {\n const file = stripQuery(id).replaceAll('\\\\', '/');\n if (!file.includes('/node_modules/')) {\n return true;\n }\n for (const name of optimizer.packages ?? []) {\n if (file.includes(`/node_modules/${name}/`)) {\n return true;\n }\n }\n return false;\n };\n\n /** The modules each module imports, read from its file. */\n const localImports = new Map<string, Promise<string[]>>();\n\n /**\n * The code of a module as its file holds it. A module with no file, like\n * a virtual module a plugin generates, is loaded instead, unless it has\n * JSX: this plugin transforms such a module, so loading it could wait for\n * the transform that asks. Its imports are then not followed.\n */\n async function readModuleCode(\n context: Rollup.PluginContext,\n id: string,\n ): Promise<string | undefined> {\n try {\n return await readFile(stripQuery(id), 'utf8');\n } catch {\n if (isJSXModule(id)) {\n return undefined;\n }\n }\n try {\n return (await context.load({ id })).code ?? undefined;\n } catch {\n return undefined;\n }\n }\n\n /**\n * The modules a module imports at runtime that a transform can wait for:\n * the app's, those of packages listed in `optimizer.packages`, and virtual\n * modules. A transform only waits for a module it copies from, and it only\n * copies from those, so a module of another package is never in a loop of\n * transforms that wait for each other. A virtual module can re-export the\n * app, so a listed package can import the app back through one, like a\n * docs framework that imports its theme's layout.\n *\n * Imports only used as types are left out, since TypeScript drops them,\n * and so are Solid's own modules and Node's built-ins. The imports come\n * from the file on disk, so they do not depend on the order modules are\n * transformed in. Modules without JSX count too, since reading their\n * constants can load a module with JSX.\n */\n async function findLocalImports(context: Rollup.PluginContext, id: string): Promise<string[]> {\n let pending = localImports.get(id);\n if (!pending) {\n pending = (async () => {\n const code = await readModuleCode(context, id);\n if (code === undefined) {\n return [];\n }\n let program: Program;\n try {\n // A loaded module is JavaScript, whatever its id says.\n program = parse(\n /\\.[cm]?[jt]sx?$/.test(stripQuery(id)) ? stripQuery(id) : `${id}.js`,\n code,\n );\n } catch {\n return [];\n }\n const resolving = [];\n for (const source of runtimeImportSources(program)) {\n if (!moduleSources.includes(source) && !source.startsWith('node:')) {\n resolving.push(context.resolve(source, id));\n }\n }\n const resolved = await Promise.all(resolving);\n const local: string[] = [];\n for (const target of resolved) {\n if (target && !target.external && isCopyable(target.id)) {\n local.push(target.id);\n }\n }\n return local;\n })();\n localImports.set(id, pending);\n }\n return pending;\n }\n\n /** Whether `from` imports `to`, directly or through other modules. */\n async function reaches(\n context: Rollup.PluginContext,\n from: string,\n to: string,\n ): Promise<boolean> {\n const seen = new Set<string>();\n let frontier = [from];\n while (frontier.length > 0) {\n if (frontier.includes(to)) {\n return true;\n }\n for (const id of frontier) {\n seen.add(id);\n }\n const reading = [];\n for (const id of frontier) {\n reading.push(findLocalImports(context, id));\n }\n // oxlint-disable-next-line no-await-in-loop\n const next = await Promise.all(reading);\n frontier = [];\n for (const id of new Set(next.flat())) {\n if (!seen.has(id)) {\n frontier.push(id);\n }\n }\n }\n return false;\n }\n\n /**\n * The code of a module with JSX before Solid's JSX transform, with its\n * types stripped. A module that imports the importer back is skipped, so\n * no two transforms wait for each other, and the server and client builds\n * skip the same ones.\n */\n async function loadRecorded(\n context: Rollup.PluginContext,\n importer: string,\n target: string,\n ): Promise<string | undefined> {\n if (await reaches(context, target, importer)) {\n return undefined;\n }\n await context.load({ id: target });\n const code = recorded.get(environmentKey(context, target));\n if (code === undefined) {\n return undefined;\n }\n const stripped = await transformWithOxc(code, stripQuery(target), {\n jsx: 'preserve',\n sourcemap: false,\n });\n return stripped.code;\n }\n\n /**\n * The scripts a virtual entry runs, like the server entry `start` mode\n * generates: the app's modules it imports. It has no file to read, and\n * the server and client builds have to see the same uses of each export.\n * `undefined` when the entry has not been loaded or imports none.\n */\n function virtualEntryScripts(context: Rollup.PluginContext, id: string): string[] | undefined {\n const info = context.getModuleInfo(id);\n if (!info || info.code === null) {\n return undefined;\n }\n const scripts: string[] = [];\n for (const imported of [...info.importedIds, ...info.dynamicallyImportedIds]) {\n // Packages and other virtual modules hold none of the app's components.\n if (!imported.startsWith('\\0') && !imported.includes('/node_modules/')) {\n scripts.push(imported);\n }\n }\n return scripts.length > 0 ? scripts : undefined;\n }\n\n /**\n * The scripts an entry runs: the entry itself, or the module scripts of an\n * HTML entry. `undefined` when an HTML entry has an inline module script,\n * whose imports the usage index cannot read.\n */\n async function scriptEntries(\n context: Rollup.PluginContext,\n id: string,\n ): Promise<string[] | undefined> {\n if (/\\.[mc]?[jt]sx?(?:\\?|$)/.test(id)) {\n return [id];\n }\n let html: string;\n try {\n html = await readFile(stripQuery(id), 'utf8');\n } catch {\n return virtualEntryScripts(context, id);\n }\n const scripts: string[] = [];\n for (const [tag] of html.matchAll(/<script\\b[^>]*>/gi)) {\n if (!/\\btype\\s*=\\s*[\"']?module/i.test(tag)) {\n continue;\n }\n const src = /\\bsrc\\s*=\\s*[\"']([^\"']+)[\"']/i.exec(tag)?.[1];\n if (src === undefined) {\n return undefined;\n }\n // oxlint-disable-next-line no-await-in-loop\n const resolved = await context.resolve(src, id);\n if (!resolved || resolved.external) {\n return undefined;\n }\n scripts.push(resolved.id);\n }\n return scripts;\n }\n\n /** How the app uses each export, built once per environment and build. */\n const usageIndexes = new Map<string, Promise<UsageIndex>>();\n\n /**\n * How the app uses each export, read from the modules the entries reach.\n */\n async function usageIndex(context: Rollup.PluginContext): Promise<UsageIndex> {\n const key = environmentKey(context, '');\n let pending = usageIndexes.get(key);\n if (!pending) {\n pending = (async () => {\n const reading = [];\n for (const id of context.getModuleIds()) {\n if (context.getModuleInfo(id)?.isEntry === true) {\n reading.push(scriptEntries(context, id));\n }\n }\n const entries = await Promise.all(reading);\n // A script the index cannot read could use any export.\n const scriptIds: string[] = [];\n let known = true;\n for (const scripts of entries) {\n if (scripts === undefined) {\n known = false;\n break;\n }\n scriptIds.push(...scripts);\n }\n return buildUsageIndex(known ? scriptIds : [], {\n resolve: async (source, importer) => {\n const resolved = await context.resolve(source, importer);\n return !resolved || resolved.external || resolved.id.includes('/node_modules/')\n ? undefined\n : resolved.id;\n },\n read: async (id) => {\n try {\n return await readFile(stripQuery(id), 'utf8');\n } catch {\n return undefined;\n }\n },\n });\n })();\n usageIndexes.set(key, pending);\n }\n return pending;\n }\n\n /**\n * The text that imports a binding under `local`.\n */\n function importText(local: string, imported: string, source: string): string {\n const from = JSON.stringify(source);\n if (imported === '*') {\n return `import * as ${local} from ${from};`;\n }\n if (imported === 'default') {\n return `import ${local} from ${from};`;\n }\n return `import { ${imported} as ${local} } from ${from};`;\n }\n\n interface Copy {\n /** The module and export the copy comes from. */\n readonly key: string;\n /** Whether it comes from a package in `optimizer.packages`. */\n readonly fromPackage: boolean;\n readonly name: string;\n /** The tags in the importer that call it. */\n readonly tags: Node[];\n readonly text: string;\n }\n\n interface CopyState {\n /** Components that cannot be copied, or were left over before. */\n readonly excluded: Set<string>;\n /** The contexts the copies import, by module. */\n readonly contexts: Map<string, Set<string>>;\n /** Imports a binding into the importer, and gives its local name. */\n readonly importAs: (base: string, imported: string, from: string) => string;\n /** The code of a module with JSX to copy from, or `undefined` to skip it. */\n readonly load: (target: string) => Promise<string | undefined>;\n /** Where the copies that are not made are recorded, when the report is on. */\n readonly skips: Skip[] | undefined;\n }\n\n /** The listed packages already warned about, by environment. */\n const warnedPackages = new Set<string>();\n\n /**\n * Warns once when a listed package is external, like a server build that\n * leaves it to Node. Its components are not copied there, so a build that\n * copies them would hydrate different markup.\n */\n const warnExternalPackage = (context: Rollup.PluginContext, source: string): void => {\n let name: string | undefined;\n for (const item of optimizer.packages ?? []) {\n if (source === item || source.startsWith(`${item}/`)) {\n name = item;\n break;\n }\n }\n const key = environmentKey(context, name ?? '');\n if (name === undefined || warnedPackages.has(key)) {\n return;\n }\n warnedPackages.add(key);\n context.warn(\n `[solid-optimizer] ${name} is external in this build, so its components are not copied. Bundle it, like with \\`ssr.noExternal\\`, so every build copies the same components.`,\n );\n };\n\n /**\n * Reads the component `source` exports as `imported`, and imports what it\n * needs into the importer. `undefined` when it cannot be copied.\n */\n async function copyImported(\n context: Rollup.PluginContext,\n id: string,\n source: string,\n requested: string,\n state: CopyState,\n ): Promise<{ key: string; text: (name: string) => string } | undefined> {\n const skip = (reason: string): void => {\n state.skips?.push({ pass: 'inline', reason, name: `${requested} (${source})` });\n };\n // The export's name in the module that declares it, past any re-exports.\n let imported = requested;\n let resolved = await context.resolve(source, id);\n if (!resolved || resolved.external) {\n warnExternalPackage(context, source);\n skip('copy-external');\n return undefined;\n }\n if (!isCopyable(resolved.id)) {\n skip('copy-package');\n return undefined;\n }\n // A module that re-exports the component by name, like a library's\n // entry, leads to the module that declares it.\n for (let depth = 0; depth < 8 && isJSXModule(resolved.id); depth += 1) {\n // oxlint-disable-next-line no-await-in-loop\n const code = await state.load(resolved.id);\n const reexport =\n code === undefined ? undefined : readReexport(code, stripQuery(resolved.id), imported);\n if (!reexport) {\n break;\n }\n // oxlint-disable-next-line no-await-in-loop\n const next = await context.resolve(reexport.source, resolved.id);\n if (!next || next.external || !isCopyable(next.id)) {\n skip('copy-package');\n return undefined;\n }\n resolved = next;\n imported = reexport.imported;\n }\n if (resolved.id === id) {\n return undefined;\n }\n if (!isJSXModule(resolved.id)) {\n skip('copy-not-jsx');\n return undefined;\n }\n const key = `${resolved.id}\\0${imported}`;\n if (state.excluded.has(key)) {\n return undefined;\n }\n const loaded = await state.load(resolved.id);\n if (loaded === undefined) {\n state.excluded.add(key);\n skip('copy-cycle');\n return undefined;\n }\n const component = readExportedComponent(\n loaded,\n stripQuery(resolved.id),\n imported,\n moduleSources,\n );\n if (!component) {\n state.excluded.add(key);\n skip('copy-shape');\n return undefined;\n }\n // Its copy would still call a component of that module, so the call\n // site gains nothing. Moving its template out of its module makes both\n // compress worse.\n if (component.wrapsLocal) {\n state.excluded.add(key);\n skip('copy-wrapper');\n return undefined;\n }\n // Each import of the module resolves from it, so the copy imports the same module.\n const targets = new Map<string, string>();\n for (const dependency of component.dependencies.values()) {\n if (dependency.kind === 'import' && !moduleSources.includes(dependency.source)) {\n // oxlint-disable-next-line no-await-in-loop\n const target = await context.resolve(dependency.source, resolved.id);\n if (!target) {\n state.excluded.add(key);\n skip('copy-external');\n return undefined;\n }\n if (!target.id.startsWith('\\0')) {\n targets.set(dependency.source, target.external ? dependency.source : target.id);\n continue;\n }\n // A virtual module's id cannot be imported again, so the copy keeps\n // the specifier, when it means the same module from the importer.\n // oxlint-disable-next-line no-await-in-loop\n const fromImporter = await context.resolve(dependency.source, id);\n if (fromImporter?.id !== target.id) {\n state.excluded.add(key);\n skip('copy-virtual');\n return undefined;\n }\n targets.set(dependency.source, dependency.source);\n }\n }\n const rename = new Map<string, string>();\n for (const [local, dependency] of component.dependencies) {\n if (dependency.kind === 'import') {\n const from = targets.get(dependency.source) ?? dependency.source;\n rename.set(local, state.importAs(local, dependency.imported, from));\n continue;\n }\n rename.set(local, state.importAs(local, dependency.exported, resolved.id));\n if (dependency.context) {\n const known = state.contexts.get(resolved.id) ?? new Set<string>();\n known.add(dependency.exported);\n state.contexts.set(resolved.id, known);\n }\n }\n return { key, text: (name) => component.copy(name, rename) };\n }\n\n /**\n * Copies the components a module imports from other modules with JSX into\n * it, and inlines them there. A copy the inline pass cannot inline at\n * every call is left out, so a component is never in both places. Copies\n * can import components in turn, which a few more rounds take in.\n */\n async function inlineImports(\n context: Rollup.PluginContext,\n source: string,\n id: string,\n compileOptionsOfModule: CompileOptions,\n load: (target: string) => Promise<string | undefined>,\n copySkips?: Skip[],\n ): Promise<{ code: string; maps: string[]; skipped?: Skip[] } | undefined> {\n const filename = stripQuery(id);\n const maps: string[] = [];\n let skipped: Skip[] | undefined;\n const excluded = new Set<string>();\n const usage = await usageIndex(context);\n // The components copied here that leave their module, by module.\n const absorbed = new Map<string, Set<string>>();\n // How many modules use the original of a copy, this one included.\n const countUsers = (copy: Copy): number => {\n const [module = '', exported = ''] = copy.key.split('\\0');\n return usage.users(module, exported, id, absorbed);\n };\n // The contexts the copies import, which the provider pass needs to know.\n const contexts = new Map<string, Set<string>>();\n let code = source;\n const copyNames = new Map<string, string>();\n for (let round = 0; round < 4; round += 1) {\n const program = parse(filename, code);\n const scopes = analyzeScopes(program);\n const parents = collectParents(program);\n const names = new Set(scopes.names);\n const fresh = (base: string): string => {\n let name = base;\n for (let index = 1; names.has(name); index += 1) {\n name = `${base}$${String(index)}`;\n }\n names.add(name);\n return name;\n };\n\n // The module's own imports, so a copy reuses one instead of adding another.\n // Two imports of one context would be two bindings to the provider pass.\n const existing = importedNames(program);\n // Imports added in this round, shared by every copy.\n const imports: string[] = [];\n const added = new Map<string, string>();\n const importAs = (base: string, imported: string, from: string): string => {\n const key = `${from}\\0${imported}`;\n const known = existing.get(key) ?? added.get(key);\n if (known !== undefined) {\n return known;\n }\n const name = fresh(base);\n added.set(key, name);\n imports.push(importText(name, imported, from));\n return name;\n };\n\n // Each imported binding used as a JSX tag, and its copy.\n const copies: Copy[] = [];\n for (const statement of program.body) {\n if (\n statement.type !== 'ImportDeclaration' ||\n statement.importKind === 'type' ||\n moduleSources.includes(statement.source.value)\n ) {\n continue;\n }\n for (const specifier of statement.specifiers) {\n const binding = scopes.root.bindings.get(specifier.local.name);\n // Only tags are copied. The import stays for any other use.\n const tags = findTags(binding?.references ?? [], parents);\n if (\n specifier.type === 'ImportNamespaceSpecifier' ||\n binding?.imported === undefined ||\n tags.length === 0\n ) {\n continue;\n }\n // oxlint-disable-next-line no-await-in-loop\n const copy = await copyImported(context, id, statement.source.value, binding.imported, {\n excluded,\n contexts,\n importAs,\n load,\n skips: copySkips,\n });\n if (copy && copySkips) {\n // A copy the inline pass leaves behind is recorded under the reason it gave.\n copyNames.set(copy.key, `${binding.imported} (${statement.source.value})`);\n }\n if (copy) {\n const name = fresh(specifier.local.name);\n const fromPackage = isPackageModule(copy.key);\n copies.push({ key: copy.key, fromPackage, name, tags, text: copy.text(name) });\n }\n }\n }\n if (copies.length === 0) {\n break;\n }\n\n // Drop the copies the inline pass leaves behind, and try again without them.\n let result: CompileResult | undefined;\n let edit: MagicString | undefined;\n for (let attempt = 0; attempt < 4 && copies.length > 0; attempt += 1) {\n edit = new MagicString(code);\n for (const copy of copies) {\n for (const tag of copy.tags) {\n edit.overwrite(tag.start, tag.end, copy.name);\n }\n edit.append(`\\n${copy.text}\\n`);\n }\n edit.append(`\\n${imports.join('\\n')}\\n`);\n const importedContexts: Record<string, string[]> = {};\n for (const [module, exported] of contexts) {\n importedContexts[module] = [...exported];\n }\n const sharedComponents: Record<string, number> = {};\n const alwaysInlineComponents: string[] = [];\n for (const copy of copies) {\n const users = countUsers(copy);\n if (users !== 1) {\n sharedComponents[copy.name] = users;\n }\n if (copy.fromPackage) {\n alwaysInlineComponents.push(copy.name);\n }\n }\n result = compile(edit.toString(), {\n ...compileOptionsOfModule,\n filename,\n sourceMap: wantsMaps(),\n importedContexts,\n // The original of a copy stays in its module for its other users.\n sharedComponents,\n // The estimate cannot see what a package's own modules use, so a\n // copy of its component never counts its declaration, or the\n // runtime code only it used, as removed. Listing the package asks\n // for its components to inline wherever they can be.\n alwaysInlineComponents,\n });\n const left = analyzeScopes(parse(filename, result.code)).root.bindings;\n const stuck = [];\n for (const copy of copies) {\n if (left.has(copy.name)) {\n stuck.push(copy);\n }\n }\n if (stuck.length === 0) {\n break;\n }\n for (const copy of stuck) {\n excluded.add(copy.key);\n copies.splice(copies.indexOf(copy), 1);\n const reason = findSkipReason(result.skipped ?? [], copy.name);\n copySkips?.push({\n pass: 'inline',\n reason: `copy-${reason ?? 'left'}`,\n name: copyNames.get(copy.key) ?? copy.name,\n });\n }\n result = undefined;\n }\n if (!result || !edit) {\n break;\n }\n // Their uses of other components move here with them. Count every copy's\n // users first, since moving one changes what the next one counts.\n const sole: Copy[] = [];\n for (const copy of copies) {\n if (countUsers(copy) === 1) {\n sole.push(copy);\n }\n }\n for (const copy of sole) {\n const [module = '', exported = ''] = copy.key.split('\\0');\n absorbed.set(module, new Set([...(absorbed.get(module) ?? []), exported]));\n }\n if (wantsMaps()) {\n maps.push(\n edit.generateMap({ source: filename, hires: true, includeContent: true }).toString(),\n );\n }\n if (result.map) {\n maps.push(result.map.toString());\n }\n code = result.code;\n ({ skipped } = result);\n }\n return code === source ? undefined : { code, maps, skipped };\n }\n\n /**\n * Prepares a client module for chunk mode. It runs the passes the official\n * plugin runs before lowering JSX, and adds the helper marker instead of\n * lowering.\n */\n async function keepJSX(\n context: Rollup.TransformPluginContext,\n source: string,\n id: string,\n ): Promise<Rollup.TransformResult> {\n const filename = stripQuery(id);\n const solidCompiler = getCompiler();\n const maps: (string | null | undefined)[] = [];\n let code = source;\n\n // Fold and inline memos before bundling. A branch that folds away takes\n // its imports and `lazy()` chunks out of the module graph, which the\n // chunk step can no longer do. Inlining waits for the chunk, where the\n // components it can reach are known.\n const moduleCompileOptions = await moduleOptions(context, code, id);\n const local = compile(code, { ...moduleCompileOptions, inline: false });\n // `map` is `null` when nothing changed, and when the build writes no maps.\n code = local.code;\n if (local.map) {\n maps.push(local.map.toString());\n }\n // `<Ns.Member>` would keep a namespace object, which lowered code does not.\n const named = nameNamespaceTags(code, filename);\n if (named) {\n code = named.code;\n maps.push(named.map);\n }\n\n // Components imported from other modules inline here, so the bundler\n // drops them, and what only they used, before it splits the chunks.\n if (moduleCompileOptions.inline !== false) {\n const copySkips: Skip[] | undefined = compileOptions.report ? [] : undefined;\n const imported = await inlineImports(\n context,\n code,\n id,\n moduleCompileOptions,\n async (target) => loadModule(context, id, target),\n copySkips,\n );\n // The rest of the report comes from the chunk this module ends up in.\n addSkips(context, copySkips, id);\n if (imported) {\n code = imported.code;\n maps.push(...imported.maps);\n }\n }\n // An entry's exports are its public API, so it gets no extra names.\n const exposed = context.getModuleInfo(id)?.isEntry ? undefined : exposeLocals(code, filename);\n if (exposed) {\n code = exposed.code;\n maps.push(exposed.map);\n }\n\n const lazy = await solidCompiler.transformLazyAsync(code, { filename, sourceMap: wantsMaps() });\n code = lazy.code;\n maps.push(lazy.map);\n\n // The helpers the module's JSX needs, as written and with its own\n // components inlined. Inlining can turn a spread into attributes, which\n // need helpers the spread did not.\n const lowering = jsxOptions(false);\n const needed = new Set<string>();\n const inlined =\n moduleCompileOptions.inline === false\n ? undefined\n : compile(code, { ...moduleCompileOptions, sourceMap: false });\n for (const version of new Set([code, inlined?.code ?? code])) {\n // oxlint-disable-next-line no-await-in-loop\n const dryRun = await solidCompiler.transformAsync(version, { ...lowering, filename });\n for (const helper of generatedImports(dryRun.code, filename, moduleName)) {\n needed.add(helper);\n }\n }\n // A component inlined into another module of the chunk can turn its\n // spread into any attribute.\n if (moduleCompileOptions.inline !== false && spreadsOntoElement(code, filename)) {\n for (const helper of attributeHelpers()) {\n needed.add(helper);\n }\n }\n\n if (needed.size > 0) {\n const marked = addMarker(code, filename, {\n moduleName,\n helpers: withRelated([...needed]),\n moduleSources,\n // The passes also recognize these primitives, which a chunk renames\n // too. `render` takes a callback that statements can move into, and\n // `children` can be inlined like a memo.\n builtIns: new Set([\n ...builtIns,\n 'createContext',\n 'render',\n 'children',\n ...CONTEXT_SAFE_PRIMITIVES,\n ]),\n });\n if (marked) {\n code = marked.code;\n maps.push(marked.map);\n }\n }\n\n // The bundler has to see that a `ref` writes its variable. See `refs.ts`.\n const protectedRefs = protectRefs(code, filename);\n if (protectedRefs) {\n code = protectedRefs.code;\n maps.push(protectedRefs.map);\n }\n\n code = await resolveLazyModuleUrls(context, code, filename);\n preserved.add(id);\n return { code, map: combineMaps(wantsMaps(), maps) };\n }\n\n let main: Plugin | undefined;\n for (const plugin of plugins) {\n if (plugin.name === 'solid') {\n main = plugin;\n break;\n }\n }\n const originalTransform = main?.transform;\n const originalHandler =\n typeof originalTransform === 'function' ? originalTransform : originalTransform?.handler;\n if (main && originalHandler) {\n main.transform = async function transform(code, id, transformOptions) {\n if (chunkMode() && isClient(this) && isJSXModule(id)) {\n return keepJSX(this, code, id);\n }\n return originalHandler.call(this, code, id, transformOptions);\n };\n }\n\n const modulePlugin: Plugin = {\n name: 'solid-optimizer:module',\n enforce: 'pre',\n configResolved(resolved) {\n config = resolved;\n globals = sharedGlobals(resolved);\n },\n buildStart() {\n moduleConstants.clear();\n localImports.clear();\n usageIndexes.clear();\n skips.delete(this.environment.name);\n },\n watchChange() {\n moduleConstants.clear();\n localImports.clear();\n usageIndexes.clear();\n },\n async transform(source, id) {\n if (!isBuild() && optimizer.dev !== true) {\n return null;\n }\n if ((chunkMode() && isClient(this)) || !isJSXModule(id)) {\n return null;\n }\n const filename = stripQuery(id);\n const sourceOptions = await moduleOptions(this, source, id);\n const result = compile(source, sourceOptions);\n let code = result.code;\n const maps: (string | null | undefined)[] = [result.map?.toString()];\n // Components imported from other modules inline here too. The server\n // and client builds read the same modules, so they inline the same ones.\n let { skipped } = result;\n if (isBuild() && sourceOptions.inline !== false) {\n const copySkips: Skip[] | undefined = compileOptions.report ? [] : undefined;\n const imported = await inlineImports(\n this,\n code,\n id,\n sourceOptions,\n async (target) => loadRecorded(this, id, target),\n copySkips,\n );\n addSkips(this, copySkips, id);\n if (imported) {\n code = imported.code;\n maps.push(...imported.maps);\n skipped = imported.skipped ?? skipped;\n }\n // Entries get the extra exports too. The server and client builds\n // have different entries, and both have to copy the same components.\n const exposed = exposeLocals(code, filename);\n if (exposed) {\n code = exposed.code;\n maps.push(exposed.map);\n }\n }\n addSkips(this, skipped, id);\n recorded.set(environmentKey(this, id), code);\n if (code === source) {\n return null;\n }\n return { code, map: combineMaps(wantsMaps(), maps) };\n },\n };\n\n const chunkPlugin: Plugin = {\n name: 'solid-optimizer:chunk',\n enforce: 'post',\n config(_, env) {\n if (env.command !== 'build') {\n return undefined;\n }\n // Kept JSX has to reach the bundler as JSX. Modules the official plugin\n // lowers have no JSX left, so this changes nothing for them.\n return {\n oxc: { jsx: 'preserve' },\n build: { rolldownOptions: { transform: { jsx: 'preserve' } } },\n };\n },\n renderChunk: {\n order: 'pre',\n handler(code, chunk) {\n if (!chunkMode() || !isClient(this) || !code.includes(MARKER)) {\n return null;\n }\n const filename = chunk.fileName;\n let repaired: { code: string; map: string } | undefined;\n let runtime: ReturnType<typeof readMarkers>;\n try {\n runtime = readMarkers(code, filename);\n } catch (error) {\n repaired = error instanceof SyntaxError ? repairJSXSequences(code, filename) : undefined;\n if (!repaired) {\n throw error;\n }\n runtime = readMarkers(repaired.code, filename);\n }\n if (!runtime) {\n return null;\n }\n const restored = restoreRefs(runtime.code, filename);\n const chunkCode = restored?.code ?? runtime.code;\n const lowerChunk = (source: string): SolidCompiler.TransformResult =>\n getCompiler().transform(source, {\n ...jsxOptions(false),\n // The compiler picks its parser by extension, and a chunk is a `.js` file with JSX.\n filename: `${filename}.jsx`,\n sourceMap: wantsMaps(),\n });\n const chunkOptions: CompileOptions = {\n ...compileOptions,\n filename,\n sourceMap: wantsMaps(),\n constantVars: true,\n builtInAliases: runtime.builtInAliases,\n };\n // Each module keeps the helpers its own JSX needs, and a merged tree\n // can need one none of them did. Such a candidate is left out.\n let missing: MissingHelperError | undefined;\n const lowerCandidate = (optimized: CompileResult): ChunkCandidate | undefined => {\n const lowered = lowerChunk(optimized.code);\n try {\n const linked = linkHelpers(lowered.code, filename, moduleName, runtime.helpers);\n return { optimized, lowered, linked };\n } catch (error) {\n if (!(error instanceof MissingHelperError)) {\n throw error;\n }\n missing ??= error;\n return undefined;\n }\n };\n let chosen = lowerCandidate(compile(chunkCode, chunkOptions));\n // The estimate weighs each component on its own. It cannot see the\n // runtime code that only leaves the chunk once every call that needs\n // it is inlined, like `<Dynamic>`, `merge()`, and `omit()` behind a\n // headless library's components. So the chunk is also built with\n // every component inlined that can be, and the smaller one is kept,\n // as minified and gzipped.\n if (compileOptions.alwaysInline !== true) {\n const always = compile(chunkCode, { ...chunkOptions, alwaysInline: true });\n const other = always.code === chosen?.optimized.code ? undefined : lowerCandidate(always);\n if (other && (!chosen || shippedSize(other, filename) < shippedSize(chosen, filename))) {\n chosen = other;\n }\n }\n let optimized: CompileResult | undefined;\n let linked: { code: string; map: string };\n let lowered: SolidCompiler.TransformResult;\n if (chosen) {\n ({ optimized, lowered, linked } = chosen);\n addSkips(this, optimized.skipped);\n } else {\n // Without the helper, the chunk is lowered as its modules were\n // written. Chunk mode never hydrates, so the chunks do not have to\n // match anything else.\n this.warn(`${missing?.message ?? ''} ${filename} is not optimized.`);\n addSkips(this, [{ pass: 'inline', reason: 'missing-helper', name: filename }]);\n lowered = lowerChunk(chunkCode);\n linked = linkHelpers(lowered.code, filename, moduleName, runtime.helpers);\n }\n return {\n code: linked.code,\n map: combineMaps(wantsMaps(), [\n repaired?.map,\n runtime.map,\n restored?.map,\n optimized?.map?.toString(),\n lowered.map,\n linked.map,\n ]),\n };\n },\n },\n };\n\n // Prints the report once every chunk is rendered.\n chunkPlugin.generateBundle = function generateBundle() {\n const { report } = optimizer;\n if (report === undefined || report === false) {\n return;\n }\n const environment = this.environment.name;\n const result: OptimizerReport = { environment, skips: skips.get(environment) ?? [] };\n if (typeof report === 'function') {\n report(result);\n } else {\n this.environment.logger.info(formatReport(result));\n }\n };\n\n // Runs after `vite:oxc` strips types, which reports the module as plain\n // JavaScript, and before the built-in plugins that parse it again.\n const moduleTypePlugin: Plugin = {\n name: 'solid-optimizer:module-type',\n transform(code, id) {\n if (!preserved.has(id)) {\n return null;\n }\n // `vite:oxc` prints JSX like Rolldown does, without the parentheses a\n // comma expression needs in a JSX expression container.\n const repaired = repairJSXSequences(code, stripQuery(id));\n return repaired\n ? { code: repaired.code, map: repaired.map, moduleType: 'jsx' }\n : { code, moduleType: 'jsx' };\n },\n };\n\n return [modulePlugin, ...plugins, moduleTypePlugin, chunkPlugin];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAaA,SAAgB,cACd,QAC2B;CAC3B,MAAM,UAAqC,CAAC;CAC5C,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,GAAG,GAClD,IACE,QAAQ,UACP,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,OAAO,UAAU,YAE5E,QAAQ,mBAAmB,SAAS;CAGxC,MA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Y,QAAQ,OAAO;IAC1E;IACA,OAAO;KACL,MAAM,OAAO;KACb,KAAK,YAAY,UAAU,GAAG;MAC5B,UAAU;MACV,QAAQ;MACR,UAAU;MACV,WAAW,KAAK,SAAS;MACzB,QAAQ;MACR,OAAO;KACT,CAAC;IACH;GACF;EACF;CACF;CAGA,YAAY,iBAAiB,SAAS,iBAAiB;EACrD,MAAM,EAAE,WAAW;EACnB,IAAI,WAAW,KAAA,KAAa,WAAW,OACrC;EAEF,MAAM,cAAc,KAAK,YAAY;EACrC,MAAM,SAA0B;GAAE;GAAa,OAAO,MAAM,IAAI,WAAW,KAAK,CAAC;EAAE;EACnF,IAAI,OAAO,WAAW,YACpB,OAAO,MAAM;OAEb,KAAK,YAAY,OAAO,KAAK,aAAa,MAAM,CAAC;CAErD;CAIA,MAAM,mBAA2B;EAC/B,MAAM;EACN,UAAU,MAAM,IAAI;GAClB,IAAI,CAAC,UAAU,IAAI,EAAE,GACnB,OAAO;GAIT,MAAM,WAAW,mBAAmB,MAAM,WAAW,EAAE,CAAC;GACxD,OAAO,WACH;IAAE,MAAM,SAAS;IAAM,KAAK,SAAS;IAAK,YAAY;GAAM,IAC5D;IAAE;IAAM,YAAY;GAAM;EAChC;CACF;CAEA,OAAO;EAAC;EAAc,GAAG;EAAS;EAAkB;CAAW;AACjE"}
1
+ {"version":3,"file":"vite.mjs","names":["generateMap","generateMap"],"sources":["../src/vite/globals.ts","../src/vite/report.ts","../src/vite/runtime.ts","../src/vite/inject.ts","../src/vite/namespace.ts","../src/vite/refs.ts","../src/vite/usage.ts","../src/vite/index.ts"],"sourcesContent":["/**\n * The global constants every build environment shares, from Vite's `define`\n * and `import.meta.env`.\n */\nimport type { ResolvedConfig } from 'vite';\nimport type { Primitive } from '../value';\n\n/**\n * The `define` entries and `import.meta.env` values that are the same in\n * every build environment, as global constants. A value that differs, like\n * `import.meta.env.SSR`, could make the server and client builds fold, and\n * then inline, differently, so their hydration keys would not match.\n */\nexport function sharedGlobals(\n config: Pick<ResolvedConfig, 'env' | 'define' | 'environments'>,\n): Record<string, Primitive> {\n const globals: Record<string, Primitive> = {};\n for (const [key, value] of Object.entries(config.env)) {\n if (\n key !== 'SSR' &&\n (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean')\n ) {\n globals[`import.meta.env.${key}`] = value;\n }\n }\n const environments = Object.values(config.environments);\n const defines: Record<string, unknown>[] = [];\n if (environments.length > 0) {\n for (const environment of environments) {\n defines.push(environment.define ?? config.define ?? {});\n }\n } else {\n defines.push(config.define ?? {});\n }\n const keys = new Set<string>();\n for (const define of defines) {\n for (const key of Object.keys(define)) {\n keys.add(key);\n }\n }\n for (const key of keys) {\n // Every environment must define the key as the same value.\n let first: { value: Primitive } | undefined;\n let same = true;\n for (const define of defines) {\n const value = defineValue(define[key]);\n first ??= value;\n if (value === undefined || !Object.is(value.value, first?.value)) {\n same = false;\n break;\n }\n }\n if (first !== undefined && same) {\n globals[key] = first.value;\n }\n }\n return globals;\n}\n\n/**\n * The primitive a `define` entry replaces its key with. A string is code,\n * so only one that is a JSON literal counts.\n */\nfunction defineValue(value: unknown): { value: Primitive } | undefined {\n let parsed: unknown = value;\n if (typeof value === 'string') {\n try {\n parsed = JSON.parse(value);\n } catch {\n return undefined;\n }\n }\n if (\n parsed === null ||\n typeof parsed === 'string' ||\n typeof parsed === 'number' ||\n typeof parsed === 'boolean'\n ) {\n return { value: parsed };\n }\n return undefined;\n}\n","/**\n * The report of what the optimizer leaves alone in a build, and why.\n *\n * Each pass records a short reason code for every component call, provider,\n * and memo it does not optimize. The plugin collects them from the final\n * compile of each chunk or module, and prints them grouped by reason.\n */\nimport type { Skip, SkipPass } from '../context';\n\n/** What the optimizer left alone in one build environment. */\nexport interface OptimizerReport {\n /** The Vite environment, like `client` or `ssr`. */\n readonly environment: string;\n readonly skips: readonly Skip[];\n}\n\nexport interface ReasonSummary {\n readonly pass: SkipPass;\n readonly reason: string;\n readonly count: number;\n /** How many times each name was skipped for this reason, most first. */\n readonly names: readonly (readonly [string, number])[];\n}\n\n/**\n * Groups skips by pass and reason, most frequent first.\n */\nexport function summarizeSkips(skips: readonly Skip[]): ReasonSummary[] {\n const groups = new Map<string, { pass: SkipPass; reason: string; names: Map<string, number> }>();\n for (const skip of skips) {\n const key = `${skip.pass}\\0${skip.reason}`;\n const group = groups.get(key) ?? { pass: skip.pass, reason: skip.reason, names: new Map() };\n group.names.set(skip.name, (group.names.get(skip.name) ?? 0) + 1);\n groups.set(key, group);\n }\n const summaries: ReasonSummary[] = [];\n for (const { pass, reason, names } of groups.values()) {\n let count = 0;\n for (const times of names.values()) {\n count += times;\n }\n summaries.push({\n pass,\n reason,\n count,\n names: [...names].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])),\n });\n }\n return summaries.sort(\n (a, b) => b.count - a.count || a.pass.localeCompare(b.pass) || a.reason.localeCompare(b.reason),\n );\n}\n\n/** The most names listed for a reason. */\nconst NAMES_SHOWN = 6;\n\n/**\n * The report as text, one line per reason.\n */\nexport function formatReport(report: OptimizerReport): string {\n const lines = [`solid-optimizer: what stays as written in ${report.environment}`];\n const summaries = summarizeSkips(report.skips);\n if (summaries.length === 0) {\n lines.push(' nothing');\n }\n let reasonWidth = 0;\n for (const summary of summaries) {\n reasonWidth = Math.max(reasonWidth, summary.reason.length);\n }\n for (const summary of summaries) {\n const shown: string[] = [];\n for (const [name, count] of summary.names.slice(0, NAMES_SHOWN)) {\n shown.push(count > 1 ? `${name}×${String(count)}` : name);\n }\n if (summary.names.length > NAMES_SHOWN) {\n shown.push(`${String(summary.names.length - NAMES_SHOWN)} more`);\n }\n lines.push(\n ` ${summary.pass.padEnd(8)} ${summary.reason.padEnd(reasonWidth)} ${String(summary.count).padStart(4)} ${shown.join(', ')}`,\n );\n }\n return lines.join('\\n');\n}\n","/**\n * Keeps Solid's runtime helpers reachable while JSX waits in a bundled chunk.\n *\n * Solid's JSX transform imports helpers like `template` and `insert` from\n * `@solidjs/web`. When the transform runs on a chunk, the bundle is already\n * built, so a new bare import cannot be resolved or bundled anymore. Instead,\n * every module imports the helpers it will need before bundling, and passes\n * them to a marker call. The bundler keeps the call, since it could have side\n * effects, and renames the helpers to whatever they are called in the chunk.\n * The chunk step reads the marker, removes it, and points the lowered code at\n * those names.\n *\n * The marker also records which bindings are Solid's built-in components, so\n * the fold pass still recognizes `Show` after the bundler renamed it.\n */\nimport MagicString from 'magic-string';\nimport { parseSync } from 'oxc-parser';\nimport type {\n ExpressionStatement,\n ImportDeclarationSpecifier,\n ImportSpecifier,\n Node,\n Program,\n} from 'oxc-parser';\nimport { collectParents, forEachChild, parse, unwrap } from '../ast';\nimport type { ScopeAnalysis } from '../scope';\nimport { analyzeScopes, lookup, scopeAt } from '../scope';\n\nexport const MARKER = '__SOLID_OPTIMIZER_KEEP__';\n\n/**\n * The lowered chunk needs a helper that no module in the chunk kept.\n */\nexport class MissingHelperError extends Error {\n override readonly name = 'MissingHelperError';\n}\n\nconst HELPER_PREFIX = 'helper:';\nconst BUILT_IN_PREFIX = 'builtin:';\n\nexport interface EditResult {\n code: string;\n map: string;\n}\n\nfunction generateMap(s: MagicString, filename: string): string {\n return s.generateMap({ source: filename, hires: true, includeContent: true }).toString();\n}\n\nfunction freshName(scopes: ScopeAnalysis, base: string): string {\n let name = base;\n let index = 1;\n while (scopes.names.has(name)) {\n name = `${base}$${String(index)}`;\n index += 1;\n }\n scopes.names.add(name);\n return name;\n}\n\nfunction isAllGenerated(specifiers: readonly ImportDeclarationSpecifier[]): boolean {\n for (const specifier of specifiers) {\n if (!isGeneratedSpecifier(specifier)) {\n return false;\n }\n }\n return true;\n}\n\nfunction hasStatement(functions: readonly { statement: Node }[], statement: Node): boolean {\n for (const entry of functions) {\n if (entry.statement === statement) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Whether an import specifier was added by Solid's JSX transform, which\n * names every helper it imports `_$name`.\n */\nfunction isGeneratedSpecifier(specifier: ImportDeclarationSpecifier): boolean {\n return specifier.type === 'ImportSpecifier' && specifier.local.name.startsWith('_$');\n}\n\nfunction exportedName(specifier: ImportSpecifier): string {\n return specifier.imported.type === 'Literal' ? specifier.imported.value : specifier.imported.name;\n}\n\n/**\n * The helpers Solid's JSX transform imported from `source` into its output.\n * The module's own imports, including type imports, are left out.\n */\nexport function generatedImports(code: string, filename: string, source: string): string[] {\n const program = parse(filename, code);\n const names: string[] = [];\n for (const statement of program.body) {\n if (statement.type !== 'ImportDeclaration' || statement.source.value !== source) {\n continue;\n }\n for (const specifier of statement.specifiers) {\n if (specifier.type === 'ImportSpecifier' && isGeneratedSpecifier(specifier)) {\n names.push(exportedName(specifier));\n }\n }\n }\n return names;\n}\n\nexport interface MarkerOptions {\n /** The module the helpers come from, usually `@solidjs/web`. */\n readonly moduleName: string;\n /** The helpers to keep. */\n readonly helpers: ReadonlySet<string>;\n /** The modules Solid's built-in components come from. */\n readonly moduleSources: readonly string[];\n /** The names of Solid's built-in components. */\n readonly builtIns: ReadonlySet<string>;\n}\n\n/**\n * The functions declared at the top level of a module, with the statement\n * that declares each: `function A() {}`, `const A = () => ...`, and their\n * `export` forms.\n */\nfunction topLevelFunctions(program: Program): { statement: Node; fn: Node }[] {\n const found: { statement: Node; fn: Node }[] = [];\n for (const statement of program.body) {\n const declaration =\n statement.type === 'ExportNamedDeclaration' || statement.type === 'ExportDefaultDeclaration'\n ? statement.declaration\n : statement;\n if (!declaration) {\n continue;\n }\n if (declaration.type === 'FunctionDeclaration') {\n found.push({ statement, fn: declaration });\n } else if (\n declaration.type === 'VariableDeclaration' &&\n declaration.declarations.length === 1\n ) {\n const init = declaration.declarations.at(0)?.init;\n const fn = init ? unwrap(init) : undefined;\n if (fn?.type === 'ArrowFunctionExpression' || fn?.type === 'FunctionExpression') {\n found.push({ statement, fn });\n }\n }\n }\n return found;\n}\n\nfunction containsJSX(node: Node): boolean {\n let found = false;\n const visit = (current: Node): void => {\n if (found) {\n return;\n }\n if (current.type === 'JSXElement' || current.type === 'JSXFragment') {\n found = true;\n return;\n }\n forEachChild(current, visit);\n };\n visit(node);\n return found;\n}\n\n/**\n * Adds the helper imports and the marker calls to a module.\n *\n * Each top-level function with JSX gets its own marker, so a component the\n * bundler drops takes its helpers with it. JSX anywhere else gets a marker\n * at the top level. Returns `undefined` when the module needs no helper.\n */\nexport function addMarker(\n code: string,\n filename: string,\n options: MarkerOptions,\n): EditResult | undefined {\n if (options.helpers.size === 0) {\n return undefined;\n }\n const program = parse(filename, code);\n const scopes = analyzeScopes(program);\n const entries: string[] = [];\n const specifiers: string[] = [];\n for (const helper of options.helpers) {\n const local = freshName(scopes, `__so$${helper}`);\n specifiers.push(`${helper} as ${local}`);\n entries.push(`${JSON.stringify(HELPER_PREFIX + helper)}: ${local}`);\n }\n for (const statement of program.body) {\n if (\n statement.type !== 'ImportDeclaration' ||\n statement.importKind === 'type' ||\n !options.moduleSources.includes(statement.source.value)\n ) {\n continue;\n }\n for (const specifier of statement.specifiers) {\n if (specifier.type !== 'ImportSpecifier' || specifier.importKind === 'type') {\n continue;\n }\n const imported = exportedName(specifier);\n // A built-in that folding left unused stays out, so the bundler can drop it.\n const used = (scopes.root.bindings.get(specifier.local.name)?.references.length ?? 0) > 0;\n if (options.builtIns.has(imported) && used) {\n entries.push(`${JSON.stringify(BUILT_IN_PREFIX + imported)}: ${specifier.local.name}`);\n }\n }\n }\n const call = `${MARKER}({ ${entries.join(', ')} })`;\n const s = new MagicString(code);\n const functions: { statement: Node; fn: Node }[] = [];\n for (const entry of topLevelFunctions(program)) {\n if (containsJSX(entry.fn)) {\n functions.push(entry);\n }\n }\n for (const { fn } of functions) {\n if (\n fn.type !== 'FunctionDeclaration' &&\n fn.type !== 'FunctionExpression' &&\n fn.type !== 'ArrowFunctionExpression'\n ) {\n continue;\n }\n const { body } = fn;\n if (!body) {\n continue;\n }\n if (body.type === 'BlockStatement') {\n s.appendLeft(body.start + 1, `${call};`);\n } else {\n s.prependRight(body.start, `{ ${call}; return `);\n s.appendLeft(body.end, '; }');\n }\n }\n let outside = false;\n for (const statement of program.body) {\n if (!hasStatement(functions, statement) && containsJSX(statement)) {\n outside = true;\n break;\n }\n }\n s.append(\n `\\nimport { ${specifiers.join(', ')} } from ${JSON.stringify(options.moduleName)};\\n` +\n (outside ? `${call};\\n` : ''),\n );\n return { code: s.toString(), map: generateMap(s, filename) };\n}\n\n/**\n * Puts back the parentheses around a comma expression that is the whole of a\n * JSX expression container. Rolldown drops them when it prints a chunk that\n * kept its JSX, and JSX does not allow the result. Returns `undefined` when\n * the chunk has none.\n */\nexport function repairJSXSequences(code: string, filename: string): EditResult | undefined {\n // The chunk does not parse cleanly, which is why this runs, so errors are expected.\n const { program } = parseSync(filename, code, {\n lang: 'jsx',\n sourceType: 'module',\n preserveParens: true,\n });\n const sequences: Node[] = [];\n const visit = (node: Node): void => {\n if (node.type === 'JSXExpressionContainer' && node.expression.type === 'SequenceExpression') {\n sequences.push(node.expression);\n }\n forEachChild(node, visit);\n };\n visit(program);\n if (sequences.length === 0) {\n return undefined;\n }\n const s = new MagicString(code);\n for (const sequence of sequences) {\n s.appendLeft(sequence.start, '(');\n s.prependRight(sequence.end, ')');\n }\n return { code: s.toString(), map: generateMap(s, filename) };\n}\n\nexport interface ChunkRuntime extends EditResult {\n /** The chunk's name for each helper, keyed by the name `@solidjs/web` exports. */\n readonly helpers: ReadonlyMap<string, string>;\n /** The built-in each chunk binding refers to, keyed by the chunk's name for it. */\n readonly builtInAliases: Record<string, string>;\n}\n\nfunction propertyKey(node: Node): string | undefined {\n if (node.type === 'Literal' && typeof node.value === 'string') {\n return node.value;\n }\n if (node.type === 'Identifier') {\n return node.name;\n }\n return undefined;\n}\n\n/**\n * Reads and removes the marker calls of a chunk.\n * Returns `undefined` when the chunk has none.\n */\nexport function readMarkers(code: string, filename: string): ChunkRuntime | undefined {\n if (!code.includes(MARKER)) {\n return undefined;\n }\n const program = parse(filename, code);\n const s = new MagicString(code);\n const helpers = new Map<string, string>();\n const builtInAliases: Record<string, string> = {};\n // A marker is usually a top-level statement. The bundler moves a module\n // into an init function when it has to run lazily, such as a module that\n // a dynamic import pulled into the same chunk, so every statement is searched.\n const markers: ExpressionStatement[] = [];\n const visit = (node: Node): void => {\n if (\n node.type === 'ExpressionStatement' &&\n node.expression.type === 'CallExpression' &&\n node.expression.callee.type === 'Identifier' &&\n node.expression.callee.name === MARKER\n ) {\n markers.push(node);\n return;\n }\n forEachChild(node, visit);\n };\n visit(program);\n for (const statement of markers) {\n s.remove(statement.start, statement.end);\n if (statement.expression.type !== 'CallExpression') {\n continue;\n }\n const argument = statement.expression.arguments.at(0);\n if (argument?.type !== 'ObjectExpression') {\n continue;\n }\n for (const property of argument.properties) {\n if (property.type !== 'Property' || property.value.type !== 'Identifier') {\n continue;\n }\n const key = propertyKey(property.key);\n if (key?.startsWith(HELPER_PREFIX)) {\n helpers.set(key.slice(HELPER_PREFIX.length), property.value.name);\n } else if (key?.startsWith(BUILT_IN_PREFIX)) {\n builtInAliases[property.value.name] = key.slice(BUILT_IN_PREFIX.length);\n }\n }\n }\n if (markers.length === 0) {\n return undefined;\n }\n return {\n code: s.toString(),\n map: generateMap(s, filename),\n helpers,\n builtInAliases,\n };\n}\n\n/**\n * Replaces the helper imports that Solid's JSX transform added to a chunk\n * with the chunk's own names for those helpers.\n */\nexport function linkHelpers(\n code: string,\n filename: string,\n moduleName: string,\n helpers: ReadonlyMap<string, string>,\n): EditResult {\n const program = parse(filename, code);\n const scopes = analyzeScopes(program);\n const parents = collectParents(program);\n const s = new MagicString(code);\n for (const statement of program.body) {\n if (\n statement.type !== 'ImportDeclaration' ||\n statement.source.value !== moduleName ||\n !isAllGenerated(statement.specifiers)\n ) {\n continue;\n }\n for (const specifier of statement.specifiers) {\n if (specifier.type !== 'ImportSpecifier') {\n continue;\n }\n const imported = exportedName(specifier);\n const target = helpers.get(imported);\n if (target === undefined) {\n throw new MissingHelperError(\n `[solid-optimizer] ${filename} needs \"${imported}\" from \"${moduleName}\", but no module in the chunk imports it.`,\n );\n }\n const binding = scopes.root.bindings.get(specifier.local.name);\n const targetBinding = scopes.root.bindings.get(target);\n if (!targetBinding) {\n throw new Error(\n `[solid-optimizer] ${filename} has no top-level \"${target}\" for \"${imported}\".`,\n );\n }\n for (const reference of binding?.references ?? []) {\n if (lookup(scopeAt(scopes, parents, reference), target) !== targetBinding) {\n throw new Error(\n `[solid-optimizer] ${filename} shadows \"${target}\" where the JSX transform uses \"${imported}\".`,\n );\n }\n s.overwrite(reference.start, reference.end, target);\n }\n }\n s.remove(statement.start, statement.end);\n }\n return { code: s.toString(), map: generateMap(s, filename) };\n}\n","/**\n * Copies components from other modules into a module before bundling, so\n * the inline pass can inline them there.\n *\n * In chunk mode, the chunk step inlines any component in the same chunk.\n * It runs after the bundler has split the chunks, so a shared chunk still\n * exports what an inlined component needed, like the runtime's `spread`.\n * Inlining an imported component while its importer is transformed lets\n * the bundler drop the component, and what only it used, before splitting.\n *\n * A copy refers to the bindings of its own module. Imports are imported\n * again by the module they resolve to. A binding the module declares but\n * does not export is exported under an extra name, which `exposeLocals`\n * adds when the module is transformed.\n */\nimport MagicString from 'magic-string';\nimport type { Expression, Node, Program } from 'oxc-parser';\nimport { forEachChild, parse, unwrap } from '../ast';\nimport type { Binding, ScopeAnalysis } from '../scope';\nimport { analyzeScopes } from '../scope';\nimport { MARKER } from './runtime';\nimport type { EditResult } from './runtime';\n\n/**\n * Whether a binding is `const X = createContext(...)`, with `createContext`\n * imported from Solid.\n */\nfunction isContext(\n binding: Binding,\n scopes: ScopeAnalysis,\n moduleSources: readonly string[],\n): boolean {\n const { declaration } = binding;\n if (\n binding.kind !== 'const' ||\n binding.mutated ||\n declaration.type !== 'VariableDeclarator' ||\n !declaration.init\n ) {\n return false;\n }\n const init = unwrap(declaration.init);\n if (init.type !== 'CallExpression' || init.callee.type !== 'Identifier') {\n return false;\n }\n const callee = scopes.references.get(init.callee);\n return (\n callee?.kind === 'import' &&\n callee.imported === 'createContext' &&\n callee.source !== undefined &&\n moduleSources.includes(callee.source)\n );\n}\n\n/** The prefix of the name a module exports a local binding under. */\nexport const LOCAL_EXPORT = '__so_local$';\n\nfunction generateMap(s: MagicString, filename: string): string {\n return s.generateMap({ source: filename, hires: true, includeContent: true }).toString();\n}\n\nfunction isCapitalized(name: string): boolean {\n return /^[A-Z]/.test(name);\n}\n\ninterface TopLevelFunction {\n readonly binding: Binding;\n /** The function, or the arrow or function expression a `const` holds. */\n readonly fn: Node;\n /** The node to copy: the function declaration, or the expression. */\n readonly kind: 'declaration' | 'expression';\n}\n\n/**\n * The function a top-level binding holds: `function A() {}`, or\n * `const A = () => ...`.\n */\nfunction findTopLevelFunction(binding: Binding): TopLevelFunction | undefined {\n const { declaration } = binding;\n if (declaration.type === 'FunctionDeclaration') {\n return { binding, fn: declaration, kind: 'declaration' };\n }\n if (\n declaration.type === 'VariableDeclarator' &&\n binding.kind === 'const' &&\n declaration.id === binding.identifier &&\n declaration.init\n ) {\n const init = unwrap(declaration.init);\n if (init.type === 'ArrowFunctionExpression' || init.type === 'FunctionExpression') {\n return { binding, fn: init, kind: 'expression' };\n }\n }\n return undefined;\n}\n\n/**\n * The binding a top-level alias like `const Button = ButtonRoot` names, or\n * the binding itself when it is not one. Libraries often export a component\n * under such a second name.\n */\nfunction aliasedBinding(binding: Binding): Binding {\n let current = binding;\n for (let depth = 0; depth < 8; depth += 1) {\n const { declaration } = current;\n if (\n declaration.type !== 'VariableDeclarator' ||\n current.kind !== 'const' ||\n current.mutated ||\n declaration.id !== current.identifier ||\n !declaration.init\n ) {\n return current;\n }\n const init = unwrap(declaration.init);\n const target = init.type === 'Identifier' ? current.scope.bindings.get(init.name) : undefined;\n if (!target || target === current || target.mutated) {\n return current;\n }\n current = target;\n }\n return current;\n}\n\n/**\n * Where a module re-exports `exportName` from, like\n * `export { t as Separator } from './chunk.jsx'`, or `undefined` when it\n * does not re-export it by name.\n */\nexport function readReexport(\n code: string,\n filename: string,\n exportName: string,\n): { source: string; imported: string } | undefined {\n const program = parse(filename, code);\n for (const statement of program.body) {\n if (\n statement.type !== 'ExportNamedDeclaration' ||\n !statement.source ||\n statement.exportKind === 'type'\n ) {\n continue;\n }\n for (const specifier of statement.specifiers) {\n const exported =\n specifier.exported.type === 'Identifier'\n ? specifier.exported.name\n : specifier.exported.value;\n const local =\n specifier.local.type === 'Identifier' ? specifier.local.name : specifier.local.value;\n if (exported === exportName && specifier.exportKind !== 'type') {\n return { source: statement.source.value, imported: local };\n }\n }\n }\n return undefined;\n}\n\nfunction addDeclared(\n exports: Map<string, Binding>,\n declarators: readonly { id: { type: string; name?: string } }[],\n bindings: ReadonlyMap<string, Binding>,\n): void {\n for (const declarator of declarators) {\n const binding =\n declarator.id.type === 'Identifier' && declarator.id.name !== undefined\n ? bindings.get(declarator.id.name)\n : undefined;\n if (binding !== undefined) {\n exports.set(binding.name, binding);\n }\n }\n}\n\n/**\n * The names a module exports, each with the top-level binding it exports.\n */\nfunction collectExports(program: Program, scopes: ScopeAnalysis): Map<string, Binding> {\n const exports = new Map<string, Binding>();\n const { bindings } = scopes.root;\n for (const statement of program.body) {\n if (statement.type === 'ExportNamedDeclaration' && !statement.source) {\n const { declaration } = statement;\n if (declaration?.type === 'FunctionDeclaration' && declaration.id) {\n const binding = bindings.get(declaration.id.name);\n if (binding) {\n exports.set(declaration.id.name, binding);\n }\n } else if (declaration?.type === 'VariableDeclaration') {\n addDeclared(exports, declaration.declarations, bindings);\n }\n for (const specifier of statement.specifiers) {\n const local = specifier.local.type === 'Identifier' ? specifier.local.name : undefined;\n const exported =\n specifier.exported.type === 'Identifier'\n ? specifier.exported.name\n : specifier.exported.value;\n const binding = local === undefined ? undefined : bindings.get(local);\n if (binding) {\n exports.set(exported, binding);\n }\n }\n } else if (statement.type === 'ExportDefaultDeclaration') {\n const { declaration } = statement;\n if (declaration.type === 'FunctionDeclaration' && declaration.id) {\n const binding = bindings.get(declaration.id.name);\n if (binding) {\n exports.set('default', binding);\n }\n } else if (declaration.type === 'Identifier') {\n const binding = bindings.get(declaration.name);\n if (binding) {\n exports.set('default', binding);\n }\n }\n }\n }\n return exports;\n}\n\n/**\n * The top-level bindings a function refers to, other than itself.\n */\nfunction outerBindings(fn: Node, self: Binding, scopes: ScopeAnalysis): Map<Node, Binding> {\n const outer = new Map<Node, Binding>();\n for (const [reference, binding] of scopes.references) {\n if (\n binding &&\n binding !== self &&\n binding.scope === scopes.root &&\n reference.start >= fn.start &&\n reference.end <= fn.end\n ) {\n outer.set(reference, binding);\n }\n }\n return outer;\n}\n\n/**\n * Exports the top-level bindings that the module's exported components\n * refer to but the module does not export, under an extra name. A copy of\n * such a component in another module imports them from here.\n */\nexport function exposeLocals(code: string, filename: string): EditResult | undefined {\n const program = parse(filename, code);\n const scopes = analyzeScopes(program);\n const exports = collectExports(program, scopes);\n const exported = new Set(exports.values());\n const needed = new Set<Binding>();\n for (const [name, binding] of exports) {\n const component =\n isCapitalized(binding.name) || name === 'default' ? findTopLevelFunction(binding) : undefined;\n if (!component) {\n continue;\n }\n for (const outer of outerBindings(component.fn, binding, scopes).values()) {\n if (outer.kind !== 'import' && !exported.has(outer)) {\n needed.add(outer);\n }\n }\n }\n if (needed.size === 0) {\n return undefined;\n }\n const s = new MagicString(code);\n const specifiers: string[] = [];\n for (const binding of needed) {\n specifiers.push(`${binding.name} as ${LOCAL_EXPORT}${binding.name}`);\n }\n s.append(`\\nexport { ${specifiers.join(', ')} };\\n`);\n return { code: s.toString(), map: generateMap(s, filename) };\n}\n\n/** A binding a copied component needs from its own module's scope. */\nexport type Dependency =\n /** An import of that module, imported again by the module it resolves to. */\n | { readonly kind: 'import'; readonly source: string; readonly imported: string }\n /** A binding that module exports, imported from it under this name. */\n | { readonly kind: 'export'; readonly exported: string; readonly context: boolean };\n\nexport interface ExportedComponent {\n /** Each top-level binding the component refers to, by its name in the module. */\n readonly dependencies: ReadonlyMap<string, Dependency>;\n /**\n * The component's declaration under `name`, with each dependency renamed\n * as `rename` gives it.\n */\n readonly copy: (name: string, rename: ReadonlyMap<string, string>) => string;\n /**\n * Whether the component only returns a call of another component of its\n * module, like `(props) => <Icon {...props}><path /></Icon>`.\n */\n readonly wrapsLocal: boolean;\n}\n\n/**\n * Whether a function returns JSX whose root calls a component declared at\n * the top of its own module. A context's provider does not count, since the\n * provider pass can remove it from a copy.\n */\nfunction returnsLocalCall(\n fn: TopLevelFunction['fn'],\n scopes: ScopeAnalysis,\n moduleSources: readonly string[],\n): boolean {\n if (\n fn.type !== 'FunctionDeclaration' &&\n fn.type !== 'FunctionExpression' &&\n fn.type !== 'ArrowFunctionExpression'\n ) {\n return false;\n }\n const { body } = fn;\n if (!body) {\n return false;\n }\n let root: Expression | null | undefined;\n if (body.type === 'BlockStatement') {\n const last = body.body.at(-1);\n root = last?.type === 'ReturnStatement' ? last.argument : undefined;\n } else {\n root = body;\n }\n if (!root) {\n return false;\n }\n const inner = unwrap(root);\n if (inner.type !== 'JSXElement' || inner.openingElement.name.type !== 'JSXIdentifier') {\n return false;\n }\n const binding = scopes.references.get(inner.openingElement.name);\n return (\n binding !== undefined &&\n binding.scope === scopes.root &&\n binding.kind !== 'import' &&\n !isContext(binding, scopes, moduleSources)\n );\n}\n\n/**\n * Reads the component a module exports under `exportName`, from the module\n * as the bundler loaded it. `undefined` when that export is not a function\n * component, or it refers to a top-level binding the module cannot export.\n */\nexport function readExportedComponent(\n code: string,\n filename: string,\n exportName: string,\n moduleSources: readonly string[],\n): ExportedComponent | undefined {\n const program = parse(filename, code);\n const scopes = analyzeScopes(program);\n const exports = collectExports(program, scopes);\n const named = exports.get(exportName);\n const binding = named ? aliasedBinding(named) : undefined;\n const component = binding ? findTopLevelFunction(binding) : undefined;\n if (!binding || !component) {\n return undefined;\n }\n const exportNames = new Map<Binding, string>();\n for (const [name, exported] of exports) {\n if (!exportNames.has(exported)) {\n exportNames.set(exported, name);\n }\n }\n\n const outer = outerBindings(component.fn, binding, scopes);\n const dependencies = new Map<string, Dependency>();\n for (const dependency of outer.values()) {\n if (dependencies.has(dependency.name)) {\n continue;\n }\n if (dependency.kind === 'import') {\n if (dependency.source === undefined || dependency.imported === undefined) {\n return undefined;\n }\n dependencies.set(dependency.name, {\n kind: 'import',\n source: dependency.source,\n imported: dependency.imported,\n });\n continue;\n }\n // A local binding is exported under its extra name, which `exposeLocals` added.\n const name = exportNames.get(dependency);\n if (name === undefined) {\n return undefined;\n }\n dependencies.set(dependency.name, {\n kind: 'export',\n exported: name,\n context: isContext(dependency, scopes, moduleSources),\n });\n }\n\n // The helper markers in the copy belong to the module it comes from.\n const markers: Node[] = [];\n const findMarkers = (node: Node): void => {\n if (\n node.type === 'ExpressionStatement' &&\n node.expression.type === 'CallExpression' &&\n node.expression.callee.type === 'Identifier' &&\n node.expression.callee.name === MARKER\n ) {\n markers.push(node);\n return;\n }\n forEachChild(node, findMarkers);\n };\n findMarkers(component.fn);\n\n const copy = (name: string, rename: ReadonlyMap<string, string>): string => {\n const s = new MagicString(code);\n for (const [reference, dependency] of outer) {\n const renamed = rename.get(dependency.name);\n if (renamed !== undefined && renamed !== dependency.name) {\n s.overwrite(reference.start, reference.end, renamed);\n }\n }\n for (const marker of markers) {\n s.remove(marker.start, marker.end);\n }\n if (\n component.kind === 'declaration' &&\n component.fn.type === 'FunctionDeclaration' &&\n component.fn.id\n ) {\n s.overwrite(component.fn.id.start, component.fn.id.end, name);\n return s.slice(component.fn.start, component.fn.end);\n }\n return `const ${name} = ${s.slice(component.fn.start, component.fn.end)};`;\n };\n return { dependencies, copy, wrapsLocal: returnsLocalCall(component.fn, scopes, moduleSources) };\n}\n","/**\n * Rewrites JSX tags that read a member of a namespace import, like\n * `<Button.Root>` with `import * as Button from '...'`, to a named import.\n *\n * A bundler resolves `Button.Root` in code to the export it reads, and\n * drops the namespace. In a JSX tag name it does not, so a module that\n * keeps its JSX through bundling would make the bundle build a namespace\n * object with every export of the module.\n */\nimport MagicString from 'magic-string';\nimport { collectParents, parse } from '../ast';\nimport { analyzeScopes } from '../scope';\nimport type { EditResult } from './runtime';\n\nexport function nameNamespaceTags(code: string, filename: string): EditResult | undefined {\n const program = parse(filename, code);\n const scopes = analyzeScopes(program);\n const parents = collectParents(program);\n const s = new MagicString(code);\n const names = new Set(scopes.names);\n const imports: string[] = [];\n for (const binding of scopes.root.bindings.values()) {\n const statement = parents.get(binding.declaration);\n if (\n binding.kind !== 'import' ||\n binding.imported !== '*' ||\n binding.source === undefined ||\n statement?.type !== 'ImportDeclaration' ||\n statement.importKind === 'type'\n ) {\n continue;\n }\n // One local name for each member, shared by its opening and closing tags.\n const locals = new Map<string, string>();\n for (const reference of binding.references) {\n const member = parents.get(reference);\n if (\n reference.type !== 'JSXIdentifier' ||\n member?.type !== 'JSXMemberExpression' ||\n member.object !== reference\n ) {\n continue;\n }\n const { name } = member.property;\n let local = locals.get(name);\n if (local === undefined) {\n local = `${binding.name}$${name}`;\n for (let index = 1; names.has(local); index += 1) {\n local = `${binding.name}$${name}$${String(index)}`;\n }\n names.add(local);\n locals.set(name, local);\n imports.push(`import { ${name} as ${local} } from ${JSON.stringify(binding.source)};`);\n }\n s.overwrite(member.start, member.end, local);\n }\n }\n if (imports.length === 0) {\n return undefined;\n }\n s.prepend(`${imports.join('\\n')}\\n`);\n return {\n code: s.toString(),\n map: s.generateMap({ source: filename, hires: true, includeContent: true }).toString(),\n };\n}\n","/**\n * Keeps a `ref` that names a variable working through bundling.\n *\n * Solid's JSX transform turns `<input ref={el} />` into code that assigns\n * the element to `el`. In chunk mode the JSX reaches the bundler before that\n * code exists, so the bundler only sees `el` read. A `let el` that nothing\n * else writes to then looks like it is always `undefined`, and the bundler\n * folds its reads, like `el ? el.value : ''`, to the `undefined` branch.\n *\n * Before bundling, `ref={el}` becomes `ref={__SO_REF__(el, (v) => (el = v))}`,\n * which shows the bundler the write. The bundler renames both uses of `el`\n * alike. Before the chunk is lowered, the call becomes `ref={el}` again, so\n * the JSX transform writes the same code it would have.\n */\nimport type { CallExpression, JSXAttribute, Node } from 'oxc-parser';\nimport MagicString from 'magic-string';\nimport { forEachChild, parse } from '../ast';\nimport { analyzeScopes } from '../scope';\nimport type { EditResult } from './runtime';\n\nexport const REF_MARKER = '__SO_REF__';\n\nfunction generateMap(s: MagicString, filename: string): string {\n return s.generateMap({ source: filename, hires: true, includeContent: true }).toString();\n}\n\nfunction isRefAttribute(node: Node): node is JSXAttribute {\n return (\n node.type === 'JSXAttribute' && node.name.type === 'JSXIdentifier' && node.name.name === 'ref'\n );\n}\n\n/**\n * Wraps each `ref` whose value is a `let` or `var` binding, so the bundler\n * sees it written. `undefined` when there is none.\n */\nexport function protectRefs(code: string, filename: string): EditResult | undefined {\n if (!code.includes('ref')) {\n return undefined;\n }\n const program = parse(filename, code);\n const scopes = analyzeScopes(program);\n const s = new MagicString(code);\n const visit = (node: Node): void => {\n if (isRefAttribute(node) && node.value?.type === 'JSXExpressionContainer') {\n const { expression } = node.value;\n const binding =\n expression.type === 'Identifier' ? scopes.references.get(expression) : undefined;\n if (\n expression.type === 'Identifier' &&\n (binding?.kind === 'let' || binding?.kind === 'var')\n ) {\n const { name } = expression;\n s.overwrite(\n expression.start,\n expression.end,\n `${REF_MARKER}(${name}, (__so_ref) => (${name} = __so_ref))`,\n );\n }\n }\n forEachChild(node, visit);\n };\n visit(program);\n return s.hasChanged() ? { code: s.toString(), map: generateMap(s, filename) } : undefined;\n}\n\n/**\n * Turns each wrapped `ref` back into its variable. `undefined` when there\n * is none.\n */\nexport function restoreRefs(code: string, filename: string): EditResult | undefined {\n if (!code.includes(REF_MARKER)) {\n return undefined;\n }\n const program = parse(filename, code);\n const s = new MagicString(code);\n const visit = (node: Node): void => {\n if (isRefAttribute(node) && node.value?.type === 'JSXExpressionContainer') {\n const { expression } = node.value;\n if (isMarkerCall(expression)) {\n const target = expression.arguments.at(0);\n if (target?.type === 'Identifier') {\n s.overwrite(expression.start, expression.end, target.name);\n }\n }\n }\n forEachChild(node, visit);\n };\n visit(program);\n return s.hasChanged() ? { code: s.toString(), map: generateMap(s, filename) } : undefined;\n}\n\nfunction isMarkerCall(node: Node): node is CallExpression {\n return (\n node.type === 'CallExpression' &&\n node.callee.type === 'Identifier' &&\n node.callee.name === REF_MARKER\n );\n}\n","/**\n * Which modules use each export of the app, read from the files on disk.\n *\n * A component copied into the module that uses it is only smaller overall\n * when the original goes away, which takes that module being its only user.\n * The index answers that from the whole module graph, so it does not depend\n * on the order the bundler transforms modules in, and a server build and its\n * client build make the same decisions.\n *\n * Anything the index cannot follow counts as another use: a re-export, a\n * dynamic import, a namespace used as a value, or a use inside the module\n * that declares the export.\n */\nimport type { Node, Program } from 'oxc-parser';\nimport { collectParents, forEachChild, parse } from '../ast';\nimport type { Parents } from '../ast';\nimport type { Binding, ScopeAnalysis } from '../scope';\nimport { analyzeScopes } from '../scope';\n\nexport interface UsageIndex {\n /**\n * How many modules use `exportName` of `module`, counting `user`, when\n * they only use it as JSX tags. `0` when anything else uses it, which\n * keeps it whoever copies it. `absorbed` holds, by module, the exported\n * components that were copied into `user` and leave their module, so the\n * uses inside them count as uses in `user`.\n */\n users(\n module: string,\n exportName: string,\n user: string,\n absorbed: ReadonlyMap<string, ReadonlySet<string>>,\n ): number;\n}\n\nexport interface UsageHost {\n /** The id `source` resolves to from `importer`, or `undefined` outside the app. */\n resolve(source: string, importer: string): Promise<string | undefined>;\n /** The code of a module, or `undefined` when it cannot be read. */\n read(id: string): Promise<string | undefined>;\n}\n\n/** The name a use counts under when it is not inside an exported declaration. */\nconst UNEXPORTED = '';\n\ninterface ExportUsage {\n /**\n * The modules that use the export as a JSX tag, each with the export\n * names of the top-level declarations the uses sit in.\n */\n readonly importers: Map<string, Set<string>>;\n /** Whether anything uses it other than as a tag. */\n other: boolean;\n}\n\nconst SCRIPT = /\\.[mc]?[jt]sx?$/;\n\nclass Usage implements UsageIndex {\n private readonly exports = new Map<string, ExportUsage>();\n\n /** Modules any of whose exports can be used in a way the index does not follow. */\n private readonly opaque = new Set<string>();\n\n /** The modules each module imports. */\n readonly imports = new Map<string, readonly string[]>();\n\n /** Whether `from` imports `to`, directly or through other modules. */\n private reaches(from: string, to: string): boolean {\n const seen = new Set<string>();\n const stack = [from];\n for (let id = stack.pop(); id !== undefined; id = stack.pop()) {\n if (id === to) {\n return true;\n }\n if (!seen.has(id)) {\n seen.add(id);\n stack.push(...(this.imports.get(id) ?? []));\n }\n }\n return false;\n }\n\n private entry(module: string, name: string): ExportUsage {\n const key = `${module}\\0${name}`;\n let usage = this.exports.get(key);\n if (!usage) {\n usage = { importers: new Map(), other: false };\n this.exports.set(key, usage);\n }\n return usage;\n }\n\n tag(module: string, name: string, importer: string, containers: readonly string[]): void {\n const { importers } = this.entry(module, name);\n const known = importers.get(importer) ?? new Set();\n for (const container of containers) {\n known.add(container);\n }\n importers.set(importer, known);\n }\n\n other(module: string, name: string): void {\n this.entry(module, name).other = true;\n }\n\n all(module: string): void {\n this.opaque.add(module);\n }\n\n users(\n module: string,\n exportName: string,\n user: string,\n absorbed: ReadonlyMap<string, ReadonlySet<string>>,\n ): number {\n if (this.opaque.has(module)) {\n return 0;\n }\n const usage = this.exports.get(`${module}\\0${exportName}`);\n if (!usage || usage.other || usage.importers.size === 0) {\n return 0;\n }\n const users = new Set([user]);\n for (const [importer, containers] of usage.importers) {\n const moved = absorbed.get(importer);\n users.add(hasEvery(containers, moved) ? user : importer);\n }\n // A module the component's module imports never gets a copy of it, so\n // the original stays for it.\n for (const id of users) {\n if (this.reaches(module, id)) {\n return 0;\n }\n }\n return users.size;\n }\n}\n\nfunction hasEvery(names: Iterable<string>, set: ReadonlySet<string> | undefined): boolean {\n for (const name of names) {\n if (set?.has(name) !== true) {\n return false;\n }\n }\n return true;\n}\n\nfunction isTagName(reference: Node, parents: Parents): boolean {\n const parent = parents.get(reference);\n return parent?.type === 'JSXOpeningElement' && parent.name === reference;\n}\n\nfunction isClosingTagName(reference: Node, parents: Parents): boolean {\n const parent = parents.get(reference);\n return parent?.type === 'JSXClosingElement' && parent.name === reference;\n}\n\n/** The names a declaration exported with `export` declares. */\nfunction declaredNames(declaration: Node | null | undefined): string[] {\n if (declaration?.type === 'FunctionDeclaration' && declaration.id) {\n return [declaration.id.name];\n }\n if (declaration?.type === 'VariableDeclaration') {\n const names: string[] = [];\n for (const declarator of declaration.declarations) {\n if (declarator.id.type === 'Identifier') {\n names.push(declarator.id.name);\n }\n }\n return names;\n }\n return [];\n}\n\n/** The top-level bindings a module exports, each with its export names. */\nfunction exportedBindings(program: Program, scopes: ScopeAnalysis): Map<Binding, string[]> {\n const exported = new Map<Binding, string[]>();\n const add = (local: string, name: string): void => {\n const binding = scopes.root.bindings.get(local);\n if (binding) {\n exported.set(binding, [...(exported.get(binding) ?? []), name]);\n }\n };\n for (const statement of program.body) {\n if (statement.type === 'ExportNamedDeclaration' && !statement.source) {\n for (const name of declaredNames(statement.declaration)) {\n add(name, name);\n }\n for (const specifier of statement.specifiers) {\n if (specifier.local.type === 'Identifier') {\n add(\n specifier.local.name,\n specifier.exported.type === 'Identifier'\n ? specifier.exported.name\n : specifier.exported.value,\n );\n }\n }\n } else if (statement.type === 'ExportDefaultDeclaration') {\n const { declaration } = statement;\n if (declaration.type === 'FunctionDeclaration' && declaration.id) {\n add(declaration.id.name, 'default');\n } else if (declaration.type === 'Identifier') {\n add(declaration.name, 'default');\n }\n }\n }\n return exported;\n}\n\n/**\n * Records how a module uses what it imports, and the uses of its own\n * exports inside it.\n */\nfunction recordModule(\n usage: Usage,\n id: string,\n program: Program,\n targets: ReadonlyMap<string, string>,\n): void {\n const scopes = analyzeScopes(program);\n const parents = collectParents(program);\n\n // A module that uses its own export keeps it, whoever else copies it.\n const exported = exportedBindings(program, scopes);\n // The export names of the top-level declaration a use sits in.\n const findContainers = (reference: Node): string[] => {\n let node: Node = reference;\n let parent = parents.get(node);\n while (parent && parent.type !== 'Program') {\n node = parent;\n parent = parents.get(node);\n }\n const declaration =\n (node.type === 'ExportNamedDeclaration' || node.type === 'ExportDefaultDeclaration') &&\n node.declaration\n ? node.declaration\n : node;\n const bindings: (Binding | undefined)[] = [];\n if (declaration.type === 'FunctionDeclaration' && declaration.id) {\n bindings.push(scopes.root.bindings.get(declaration.id.name));\n } else if (declaration.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations) {\n if (\n declarator.id.type === 'Identifier' &&\n reference.start >= declarator.start &&\n reference.end <= declarator.end\n ) {\n bindings.push(scopes.root.bindings.get(declarator.id.name));\n }\n }\n }\n const names: string[] = [];\n for (const binding of bindings) {\n if (binding) {\n names.push(...(exported.get(binding) ?? []));\n }\n }\n return names.length > 0 ? names : [UNEXPORTED];\n };\n\n const record = (binding: Binding, target: string): void => {\n const imported = binding.imported ?? '*';\n for (const reference of binding.references) {\n if (isClosingTagName(reference, parents)) {\n continue;\n }\n if (imported !== '*') {\n if (isTagName(reference, parents)) {\n usage.tag(target, imported, id, findContainers(reference));\n } else {\n usage.other(target, imported);\n }\n continue;\n }\n // `<Ns.Member>` and `Ns.member` use one export. Anything else may use any.\n const member = parents.get(reference);\n if (member?.type === 'JSXMemberExpression' && member.object === reference) {\n if (isTagName(member, parents)) {\n usage.tag(target, member.property.name, id, findContainers(reference));\n } else {\n usage.other(target, member.property.name);\n }\n } else if (\n member?.type === 'MemberExpression' &&\n member.object === reference &&\n !member.computed &&\n member.property.type === 'Identifier'\n ) {\n usage.other(target, member.property.name);\n } else {\n usage.all(target);\n }\n }\n };\n for (const binding of scopes.root.bindings.values()) {\n if (binding.kind === 'import' && binding.source !== undefined) {\n const target = targets.get(binding.source);\n if (target !== undefined) {\n record(binding, target);\n }\n }\n }\n\n // Re-exports pass an export on, which the index does not follow.\n for (const statement of program.body) {\n if (statement.type === 'ExportAllDeclaration') {\n const target = targets.get(statement.source.value);\n if (target !== undefined) {\n usage.all(target);\n }\n } else if (statement.type === 'ExportNamedDeclaration' && statement.source) {\n const target = targets.get(statement.source.value);\n for (const specifier of statement.specifiers) {\n const name =\n specifier.local.type === 'Identifier' ? specifier.local.name : specifier.local.value;\n if (target !== undefined) {\n usage.other(target, name);\n }\n }\n }\n }\n\n for (const [binding, names] of exported) {\n let used = false;\n for (const reference of binding.references) {\n const parent = parents.get(reference);\n if (\n parent?.type !== 'ExportSpecifier' &&\n parent?.type !== 'ExportDefaultDeclaration' &&\n !isClosingTagName(reference, parents)\n ) {\n used = true;\n break;\n }\n }\n if (used) {\n for (const name of names) {\n usage.other(id, name);\n }\n }\n }\n}\n\n/** The import specifiers a module loads, statically or with `import()`. */\nfunction collectSpecifiers(program: Program): { static: Set<string>; dynamic: Set<string> } {\n const statics = new Set<string>();\n const dynamics = new Set<string>();\n for (const statement of program.body) {\n if (\n (statement.type === 'ImportDeclaration' && statement.importKind !== 'type') ||\n ((statement.type === 'ExportNamedDeclaration' || statement.type === 'ExportAllDeclaration') &&\n statement.source &&\n statement.exportKind !== 'type')\n ) {\n const value = statement.source?.value;\n if (value !== undefined) {\n statics.add(value);\n }\n }\n }\n const visit = (node: Node): void => {\n if (\n node.type === 'ImportExpression' &&\n node.source.type === 'Literal' &&\n typeof node.source.value === 'string'\n ) {\n dynamics.add(node.source.value);\n }\n forEachChild(node, visit);\n };\n visit(program);\n return { static: statics, dynamic: dynamics };\n}\n\n/**\n * Reads every module reachable from `entries` and records how each export\n * is used.\n */\nexport async function buildUsageIndex(\n entries: readonly string[],\n host: UsageHost,\n): Promise<UsageIndex> {\n const usage = new Usage();\n // An entry's exports are its public API.\n for (const entry of entries) {\n usage.all(entry);\n }\n const seen = new Set<string>();\n let frontier: string[] = [];\n for (const id of entries) {\n if (SCRIPT.test(id.replace(/\\?.*$/, ''))) {\n frontier.push(id);\n }\n }\n while (frontier.length > 0) {\n for (const id of frontier) {\n seen.add(id);\n }\n async function readModule(id: string): Promise<string[]> {\n const code = await host.read(id);\n let program: Program;\n try {\n program = parse(id.replace(/\\?.*$/, ''), code ?? '');\n } catch {\n return [];\n }\n const { static: statics, dynamic } = collectSpecifiers(program);\n const targets = new Map<string, string>();\n async function resolveSource(source: string): Promise<void> {\n const target = await host.resolve(source, id);\n if (target !== undefined) {\n targets.set(source, target);\n }\n }\n const resolving: Promise<void>[] = [];\n for (const source of [...statics, ...dynamic]) {\n resolving.push(resolveSource(source));\n }\n await Promise.all(resolving);\n // A module loaded with `import()` is used as a whole.\n for (const source of dynamic) {\n const target = targets.get(source);\n if (target !== undefined) {\n usage.all(target);\n }\n }\n recordModule(usage, id, program, targets);\n usage.imports.set(id, [...targets.values()]);\n return [...targets.values()];\n }\n const reading: Promise<string[]>[] = [];\n for (const id of frontier) {\n reading.push(readModule(id));\n }\n // oxlint-disable-next-line no-await-in-loop\n const next = await Promise.all(reading);\n frontier = [];\n for (const id of new Set(next.flat())) {\n if (!seen.has(id) && SCRIPT.test(id.replace(/\\?.*$/, ''))) {\n frontier.push(id);\n }\n }\n }\n return usage;\n}\n","/**\n * `solid-optimizer/vite`: `@solidjs/vite-plugin` with the optimizer built in.\n *\n * It takes the same options as `@solidjs/vite-plugin`, plus `optimizer`, and\n * returns the official plugins with the optimizer wired in. It runs in one of\n * two modes.\n *\n * - Chunk mode keeps JSX through bundling. Each chunk is optimized as a whole\n * and then lowered by Solid's JSX transform, so a component inlines into\n * any other component in the same chunk. It applies to client builds that\n * do not hydrate.\n * - Module mode optimizes each module before the official plugin lowers it.\n * It applies everywhere else. A server build and its client build chunk\n * differently, and hydration needs both to render the same tree, so\n * hydrating builds only optimize within a module.\n */\nimport { readFile } from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\nimport { gzipSync } from 'node:zlib';\nimport remapping from '@jridgewell/remapping';\nimport MagicString from 'magic-string';\nimport type * as SolidCompiler from '@solidjs/compiler';\nimport type { Options as SolidPluginOptions } from '@solidjs/vite-plugin';\nimport solidPlugin from '@solidjs/vite-plugin';\nimport type { Node, Program } from 'oxc-parser';\nimport type { Plugin, ResolvedConfig, Rollup } from 'vite';\nimport { createFilter, minifySync, transformWithOxc } from 'vite';\nimport type { CompileOptions, CompileResult, ModuleConstants } from '../compile';\nimport { compile, readModuleConstants } from '../compile';\nimport { collectParents, forEachChild, isIntrinsicTag, parse } from '../ast';\nimport { analyzeScopes } from '../scope';\nimport { CONTEXT_SAFE_PRIMITIVES } from '../provider';\nimport type { ImportedConstants } from '../constants';\nimport { runtimeImportSources } from '../constants';\nimport type { Primitive } from '../value';\nimport { sharedGlobals } from './globals';\nimport type { Skip } from '../context';\nimport type { OptimizerReport } from './report';\nimport { formatReport } from './report';\nimport { exposeLocals, readExportedComponent, readReexport } from './inject';\nimport { nameNamespaceTags } from './namespace';\nimport { protectRefs, restoreRefs } from './refs';\nimport type { UsageIndex } from './usage';\nimport { buildUsageIndex } from './usage';\nimport {\n MARKER,\n MissingHelperError,\n addMarker,\n generatedImports,\n linkHelpers,\n readMarkers,\n repairJSXSequences,\n} from './runtime';\n\nexport interface OptimizerOptions extends Pick<\n CompileOptions,\n 'fold' | 'inline' | 'alwaysInline' | 'contexts' | 'memos' | 'conditionals' | 'maxPasses'\n> {\n /**\n * Where the optimizer runs.\n *\n * - `auto` uses chunk mode for client builds that do not hydrate, and module mode otherwise.\n * - `module` optimizes each module on its own.\n *\n * @default 'auto'\n */\n mode?: 'auto' | 'module';\n /**\n * Also optimize while serving, in module mode.\n *\n * @default false\n */\n dev?: boolean;\n /**\n * Report what the optimizer leaves alone in each build, and why: each\n * component call that stays a call, each provider that stays, and each\n * memo that stays. `true` prints the report. A function receives it\n * instead, once per build environment.\n *\n * @default false\n */\n report?: boolean | ((report: OptimizerReport) => void);\n /**\n * Packages whose components can be copied into the modules that use\n * them, like `['@kobalte/core']`. A package has to publish its JSX, as\n * most Solid libraries do through the `solid` export condition. A copy\n * lets the bundler drop the original, and the runtime code only it used,\n * even when the package lands in another chunk.\n *\n * @default []\n */\n packages?: readonly string[];\n}\n\nexport type { OptimizerReport } from './report';\n\nexport interface Options extends Partial<SolidPluginOptions> {\n /** Set to `false` to use `@solidjs/vite-plugin` as it is. */\n optimizer?: OptimizerOptions | false;\n}\n\ntype Compiler = typeof SolidCompiler;\ntype JSXOptions = SolidCompiler.TransformOptions;\n\nconst DEFAULT_MODULE_NAME = '@solidjs/web';\n\nconst JSX_MODULE = /\\.[mc]?[jt]sx$/i;\n\n/**\n * Helpers the JSX transform picks between for the same attribute. Inlining\n * can turn one form into the other: a style object that was a prop becomes a\n * literal, which the transform writes one property at a time. A module that\n * needs one keeps the other too.\n */\nconst RELATED_HELPERS: Readonly<Record<string, readonly string[]>> = {\n style: ['setStyleProperty'],\n setStyleProperty: ['style'],\n};\n\nfunction withRelated(helpers: readonly string[]): Set<string> {\n const result = new Set(helpers);\n for (const helper of helpers) {\n for (const related of RELATED_HELPERS[helper] ?? []) {\n result.add(related);\n }\n }\n return result;\n}\n\nconst LAZY_PLACEHOLDER = /\"__SOLID_LAZY_MODULE__:([^\"]+)\"/g;\n\n/**\n * The common kinds of attribute: a class, any other attribute, events, and\n * children. Inlining a component turns a spread onto an element into\n * attributes like these, in a module that may not use their helpers itself.\n * A `ref` can come through a spread too, and a link with a dynamic attribute\n * claims its element. A rarer kind, like `style`, can still need a helper no\n * module imports. The chunk is then lowered without optimizing it.\n */\nconst ATTRIBUTE_SAMPLE = `const a = () => 0;\nexport const Sample = () => (\n <div class={a()} id={a()} onClick={a()} onScroll={a()}>\n {a()}\n <a href=\"/\" title={a()} ref={a} />\n </div>\n);`;\n\n/** The references that are the name of a JSX tag. */\nfunction findTags(references: readonly Node[], parents: ReturnType<typeof collectParents>): Node[] {\n const tags: Node[] = [];\n for (const reference of references) {\n const parent = parents.get(reference);\n if (\n (parent?.type === 'JSXOpeningElement' || parent?.type === 'JSXClosingElement') &&\n parent.name === reference\n ) {\n tags.push(reference);\n }\n }\n return tags;\n}\n\nfunction findSkipReason(\n skipped: readonly { name: string; reason: string }[],\n name: string,\n): string | undefined {\n for (const entry of skipped) {\n if (entry.name === name) {\n return entry.reason;\n }\n }\n return undefined;\n}\n\nfunction hasSpreadAttribute(attributes: readonly { type: string }[]): boolean {\n for (const attribute of attributes) {\n if (attribute.type === 'JSXSpreadAttribute') {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Whether the code spreads anything onto an intrinsic element, or onto\n * `<Dynamic>`, which becomes one once its `component` is known.\n */\nfunction spreadsOntoElement(code: string, filename: string): boolean {\n if (!code.includes('...')) {\n return false;\n }\n let found = false;\n const visit = (node: Node): void => {\n if (found) {\n return;\n }\n if (\n node.type === 'JSXOpeningElement' &&\n node.name.type === 'JSXIdentifier' &&\n (isIntrinsicTag(node.name.name) || node.name.name === 'Dynamic') &&\n hasSpreadAttribute(node.attributes)\n ) {\n found = true;\n return;\n }\n forEachChild(node, visit);\n };\n visit(parse(filename, code));\n return found;\n}\n\n/** A chunk optimized and lowered one way, ready to be compared with another. */\ninterface ChunkCandidate {\n readonly optimized: CompileResult;\n readonly lowered: SolidCompiler.TransformResult;\n readonly linked: { code: string; map: string };\n}\n\n/**\n * How many bytes a chunk takes once minified and gzipped. Minifying drops\n * the runtime code nothing calls anymore, which is what the comparison is\n * for, so it counts even when the build does not minify.\n */\nfunction shippedSize(candidate: ChunkCandidate, filename: string): number {\n const minified = minifySync(filename, candidate.linked.code, {\n module: true,\n compress: true,\n mangle: true,\n });\n return gzipSync(minified.code).length;\n}\n\n/** Whether a module, or the module of a copy's key, is in `node_modules`. */\nfunction isPackageModule(id: string): boolean {\n return stripQuery(id).replaceAll('\\\\', '/').includes('/node_modules/');\n}\n\nfunction loadCompiler(): Compiler {\n // Use the compiler `@solidjs/vite-plugin` uses, so both lower JSX the same way.\n const require = createRequire(import.meta.url);\n const pluginRequire = createRequire(require.resolve('@solidjs/vite-plugin'));\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return pluginRequire('@solidjs/compiler') as Compiler;\n}\n\nfunction stripQuery(id: string): string {\n return id.replace(/\\?.*$/, '');\n}\n\n/**\n * The extensions `options.extensions` registers, and whether each holds\n * TypeScript, read the way `@solidjs/vite-plugin` reads them. A string\n * that contains `tsx` makes every registered extension TypeScript, as it does there.\n * `.tsrx` is left out: the official plugin compiles it on its own path, and\n * the parser here does not read it.\n */\nfunction readExtensions(extensions: Options['extensions']): Map<string, boolean> {\n const list = extensions ?? [];\n let anyTSX = false;\n for (const extension of list) {\n if (typeof extension === 'string' && extension.includes('tsx')) {\n anyTSX = true;\n }\n }\n const registered = new Map<string, boolean>();\n for (const extension of list) {\n const [name, extensionOptions] =\n typeof extension === 'string' ? [extension, undefined] : extension;\n if (name === '.tsrx') {\n continue;\n }\n const typescript = anyTSX || extensionOptions?.typescript === true;\n registered.set(name, (registered.get(name) ?? false) || typescript);\n }\n return registered;\n}\n\n/** The extension of an id, with its leading dot, as the official plugin reads it. */\nfunction readExtension(id: string): string {\n const file = stripQuery(id);\n const index = file.lastIndexOf('.');\n return index < 0 ? '' : file.slice(index);\n}\n\n/**\n * Chains the maps of each step into one, or `null` when the build writes no\n * source maps, since chaining the maps of a large chunk takes a while.\n */\nfunction combineMaps(wanted: boolean, maps: (string | null | undefined)[]): string | null {\n const present: string[] = [];\n for (const map of maps) {\n if (typeof map === 'string') {\n present.push(map);\n }\n }\n if (!wanted || present.length === 0) {\n return null;\n }\n return remapping(present.reverse(), () => null).toString();\n}\n\n/**\n * The local name of each value a module imports, keyed by its source and\n * the name it is imported as: an export name, `default`, or `*`.\n */\nfunction importedNames(program: Program): Map<string, string> {\n const names = new Map<string, string>();\n for (const statement of program.body) {\n if (statement.type !== 'ImportDeclaration' || statement.importKind === 'type') {\n continue;\n }\n for (const specifier of statement.specifiers) {\n let imported = '*';\n if (specifier.type === 'ImportDefaultSpecifier') {\n imported = 'default';\n } else if (specifier.type === 'ImportSpecifier') {\n imported =\n specifier.imported.type === 'Identifier'\n ? specifier.imported.name\n : specifier.imported.value;\n }\n const typeOnly = specifier.type === 'ImportSpecifier' && specifier.importKind === 'type';\n if (!typeOnly) {\n names.set(`${statement.source.value}\\0${imported}`, specifier.local.name);\n }\n }\n }\n return names;\n}\n\n/**\n * A key for a module in the build environment of `context`. The server and\n * client builds transform the same module into different code.\n */\nfunction environmentKey(context: { environment?: { name: string } }, id: string): string {\n return `${context.environment?.name ?? ''}\\0${id}`;\n}\n\nfunction isClient(context: { environment?: { config: { consumer: string } } }): boolean {\n return context.environment?.config.consumer === 'client';\n}\n\nexport default function solidOptimizer(options: Options = {}): Plugin[] {\n const { optimizer: optimizerOption, ...solidOptions } = options;\n const plugins = solidPlugin(solidOptions);\n if (optimizerOption === false) {\n return plugins;\n }\n const optimizer = optimizerOption ?? {};\n const moduleName = solidOptions.solid?.moduleName ?? DEFAULT_MODULE_NAME;\n const moduleSources = [...new Set(['solid-js', DEFAULT_MODULE_NAME, moduleName])];\n const builtIns = new Set(\n solidOptions.solid?.builtIns ?? [\n 'For',\n 'Show',\n 'Switch',\n 'Match',\n 'Loading',\n 'Reveal',\n 'Portal',\n 'Repeat',\n 'Dynamic',\n 'Errored',\n ],\n );\n const compileOptions: CompileOptions = {\n fold: optimizer.fold,\n inline: optimizer.inline,\n alwaysInline: optimizer.alwaysInline,\n contexts: optimizer.contexts,\n memos: optimizer.memos,\n conditionals: optimizer.conditionals,\n maxPasses: optimizer.maxPasses,\n builtIns: [...builtIns],\n moduleSources,\n report: optimizer.report !== undefined && optimizer.report !== false,\n };\n\n /** What the final compile of each chunk or module left alone, by environment. */\n const skips = new Map<string, Skip[]>();\n const addSkips = (\n context: { environment?: { name: string } },\n list?: readonly Skip[],\n module?: string,\n ): void => {\n // A package's own modules are compiled too, but what they leave alone\n // is not something the app can change. A call of a package's component\n // in the app is still reported, from the app's module.\n if (!list || (module !== undefined && isPackageModule(module))) {\n return;\n }\n const environment = context.environment?.name ?? 'client';\n const entries = skips.get(environment) ?? [];\n entries.push(...list);\n skips.set(environment, entries);\n };\n\n let config: ResolvedConfig | undefined;\n /** The `define` entries and `import.meta.env` values every environment shares. */\n let globals: Record<string, Primitive> = {};\n let compiler: Compiler | undefined;\n let filter: ((id: string) => boolean) | undefined;\n const getCompiler = (): Compiler => {\n compiler ??= loadCompiler();\n return compiler;\n };\n\n const isBuild = (): boolean => config?.command === 'build';\n /** Whether the output needs source maps: while serving, or when the build writes them. */\n const wantsMaps = (): boolean => !isBuild() || Boolean(config?.build.sourcemap);\n\n /**\n * The JSX options the official plugin passes for a posture, so the\n * lowering here matches it. Mirrors `getSolidOptions` in `@solidjs/vite-plugin`.\n */\n const jsxOptions = (isSsr: boolean): JSXOptions => {\n let posture: Pick<JSXOptions, 'generate' | 'hydratable'>;\n if (solidOptions.start && !solidOptions.ssr) {\n posture = { generate: isSsr ? 'ssr' : 'dom', hydratable: false };\n } else if (solidOptions.ssr) {\n posture = { generate: isSsr ? 'ssr' : 'dom', hydratable: true };\n } else {\n posture = { generate: 'dom', hydratable: false };\n }\n const dev = solidOptions.dev === true || (solidOptions.dev !== false && !isBuild());\n const names = dev || solidOptions.observe === true;\n const { sourceNames, ...rest } = solidOptions.solid ?? {};\n let resolvedNames: JSXOptions['sourceNames'] = false;\n if (typeof sourceNames === 'boolean') {\n resolvedNames = sourceNames;\n } else if (sourceNames !== undefined || names) {\n const components = sourceNames?.components ?? names;\n const bindings = sourceNames?.bindings ?? names;\n resolvedNames = components || bindings ? { components, bindings } : false;\n }\n return { ...posture, dev, sourceNames: resolvedNames, ...rest };\n };\n\n let sampleHelpers: string[] | undefined;\n /** The helpers the JSX transform uses for attributes in chunk mode. */\n const attributeHelpers = (): string[] => {\n sampleHelpers ??= generatedImports(\n getCompiler().transform(ATTRIBUTE_SAMPLE, { ...jsxOptions(false), filename: 'sample.jsx' })\n .code,\n 'sample.jsx',\n moduleName,\n );\n return sampleHelpers;\n };\n\n /**\n * Whether client builds keep JSX until chunks are rendered.\n */\n const chunkMode = (): boolean => {\n if (!isBuild() || (optimizer.mode ?? 'auto') !== 'auto') {\n return false;\n }\n // A Babel pass or backend has to see the modules, which chunk mode skips.\n if (solidOptions.babel || solidOptions.compiler === 'babel') {\n return false;\n }\n const client = jsxOptions(false);\n return client.generate === 'dom' && client.hydratable !== true;\n };\n\n /** The extensions the official plugin lowers besides the JSX ones. */\n const extensions = readExtensions(solidOptions.extensions);\n\n /** Whether the official plugin lowers the module, so this plugin optimizes it. */\n const isJSXModule = (id: string): boolean => {\n filter ??= createFilter(solidOptions.include, solidOptions.exclude, {\n resolve: config?.root,\n });\n return filter(id) && (JSX_MODULE.test(stripQuery(id)) || extensions.has(readExtension(id)));\n };\n\n /**\n * The file name the parser reads a module's code under. The parser picks\n * its dialect from the extension, so a registered one borrows `.tsx` or\n * `.jsx`, like the official plugin does when it lowers the module.\n */\n const parserFilename = (id: string): string => {\n const file = stripQuery(id);\n const typescript = extensions.get(readExtension(id));\n if (typescript === undefined || JSX_MODULE.test(file)) {\n return file;\n }\n return `${file}${typescript ? '.tsx' : '.jsx'}`;\n };\n\n /** Modules that keep their JSX, which the bundler must parse as JSX. */\n const preserved = new Set<string>();\n\n /**\n * What each module imports and the constants it exports, by module id,\n * once read in full. A module whose constants needed a module with JSX\n * that could not be loaded, to avoid a cycle, is not kept, since another\n * transform may load it.\n *\n * A read in progress is never shared. It can wait for a module with JSX,\n * and a read that waited for it would wait for that module too, without\n * the cycle checks knowing. Two reads of modules that import each other\n * would also wait for each other.\n */\n const moduleConstants = new Map<string, ConstantsResult>();\n\n interface ConstantsResult {\n readonly constants: ModuleConstants | undefined;\n /** Whether a module with JSX was left out to avoid a cycle. */\n readonly partial: boolean;\n }\n\n /**\n * The module an import resolves to, when its constants can be read, and\n * whether it has JSX. Dependencies are skipped to keep the build fast.\n */\n async function resolveConstantModule(\n context: Rollup.PluginContext,\n specifier: string,\n importer: string,\n ): Promise<{ id: string; jsx: boolean } | undefined> {\n if (moduleSources.includes(specifier)) {\n return undefined;\n }\n const resolved = await context.resolve(specifier, importer);\n if (!resolved || resolved.external || resolved.id.includes('/node_modules/')) {\n return undefined;\n }\n return { id: resolved.id, jsx: isJSXModule(resolved.id) };\n }\n\n /**\n * The code of a module with JSX to read constants from, as this plugin's\n * transform returns it. `transform` is the module whose transform waits for\n * it, which the cycle checks are about. `undefined` when that could wait\n * for itself.\n */\n async function loadJSXModule(\n context: Rollup.PluginContext,\n transform: string,\n target: string,\n ): Promise<string | undefined> {\n return chunkMode() && isClient(context)\n ? loadModule(context, transform, target)\n : loadRecorded(context, transform, target);\n }\n\n /**\n * The constants of the modules `code` imports, keyed by import specifier.\n *\n * Each module is read as the bundler loads it, after every plugin has\n * transformed it. A module with JSX is read from this plugin's own output\n * for it, unless its transform could be waiting for `transform`.\n */\n async function importedConstants(\n context: Rollup.PluginContext,\n imports: readonly string[],\n importer: string,\n visiting: ReadonlySet<string>,\n transform: string,\n ): Promise<{ constants: ImportedConstants; partial: boolean }> {\n let partial = false;\n async function readImport(\n specifier: string,\n ): Promise<readonly [string, Readonly<Record<string, Primitive>>] | undefined> {\n const target = await resolveConstantModule(context, specifier, importer);\n if (target === undefined || visiting.has(target.id)) {\n return undefined;\n }\n const result = await readConstants(context, target, visiting, transform);\n partial ||= result.partial;\n if (!result.constants || Object.keys(result.constants.exports).length === 0) {\n return undefined;\n }\n return [specifier, result.constants.exports] as const;\n }\n const reading = [];\n for (const specifier of imports) {\n reading.push(readImport(specifier));\n }\n const entries = await Promise.all(reading);\n const constants: Record<string, Readonly<Record<string, Primitive>>> = {};\n for (const entry of entries) {\n if (entry !== undefined) {\n constants[entry[0]] = entry[1];\n }\n }\n return { constants, partial };\n }\n\n async function readConstants(\n context: Rollup.PluginContext,\n target: { id: string; jsx: boolean },\n visiting: ReadonlySet<string>,\n transform: string,\n ): Promise<ConstantsResult> {\n const { id } = target;\n const known = moduleConstants.get(id);\n if (known) {\n return known;\n }\n const result = await (async (): Promise<ConstantsResult> => {\n let code: string | null | undefined;\n if (target.jsx) {\n code = await loadJSXModule(context, transform, id);\n if (code === undefined) {\n return { constants: undefined, partial: true };\n }\n } else {\n ({ code } = await context.load({ id }));\n }\n if (code === null) {\n return { constants: undefined, partial: false };\n }\n // Loaded code is JavaScript, whatever the module was written in, and keeps its JSX.\n const filename = `${stripQuery(id)}.${target.jsx ? 'jsx' : 'js'}`;\n try {\n const own = readModuleConstants(code, { filename, globalConstants: globals });\n if (own.imports.length === 0) {\n return { constants: own, partial: false };\n }\n const imported = await importedConstants(\n context,\n own.imports,\n id,\n new Set([...visiting, id]),\n transform,\n );\n return {\n constants: readModuleConstants(code, {\n filename,\n importedConstants: imported.constants,\n globalConstants: globals,\n }),\n partial: imported.partial,\n };\n } catch (error) {\n // A module the parser rejects fails its own transform, with a better error.\n if (error instanceof SyntaxError) {\n return { constants: undefined, partial: false };\n }\n throw error;\n }\n })();\n if (!result.partial) {\n moduleConstants.set(id, result);\n }\n return result;\n }\n\n /**\n * The compile options for a module, with the constants of its imports.\n */\n async function moduleOptions(\n context: Rollup.PluginContext,\n code: string,\n id: string,\n ): Promise<CompileOptions> {\n const filename = stripQuery(id);\n const parsedAs = parserFilename(id);\n // The dev server cannot give back the code of a loaded module.\n if (optimizer.fold === false || !isBuild()) {\n return { ...compileOptions, filename: parsedAs, sourceMap: wantsMaps() };\n }\n const { imports } = readModuleConstants(code, { filename: parsedAs });\n const imported = await importedConstants(context, imports, filename, new Set([filename]), id);\n return {\n ...compileOptions,\n filename: parsedAs,\n sourceMap: wantsMaps(),\n importedConstants: imported.constants,\n globalConstants: globals,\n };\n }\n\n async function resolveLazyModuleUrls(\n context: Rollup.TransformPluginContext,\n code: string,\n importer: string,\n ): Promise<string> {\n const root = config?.root ?? process.cwd();\n let result = code;\n for (const match of code.matchAll(LAZY_PLACEHOLDER)) {\n const specifier = match.at(1);\n if (specifier === undefined) {\n continue;\n }\n // oxlint-disable-next-line no-await-in-loop\n const resolved = await context.resolve(specifier, importer);\n if (resolved) {\n const queryIndex = resolved.id.indexOf('?');\n const file = queryIndex === -1 ? resolved.id : resolved.id.slice(0, queryIndex);\n const query = queryIndex === -1 ? '' : resolved.id.slice(queryIndex);\n const relative = path.relative(root, file).split(path.sep).join('/') + query;\n result = result.replace(match[0], JSON.stringify(relative));\n }\n }\n return result;\n }\n\n /** The modules each transform waits for, so two never wait for each other. */\n const waiting = new Map<string, Set<string>>();\n\n /** Whether the transform of `from` waits, directly or not, for `to`. */\n const waitsFor = (from: string, to: string): boolean => {\n const seen = new Set<string>();\n const stack = [from];\n for (let current = stack.pop(); current !== undefined; current = stack.pop()) {\n if (current === to) {\n return true;\n }\n if (!seen.has(current)) {\n seen.add(current);\n stack.push(...(waiting.get(current) ?? []));\n }\n }\n return false;\n };\n\n /**\n * The code of a module with JSX, as the bundler loads it. `undefined`\n * when that module's transform waits for the importer, which would then\n * wait for it in turn.\n */\n async function loadModule(\n context: Rollup.PluginContext,\n importer: string,\n target: string,\n ): Promise<string | undefined> {\n if (waitsFor(target, importer)) {\n return undefined;\n }\n const targets = waiting.get(importer) ?? new Set<string>();\n targets.add(target);\n waiting.set(importer, targets);\n try {\n const info = await context.load({ id: target });\n return info.code ?? undefined;\n } finally {\n targets.delete(target);\n }\n }\n\n /**\n * The code of each module with JSX as this plugin's module step returned\n * it, before Solid's JSX transform lowers it. In module mode, an importer\n * copies components from it.\n */\n const recorded = new Map<string, string>();\n\n /**\n * Whether components can be copied from a module: one of the app's, or\n * one of a package listed in `optimizer.packages`.\n */\n const isCopyable = (id: string): boolean => {\n const file = stripQuery(id).replaceAll('\\\\', '/');\n if (!file.includes('/node_modules/')) {\n return true;\n }\n for (const name of optimizer.packages ?? []) {\n if (file.includes(`/node_modules/${name}/`)) {\n return true;\n }\n }\n return false;\n };\n\n /** The modules each module imports, read from its file. */\n const localImports = new Map<string, Promise<string[]>>();\n\n /**\n * The code of a module as its file holds it. A module with no file, like\n * a virtual module a plugin generates, is loaded instead, unless it has\n * JSX: this plugin transforms such a module, so loading it could wait for\n * the transform that asks. Its imports are then not followed.\n */\n async function readModuleCode(\n context: Rollup.PluginContext,\n id: string,\n ): Promise<string | undefined> {\n try {\n return await readFile(stripQuery(id), 'utf8');\n } catch {\n if (isJSXModule(id)) {\n return undefined;\n }\n }\n try {\n return (await context.load({ id })).code ?? undefined;\n } catch {\n return undefined;\n }\n }\n\n /**\n * The modules a module imports at runtime that a transform can wait for:\n * the app's, those of packages listed in `optimizer.packages`, and virtual\n * modules. A transform only waits for a module it copies from, and it only\n * copies from those, so a module of another package is never in a loop of\n * transforms that wait for each other. A virtual module can re-export the\n * app, so a listed package can import the app back through one, like a\n * docs framework that imports its theme's layout.\n *\n * Imports only used as types are left out, since TypeScript drops them,\n * and so are Solid's own modules and Node's built-ins. The imports come\n * from the file on disk, so they do not depend on the order modules are\n * transformed in. Modules without JSX count too, since reading their\n * constants can load a module with JSX.\n */\n async function findLocalImports(context: Rollup.PluginContext, id: string): Promise<string[]> {\n let pending = localImports.get(id);\n if (!pending) {\n pending = (async () => {\n const code = await readModuleCode(context, id);\n if (code === undefined) {\n return [];\n }\n let program: Program;\n try {\n // A loaded module is JavaScript, whatever its id says.\n program = parse(\n /\\.[cm]?[jt]sx?$/.test(stripQuery(id)) ? stripQuery(id) : `${id}.js`,\n code,\n );\n } catch {\n return [];\n }\n const resolving = [];\n for (const source of runtimeImportSources(program)) {\n if (!moduleSources.includes(source) && !source.startsWith('node:')) {\n resolving.push(context.resolve(source, id));\n }\n }\n const resolved = await Promise.all(resolving);\n const local: string[] = [];\n for (const target of resolved) {\n if (target && !target.external && isCopyable(target.id)) {\n local.push(target.id);\n }\n }\n return local;\n })();\n localImports.set(id, pending);\n }\n return pending;\n }\n\n /** Whether `from` imports `to`, directly or through other modules. */\n async function reaches(\n context: Rollup.PluginContext,\n from: string,\n to: string,\n ): Promise<boolean> {\n const seen = new Set<string>();\n let frontier = [from];\n while (frontier.length > 0) {\n if (frontier.includes(to)) {\n return true;\n }\n for (const id of frontier) {\n seen.add(id);\n }\n const reading = [];\n for (const id of frontier) {\n reading.push(findLocalImports(context, id));\n }\n // oxlint-disable-next-line no-await-in-loop\n const next = await Promise.all(reading);\n frontier = [];\n for (const id of new Set(next.flat())) {\n if (!seen.has(id)) {\n frontier.push(id);\n }\n }\n }\n return false;\n }\n\n /**\n * The code of a module with JSX before Solid's JSX transform, with its\n * types stripped. A module that imports the importer back is skipped, so\n * no two transforms wait for each other, and the server and client builds\n * skip the same ones.\n */\n async function loadRecorded(\n context: Rollup.PluginContext,\n importer: string,\n target: string,\n ): Promise<string | undefined> {\n if (await reaches(context, target, importer)) {\n return undefined;\n }\n await context.load({ id: target });\n const code = recorded.get(environmentKey(context, target));\n if (code === undefined) {\n return undefined;\n }\n const stripped = await transformWithOxc(code, parserFilename(target), {\n jsx: 'preserve',\n sourcemap: false,\n });\n return stripped.code;\n }\n\n /**\n * The scripts a virtual entry runs, like the server entry `start` mode\n * generates: the app's modules it imports. It has no file to read, and\n * the server and client builds have to see the same uses of each export.\n * `undefined` when the entry has not been loaded or imports none.\n */\n function virtualEntryScripts(context: Rollup.PluginContext, id: string): string[] | undefined {\n const info = context.getModuleInfo(id);\n if (!info || info.code === null) {\n return undefined;\n }\n const scripts: string[] = [];\n for (const imported of [...info.importedIds, ...info.dynamicallyImportedIds]) {\n // Packages and other virtual modules hold none of the app's components.\n if (!imported.startsWith('\\0') && !imported.includes('/node_modules/')) {\n scripts.push(imported);\n }\n }\n return scripts.length > 0 ? scripts : undefined;\n }\n\n /**\n * The scripts an entry runs: the entry itself, or the module scripts of an\n * HTML entry. `undefined` when an HTML entry has an inline module script,\n * whose imports the usage index cannot read.\n */\n async function scriptEntries(\n context: Rollup.PluginContext,\n id: string,\n ): Promise<string[] | undefined> {\n if (/\\.[mc]?[jt]sx?(?:\\?|$)/.test(id)) {\n return [id];\n }\n let html: string;\n try {\n html = await readFile(stripQuery(id), 'utf8');\n } catch {\n return virtualEntryScripts(context, id);\n }\n const scripts: string[] = [];\n for (const [tag] of html.matchAll(/<script\\b[^>]*>/gi)) {\n if (!/\\btype\\s*=\\s*[\"']?module/i.test(tag)) {\n continue;\n }\n const src = /\\bsrc\\s*=\\s*[\"']([^\"']+)[\"']/i.exec(tag)?.[1];\n if (src === undefined) {\n return undefined;\n }\n // oxlint-disable-next-line no-await-in-loop\n const resolved = await context.resolve(src, id);\n if (!resolved || resolved.external) {\n return undefined;\n }\n scripts.push(resolved.id);\n }\n return scripts;\n }\n\n /** How the app uses each export, built once per environment and build. */\n const usageIndexes = new Map<string, Promise<UsageIndex>>();\n\n /**\n * How the app uses each export, read from the modules the entries reach.\n */\n async function usageIndex(context: Rollup.PluginContext): Promise<UsageIndex> {\n const key = environmentKey(context, '');\n let pending = usageIndexes.get(key);\n if (!pending) {\n pending = (async () => {\n const reading = [];\n for (const id of context.getModuleIds()) {\n if (context.getModuleInfo(id)?.isEntry === true) {\n reading.push(scriptEntries(context, id));\n }\n }\n const entries = await Promise.all(reading);\n // A script the index cannot read could use any export.\n const scriptIds: string[] = [];\n let known = true;\n for (const scripts of entries) {\n if (scripts === undefined) {\n known = false;\n break;\n }\n scriptIds.push(...scripts);\n }\n return buildUsageIndex(known ? scriptIds : [], {\n resolve: async (source, importer) => {\n const resolved = await context.resolve(source, importer);\n return !resolved || resolved.external || resolved.id.includes('/node_modules/')\n ? undefined\n : resolved.id;\n },\n read: async (id) => {\n try {\n return await readFile(stripQuery(id), 'utf8');\n } catch {\n return undefined;\n }\n },\n });\n })();\n usageIndexes.set(key, pending);\n }\n return pending;\n }\n\n /**\n * The text that imports a binding under `local`.\n */\n function importText(local: string, imported: string, source: string): string {\n const from = JSON.stringify(source);\n if (imported === '*') {\n return `import * as ${local} from ${from};`;\n }\n if (imported === 'default') {\n return `import ${local} from ${from};`;\n }\n return `import { ${imported} as ${local} } from ${from};`;\n }\n\n interface Copy {\n /** The module and export the copy comes from. */\n readonly key: string;\n /** Whether it comes from a package in `optimizer.packages`. */\n readonly fromPackage: boolean;\n readonly name: string;\n /** The tags in the importer that call it. */\n readonly tags: Node[];\n readonly text: string;\n }\n\n interface CopyState {\n /** Components that cannot be copied, or were left over before. */\n readonly excluded: Set<string>;\n /** The contexts the copies import, by module. */\n readonly contexts: Map<string, Set<string>>;\n /** Imports a binding into the importer, and gives its local name. */\n readonly importAs: (base: string, imported: string, from: string) => string;\n /** The code of a module with JSX to copy from, or `undefined` to skip it. */\n readonly load: (target: string) => Promise<string | undefined>;\n /** Where the copies that are not made are recorded, when the report is on. */\n readonly skips: Skip[] | undefined;\n }\n\n /** The listed packages already warned about, by environment. */\n const warnedPackages = new Set<string>();\n\n /**\n * Warns once when a listed package is external, like a server build that\n * leaves it to Node. Its components are not copied there, so a build that\n * copies them would hydrate different markup.\n */\n const warnExternalPackage = (context: Rollup.PluginContext, source: string): void => {\n let name: string | undefined;\n for (const item of optimizer.packages ?? []) {\n if (source === item || source.startsWith(`${item}/`)) {\n name = item;\n break;\n }\n }\n const key = environmentKey(context, name ?? '');\n if (name === undefined || warnedPackages.has(key)) {\n return;\n }\n warnedPackages.add(key);\n context.warn(\n `[solid-optimizer] ${name} is external in this build, so its components are not copied. Bundle it, like with \\`ssr.noExternal\\`, so every build copies the same components.`,\n );\n };\n\n /**\n * Reads the component `source` exports as `imported`, and imports what it\n * needs into the importer. `undefined` when it cannot be copied.\n */\n async function copyImported(\n context: Rollup.PluginContext,\n id: string,\n source: string,\n requested: string,\n state: CopyState,\n ): Promise<{ key: string; text: (name: string) => string } | undefined> {\n const skip = (reason: string): void => {\n state.skips?.push({ pass: 'inline', reason, name: `${requested} (${source})` });\n };\n // The export's name in the module that declares it, past any re-exports.\n let imported = requested;\n let resolved = await context.resolve(source, id);\n if (!resolved || resolved.external) {\n warnExternalPackage(context, source);\n skip('copy-external');\n return undefined;\n }\n if (!isCopyable(resolved.id)) {\n skip('copy-package');\n return undefined;\n }\n // A module that re-exports the component by name, like a library's\n // entry, leads to the module that declares it.\n for (let depth = 0; depth < 8 && isJSXModule(resolved.id); depth += 1) {\n // oxlint-disable-next-line no-await-in-loop\n const code = await state.load(resolved.id);\n const reexport =\n code === undefined ? undefined : readReexport(code, parserFilename(resolved.id), imported);\n if (!reexport) {\n break;\n }\n // oxlint-disable-next-line no-await-in-loop\n const next = await context.resolve(reexport.source, resolved.id);\n if (!next || next.external || !isCopyable(next.id)) {\n skip('copy-package');\n return undefined;\n }\n resolved = next;\n imported = reexport.imported;\n }\n if (resolved.id === id) {\n return undefined;\n }\n if (!isJSXModule(resolved.id)) {\n skip('copy-not-jsx');\n return undefined;\n }\n const key = `${resolved.id}\\0${imported}`;\n if (state.excluded.has(key)) {\n return undefined;\n }\n const loaded = await state.load(resolved.id);\n if (loaded === undefined) {\n state.excluded.add(key);\n skip('copy-cycle');\n return undefined;\n }\n const component = readExportedComponent(\n loaded,\n parserFilename(resolved.id),\n imported,\n moduleSources,\n );\n if (!component) {\n state.excluded.add(key);\n skip('copy-shape');\n return undefined;\n }\n // Its copy would still call a component of that module, so the call\n // site gains nothing. Moving its template out of its module makes both\n // compress worse.\n if (component.wrapsLocal) {\n state.excluded.add(key);\n skip('copy-wrapper');\n return undefined;\n }\n // Each import of the module resolves from it, so the copy imports the same module.\n const targets = new Map<string, string>();\n for (const dependency of component.dependencies.values()) {\n if (dependency.kind === 'import' && !moduleSources.includes(dependency.source)) {\n // oxlint-disable-next-line no-await-in-loop\n const target = await context.resolve(dependency.source, resolved.id);\n if (!target) {\n state.excluded.add(key);\n skip('copy-external');\n return undefined;\n }\n if (!target.id.startsWith('\\0')) {\n targets.set(dependency.source, target.external ? dependency.source : target.id);\n continue;\n }\n // A virtual module's id cannot be imported again, so the copy keeps\n // the specifier, when it means the same module from the importer.\n // oxlint-disable-next-line no-await-in-loop\n const fromImporter = await context.resolve(dependency.source, id);\n if (fromImporter?.id !== target.id) {\n state.excluded.add(key);\n skip('copy-virtual');\n return undefined;\n }\n targets.set(dependency.source, dependency.source);\n }\n }\n const rename = new Map<string, string>();\n for (const [local, dependency] of component.dependencies) {\n if (dependency.kind === 'import') {\n const from = targets.get(dependency.source) ?? dependency.source;\n rename.set(local, state.importAs(local, dependency.imported, from));\n continue;\n }\n rename.set(local, state.importAs(local, dependency.exported, resolved.id));\n if (dependency.context) {\n const known = state.contexts.get(resolved.id) ?? new Set<string>();\n known.add(dependency.exported);\n state.contexts.set(resolved.id, known);\n }\n }\n return { key, text: (name) => component.copy(name, rename) };\n }\n\n /**\n * Copies the components a module imports from other modules with JSX into\n * it, and inlines them there. A copy the inline pass cannot inline at\n * every call is left out, so a component is never in both places. Copies\n * can import components in turn, which a few more rounds take in.\n */\n async function inlineImports(\n context: Rollup.PluginContext,\n source: string,\n id: string,\n compileOptionsOfModule: CompileOptions,\n load: (target: string) => Promise<string | undefined>,\n copySkips?: Skip[],\n ): Promise<{ code: string; maps: string[]; skipped?: Skip[] } | undefined> {\n const filename = parserFilename(id);\n const maps: string[] = [];\n let skipped: Skip[] | undefined;\n const excluded = new Set<string>();\n const usage = await usageIndex(context);\n // The components copied here that leave their module, by module.\n const absorbed = new Map<string, Set<string>>();\n // How many modules use the original of a copy, this one included.\n const countUsers = (copy: Copy): number => {\n const [module = '', exported = ''] = copy.key.split('\\0');\n return usage.users(module, exported, id, absorbed);\n };\n // The contexts the copies import, which the provider pass needs to know.\n const contexts = new Map<string, Set<string>>();\n let code = source;\n const copyNames = new Map<string, string>();\n for (let round = 0; round < 4; round += 1) {\n const program = parse(filename, code);\n const scopes = analyzeScopes(program);\n const parents = collectParents(program);\n const names = new Set(scopes.names);\n const fresh = (base: string): string => {\n let name = base;\n for (let index = 1; names.has(name); index += 1) {\n name = `${base}$${String(index)}`;\n }\n names.add(name);\n return name;\n };\n\n // The module's own imports, so a copy reuses one instead of adding another.\n // Two imports of one context would be two bindings to the provider pass.\n const existing = importedNames(program);\n // Imports added in this round, shared by every copy.\n const imports: string[] = [];\n const added = new Map<string, string>();\n const importAs = (base: string, imported: string, from: string): string => {\n const key = `${from}\\0${imported}`;\n const known = existing.get(key) ?? added.get(key);\n if (known !== undefined) {\n return known;\n }\n const name = fresh(base);\n added.set(key, name);\n imports.push(importText(name, imported, from));\n return name;\n };\n\n // Each imported binding used as a JSX tag, and its copy.\n const copies: Copy[] = [];\n for (const statement of program.body) {\n if (\n statement.type !== 'ImportDeclaration' ||\n statement.importKind === 'type' ||\n moduleSources.includes(statement.source.value)\n ) {\n continue;\n }\n for (const specifier of statement.specifiers) {\n const binding = scopes.root.bindings.get(specifier.local.name);\n // Only tags are copied. The import stays for any other use.\n const tags = findTags(binding?.references ?? [], parents);\n if (\n specifier.type === 'ImportNamespaceSpecifier' ||\n binding?.imported === undefined ||\n tags.length === 0\n ) {\n continue;\n }\n // oxlint-disable-next-line no-await-in-loop\n const copy = await copyImported(context, id, statement.source.value, binding.imported, {\n excluded,\n contexts,\n importAs,\n load,\n skips: copySkips,\n });\n if (copy && copySkips) {\n // A copy the inline pass leaves behind is recorded under the reason it gave.\n copyNames.set(copy.key, `${binding.imported} (${statement.source.value})`);\n }\n if (copy) {\n const name = fresh(specifier.local.name);\n const fromPackage = isPackageModule(copy.key);\n copies.push({ key: copy.key, fromPackage, name, tags, text: copy.text(name) });\n }\n }\n }\n if (copies.length === 0) {\n break;\n }\n\n // Drop the copies the inline pass leaves behind, and try again without them.\n let result: CompileResult | undefined;\n let edit: MagicString | undefined;\n for (let attempt = 0; attempt < 4 && copies.length > 0; attempt += 1) {\n edit = new MagicString(code);\n for (const copy of copies) {\n for (const tag of copy.tags) {\n edit.overwrite(tag.start, tag.end, copy.name);\n }\n edit.append(`\\n${copy.text}\\n`);\n }\n edit.append(`\\n${imports.join('\\n')}\\n`);\n const importedContexts: Record<string, string[]> = {};\n for (const [module, exported] of contexts) {\n importedContexts[module] = [...exported];\n }\n const sharedComponents: Record<string, number> = {};\n const alwaysInlineComponents: string[] = [];\n for (const copy of copies) {\n const users = countUsers(copy);\n if (users !== 1) {\n sharedComponents[copy.name] = users;\n }\n if (copy.fromPackage) {\n alwaysInlineComponents.push(copy.name);\n }\n }\n result = compile(edit.toString(), {\n ...compileOptionsOfModule,\n filename,\n sourceMap: wantsMaps(),\n importedContexts,\n // The original of a copy stays in its module for its other users.\n sharedComponents,\n // The estimate cannot see what a package's own modules use, so a\n // copy of its component never counts its declaration, or the\n // runtime code only it used, as removed. Listing the package asks\n // for its components to inline wherever they can be.\n alwaysInlineComponents,\n });\n const left = analyzeScopes(parse(filename, result.code)).root.bindings;\n const stuck = [];\n for (const copy of copies) {\n if (left.has(copy.name)) {\n stuck.push(copy);\n }\n }\n if (stuck.length === 0) {\n break;\n }\n for (const copy of stuck) {\n excluded.add(copy.key);\n copies.splice(copies.indexOf(copy), 1);\n const reason = findSkipReason(result.skipped ?? [], copy.name);\n copySkips?.push({\n pass: 'inline',\n reason: `copy-${reason ?? 'left'}`,\n name: copyNames.get(copy.key) ?? copy.name,\n });\n }\n result = undefined;\n }\n if (!result || !edit) {\n break;\n }\n // Their uses of other components move here with them. Count every copy's\n // users first, since moving one changes what the next one counts.\n const sole: Copy[] = [];\n for (const copy of copies) {\n if (countUsers(copy) === 1) {\n sole.push(copy);\n }\n }\n for (const copy of sole) {\n const [module = '', exported = ''] = copy.key.split('\\0');\n absorbed.set(module, new Set([...(absorbed.get(module) ?? []), exported]));\n }\n if (wantsMaps()) {\n maps.push(\n edit.generateMap({ source: filename, hires: true, includeContent: true }).toString(),\n );\n }\n if (result.map) {\n maps.push(result.map.toString());\n }\n code = result.code;\n ({ skipped } = result);\n }\n return code === source ? undefined : { code, maps, skipped };\n }\n\n /**\n * Prepares a client module for chunk mode. It runs the passes the official\n * plugin runs before lowering JSX, and adds the helper marker instead of\n * lowering.\n */\n async function keepJSX(\n context: Rollup.TransformPluginContext,\n source: string,\n id: string,\n ): Promise<Rollup.TransformResult> {\n const filename = parserFilename(id);\n const solidCompiler = getCompiler();\n const maps: (string | null | undefined)[] = [];\n let code = source;\n\n // Fold and inline memos before bundling. A branch that folds away takes\n // its imports and `lazy()` chunks out of the module graph, which the\n // chunk step can no longer do. Inlining waits for the chunk, where the\n // components it can reach are known.\n const moduleCompileOptions = await moduleOptions(context, code, id);\n const local = compile(code, { ...moduleCompileOptions, inline: false });\n // `map` is `null` when nothing changed, and when the build writes no maps.\n code = local.code;\n if (local.map) {\n maps.push(local.map.toString());\n }\n // `<Ns.Member>` would keep a namespace object, which lowered code does not.\n const named = nameNamespaceTags(code, filename);\n if (named) {\n code = named.code;\n maps.push(named.map);\n }\n\n // Components imported from other modules inline here, so the bundler\n // drops them, and what only they used, before it splits the chunks.\n if (moduleCompileOptions.inline !== false) {\n const copySkips: Skip[] | undefined = compileOptions.report ? [] : undefined;\n const imported = await inlineImports(\n context,\n code,\n id,\n moduleCompileOptions,\n async (target) => loadModule(context, id, target),\n copySkips,\n );\n // The rest of the report comes from the chunk this module ends up in.\n addSkips(context, copySkips, id);\n if (imported) {\n code = imported.code;\n maps.push(...imported.maps);\n }\n }\n // An entry's exports are its public API, so it gets no extra names.\n const exposed = context.getModuleInfo(id)?.isEntry ? undefined : exposeLocals(code, filename);\n if (exposed) {\n code = exposed.code;\n maps.push(exposed.map);\n }\n\n const lazy = await solidCompiler.transformLazyAsync(code, { filename, sourceMap: wantsMaps() });\n code = lazy.code;\n maps.push(lazy.map);\n\n // The helpers the module's JSX needs, as written and with its own\n // components inlined. Inlining can turn a spread into attributes, which\n // need helpers the spread did not.\n const lowering = jsxOptions(false);\n const needed = new Set<string>();\n const inlined =\n moduleCompileOptions.inline === false\n ? undefined\n : compile(code, { ...moduleCompileOptions, sourceMap: false });\n for (const version of new Set([code, inlined?.code ?? code])) {\n // oxlint-disable-next-line no-await-in-loop\n const dryRun = await solidCompiler.transformAsync(version, { ...lowering, filename });\n for (const helper of generatedImports(dryRun.code, filename, moduleName)) {\n needed.add(helper);\n }\n }\n // A component inlined into another module of the chunk can turn its\n // spread into any attribute.\n if (moduleCompileOptions.inline !== false && spreadsOntoElement(code, filename)) {\n for (const helper of attributeHelpers()) {\n needed.add(helper);\n }\n }\n\n if (needed.size > 0) {\n const marked = addMarker(code, filename, {\n moduleName,\n helpers: withRelated([...needed]),\n moduleSources,\n // The passes also recognize these primitives, which a chunk renames\n // too. `render` takes a callback that statements can move into, and\n // `children` can be inlined like a memo.\n builtIns: new Set([\n ...builtIns,\n 'createContext',\n 'render',\n 'children',\n ...CONTEXT_SAFE_PRIMITIVES,\n ]),\n });\n if (marked) {\n code = marked.code;\n maps.push(marked.map);\n }\n }\n\n // The bundler has to see that a `ref` writes its variable. See `refs.ts`.\n const protectedRefs = protectRefs(code, filename);\n if (protectedRefs) {\n code = protectedRefs.code;\n maps.push(protectedRefs.map);\n }\n\n code = await resolveLazyModuleUrls(context, code, stripQuery(id));\n preserved.add(id);\n return { code, map: combineMaps(wantsMaps(), maps) };\n }\n\n let main: Plugin | undefined;\n for (const plugin of plugins) {\n if (plugin.name === 'solid') {\n main = plugin;\n break;\n }\n }\n const originalTransform = main?.transform;\n const originalHandler =\n typeof originalTransform === 'function' ? originalTransform : originalTransform?.handler;\n if (main && originalHandler) {\n main.transform = async function transform(code, id, transformOptions) {\n if (chunkMode() && isClient(this) && isJSXModule(id)) {\n return keepJSX(this, code, id);\n }\n return originalHandler.call(this, code, id, transformOptions);\n };\n }\n\n const modulePlugin: Plugin = {\n name: 'solid-optimizer:module',\n enforce: 'pre',\n configResolved(resolved) {\n config = resolved;\n globals = sharedGlobals(resolved);\n },\n buildStart() {\n moduleConstants.clear();\n localImports.clear();\n usageIndexes.clear();\n skips.delete(this.environment.name);\n },\n watchChange() {\n moduleConstants.clear();\n localImports.clear();\n usageIndexes.clear();\n },\n async transform(source, id) {\n if (!isBuild() && optimizer.dev !== true) {\n return null;\n }\n if ((chunkMode() && isClient(this)) || !isJSXModule(id)) {\n return null;\n }\n const filename = parserFilename(id);\n const sourceOptions = await moduleOptions(this, source, id);\n const result = compile(source, sourceOptions);\n let code = result.code;\n const maps: (string | null | undefined)[] = [result.map?.toString()];\n // Components imported from other modules inline here too. The server\n // and client builds read the same modules, so they inline the same ones.\n let { skipped } = result;\n if (isBuild() && sourceOptions.inline !== false) {\n const copySkips: Skip[] | undefined = compileOptions.report ? [] : undefined;\n const imported = await inlineImports(\n this,\n code,\n id,\n sourceOptions,\n async (target) => loadRecorded(this, id, target),\n copySkips,\n );\n addSkips(this, copySkips, id);\n if (imported) {\n code = imported.code;\n maps.push(...imported.maps);\n skipped = imported.skipped ?? skipped;\n }\n // Entries get the extra exports too. The server and client builds\n // have different entries, and both have to copy the same components.\n const exposed = exposeLocals(code, filename);\n if (exposed) {\n code = exposed.code;\n maps.push(exposed.map);\n }\n }\n addSkips(this, skipped, id);\n recorded.set(environmentKey(this, id), code);\n if (code === source) {\n return null;\n }\n return { code, map: combineMaps(wantsMaps(), maps) };\n },\n };\n\n const chunkPlugin: Plugin = {\n name: 'solid-optimizer:chunk',\n enforce: 'post',\n config(_, env) {\n if (env.command !== 'build') {\n return undefined;\n }\n // Kept JSX has to reach the bundler as JSX. Modules the official plugin\n // lowers have no JSX left, so this changes nothing for them.\n return {\n oxc: { jsx: 'preserve' },\n build: { rolldownOptions: { transform: { jsx: 'preserve' } } },\n };\n },\n renderChunk: {\n order: 'pre',\n handler(code, chunk) {\n if (!chunkMode() || !isClient(this) || !code.includes(MARKER)) {\n return null;\n }\n const filename = chunk.fileName;\n let repaired: { code: string; map: string } | undefined;\n let runtime: ReturnType<typeof readMarkers>;\n try {\n runtime = readMarkers(code, filename);\n } catch (error) {\n repaired = error instanceof SyntaxError ? repairJSXSequences(code, filename) : undefined;\n if (!repaired) {\n throw error;\n }\n runtime = readMarkers(repaired.code, filename);\n }\n if (!runtime) {\n return null;\n }\n const restored = restoreRefs(runtime.code, filename);\n const chunkCode = restored?.code ?? runtime.code;\n const lowerChunk = (source: string): SolidCompiler.TransformResult =>\n getCompiler().transform(source, {\n ...jsxOptions(false),\n // The compiler picks its parser by extension, and a chunk is a `.js` file with JSX.\n filename: `${filename}.jsx`,\n sourceMap: wantsMaps(),\n });\n const chunkOptions: CompileOptions = {\n ...compileOptions,\n filename,\n sourceMap: wantsMaps(),\n constantVars: true,\n builtInAliases: runtime.builtInAliases,\n };\n // Each module keeps the helpers its own JSX needs, and a merged tree\n // can need one none of them did. Such a candidate is left out.\n let missing: MissingHelperError | undefined;\n const lowerCandidate = (optimized: CompileResult): ChunkCandidate | undefined => {\n const lowered = lowerChunk(optimized.code);\n try {\n const linked = linkHelpers(lowered.code, filename, moduleName, runtime.helpers);\n return { optimized, lowered, linked };\n } catch (error) {\n if (!(error instanceof MissingHelperError)) {\n throw error;\n }\n missing ??= error;\n return undefined;\n }\n };\n let chosen = lowerCandidate(compile(chunkCode, chunkOptions));\n // The estimate weighs each component on its own. It cannot see the\n // runtime code that only leaves the chunk once every call that needs\n // it is inlined, like `<Dynamic>`, `merge()`, and `omit()` behind a\n // headless library's components. So the chunk is also built with\n // every component inlined that can be, and the smaller one is kept,\n // as minified and gzipped.\n if (compileOptions.alwaysInline !== true) {\n const always = compile(chunkCode, { ...chunkOptions, alwaysInline: true });\n const other = always.code === chosen?.optimized.code ? undefined : lowerCandidate(always);\n if (other && (!chosen || shippedSize(other, filename) < shippedSize(chosen, filename))) {\n chosen = other;\n }\n }\n let optimized: CompileResult | undefined;\n let linked: { code: string; map: string };\n let lowered: SolidCompiler.TransformResult;\n if (chosen) {\n ({ optimized, lowered, linked } = chosen);\n addSkips(this, optimized.skipped);\n } else {\n // Without the helper, the chunk is lowered as its modules were\n // written. Chunk mode never hydrates, so the chunks do not have to\n // match anything else.\n this.warn(`${missing?.message ?? ''} ${filename} is not optimized.`);\n addSkips(this, [{ pass: 'inline', reason: 'missing-helper', name: filename }]);\n lowered = lowerChunk(chunkCode);\n linked = linkHelpers(lowered.code, filename, moduleName, runtime.helpers);\n }\n return {\n code: linked.code,\n map: combineMaps(wantsMaps(), [\n repaired?.map,\n runtime.map,\n restored?.map,\n optimized?.map?.toString(),\n lowered.map,\n linked.map,\n ]),\n };\n },\n },\n };\n\n // Prints the report once every chunk is rendered.\n chunkPlugin.generateBundle = function generateBundle() {\n const { report } = optimizer;\n if (report === undefined || report === false) {\n return;\n }\n const environment = this.environment.name;\n const result: OptimizerReport = { environment, skips: skips.get(environment) ?? [] };\n if (typeof report === 'function') {\n report(result);\n } else {\n this.environment.logger.info(formatReport(result));\n }\n };\n\n // Runs after `vite:oxc` strips types, which reports the module as plain\n // JavaScript, and before the built-in plugins that parse it again.\n const moduleTypePlugin: Plugin = {\n name: 'solid-optimizer:module-type',\n transform(code, id) {\n if (!preserved.has(id)) {\n return null;\n }\n // `vite:oxc` prints JSX like Rolldown does, without the parentheses a\n // comma expression needs in a JSX expression container.\n const repaired = repairJSXSequences(code, parserFilename(id));\n return repaired\n ? { code: repaired.code, map: repaired.map, moduleType: 'jsx' }\n : { code, moduleType: 'jsx' };\n },\n };\n\n return [modulePlugin, ...plugins, moduleTypePlugin, chunkPlugin];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAaA,SAAgB,cACd,QAC2B;CAC3B,MAAM,UAAqC,CAAC;CAC5C,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,GAAG,GAClD,IACE,QAAQ,UACP,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,OAAO,UAAU,YAE5E,QAAQ,mBAAmB,SAAS;CAGxC,MAAM,eAAe,OAAO,OAAO,OAAO,YAAY;CACtD,MAAM,UAAqC,CAAC;CAC5C,IAAI,aAAa,SAAS,GACxB,KAAK,MAAM,eAAe,cACxB,QAAQ,KAAK,YAAY,UAAU,OAAO,UAAU,CAAC,CAAC;MAGxD,QAAQ,KAAK,OAAO,UAAU,CAAC,CAAC;CAElC,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,UAAU,SACnB,KAAK,MAAM,OAAO,OAAO,KAAK,MAAM,GAClC,KAAK,IAAI,GAAG;CAGhB,KAAK,MAAM,OAAO,MAAM;EAEtB,IAAI;EACJ,IAAI,OAAO;EACX,KAAK,MAAM,UAAU,SAAS;GAC5B,MAAM,QAAQ,YAAY,OAAO,IAAI;GACrC,UAAU;GACV,IAAI,UAAU,KAAA,KAAa,CAAC,OAAO,GAAG,MAAM,OAAO,OAAO,KAAK,GAAG;IAChE,OAAO;IACP;GACF;EACF;EACA,IAAI,UAAU,KAAA,KAAa,MACzB,QAAQ,OAAO,MAAM;CAEzB;CACA,OAAO;AACT;;;;;AAMA,SAAS,YAAY,OAAkD;CACrE,IAAI,SAAkB;CACtB,IAAI,OAAO,UAAU,UACnB,IAAI;EACF,SAAS,KAAK,MAAM,KAAK;CAC3B,QAAQ;EACN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