import type { Rolldown } from 'vite'; import type { AstTransformResult } from '../../../utils/transform.ts'; import type { MiniModuleClassifier } from '../module/module.ts'; /** * Materializes one final native/amphibious Rolldown chunk as executable Mini Program CommonJS. * * The transform performs five semantic operations: * * 1. Static ESM imports are hoisted into source-order `require` calls. Named imports remain property reads from the required * namespace so they observe current values. Default and namespace imports receive Babel-compatible CommonJS interop. * 2. An import whose target owns a capsule entry is not passed to native `require`. It becomes * bootstrap's `System.importSync(logicalChunkId)`, synchronously linking the capsule before the native lifecycle call. * 3. Local exports are published at declaration and mutation points. Imported re-exports use getters, while assignments and * updates notify every alias without changing expression completion values or accidentally matching shadowed bindings. * 4. ESM top-level `this` becomes `undefined`. Direct imported calls and tags are explicitly unbound so converting an import * into a namespace property does not introduce a false CommonJS receiver. * 5. Dynamic imports call the shared SystemJS loader. Relative string literals become logical chunk IDs, while computed IDs * are preserved, matching capsule loading and leaving physical require/require.async selection to transport. * * Static dependency loading is emitted before the untouched module body because ESM evaluates dependencies before body * statements regardless of where import declarations appear textually. Generated helper names are allocated against every * source identifier. Source maps use the same range edits when requested; Mini Program development disables them and keeps this path * focused on startup latency. */ export declare function renderNative({ code, chunk, chunks, bootstrapModuleId, getPhysicalChunkId, classifyModule, sourcemap }: { code: string; chunk: Rolldown.RenderedChunk; chunks: Readonly>; bootstrapModuleId: string; getPhysicalChunkId: (chunk: Rolldown.RenderedChunk | string) => string; classifyModule: MiniModuleClassifier; sourcemap: boolean; }): AstTransformResult;