UNPKG

weapp-vite

Version:

weapp-vite 一个现代化的小程序打包工具

1,612 lines (1,611 loc) 72.3 kB
import { d as ResolvedValue, f as Resolver } from "./index-CaXAtb9e.mjs"; import { t as AutoRoutes } from "./routes-C7fCmf92.mjs"; import { MpPlatform, OutputExtensions } from "@weapp-core/shared"; import { WeappAstConfig } from "@weapp-vite/ast"; import "@weapp-vite/ast/operations/onPageScroll"; import "@weapp-vite/ast/operations/setDataPick"; import { LoggerConfig } from "@weapp-core/logger"; import "@weapp-vite/ast/babel"; import { ConfigEnv, ConfigEnv as ConfigEnv$1, InlineConfig, InlineConfig as InlineConfig$1, Plugin as Plugin$1, PluginOption, ResolvedConfig, UserConfig, ViteDevServer, ViteDevServer as ViteDevServer$1, build } from "vite"; import { LRUCache } from "lru-cache"; import { fdir } from "fdir"; import { InputOption, ResolvedId, RolldownBuild, RolldownOptions, RolldownOutput, RolldownOutput as RolldownOutput$1, RolldownPlugin, RolldownPluginOption, RolldownWatcher, RolldownWatcher as RolldownWatcher$1, WatchOptions as RolldownWatchOptions } from "rolldown"; import { Options } from "rolldown-plugin-dts"; import PQueue from "p-queue"; import { Buffer } from "node:buffer"; import { PluginOptions } from "vite-tsconfig-paths"; import { WrapPluginOptions } from "vite-plugin-performance"; import { ComputedDefinitions as ComputedDefinitions$1, MethodDefinitions as MethodDefinitions$1, PageLayoutMeta, Ref, WevuDefaults } from "wevu"; import { MiniProgramNetworkDefaults } from "@wevu/web-apis"; import { App, App as App$1, Component, Component as Component$1, GenerateType, Page, Page as Page$1, Plugin, Sitemap, Sitemap as Sitemap$1, Theme, Theme as Theme$1 } from "@weapp-core/schematics"; import { WeappWebPluginOptions } from "@weapp-vite/web/plugin"; import { CompilerOptions } from "typescript"; import { DetectResult } from "package-manager-detector"; //#region src/runtimeTarget.d.ts type WebPlatform = 'web'; type WeappViteRuntime = 'miniprogram' | 'web'; type WeappVitePlatform = MpPlatform$1 | WebPlatform; type WeappViteTargetInput = WeappVitePlatform | 'h5' | 'all' | 'both' | (string & {}); type WeappViteTargetKind = WeappViteRuntime | 'all'; interface ResolvedWeappViteTarget { kind: WeappViteTargetKind; runMini: boolean; runWeb: boolean; platform?: WeappVitePlatform; label: string; raw?: string; } interface ResolveWeappViteTargetOptions { fallbackMiniPlatform?: MpPlatform$1; warn?: (message: string) => void; } interface WeappViteTargetDescriptor { platform: WeappVitePlatform; runtime: WeappViteRuntime; aliases: readonly string[]; label: string; } declare const WEB_PLATFORM_ALIASES: readonly string[]; declare function isWebPlatform(input?: string | null): boolean; declare function getSupportedWeappViteTargetDescriptors(): readonly WeappViteTargetDescriptor[]; declare function getSupportedWeappVitePlatforms(): readonly WeappVitePlatform[]; declare function resolveWeappViteTarget(input?: WeappViteTargetInput | null, options?: ResolveWeappViteTargetOptions): ResolvedWeappViteTarget; //#endregion //#region src/pluginHost.d.ts declare const WEAPP_VITE_HOST_NAME = "weapp-vite"; interface WeappViteHostMeta { name: typeof WEAPP_VITE_HOST_NAME; runtime: WeappViteRuntime; platform?: WeappVitePlatform; } declare function createWeappViteHostMeta(runtime: WeappViteRuntime, platform?: WeappVitePlatform): WeappViteHostMeta; declare function applyWeappViteHostMeta(config: InlineConfig, runtime: WeappViteRuntime, platform?: WeappVitePlatform): InlineConfig; declare function resolveWeappViteHostMeta(config: Pick<InlineConfig, 'weappVite'> | undefined): WeappViteHostMeta | undefined; declare function isWeappViteHost(config: Pick<InlineConfig, 'weappVite'> | undefined): boolean; declare module 'vite' { interface UserConfig { weappVite?: WeappViteHostMeta; } interface ResolvedConfig { weappVite?: WeappViteHostMeta; } } //#endregion //#region src/utils/importMeta.d.ts interface ImportMetaDefineRegistry { defineEntries: Record<string, any>; envObject: Record<string, any>; envMemberAccess: Record<string, any>; } //#endregion //#region src/types/config/foundation.d.ts type NpmBuildOptions = InlineConfig; type MpPlatform$1 = MpPlatform; /** * @description 支付宝平台本地 npm 输出模式 */ type AlipayNpmMode = 'miniprogram_npm' | 'node_modules'; interface Alias { /** * @description 被匹配的原始路径或正则 */ find: string | RegExp; /** * @description 命中后的替换路径 */ replacement: string; } interface ResolvedAlias { /** * @description 解析后的匹配条件 */ find: string | RegExp; /** * @description 解析后的替换路径 */ replacement: string; } interface AliasOptions { /** * @example * ```ts * entries: [ * { * find: '@', * replacement: path.resolve(import.meta.dirname, 'components'), * }, * ] * ``` */ entries?: readonly Alias[] | { [find: string]: string; }; } interface SubPackage { /** * @description 分包内页面列表,路径相对于分包 root */ pages: string[]; /** * @description 分包根目录 */ root: string; /** * @description 是否为独立分包 */ independent?: boolean; /** * @description 分包入口文件,也基于 root 解析 */ entry?: string; /** * @description 分包名称 */ name?: string; /** * @description 分包依赖范围控制 */ dependencies?: (string | RegExp)[]; /** * @description 分包级额外 inline Vite 配置 */ inlineConfig?: Partial<InlineConfig>; } type SubPackageStyleScope = 'all' | 'pages' | 'components'; interface SubPackageStyleConfigObject { /** 样式文件路径,可以是相对分包 root、相对 `srcRoot` 或绝对路径 */ source: string; /** * @description 作用范围快捷配置 */ scope?: SubPackageStyleScope; /** 自定义包含路径,支持传入单个 glob 或数组,默认覆盖分包内所有文件 */ include?: string | string[]; /** 自定义排除路径,支持传入单个 glob 或数组 */ exclude?: string | string[]; } type SubPackageStyleConfigEntry = string | SubPackageStyleConfigObject; interface SubPackageStyleEntry { source: string; absolutePath: string; outputRelativePath: string; inputExtension: string; scope: SubPackageStyleScope; include: string[]; exclude: string[]; } type GenerateExtensionsOptions = Partial<{ js: 'js' | 'ts' | (string & {}); json: 'js' | 'ts' | 'json' | (string & {}); wxml: 'wxml' | (string & {}); wxss: 'wxss' | 'scss' | 'less' | 'css' | (string & {}); }>; type GenerateDirsOptions = Partial<{ app: string; page: string; component: string; }>; type GenerateFilenamesOptions = Partial<{ app: string; page: string; component: string; }>; type GenerateFileType = 'js' | 'json' | 'wxml' | 'wxss'; interface GenerateTemplateContext { type: GenerateType; fileType: GenerateFileType; fileName: string; outDir: string; extension: string; cwd: string; defaultCode?: string; } interface GenerateTemplateFileSource { path: string; } interface GenerateTemplateInlineSource { content: string; } type GenerateTemplateFactory = (context: GenerateTemplateContext) => string | Promise<string> | undefined; type GenerateTemplate = string | GenerateTemplateFileSource | GenerateTemplateInlineSource | GenerateTemplateFactory; type GenerateTemplateEntry = Partial<Record<GenerateFileType, GenerateTemplate>>; type GenerateTemplateScope = GenerateType | 'shared'; type GenerateTemplatesConfig = Partial<Record<GenerateTemplateScope, GenerateTemplateEntry>>; interface GenerateOptions { extensions?: GenerateExtensionsOptions; dirs?: GenerateDirsOptions; filenames?: GenerateFilenamesOptions; templates?: GenerateTemplatesConfig; } interface CopyOptions { include?: CopyGlobs; exclude?: CopyGlobs; filter?: (filePath: string, index: number, array: string[]) => boolean; } /** * @description 资源复制使用的 glob 列表 */ type CopyGlobs = string[]; interface WeappWebConfig { enable?: boolean; root?: string; srcDir?: string; outDir?: string; pluginOptions?: Partial<Omit<WeappWebPluginOptions, 'srcDir'>>; vite?: InlineConfig; } interface WeappManagedSharedTsconfigConfig { compilerOptions?: CompilerOptions; } interface WeappManagedAppTsconfigConfig { compilerOptions?: CompilerOptions; vueCompilerOptions?: Record<string, any>; include?: string[]; exclude?: string[]; files?: string[]; } interface WeappManagedNodeTsconfigConfig { compilerOptions?: CompilerOptions; include?: string[]; exclude?: string[]; files?: string[]; } interface WeappManagedServerTsconfigConfig { compilerOptions?: CompilerOptions; include?: string[]; exclude?: string[]; files?: string[]; } interface WeappManagedTypeScriptConfig { shared?: WeappManagedSharedTsconfigConfig; app?: WeappManagedAppTsconfigConfig; node?: WeappManagedNodeTsconfigConfig; server?: WeappManagedServerTsconfigConfig; } interface WeappLibEntryContext { name: string; input: string; } type WeappLibFileName = string | ((context: WeappLibEntryContext) => string); type WeappLibComponentJson = boolean | 'auto' | ((context: WeappLibEntryContext) => Record<string, any>); interface WeappLibInternalDtsOptions { tsconfig?: string | false; compilerOptions?: CompilerOptions; vueCompilerOptions?: Record<string, any>; } interface WeappLibVueTscOptions { tsconfig?: Record<string, any>; compilerOptions?: CompilerOptions; vueCompilerOptions?: Record<string, any>; } interface WeappLibDtsOptions { enabled?: boolean; mode?: 'internal' | 'vue-tsc'; internal?: WeappLibInternalDtsOptions; rolldown?: Options; vueTsc?: WeappLibVueTscOptions; } interface WeappLibConfig { entry: string | string[] | Record<string, string>; root?: string; outDir?: string; preservePath?: boolean; fileName?: WeappLibFileName; componentJson?: WeappLibComponentJson; dts?: boolean | WeappLibDtsOptions; } interface BuildNpmPackageMeta { name: string; entry: InputOption; } type NpmDependencyPattern = string | RegExp; type NpmStrategy = 'explicit' | 'legacy'; interface NpmSubPackageConfig { dependencies?: NpmDependencyPattern[]; } interface NpmMainPackageConfig { dependencies?: false | NpmDependencyPattern[]; } interface NpmPluginPackageConfig { dependencies?: false | NpmDependencyPattern[]; } type JsFormat = 'cjs' | 'esm'; type SharedChunkStrategy = 'hoist' | 'duplicate'; type SharedChunkMode = 'common' | 'path' | 'inline'; /** * @deprecated `inline` 当前会回退为 `preserve`,请改用 `preserve` 或 `native`。 */ type DeprecatedInlineDynamicImports = 'inline'; type SharedChunkDynamicImports = 'preserve' | 'native' | DeprecatedInlineDynamicImports; interface SharedChunkOverride { test: string | RegExp; mode: SharedChunkMode; } type JsonMergeStage = 'defaults' | 'json-block' | 'auto-using-components' | 'component-generics' | 'macro' | 'emit' | 'merge-existing'; interface JsonMergeContext { filename?: string; kind?: 'app' | 'page' | 'component' | 'unknown'; stage: JsonMergeStage; } type JsonMergeFunction = (target: Record<string, any>, source: Record<string, any>, context: JsonMergeContext) => Record<string, any> | void; type JsonMergeStrategy = 'deep' | 'assign' | 'replace' | JsonMergeFunction; interface JsonConfig { defaults?: { app?: Record<string, any>; page?: Record<string, any>; component?: Record<string, any>; }; mergeStrategy?: JsonMergeStrategy; } interface ChunksConfig { sharedStrategy?: SharedChunkStrategy; sharedMode?: SharedChunkMode; sharedOverrides?: SharedChunkOverride[]; sharedPathRoot?: string; dynamicImports?: SharedChunkDynamicImports; logOptimization?: boolean; forceDuplicatePatterns?: (string | RegExp)[]; duplicateWarningBytes?: number; } //#endregion //#region src/types/config/features.d.ts /** * @description 自动导入组件配置 */ interface AutoImportComponents { /** * @description 组件扫描范围 */ globs?: string[]; /** * @description 组件解析器列表 */ resolvers?: Resolver[]; /** * @description 组件清单输出路径 */ output?: string | boolean; /** * @description WXML 组件 props 类型声明输出路径 */ typedComponents?: boolean | string; /** * @description VS Code HTML customData 输出路径 */ htmlCustomData?: boolean | string; /** * @description Vue SFC 组件声明输出路径 */ vueComponents?: boolean | string; /** * @description 生成 `components.d.ts` 时使用的运行时模块名 */ vueComponentsModule?: string; } type AutoImportComponentsOption = AutoImportComponents | boolean; /** * @description 实验性的 uni-app 源码兼容配置。 */ interface WeappUniAppConfig { /** * @description 允许参与兼容转换的 npm 包名。项目源码始终参与转换。 */ include: string[]; } type EnhanceWxmlOptions = ScanWxmlOptions & HandleWxmlOptions; /** * @description WXML 扫描阶段配置 */ interface ScanWxmlOptions { excludeComponent?: (tagName: string) => boolean; platform?: MpPlatform$1; } /** * @description WXML 处理阶段配置 */ interface HandleWxmlOptions { defineImportMetaEnv?: Record<string, any>; importMetaDefineRegistry?: ImportMetaDefineRegistry; importMetaRelativePath?: string; importMetaExtension?: string; removeComment?: boolean; transformEvent?: boolean; scriptModuleExtension?: string; scriptModuleTag?: string; templateExtension?: string; } interface EnhanceOptions { wxml?: boolean | Partial<Omit<EnhanceWxmlOptions, 'platform'>>; wxs?: boolean; autoImportComponents?: AutoImportComponentsOption; } /** * @description 多平台 project.config 配置 */ interface MultiPlatformConfig { enabled?: boolean; projectConfigRoot?: string; /** * @description 多平台模式下允许参与构建/开发的目标平台集合 */ targets?: 'all' | readonly MpPlatform$1[]; } /** * @description MCP 服务配置 */ interface WeappMcpConfig { enabled?: boolean; autoStart?: boolean | 'ai'; host?: string; port?: number | 'auto'; endpoint?: string; /** * @description streamable-http 模式下的 DevTools runtime REST 入口;设为 false 可关闭。 */ restEndpoint?: string | false; } /** * @description 自动路由配置 */ type WeappAutoRoutesIncludePattern = string | RegExp; /** * @description 自动路由包含规则 */ type WeappAutoRoutesInclude = WeappAutoRoutesIncludePattern | WeappAutoRoutesIncludePattern[]; /** * @description 自动路由配置 */ interface WeappAutoRoutesConfig { enabled?: boolean; typedRouter?: boolean; /** * @description 自动路由扫描规则,支持字符串 glob、正则以及它们的数组 * @remarks 默认会扫描主包 `pages/**`,以及已声明分包 root 下的 `pages/**` */ include?: WeappAutoRoutesInclude; /** * @description 是否启用自动路由持久化缓存,或指定自定义缓存文件路径 * @default false */ persistentCache?: boolean | string; watch?: boolean; } /** * @description 局部构建范围配置。 */ interface WeappBuildScopeObjectConfig { /** * @description 是否包含主包页面。 */ includeMainPackage?: boolean; /** * @description 参与构建的分包 root 列表。`main` 表示主包。 */ include?: string[]; /** * @internal * @description CLI 注入来源标记。 */ __weappViteBuildScopeSource?: boolean; } type WeappBuildScopeConfig = string | string[] | WeappBuildScopeObjectConfig; /** * @description `@wevu/api` 注入配置 */ interface WeappInjectWeapiConfig { enabled?: boolean; replaceWx?: boolean; globalName?: string; } type WeappInjectWebRuntimeGlobalsTarget = 'fetch' | 'Headers' | 'Request' | 'Response' | 'TextEncoder' | 'TextDecoder' | 'AbortController' | 'AbortSignal' | 'XMLHttpRequest' | 'WebSocket' | 'atob' | 'btoa' | 'queueMicrotask' | 'performance' | 'crypto' | 'Event' | 'CustomEvent'; type WeappInjectRequestGlobalsTarget = WeappInjectWebRuntimeGlobalsTarget; /** * @description Web Runtime 全局对象注入配置 */ interface WeappInjectWebRuntimeGlobalsConfig { enabled?: boolean; targets?: WeappInjectWebRuntimeGlobalsTarget[]; dependencies?: (string | RegExp)[]; prelude?: boolean; /** * @description Web Runtime 网络兼容层的宿主默认参数。 * @description 会透传给 `fetch` / `XMLHttpRequest` / `WebSocket` 对应的小程序底层能力。 * @description 显式调用时传入的 `miniProgram` / `miniprogram` 参数优先级更高。 */ networkDefaults?: MiniProgramNetworkDefaults; } /** * @description 已废弃,请迁移到 `WeappInjectWebRuntimeGlobalsConfig` */ interface WeappInjectRequestGlobalsConfig extends WeappInjectWebRuntimeGlobalsConfig {} /** * @description `app.prelude` 中的 Web Runtime 安装配置 */ interface WeappWebRuntimeConfig extends Omit<WeappInjectWebRuntimeGlobalsConfig, 'prelude'> {} /** * @description 已废弃,请迁移到 `WeappWebRuntimeConfig` */ interface WeappRequestRuntimeConfig extends WeappWebRuntimeConfig {} type WeappAppPreludeMode = 'inline' | 'entry' | 'require'; /** * @description `app.prelude` 前置注入配置 */ interface WeappAppPreludeConfig { enabled?: boolean; mode?: WeappAppPreludeMode; webRuntime?: boolean | WeappWebRuntimeConfig; /** * @deprecated 已废弃,请迁移到 `weapp.appPrelude.webRuntime`。 */ requestRuntime?: boolean | WeappRequestRuntimeConfig; } /** * @description 本地 npm 构建配置 */ interface WeappNpmConfig { enable?: boolean; cache?: boolean; strategy?: NpmStrategy; include?: NpmDependencyPattern[]; mainPackage?: NpmMainPackageConfig; pluginPackage?: NpmPluginPackageConfig; subPackages?: Record<string, NpmSubPackageConfig>; buildOptions?: (options: NpmBuildOptions, pkgMeta: BuildNpmPackageMeta) => NpmBuildOptions | undefined; alipayNpmMode?: AlipayNpmMode; } /** * @description 分包级额外配置 */ interface WeappSubPackageConfig { independent?: boolean; inlineConfig?: Partial<InlineConfig>; autoImportComponents?: AutoImportComponentsOption; watchSharedStyles?: boolean; styles?: SubPackageStyleConfigEntry | SubPackageStyleConfigEntry[]; } /** * @description HMR 配置 */ interface WeappHmrConfig { /** * @description 微信开发者工具热更新运行时。stateful-experimental 使用实验性的状态保持协议。 */ runtime?: 'auto' | 'classic' | 'stateful-experimental'; sharedChunks?: 'full' | 'auto' | 'off'; touchAppWxss?: boolean | 'auto'; /** * @description HMR 终端日志档位:默认仅输出总耗时,显式开启 concise/verbose 后再展示阶段诊断。 */ logLevel?: 'default' | 'concise' | 'verbose'; /** * @description 是否输出 HMR 结构化 profile,或指定自定义 JSONL 输出路径 */ profileJson?: boolean | string; } /** * @description worker 构建配置 */ interface WeappWorkerConfig { entry?: string | string[]; } /** * @description Vue 模板编译配置 */ interface WeappVueTemplateConfig { removeComments?: boolean; simplifyWhitespace?: boolean; formatWxml?: boolean | 'auto'; htmlTagToWxml?: boolean | Record<string, string>; htmlTagToWxmlTagClass?: boolean; scopedSlotsCompiler?: 'auto' | 'augmented' | 'off'; scopedSlotsRequireProps?: boolean; slotSingleRootNoWrapper?: boolean; slotFallbackWrapperStrategy?: 'view' | 'virtual-host'; slotFallbackWrapper?: string | { tag?: string; attrs?: Record<string, string>; singleRootNoWrapper?: boolean; rules?: Array<{ component?: string | RegExp | Array<string | RegExp>; componentName?: string | RegExp | Array<string | RegExp>; slot?: string | RegExp | Array<string | RegExp>; tag?: string; attrs?: Record<string, string>; singleRootNoWrapper?: boolean; }>; }; slotMultipleInstance?: boolean; classStyleRuntime?: 'auto' | 'wxs' | 'js'; objectLiteralBindMode?: 'runtime' | 'inline'; mustacheInterpolation?: 'compact' | 'spaced'; classStyleWxsShared?: boolean; functionPropNames?: Array<string | RegExp>; } /** * @description Vue 支持配置 */ interface WeappVueConfig { enable?: boolean; template?: WeappVueTemplateConfig; autoImport?: boolean; } /** * @description wevu 编译期默认值配置 */ interface WeappWevuConfig { preset?: 'performance'; defaults?: WevuDefaults; autoSetDataPick?: boolean; /** * @description 是否压缩 wevu 相关脚本输出。 * @description 默认保持当前可读输出行为,开启后仅影响 wevu 编译生成的脚本代码。 */ minify?: boolean; /** * @description wevu 运行时入口版本。`auto` 表示开发模式使用 `dist/dev`,构建模式使用 `dist`。 */ runtime?: 'auto' | 'dev' | 'build'; } interface WeappRouteRule { appLayout?: PageLayoutMeta; } type WeappRouteRules = Record<string, WeappRouteRule>; //#endregion //#region src/types/config/main.d.ts /** * @description 分包元信息 */ interface SubPackageMetaValue { entries: string[]; subPackage: SubPackage; autoImportComponents?: AutoImportComponentsOption; styleEntries?: SubPackageStyleEntry[]; watchSharedStyles?: boolean; } /** * @description 调试输出配置 */ interface WeappDebugConfig { watchFiles?: (watchFiles: string[], subPackageMeta?: SubPackageMetaValue) => void; resolveId?: (id: string, subPackageMeta?: SubPackageMetaValue) => void; load?: (id: string, subPackageMeta?: SubPackageMetaValue) => void; vueTransformTiming?: (timing: { id: string; isPage: boolean; totalMs: number; stages: Record<string, number>; }) => void; inspect?: WrapPluginOptions; } type WeappForwardConsoleLogLevel = 'debug' | 'log' | 'info' | 'warn' | 'error'; /** * @description 微信开发者工具日志转发配置。 */ interface WeappForwardConsoleConfig { /** * 是否启用日志转发。 * - `true`: 始终开启 * - `false`: 始终关闭 * - `'auto'`: 仅在检测到 AI 终端时开启 */ enabled?: boolean | 'auto'; /** * 允许转发的日志级别。 */ logLevels?: WeappForwardConsoleLogLevel[]; /** * 是否同时转发未捕获异常。 */ unhandledErrors?: boolean; } /** * @description analyze 包体预算配置。 */ interface WeappAnalyzeBudgetConfig { /** * 总包预算阈值(字节)。 */ totalBytes?: number; /** * 主包预算阈值(字节)。 */ mainBytes?: number; /** * 普通分包预算阈值(字节)。 */ subPackageBytes?: number; /** * 独立分包预算阈值(字节)。 */ independentBytes?: number; /** * 预算预警比例,默认 0.85。 */ warningRatio?: number; } /** * @description analyze 历史快照配置。 */ interface WeappAnalyzeHistoryConfig { /** * 是否写入历史快照。 */ enabled?: boolean; /** * 历史快照目录,默认 `.weapp-vite/analyze-history`。 */ dir?: string; /** * 保留快照数量,默认 20。 */ limit?: number; } /** * @description analyze 配置。 */ interface WeappAnalyzeConfig { /** * dashboard 与 Markdown 报告使用的包体预算。 */ budgets?: WeappAnalyzeBudgetConfig; /** * CLI 侧历史快照。设置为 `false` 可关闭。 */ history?: boolean | WeappAnalyzeHistoryConfig; } /** * @description weapp-vite 主配置 */ interface WeappViteConfig { /** * 开发态是否在启动构建前清空输出目录。 * 开发态默认 `true`,设置为 `false` 可跳过每次 dev 启动前的全量输出目录清理。 * 生产构建始终会清空输出目录。 */ cleanOutputsInDev?: boolean; /** * 应用入口目录(`app.json` 所在目录)。 */ srcRoot?: string; /** * 自动路由模块配置。 * - `undefined` / `false`: 默认关闭 * - `true`: 启用默认自动路由配置 * - `object`: 启用自动路由并允许细粒度控制 */ autoRoutes?: boolean | WeappAutoRoutesConfig; /** * 插件入口目录(`plugin.json` 所在目录)。 */ pluginRoot?: string; /** * 日志输出配置。 */ logger?: LoggerConfig; /** * AST 引擎配置。 */ ast?: WeappAstConfig; /** * 主包/分包体积告警阈值(字节)。 */ packageSizeWarningBytes?: number; /** * analyze 报告配置。 */ analyze?: WeappAnalyzeConfig; /** * 局部构建范围。默认不启用,启用后只构建主包和指定分包。 */ buildScope?: WeappBuildScopeConfig; jsonAlias?: AliasOptions | false; npm?: WeappNpmConfig; generate?: GenerateOptions; tsconfigPaths?: boolean | PluginOptions; subPackages?: Record<string, WeappSubPackageConfig>; copy?: CopyOptions; web?: WeappWebConfig; typescript?: WeappManagedTypeScriptConfig; lib?: WeappLibConfig; isAdditionalWxml?: (wxmlFilePath: string) => boolean; platform?: MpPlatform$1; multiPlatform?: boolean | MultiPlatformConfig; jsFormat?: JsFormat; /** * @deprecated 已废弃,不建议继续使用。请改为保持 `build.target >= es2020`,并在开发者工具中开启“将 JS 编译成 ES5”功能。 * 该选项依赖 `@swc/core` 做额外 ES5 降级,后续版本将移除。 */ es5?: boolean; wxml?: EnhanceOptions['wxml']; wxs?: EnhanceOptions['wxs']; autoImportComponents?: AutoImportComponentsOption; /** * 实验性的 uni-app 源码兼容层。默认关闭。 */ uniApp?: false | WeappUniAppConfig; enhance?: EnhanceOptions; debug?: WeappDebugConfig; hmr?: WeappHmrConfig; worker?: WeappWorkerConfig; vue?: WeappVueConfig; wevu?: WeappWevuConfig; routeRules?: WeappRouteRules; appPrelude?: boolean | WeappAppPreludeConfig; injectWeapi?: boolean | WeappInjectWeapiConfig; injectWebRuntimeGlobals?: boolean | WeappInjectWebRuntimeGlobalsConfig; /** * @deprecated 已废弃,请迁移到 `weapp.appPrelude.webRuntime`。 */ injectRequestGlobals?: boolean | WeappInjectRequestGlobalsConfig; mcp?: boolean | WeappMcpConfig; forwardConsole?: boolean | WeappForwardConsoleConfig; chunks?: ChunksConfig; json?: JsonConfig; } type UserConfig$2 = UserConfig & { weapp?: WeappViteConfig; }; /** * @description 小程序 project.config 结构 */ interface ProjectConfig { miniprogramRoot?: string; srcMiniprogramRoot?: string; smartProgramRoot?: string; setting?: { packNpmManually?: boolean; packNpmRelationList?: { packageJsonPath: string; miniprogramNpmDistDir: string; }[]; }; } //#endregion //#region src/types/context.d.ts interface WxmlDep { tagName: string; start: number; end: number; quote: string | null | undefined; name: string; value: string; attrs: Record<string, string>; } interface ScanComponentItem { start: number; end: number; } type ComponentsMap = Record<string, ScanComponentItem[]>; //#endregion //#region src/types/entry.d.ts interface BaseEntry { path: string; jsonPath?: string; json?: object; type: 'app' | 'page' | 'component' | (string & {}); } type Entry = AppEntry | PageEntry | ComponentEntry; /** * 应用入口 js + json */ interface AppEntry extends BaseEntry { type: 'app'; preludePath?: string; themeJsonPath?: string; themeJson?: Theme; sitemapJsonPath?: string; sitemapJson?: Sitemap; json: App; jsonPath: string; } /** * 页面入口 js + wxml */ interface PageEntry extends BaseEntry { type: 'page'; templatePath: string; json?: Page; } /** * 组件入口 js + wxml + json + json.component === true */ interface ComponentEntry extends BaseEntry { type: 'component'; templatePath: string; json: Component; jsonPath: string; } type EntryJsonFragment = Omit<BaseEntry, 'path' | 'type'>; //#endregion //#region src/types/errors.d.ts interface BindingErrorLike { message?: string; code?: string; plugin?: string; id?: string; frame?: string; stack?: string; } //#endregion //#region src/moduleGraph/protocol.d.ts type SidecarModuleKind = 'json' | 'layout' | 'script' | 'style' | 'template' | 'using-component' | 'wxs'; //#endregion //#region src/moduleGraph/types.d.ts interface BuildModuleInfo { dynamicImporters?: readonly string[]; exports?: readonly string[]; importers?: readonly string[]; isEntry?: boolean; } interface BuildGraphContext { getModuleIds?: () => Iterable<string>; getModuleInfo?: (id: string) => BuildModuleInfo | null | undefined; load?: (options: { id: string; resolveDependencies?: boolean; }) => Promise<BuildModuleInfo>; resolve?: (source: string, importer?: string, options?: { skipSelf?: boolean; }) => Promise<{ id: string; } | null>; } interface DevModuleNode { file?: string | null; id?: string | null; importedModules?: Set<DevModuleNode>; importers?: Set<DevModuleNode>; url?: string; } interface DevModuleGraph { getModuleById: (id: string) => DevModuleNode | undefined; getModulesByFile: (file: string) => Set<DevModuleNode> | undefined; idToModuleMap?: Map<string, DevModuleNode>; invalidateModule(module: DevModuleNode): void; } interface DevServerGraphHost { moduleGraph: DevModuleGraph; transformRequest?: (url: string) => Promise<unknown>; } interface TopologyRescanRequest { files: Set<string>; reasons: Set<string>; } //#endregion //#region src/moduleGraph/service.d.ts interface ModuleGraphService { bindBuildContext: (scope: object, context: BuildGraphContext) => void; bindDevServer: (server: DevServerGraphHost | undefined) => void; bindPluginContext: (context: BuildGraphContext) => void; collectAffectedEntries: (file: string) => Set<string>; getPendingChanges: () => Array<{ event: string; file: string; }>; consumeTopologyRescan: () => TopologyRescanRequest | undefined; hasModule: (file: string) => boolean; invalidate: (file: string) => Set<string>; isLogicalLayoutEntry: (file: string) => boolean; load: (options: { id: string; resolveDependencies?: boolean; }) => Promise<BuildModuleInfo>; replaceEntryDependencies: (ownerId: string, kind: SidecarModuleKind, sourceIds: Iterable<string>) => void; recordChangedFile: (file: string, event: string) => void; clearPendingChanges: () => void; requestTopologyRescan: (reason: string, file: string) => void; resolve: (source: string, importer?: string, options?: { skipSelf?: boolean; }) => Promise<{ id: string; } | null>; syncDevGraph: (context: BuildGraphContext) => Promise<void>; getEntryDependencies: (ownerId: string) => Array<{ kind: SidecarModuleKind; sourceId: string; }>; } //#endregion //#region src/runtime/buildPlugin/service.d.ts interface BuildOptions { skipNpm?: boolean; } interface BuildService { queue: PQueue; build: (options?: BuildOptions) => Promise<RolldownOutput | RolldownOutput[] | RolldownWatcher>; requestConfigRestart: (target?: BuildTarget) => void; buildIndependentBundle: (root: string, meta: SubPackageMetaValue) => Promise<RolldownOutput>; getIndependentOutput: (root: string) => RolldownOutput | undefined; invalidateIndependentOutput: (root: string) => void; } //#endregion //#region ../../node_modules/.pnpm/pkg-types@2.3.1/node_modules/pkg-types/dist/index.d.mts //#endregion //#region src/packagejson/types.d.ts interface PackageJson { /** * The name is what your thing is called. * Some rules: * - The name must be less than or equal to 214 characters. This includes the scope for scoped packages. * - The name can’t start with a dot or an underscore. * - New packages must not have uppercase letters in the name. * - The name ends up being part of a URL, an argument on the command line, and a folder name. Therefore, the name can’t contain any non-URL-safe characters. */ name?: string; /** * Version must be parseable by `node-semver`, which is bundled with npm as a dependency. (`npm install semver` to use it yourself.) */ version?: string; /** * Put a description in it. It’s a string. This helps people discover your package, as it’s listed in `npm search`. */ description?: string; /** * Put keywords in it. It’s an array of strings. This helps people discover your package as it’s listed in `npm search`. */ keywords?: string[]; /** * The url to the project homepage. */ homepage?: string; /** * The url to your project’s issue tracker and / or the email address to which issues should be reported. These are helpful for people who encounter issues with your package. */ bugs?: string | { url?: string; email?: string; }; /** * You should specify a license for your package so that people know how they are permitted to use it, and any restrictions you’re placing on it. */ license?: string; /** * Specify the place where your code lives. This is helpful for people who want to contribute. If the git repo is on GitHub, then the `npm docs` command will be able to find you. * For GitHub, GitHub gist, Bitbucket, or GitLab repositories you can use the same shortcut syntax you use for npm install: */ repository?: string | { type: string; url: string; /** * If the `package.json` for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives: */ directory?: string; }; /** * The `scripts` field is a dictionary containing script commands that are run at various times in the lifecycle of your package. */ scripts?: PackageJsonScripts; /** * If you set `"private": true` in your package.json, then npm will refuse to publish it. */ private?: boolean; /** * The “author” is one person. */ author?: PackageJsonPerson; /** * “contributors” is an array of people. */ contributors?: PackageJsonPerson[]; /** * An object containing a URL that provides up-to-date information * about ways to help fund development of your package, * a string URL, or an array of objects and string URLs */ funding?: PackageJsonFunding | PackageJsonFunding[]; /** * The optional `files` field is an array of file patterns that describes the entries to be included when your package is installed as a dependency. File patterns follow a similar syntax to `.gitignore`, but reversed: including a file, directory, or glob pattern (`*`, `**\/*`, and such) will make it so that file is included in the tarball when it’s packed. Omitting the field will make it default to `["*"]`, which means it will include all files. */ files?: string[]; /** * The main field is a module ID that is the primary entry point to your program. That is, if your package is named `foo`, and a user installs it, and then does `require("foo")`, then your main module’s exports object will be returned. * This should be a module ID relative to the root of your package folder. * For most modules, it makes the most sense to have a main script and often not much else. */ main?: string; /** * If your module is meant to be used client-side the browser field should be used instead of the main field. This is helpful to hint users that it might rely on primitives that aren’t available in Node.js modules. (e.g. window) */ browser?: string | Record<string, string | false>; /** * The `unpkg` field is used to specify the URL to a UMD module for your package. This is used by default in the unpkg.com CDN service. */ unpkg?: string; /** * A map of command name to local file name. On install, npm will symlink that file into `prefix/bin` for global installs, or `./node_modules/.bin/` for local installs. */ bin?: string | Record<string, string>; /** * Specify either a single file or an array of filenames to put in place for the `man` program to find. */ man?: string | string[]; /** * Dependencies are specified in a simple object that maps a package name to a version range. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or git URL. */ dependencies?: Record<string, string>; /** * If someone is planning on downloading and using your module in their program, then they probably don’t want or need to download and build the external test or documentation framework that you use. * In this case, it’s best to map these additional items in a `devDependencies` object. */ devDependencies?: Record<string, string>; /** * If a dependency can be used, but you would like npm to proceed if it cannot be found or fails to install, then you may put it in the `optionalDependencies` object. This is a map of package name to version or url, just like the `dependencies` object. The difference is that build failures do not cause installation to fail. */ optionalDependencies?: Record<string, string>; /** * In some cases, you want to express the compatibility of your package with a host tool or library, while not necessarily doing a `require` of this host. This is usually referred to as a plugin. Notably, your module may be exposing a specific interface, expected and specified by the host documentation. */ peerDependencies?: Record<string, string>; /** * TypeScript typings, typically ending by `.d.ts`. */ types?: string; /** * This field is synonymous with `types`. */ typings?: string; /** * Non-Standard Node.js alternate entry-point to main. * An initial implementation for supporting CJS packages (from main), and use module for ESM modules. */ module?: string; /** * Make main entry-point be loaded as an ESM module, support "export" syntax instead of "require" * * Docs: * - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_package_json_type_field * * @default 'commonjs' * @since Node.js v14 */ type?: "module" | "commonjs"; /** * Alternate and extensible alternative to "main" entry point. * * When using `{type: "module"}`, any ESM module file MUST end with `.mjs` extension. * * Docs: * - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_exports_sugar * * @since Node.js v12.7 */ exports?: PackageJsonExports; /** * Docs: * - https://nodejs.org/api/packages.html#imports */ imports?: Record<string, string | Record<string, string>>; /** * The field is used to define a set of sub-packages (or workspaces) within a monorepo. * * This field is an array of glob patterns or an object with specific configurations for managing * multiple packages in a single repository. */ workspaces?: string[] | { /** * Workspace package paths. Glob patterns are supported. */ packages?: string[]; /** * Packages to block from hoisting to the workspace root. * Uses glob patterns to match module paths in the dependency tree. * * Docs: * - https://classic.yarnpkg.com/blog/2018/02/15/nohoist/ */ nohoist?: string[]; }; /** * The field is used to specify different TypeScript declaration files for * different versions of TypeScript, allowing for version-specific type definitions. */ typesVersions?: Record<string, Record<string, string[]>>; /** * You can specify which operating systems your module will run on: * ```json * { * "os": ["darwin", "linux"] * } * ``` * You can also block instead of allowing operating systems, just prepend the blocked os with a '!': * ```json * { * "os": ["!win32"] * } * ``` * The host operating system is determined by `process.platform` * It is allowed to both block and allow an item, although there isn't any good reason to do this. */ os?: string[]; /** * If your code only runs on certain cpu architectures, you can specify which ones. * ```json * { * "cpu": ["x64", "ia32"] * } * ``` * Like the `os` option, you can also block architectures: * ```json * { * "cpu": ["!arm", "!mips"] * } * ``` * The host architecture is determined by `process.arch` */ cpu?: string[]; /** * This is a set of config values that will be used at publish-time. */ publishConfig?: { /** * The registry that will be used if the package is published. */ registry?: string; /** * The tag that will be used if the package is published. */ tag?: string; /** * The access level that will be used if the package is published. */ access?: "public" | "restricted"; /** * **pnpm-only** * * By default, for portability reasons, no files except those listed in * the bin field will be marked as executable in the resulting package * archive. The executableFiles field lets you declare additional fields * that must have the executable flag (+x) set even if * they aren't directly accessible through the bin field. */ executableFiles?: string[]; /** * **pnpm-only** * * You also can use the field `publishConfig.directory` to customize * the published subdirectory relative to the current `package.json`. * * It is expected to have a modified version of the current package in * the specified directory (usually using third party build tools). */ directory?: string; /** * **pnpm-only** * * When set to `true`, the project will be symlinked from the * `publishConfig.directory` location during local development. * @default true */ linkDirectory?: boolean; } & Pick<PackageJson, "bin" | "main" | "exports" | "types" | "typings" | "module" | "browser" | "unpkg" | "typesVersions" | "os" | "cpu">; /** * See: https://nodejs.org/api/packages.html#packagemanager * This field defines which package manager is expected to be used when working on the current project. * Should be of the format: `<name>@<version>[#hash]` */ packageManager?: string; [key: string]: any; } /** * See: https://docs.npmjs.com/cli/v11/using-npm/scripts#pre--post-scripts */ type PackageJsonScriptWithPreAndPost<S extends string> = S | `${"pre" | "post"}${S}`; /** * See: https://docs.npmjs.com/cli/v11/using-npm/scripts#life-cycle-operation-order */ type PackageJsonNpmLifeCycleScripts = "dependencies" | "prepublishOnly" | PackageJsonScriptWithPreAndPost<"install" | "pack" | "prepare" | "publish" | "restart" | "start" | "stop" | "test" | "version">; /** * See: https://pnpm.io/scripts#lifecycle-scripts */ type PackageJsonPnpmLifeCycleScripts = "pnpm:devPreinstall"; type PackageJsonCommonScripts = "build" | "coverage" | "deploy" | "dev" | "format" | "lint" | "preview" | "release" | "typecheck" | "watch"; type PackageJsonScriptName = PackageJsonCommonScripts | PackageJsonNpmLifeCycleScripts | PackageJsonPnpmLifeCycleScripts | (string & {}); type PackageJsonScripts = { [P in PackageJsonScriptName]?: string; }; /** * A “person” is an object with a “name” field and optionally “url” and “email”. Or you can shorten that all into a single string, and npm will parse it for you. */ type PackageJsonPerson = string | { name: string; email?: string; url?: string; }; type PackageJsonFunding = string | { url: string; type?: string; }; type PackageJsonExportKey = "." | "import" | "require" | "types" | "node" | "browser" | "default" | (string & {}); type PackageJsonExportsObject = { [P in PackageJsonExportKey]?: string | PackageJsonExportsObject | Array<string | PackageJsonExportsObject>; }; type PackageJsonExports = string | PackageJsonExportsObject | Array<string | PackageJsonExportsObject>; //#endregion //#region src/multiPlatform.d.ts interface ResolvedMultiPlatformConfig { enabled: boolean; projectConfigRoot: string; targets: readonly MpPlatform$1[]; } //#endregion //#region src/utils/json.d.ts interface JsonResolvableEntry { json?: any; jsonPath?: string; type?: 'app' | 'page' | 'component' | 'plugin'; } //#endregion //#region src/utils/loadViteConfigFile.d.ts type ViteConfigLoader = 'bundle' | 'runner' | 'native'; //#endregion //#region src/runtime/config/types.d.ts interface LoadConfigOptions { cwd: string; isDev: boolean; mode: string; emitDefaultAutoImportOutputs?: boolean; outputRoot?: string; pluginOnly?: boolean; inlineConfig?: InlineConfig; configFile?: string; configLoader?: ViteConfigLoader; cliPlatform?: string; projectConfigPath?: string; } interface LoadConfigResult { loadOptions: LoadConfigOptions; config: InlineConfig; aliasEntries: ResolvedAlias[]; outputExtensions: OutputExtensions; packageJson: PackageJson; relativeSrcRoot: (p: string) => string; cwd: string; isDev: boolean; mode: string; emitDefaultAutoImportOutputs: boolean; chunksConfigured?: boolean; projectConfig: Record<string, any>; projectPrivateConfig: Record<string, any>; projectConfigPath?: string; projectPrivateConfigPath?: string; mpDistRoot: string; multiPlatform: ResolvedMultiPlatformConfig; weappLib?: ResolvedWeappLibConfig; weappLibOutputMap?: Map<string, string>; packageJsonPath: string; platform: MpPlatform$1; srcRoot: string; pluginOnly?: boolean; configFilePath?: string; configFileDependencies: string[]; currentSubPackageRoot?: string; weappWeb?: ResolvedWeappWebConfig; configMergeInfo?: ResolvedConfigMergeInfo; } interface ResolvedConfigMergeInfo { merged: boolean; viteConfigPath?: string; weappConfigPath?: string; } interface ResolvedWeappLibConfig { enabled: boolean; entry: WeappLibConfig['entry']; root: string; outDir?: string; preservePath: boolean; fileName?: WeappLibFileName; componentJson: WeappLibComponentJson; dts: WeappLibDtsOptions; source?: WeappLibConfig; } interface PackageInfo { name: string; version: string | undefined; rootPath: string; packageJsonPath: string; packageJson: PackageJson; } interface ConfigService { options: LoadConfigResult; readonly loadOptions: LoadConfigOptions; outputExtensions: OutputExtensions; defineEnv: Record<string, any>; packageManager: DetectResult; packageInfo: PackageInfo; setDefineEnv: (key: string, value: any) => void; setImportMetaEnvDefineOverride: (define?: Record<string, any>) => void; load: (options?: Partial<LoadConfigOptions>) => Promise<LoadConfigResult>; mergeWorkers: (...configs: Partial<InlineConfig>[]) => InlineConfig; merge: (subPackageMeta?: SubPackageMetaValue, ...configs: Partial<InlineConfig | undefined>[]) => InlineConfig; mergeWeb: (...configs: Partial<InlineConfig | undefined>[]) => InlineConfig | undefined; mergeInlineConfig: (...configs: Partial<InlineConfig>[]) => InlineConfig; readonly importMetaDefineEntries: Record<string, any>; readonly defineImportMetaEnv: Record<string, any>; readonly importMetaEnvDefineOverride?: Record<string, any>; readonly importMetaDefineRegistry: ImportMetaDefineRegistry; readonly cwd: string; readonly isDev: boolean; readonly emitDefaultAutoImportOutputs: boolean; readonly mpDistRoot: string; readonly outDir: string; readonly multiPlatform: ResolvedMultiPlatformConfig; readonly inlineConfig: InlineConfig; readonly weappViteConfig: NonNullable<InlineConfig['weapp']>; readonly packageJson: PackageJson; readonly projectConfig: Record<string, any>; readonly projectPrivateConfig: Record<string, any>; readonly projectConfigPath?: string; readonly projectPrivateConfigPath?: string; readonly srcRoot: string; readonly pluginOnly: boolean; readonly pluginRoot: string | undefined; readonly absolutePluginRoot: string | undefined; readonly absolutePluginOutputRoot: string | undefined; readonly absoluteSrcRoot: string; readonly mode: string; readonly aliasEntries: ResolvedAlias[]; readonly platform: MpPlatform$1; readonly configFilePath?: string; readonly configFileDependencies: string[]; readonly weappWebConfig?: ResolvedWeappWebConfig; readonly weappLibConfig?: ResolvedWeappLibConfig; readonly weappLibOutputMap?: Map<string, string>; relativeCwd: (p: string) => string; relativeSrcRoot: (p: string) => string; relativeAbsoluteSrcRoot: (p: string) => string; relativeOutputPath: (p: string) => string; readonly currentSubPackageRoot?: string; } interface ResolvedWeappWebConfig { enabled: boolean; root: string; srcDir: string; outDir: string; pluginOptions: Omit<WeappWebPluginOptions, 'srcDir'> & { srcDir: string; }; userConfig?: InlineConfig; source?: WeappWebConfig; } //#endregion //#region src/cache/file.d.ts type HashInput = string | Buffer; declare class FileCache<T extends object> { cache: LRUCache<string, T>; mtimeMap: Map<string, number>; signatureMap: Map<string, string>; constructor(max?: number); get(id: string): T | undefined; set(id: string, content: T): LRUCache<string, T, unknown>; delete(id: string): boolean; isInvalidate(id: string, options?: { content?: HashInput; checkMtime?: boolean; mtimeMs?: number; signature?: string; }): Promise<boolean>; } //#endregion //#region src/runtime/jsonPlugin.d.ts interface JsonService { read: (filepath: string) => Promise<any>; resolve: (entry: JsonResolvableEntry) => string | undefined; cache: FileCache<any>; } //#endregion //#region src/runtime/npmPlugin/service/types.d.ts interface NpmService { getDependenciesCacheFilePath: (key?: string) => string; readonly dependenciesCacheHash: string; isMiniprogramPackage: (pkg: PackageJson) => boolean; shouldSkipBuild: (outDir: string, isOutdated: boolean) => Promise<boolean>; writeDependenciesCache: (root?: string) => Promise<void>; readDependenciesCache: (root?: string) => Promise<any>; checkDependenciesCacheOutdate: (root?: string) => Promise<boolean>; bundleBuild: (args: { entry: InputOption; name: string; options?: NpmBuildOptions; outDir: string; }) => Promise<void>; copyBuild: (args: { from: string; to: string; name: string; }) => Promise<void>; buildPackage: (args: { dep: string; outDir: string; options?: NpmBuildOptions; isDependenciesCacheOutdate: boolean; }) => Promise<void>; getPackNpmRelationList: () => { packageJsonPath: string; miniprogramNpmDistDir: string; }[]; build: (options?: NpmBuildOptions) => Promise<void>; } //#endregion //#region src/wxml/shared.d.ts interface Token { start: number; end: number; value: string; } //#endregion //#region src/wxml/scan/types.d.ts interface RemovalRange { start: number; end: number; } interface WxmlToken { /** * @description 参与常规组件分析的标签集合。 * 会应用 `excludeComponent` 过滤,通常会排除宿主内置组件, * 供原有的 `usingComponents` 推断与模板依赖聚合使用。 */ components: ComponentsMap; /** * @description 供自动导入使用的完整标签集合。 * 不会因为“这是宿主内置组件名”而被提前过滤, * 用来支持“本地组件与内置组件重名时仍优先命中用户组件”的场景。 */ autoImportComponents?: ComponentsMap; deps: WxmlDep[]; removalRanges: RemovalRange[]; commentTokens: Token[]; inlineWxsTokens: Token[]; wxsImportNormalizeTokens: Token[]; removeWxsLangAttrTokens: Token[]; templateImportNormalizeTokens: Token[]; scriptModuleTagTokens: Token[]; eventTokens: Token[]; directiveTokens?: Token[]; tagNameTokens?: Token[]; code: string; } //#endregion //#region src/wxml/scan/index.d.ts declare function scanWxml(wxml: string | Buffer, options?: ScanWxmlOptions): WxmlToken; type ScanWxmlResult = ReturnType<typeof scanWxml>; //#endregion //#region src/runtime/autoImport/types.d.ts interface LocalAutoImportMatch { kind: 'local'; entry: ComponentEntry; value: ResolvedValue; } //#endregion //#region src/runtime/watcher/types.d.ts interface WatcherInstance { close: () => void | Promise<void>; } interface SidecarWatcher { close: () => void | Promise<void>; } //#endregion //#region src/runtime/runtimeState.d.ts interface AutoRoutesCandidateState { base: string; files: Set<string>; hasScript: boolean; hasTemplate: boolean; jsonPath?: string; } interface LibEntryState { name: string; input: string; outputBase: string; relativeBase: string; } interface RuntimeState { autoRoutes: { routes: AutoRoutes; serialized: string; moduleCode: string; typedDefinition: string; watchFiles: Set<string>; watchDirs: Set<string>; dirty: boolean; initialized: boolean; candidates: Map<string, AutoRoutesCandidateState>; needsFullRescan: boolean; loadingAppConfig: boolean; }; autoImport: {