weapp-vite 5.3.0 → 5.4.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.
@@ -1,10 +1,12 @@
1
- import { InlineConfig, UserConfig as UserConfig$1, UserConfigFnObject, UserConfigExport } from 'vite';
2
- import { GenerateType, Component, Theme, Sitemap, App, Page, Plugin } from '@weapp-core/schematics';
3
1
  import { InputOption, RolldownOutput, RolldownWatcher } from 'rolldown';
2
+ import { InlineConfig, UserConfig as UserConfig$1, ViteDevServer, build, UserConfigFnObject, UserConfigExport } from 'vite';
3
+ import { A as AutoRoutes } from './routes-C9hKJjXs.cjs';
4
+ import { a as Resolver, R as ResolvedValue } from './types-g_G_na7r.cjs';
4
5
  import { Options } from 'tsdown';
6
+ import { GenerateType, Component, Theme, Sitemap, App, Page, Plugin } from '@weapp-core/schematics';
7
+ import { WeappWebPluginOptions } from '@weapp-vite/web';
5
8
  import { WrapPluginOptions } from 'vite-plugin-performance';
6
9
  import { PluginOptions } from 'vite-tsconfig-paths';
7
- import { R as Resolver, a as ResolvedValue } from './types-3q1Qq6Fe.cjs';
8
10
  import PQueue from 'p-queue';
9
11
  import { DetectResult } from 'package-manager-detector';
10
12
  import { PackageJson } from 'pkg-types';
@@ -45,7 +47,7 @@ interface AliasOptions {
45
47
  [find: string]: string;
46
48
  };
47
49
  }
48
- type MpPlatform = 'weapp' | 'alipay' | 'tt';
50
+ type MpPlatform = 'weapp' | 'alipay' | 'tt' | 'swan' | 'jd' | 'xhs';
49
51
  interface SubPackage {
50
52
  pages: string[];
51
53
  root: string;
@@ -116,6 +118,35 @@ interface CopyOptions {
116
118
  filter?: (filePath: string, index: number, array: string[]) => boolean;
117
119
  }
118
120
  type CopyGlobs = string[];
121
+ interface WeappWebConfig {
122
+ /**
123
+ * @description 是否启用浏览器端运行时集成
124
+ * @default false
125
+ */
126
+ enable?: boolean;
127
+ /**
128
+ * @description Web 侧项目根目录(即 index.html 所在目录)
129
+ * @default 项目根目录
130
+ */
131
+ root?: string;
132
+ /**
133
+ * @description 小程序源码目录(相对于 `root`),默认与 `weapp.srcRoot` 保持一致
134
+ */
135
+ srcDir?: string;
136
+ /**
137
+ * @description Web 构建产物输出目录;相对路径基于 `root`
138
+ * @default "dist-web"
139
+ */
140
+ outDir?: string;
141
+ /**
142
+ * @description 传递给 `weappWebPlugin` 的额外参数(不包含 `srcDir`)
143
+ */
144
+ pluginOptions?: Partial<Omit<WeappWebPluginOptions, 'srcDir'>>;
145
+ /**
146
+ * @description 额外合并到 Web 构建中的 Vite 内联配置
147
+ */
148
+ vite?: InlineConfig;
149
+ }
119
150
  interface AutoImportComponents {
120
151
  /**
121
152
  * 自动导入组件
@@ -132,6 +163,20 @@ interface AutoImportComponents {
132
163
  * - `false`: 不生成清单文件
133
164
  */
134
165
  output?: string | boolean;
166
+ /**
167
+ * 生成 WXML 组件 props 类型声明文件。
168
+ * - `true`: 输出到 `vite.config.ts` 同级目录的 `typed-components.d.ts`
169
+ * - 传入字符串: 自定义输出路径 (支持绝对/相对路径)
170
+ * - `false` 或未配置: 不生成类型文件
171
+ */
172
+ typedComponents?: boolean | string;
173
+ /**
174
+ * 生成 VS Code HTML customData 用于模板补全。
175
+ * - `true`: 输出到 `vite.config.ts` 同级目录的 `mini-program.html-data.json`
176
+ * - 传入字符串: 自定义输出路径 (支持绝对/相对路径)
177
+ * - `false` 或未配置: 不生成 customData
178
+ */
179
+ htmlCustomData?: boolean | string;
135
180
  }
136
181
  type EnhanceWxmlOptions = ScanWxmlOptions & HandleWxmlOptions;
137
182
  interface ScanWxmlOptions {
@@ -160,6 +205,7 @@ interface BuildNpmPackageMeta {
160
205
  name: string;
161
206
  entry: InputOption;
162
207
  }
208
+ type JsFormat = 'cjs' | 'esm';
163
209
  interface WeappViteConfig {
164
210
  /**
165
211
  * @description 应用入口目录 (app.json 所在的目录)
@@ -167,6 +213,12 @@ interface WeappViteConfig {
167
213
  * @default '.'
168
214
  */
169
215
  srcRoot?: string;
216
+ /**
217
+ * @description 是否启用自动路由模块 (`weapp-vite/auto-routes`)
218
+ * 默认关闭,需要显式启用后才会扫描 `pages/` 目录并生成路由清单。
219
+ * @default false
220
+ */
221
+ autoRoutes?: boolean;
170
222
  /**
171
223
  * @description 插件入口目录 (plugin.json 所在的目录)
172
224
  * @default undefined
@@ -221,6 +273,11 @@ interface WeappViteConfig {
221
273
  * 默认情况下包括大部分的图片资源格式
222
274
  */
223
275
  copy?: CopyOptions;
276
+ /**
277
+ * @group Web 运行时
278
+ * 浏览器端运行时相关配置
279
+ */
280
+ web?: WeappWebConfig;
224
281
  /**
225
282
  * @description 额外的 wxml 文件
226
283
  * 把这个方法,扫描到的 `wxml` 添加到额外的 `wxml` 文件列表, **处理** 之后输出到最终的产物中
@@ -234,6 +291,28 @@ interface WeappViteConfig {
234
291
  */
235
292
  platform?: MpPlatform;
236
293
  /**
294
+ * @description 生成的 JS 模块格式
295
+ * - `cjs`: 输出 CommonJS
296
+ * - `esm`: 输出 ESM,需要在微信开发者工具中启用「ES6 转 ES5」
297
+ * @default 'cjs'
298
+ */
299
+ jsFormat?: JsFormat;
300
+ /**
301
+ * @description 是否启用基于 `@swc/core` 的 ES5 降级(仅支持 `jsFormat: 'cjs'`)
302
+ * @default false
303
+ */
304
+ es5?: boolean;
305
+ wxml?: EnhanceOptions['wxml'];
306
+ /**
307
+ * wxs 增强
308
+ */
309
+ wxs?: EnhanceOptions['wxs'];
310
+ /**
311
+ * 自动导入小程序组件
312
+ */
313
+ autoImportComponents?: AutoImportComponents;
314
+ /**
315
+ * @deprecated 请改用顶层的 `wxml`、`wxs` 与 `autoImportComponents`
237
316
  * 增强配置
238
317
  */
239
318
  enhance?: EnhanceOptions;
@@ -364,6 +443,7 @@ interface LoadConfigResult {
364
443
  srcRoot: string;
365
444
  configFilePath?: string;
366
445
  currentSubPackageRoot?: string;
446
+ weappWeb?: ResolvedWeappWebConfig;
367
447
  }
368
448
  interface PackageInfo {
369
449
  name: string;
@@ -382,6 +462,7 @@ interface ConfigService {
382
462
  load: (options?: Partial<LoadConfigOptions>) => Promise<LoadConfigResult>;
383
463
  mergeWorkers: (...configs: Partial<InlineConfig>[]) => InlineConfig;
384
464
  merge: (subPackageMeta?: SubPackageMetaValue, ...configs: Partial<InlineConfig | undefined>[]) => InlineConfig;
465
+ mergeWeb: (...configs: Partial<InlineConfig | undefined>[]) => InlineConfig | undefined;
385
466
  readonly defineImportMetaEnv: Record<string, any>;
386
467
  readonly cwd: string;
387
468
  readonly isDev: boolean;
@@ -399,11 +480,23 @@ interface ConfigService {
399
480
  readonly aliasEntries: ResolvedAlias[];
400
481
  readonly platform: MpPlatform;
401
482
  readonly configFilePath?: string;
483
+ readonly weappWebConfig?: ResolvedWeappWebConfig;
402
484
  relativeCwd: (p: string) => string;
403
485
  relativeSrcRoot: (p: string) => string;
404
486
  relativeAbsoluteSrcRoot: (p: string) => string;
405
487
  readonly currentSubPackageRoot?: string;
406
488
  }
489
+ interface ResolvedWeappWebConfig {
490
+ enabled: boolean;
491
+ root: string;
492
+ srcDir: string;
493
+ outDir: string;
494
+ pluginOptions: Omit<WeappWebPluginOptions, 'srcDir'> & {
495
+ srcDir: string;
496
+ };
497
+ userConfig?: InlineConfig;
498
+ source?: WeappWebConfig;
499
+ }
407
500
 
408
501
  type HashInput = string | Buffer;
409
502
  declare class FileCache<T extends object> {
@@ -495,6 +588,16 @@ interface SidecarWatcher {
495
588
  }
496
589
 
497
590
  interface RuntimeState {
591
+ autoRoutes: {
592
+ routes: AutoRoutes;
593
+ serialized: string;
594
+ moduleCode: string;
595
+ typedDefinition: string;
596
+ watchFiles: Set<string>;
597
+ watchDirs: Set<string>;
598
+ dirty: boolean;
599
+ initialized: boolean;
600
+ };
498
601
  autoImport: {
499
602
  registry: Map<string, LocalAutoImportMatch>;
500
603
  matcher?: (input: string) => boolean;
@@ -557,6 +660,14 @@ interface WatcherService {
557
660
  closeAll: () => void;
558
661
  }
559
662
 
663
+ interface WebService {
664
+ readonly devServer?: ViteDevServer;
665
+ isEnabled: () => boolean;
666
+ startDevServer: () => Promise<ViteDevServer | undefined>;
667
+ build: () => Promise<Awaited<ReturnType<typeof build>> | undefined>;
668
+ close: () => Promise<void>;
669
+ }
670
+
560
671
  interface WxmlService {
561
672
  depsMap: Map<string, Set<string>>;
562
673
  tokenMap: Map<string, ScanWxmlResult>;
@@ -584,6 +695,20 @@ interface AutoImportService {
584
695
  awaitManifestWrites: () => Promise<void>;
585
696
  }
586
697
 
698
+ interface AutoRoutesService {
699
+ ensureFresh: () => Promise<void>;
700
+ markDirty: () => void;
701
+ getSnapshot: () => AutoRoutes;
702
+ getReference: () => AutoRoutes;
703
+ getModuleCode: () => string;
704
+ getWatchFiles: () => Iterable<string>;
705
+ getWatchDirectories: () => Iterable<string>;
706
+ isRouteFile: (filePath: string) => boolean;
707
+ handleFileChange: (filePath: string, event?: ChangeEvent) => Promise<void>;
708
+ isInitialized: () => boolean;
709
+ isEnabled: () => boolean;
710
+ }
711
+
587
712
  interface CompilerContext {
588
713
  runtimeState: RuntimeState;
589
714
  configService: ConfigService;
@@ -591,11 +716,18 @@ interface CompilerContext {
591
716
  wxmlService: WxmlService;
592
717
  jsonService: JsonService;
593
718
  watcherService: WatcherService;
719
+ webService: WebService;
594
720
  autoImportService: AutoImportService;
721
+ autoRoutesService: AutoRoutesService;
595
722
  buildService: BuildService;
596
723
  scanService: ScanService;
597
724
  }
598
725
 
726
+ interface WeappVitePluginApi {
727
+ ctx: CompilerContext;
728
+ }
729
+ type ChangeEvent = 'create' | 'update' | 'delete';
730
+
599
731
  type ReturnSelf<T> = (config: T) => T;
600
732
  type ConfigFn<T> = T | ((ctx: CompilerContext) => T);
601
733
  type DefineJsonFn<T> = ReturnSelf<ConfigFn<T>>;
@@ -615,4 +747,4 @@ declare function defineConfig(config: Promise<UserConfig$1>): Promise<UserConfig
615
747
  declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
616
748
  declare function defineConfig(config: UserConfigExport): UserConfigExport;
617
749
 
618
- export { type Alias as A, type BuildNpmPackageMeta as B, type CompilerContext as C, type ScanComponentItem as D, type EnhanceWxmlOptions as E, type ComponentsMap as F, type GenerateExtensionsOptions as G, type HandleWxmlOptions as H, type BaseEntry as I, type Entry as J, type AppEntry as K, type LoadConfigOptions as L, type MpPlatform as M, type PageEntry as N, type ComponentEntry as O, type ProjectConfig as P, type EntryJsonFragment as Q, type ResolvedAlias as R, type SubPackage as S, type UserConfig as U, type WeappViteConfig as W, defineAppJson as a, definePageJson as b, defineComponentJson as c, defineConfig as d, defineSitemapJson as e, defineThemeJson as f, type AliasOptions as g, type GenerateDirsOptions as h, type GenerateFilenamesOptions as i, type GenerateFileType as j, type GenerateTemplateContext as k, type GenerateTemplateFileSource as l, type GenerateTemplateInlineSource as m, type GenerateTemplateFactory as n, type GenerateTemplate as o, type GenerateTemplateEntry as p, type GenerateTemplateScope as q, type GenerateTemplatesConfig as r, type GenerateOptions as s, type CopyOptions as t, type CopyGlobs as u, type AutoImportComponents as v, type ScanWxmlOptions as w, type EnhanceOptions as x, type SubPackageMetaValue as y, type WxmlDep as z };
750
+ export { type Alias as A, type BuildNpmPackageMeta as B, type CompilerContext as C, type WxmlDep as D, type EnhanceWxmlOptions as E, type ScanComponentItem as F, type GenerateExtensionsOptions as G, type HandleWxmlOptions as H, type ComponentsMap as I, type JsFormat as J, type BaseEntry as K, type LoadConfigOptions as L, type MpPlatform as M, type Entry as N, type AppEntry as O, type ProjectConfig as P, type PageEntry as Q, type ResolvedAlias as R, type SubPackage as S, type ComponentEntry as T, type UserConfig as U, type EntryJsonFragment as V, type WeappViteConfig as W, type WeappVitePluginApi as X, type ChangeEvent as Y, defineAppJson as a, definePageJson as b, defineComponentJson as c, defineConfig as d, defineSitemapJson as e, defineThemeJson as f, type AliasOptions as g, type GenerateDirsOptions as h, type GenerateFilenamesOptions as i, type GenerateFileType as j, type GenerateTemplateContext as k, type GenerateTemplateFileSource as l, type GenerateTemplateInlineSource as m, type GenerateTemplateFactory as n, type GenerateTemplate as o, type GenerateTemplateEntry as p, type GenerateTemplateScope as q, type GenerateTemplatesConfig as r, type GenerateOptions as s, type CopyOptions as t, type CopyGlobs as u, type WeappWebConfig as v, type AutoImportComponents as w, type ScanWxmlOptions as x, type EnhanceOptions as y, type SubPackageMetaValue as z };
@@ -1,10 +1,12 @@
1
- import { InlineConfig, UserConfig as UserConfig$1, UserConfigFnObject, UserConfigExport } from 'vite';
2
- import { GenerateType, Component, Theme, Sitemap, App, Page, Plugin } from '@weapp-core/schematics';
3
1
  import { InputOption, RolldownOutput, RolldownWatcher } from 'rolldown';
2
+ import { InlineConfig, UserConfig as UserConfig$1, ViteDevServer, build, UserConfigFnObject, UserConfigExport } from 'vite';
3
+ import { A as AutoRoutes } from './routes-C9hKJjXs.js';
4
+ import { a as Resolver, R as ResolvedValue } from './types-g_G_na7r.js';
4
5
  import { Options } from 'tsdown';
6
+ import { GenerateType, Component, Theme, Sitemap, App, Page, Plugin } from '@weapp-core/schematics';
7
+ import { WeappWebPluginOptions } from '@weapp-vite/web';
5
8
  import { WrapPluginOptions } from 'vite-plugin-performance';
6
9
  import { PluginOptions } from 'vite-tsconfig-paths';
7
- import { R as Resolver, a as ResolvedValue } from './types-3q1Qq6Fe.js';
8
10
  import PQueue from 'p-queue';
9
11
  import { DetectResult } from 'package-manager-detector';
10
12
  import { PackageJson } from 'pkg-types';
@@ -45,7 +47,7 @@ interface AliasOptions {
45
47
  [find: string]: string;
46
48
  };
47
49
  }
48
- type MpPlatform = 'weapp' | 'alipay' | 'tt';
50
+ type MpPlatform = 'weapp' | 'alipay' | 'tt' | 'swan' | 'jd' | 'xhs';
49
51
  interface SubPackage {
50
52
  pages: string[];
51
53
  root: string;
@@ -116,6 +118,35 @@ interface CopyOptions {
116
118
  filter?: (filePath: string, index: number, array: string[]) => boolean;
117
119
  }
118
120
  type CopyGlobs = string[];
121
+ interface WeappWebConfig {
122
+ /**
123
+ * @description 是否启用浏览器端运行时集成
124
+ * @default false
125
+ */
126
+ enable?: boolean;
127
+ /**
128
+ * @description Web 侧项目根目录(即 index.html 所在目录)
129
+ * @default 项目根目录
130
+ */
131
+ root?: string;
132
+ /**
133
+ * @description 小程序源码目录(相对于 `root`),默认与 `weapp.srcRoot` 保持一致
134
+ */
135
+ srcDir?: string;
136
+ /**
137
+ * @description Web 构建产物输出目录;相对路径基于 `root`
138
+ * @default "dist-web"
139
+ */
140
+ outDir?: string;
141
+ /**
142
+ * @description 传递给 `weappWebPlugin` 的额外参数(不包含 `srcDir`)
143
+ */
144
+ pluginOptions?: Partial<Omit<WeappWebPluginOptions, 'srcDir'>>;
145
+ /**
146
+ * @description 额外合并到 Web 构建中的 Vite 内联配置
147
+ */
148
+ vite?: InlineConfig;
149
+ }
119
150
  interface AutoImportComponents {
120
151
  /**
121
152
  * 自动导入组件
@@ -132,6 +163,20 @@ interface AutoImportComponents {
132
163
  * - `false`: 不生成清单文件
133
164
  */
134
165
  output?: string | boolean;
166
+ /**
167
+ * 生成 WXML 组件 props 类型声明文件。
168
+ * - `true`: 输出到 `vite.config.ts` 同级目录的 `typed-components.d.ts`
169
+ * - 传入字符串: 自定义输出路径 (支持绝对/相对路径)
170
+ * - `false` 或未配置: 不生成类型文件
171
+ */
172
+ typedComponents?: boolean | string;
173
+ /**
174
+ * 生成 VS Code HTML customData 用于模板补全。
175
+ * - `true`: 输出到 `vite.config.ts` 同级目录的 `mini-program.html-data.json`
176
+ * - 传入字符串: 自定义输出路径 (支持绝对/相对路径)
177
+ * - `false` 或未配置: 不生成 customData
178
+ */
179
+ htmlCustomData?: boolean | string;
135
180
  }
136
181
  type EnhanceWxmlOptions = ScanWxmlOptions & HandleWxmlOptions;
137
182
  interface ScanWxmlOptions {
@@ -160,6 +205,7 @@ interface BuildNpmPackageMeta {
160
205
  name: string;
161
206
  entry: InputOption;
162
207
  }
208
+ type JsFormat = 'cjs' | 'esm';
163
209
  interface WeappViteConfig {
164
210
  /**
165
211
  * @description 应用入口目录 (app.json 所在的目录)
@@ -167,6 +213,12 @@ interface WeappViteConfig {
167
213
  * @default '.'
168
214
  */
169
215
  srcRoot?: string;
216
+ /**
217
+ * @description 是否启用自动路由模块 (`weapp-vite/auto-routes`)
218
+ * 默认关闭,需要显式启用后才会扫描 `pages/` 目录并生成路由清单。
219
+ * @default false
220
+ */
221
+ autoRoutes?: boolean;
170
222
  /**
171
223
  * @description 插件入口目录 (plugin.json 所在的目录)
172
224
  * @default undefined
@@ -221,6 +273,11 @@ interface WeappViteConfig {
221
273
  * 默认情况下包括大部分的图片资源格式
222
274
  */
223
275
  copy?: CopyOptions;
276
+ /**
277
+ * @group Web 运行时
278
+ * 浏览器端运行时相关配置
279
+ */
280
+ web?: WeappWebConfig;
224
281
  /**
225
282
  * @description 额外的 wxml 文件
226
283
  * 把这个方法,扫描到的 `wxml` 添加到额外的 `wxml` 文件列表, **处理** 之后输出到最终的产物中
@@ -234,6 +291,28 @@ interface WeappViteConfig {
234
291
  */
235
292
  platform?: MpPlatform;
236
293
  /**
294
+ * @description 生成的 JS 模块格式
295
+ * - `cjs`: 输出 CommonJS
296
+ * - `esm`: 输出 ESM,需要在微信开发者工具中启用「ES6 转 ES5」
297
+ * @default 'cjs'
298
+ */
299
+ jsFormat?: JsFormat;
300
+ /**
301
+ * @description 是否启用基于 `@swc/core` 的 ES5 降级(仅支持 `jsFormat: 'cjs'`)
302
+ * @default false
303
+ */
304
+ es5?: boolean;
305
+ wxml?: EnhanceOptions['wxml'];
306
+ /**
307
+ * wxs 增强
308
+ */
309
+ wxs?: EnhanceOptions['wxs'];
310
+ /**
311
+ * 自动导入小程序组件
312
+ */
313
+ autoImportComponents?: AutoImportComponents;
314
+ /**
315
+ * @deprecated 请改用顶层的 `wxml`、`wxs` 与 `autoImportComponents`
237
316
  * 增强配置
238
317
  */
239
318
  enhance?: EnhanceOptions;
@@ -364,6 +443,7 @@ interface LoadConfigResult {
364
443
  srcRoot: string;
365
444
  configFilePath?: string;
366
445
  currentSubPackageRoot?: string;
446
+ weappWeb?: ResolvedWeappWebConfig;
367
447
  }
368
448
  interface PackageInfo {
369
449
  name: string;
@@ -382,6 +462,7 @@ interface ConfigService {
382
462
  load: (options?: Partial<LoadConfigOptions>) => Promise<LoadConfigResult>;
383
463
  mergeWorkers: (...configs: Partial<InlineConfig>[]) => InlineConfig;
384
464
  merge: (subPackageMeta?: SubPackageMetaValue, ...configs: Partial<InlineConfig | undefined>[]) => InlineConfig;
465
+ mergeWeb: (...configs: Partial<InlineConfig | undefined>[]) => InlineConfig | undefined;
385
466
  readonly defineImportMetaEnv: Record<string, any>;
386
467
  readonly cwd: string;
387
468
  readonly isDev: boolean;
@@ -399,11 +480,23 @@ interface ConfigService {
399
480
  readonly aliasEntries: ResolvedAlias[];
400
481
  readonly platform: MpPlatform;
401
482
  readonly configFilePath?: string;
483
+ readonly weappWebConfig?: ResolvedWeappWebConfig;
402
484
  relativeCwd: (p: string) => string;
403
485
  relativeSrcRoot: (p: string) => string;
404
486
  relativeAbsoluteSrcRoot: (p: string) => string;
405
487
  readonly currentSubPackageRoot?: string;
406
488
  }
489
+ interface ResolvedWeappWebConfig {
490
+ enabled: boolean;
491
+ root: string;
492
+ srcDir: string;
493
+ outDir: string;
494
+ pluginOptions: Omit<WeappWebPluginOptions, 'srcDir'> & {
495
+ srcDir: string;
496
+ };
497
+ userConfig?: InlineConfig;
498
+ source?: WeappWebConfig;
499
+ }
407
500
 
408
501
  type HashInput = string | Buffer;
409
502
  declare class FileCache<T extends object> {
@@ -495,6 +588,16 @@ interface SidecarWatcher {
495
588
  }
496
589
 
497
590
  interface RuntimeState {
591
+ autoRoutes: {
592
+ routes: AutoRoutes;
593
+ serialized: string;
594
+ moduleCode: string;
595
+ typedDefinition: string;
596
+ watchFiles: Set<string>;
597
+ watchDirs: Set<string>;
598
+ dirty: boolean;
599
+ initialized: boolean;
600
+ };
498
601
  autoImport: {
499
602
  registry: Map<string, LocalAutoImportMatch>;
500
603
  matcher?: (input: string) => boolean;
@@ -557,6 +660,14 @@ interface WatcherService {
557
660
  closeAll: () => void;
558
661
  }
559
662
 
663
+ interface WebService {
664
+ readonly devServer?: ViteDevServer;
665
+ isEnabled: () => boolean;
666
+ startDevServer: () => Promise<ViteDevServer | undefined>;
667
+ build: () => Promise<Awaited<ReturnType<typeof build>> | undefined>;
668
+ close: () => Promise<void>;
669
+ }
670
+
560
671
  interface WxmlService {
561
672
  depsMap: Map<string, Set<string>>;
562
673
  tokenMap: Map<string, ScanWxmlResult>;
@@ -584,6 +695,20 @@ interface AutoImportService {
584
695
  awaitManifestWrites: () => Promise<void>;
585
696
  }
586
697
 
698
+ interface AutoRoutesService {
699
+ ensureFresh: () => Promise<void>;
700
+ markDirty: () => void;
701
+ getSnapshot: () => AutoRoutes;
702
+ getReference: () => AutoRoutes;
703
+ getModuleCode: () => string;
704
+ getWatchFiles: () => Iterable<string>;
705
+ getWatchDirectories: () => Iterable<string>;
706
+ isRouteFile: (filePath: string) => boolean;
707
+ handleFileChange: (filePath: string, event?: ChangeEvent) => Promise<void>;
708
+ isInitialized: () => boolean;
709
+ isEnabled: () => boolean;
710
+ }
711
+
587
712
  interface CompilerContext {
588
713
  runtimeState: RuntimeState;
589
714
  configService: ConfigService;
@@ -591,11 +716,18 @@ interface CompilerContext {
591
716
  wxmlService: WxmlService;
592
717
  jsonService: JsonService;
593
718
  watcherService: WatcherService;
719
+ webService: WebService;
594
720
  autoImportService: AutoImportService;
721
+ autoRoutesService: AutoRoutesService;
595
722
  buildService: BuildService;
596
723
  scanService: ScanService;
597
724
  }
598
725
 
726
+ interface WeappVitePluginApi {
727
+ ctx: CompilerContext;
728
+ }
729
+ type ChangeEvent = 'create' | 'update' | 'delete';
730
+
599
731
  type ReturnSelf<T> = (config: T) => T;
600
732
  type ConfigFn<T> = T | ((ctx: CompilerContext) => T);
601
733
  type DefineJsonFn<T> = ReturnSelf<ConfigFn<T>>;
@@ -615,4 +747,4 @@ declare function defineConfig(config: Promise<UserConfig$1>): Promise<UserConfig
615
747
  declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
616
748
  declare function defineConfig(config: UserConfigExport): UserConfigExport;
617
749
 
618
- export { type Alias as A, type BuildNpmPackageMeta as B, type CompilerContext as C, type ScanComponentItem as D, type EnhanceWxmlOptions as E, type ComponentsMap as F, type GenerateExtensionsOptions as G, type HandleWxmlOptions as H, type BaseEntry as I, type Entry as J, type AppEntry as K, type LoadConfigOptions as L, type MpPlatform as M, type PageEntry as N, type ComponentEntry as O, type ProjectConfig as P, type EntryJsonFragment as Q, type ResolvedAlias as R, type SubPackage as S, type UserConfig as U, type WeappViteConfig as W, defineAppJson as a, definePageJson as b, defineComponentJson as c, defineConfig as d, defineSitemapJson as e, defineThemeJson as f, type AliasOptions as g, type GenerateDirsOptions as h, type GenerateFilenamesOptions as i, type GenerateFileType as j, type GenerateTemplateContext as k, type GenerateTemplateFileSource as l, type GenerateTemplateInlineSource as m, type GenerateTemplateFactory as n, type GenerateTemplate as o, type GenerateTemplateEntry as p, type GenerateTemplateScope as q, type GenerateTemplatesConfig as r, type GenerateOptions as s, type CopyOptions as t, type CopyGlobs as u, type AutoImportComponents as v, type ScanWxmlOptions as w, type EnhanceOptions as x, type SubPackageMetaValue as y, type WxmlDep as z };
750
+ export { type Alias as A, type BuildNpmPackageMeta as B, type CompilerContext as C, type WxmlDep as D, type EnhanceWxmlOptions as E, type ScanComponentItem as F, type GenerateExtensionsOptions as G, type HandleWxmlOptions as H, type ComponentsMap as I, type JsFormat as J, type BaseEntry as K, type LoadConfigOptions as L, type MpPlatform as M, type Entry as N, type AppEntry as O, type ProjectConfig as P, type PageEntry as Q, type ResolvedAlias as R, type SubPackage as S, type ComponentEntry as T, type UserConfig as U, type EntryJsonFragment as V, type WeappViteConfig as W, type WeappVitePluginApi as X, type ChangeEvent as Y, defineAppJson as a, definePageJson as b, defineComponentJson as c, defineConfig as d, defineSitemapJson as e, defineThemeJson as f, type AliasOptions as g, type GenerateDirsOptions as h, type GenerateFilenamesOptions as i, type GenerateFileType as j, type GenerateTemplateContext as k, type GenerateTemplateFileSource as l, type GenerateTemplateInlineSource as m, type GenerateTemplateFactory as n, type GenerateTemplate as o, type GenerateTemplateEntry as p, type GenerateTemplateScope as q, type GenerateTemplatesConfig as r, type GenerateOptions as s, type CopyOptions as t, type CopyGlobs as u, type WeappWebConfig as v, type AutoImportComponents as w, type ScanWxmlOptions as x, type EnhanceOptions as y, type SubPackageMetaValue as z };
package/dist/config.d.cts CHANGED
@@ -1,11 +1,13 @@
1
1
  export { UserConfig, UserConfigExport, UserConfigFnObject } from 'vite';
2
- export { W as WeappViteConfig, a as defineAppJson, c as defineComponentJson, d as defineConfig, b as definePageJson, e as defineSitemapJson, f as defineThemeJson } from './config-j03AZAws.cjs';
2
+ export { W as WeappViteConfig, a as defineAppJson, c as defineComponentJson, d as defineConfig, b as definePageJson, e as defineSitemapJson, f as defineThemeJson } from './config-DNP6NeTc.cjs';
3
3
  export { App, Component, Page, Sitemap, Theme } from '@weapp-core/schematics';
4
4
  import 'rolldown';
5
+ import './routes-C9hKJjXs.cjs';
6
+ import './types-g_G_na7r.cjs';
5
7
  import 'tsdown';
8
+ import '@weapp-vite/web';
6
9
  import 'vite-plugin-performance';
7
10
  import 'vite-tsconfig-paths';
8
- import './types-3q1Qq6Fe.cjs';
9
11
  import 'p-queue';
10
12
  import 'package-manager-detector';
11
13
  import 'pkg-types';
package/dist/config.d.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  export { UserConfig, UserConfigExport, UserConfigFnObject } from 'vite';
2
- export { W as WeappViteConfig, a as defineAppJson, c as defineComponentJson, d as defineConfig, b as definePageJson, e as defineSitemapJson, f as defineThemeJson } from './config-BMJAZP6e.js';
2
+ export { W as WeappViteConfig, a as defineAppJson, c as defineComponentJson, d as defineConfig, b as definePageJson, e as defineSitemapJson, f as defineThemeJson } from './config-jhY9Idrt.js';
3
3
  export { App, Component, Page, Sitemap, Theme } from '@weapp-core/schematics';
4
4
  import 'rolldown';
5
+ import './routes-C9hKJjXs.js';
6
+ import './types-g_G_na7r.js';
5
7
  import 'tsdown';
8
+ import '@weapp-vite/web';
6
9
  import 'vite-plugin-performance';
7
10
  import 'vite-tsconfig-paths';
8
- import './types-3q1Qq6Fe.js';
9
11
  import 'p-queue';
10
12
  import 'package-manager-detector';
11
13
  import 'pkg-types';
package/dist/index.cjs CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkN2SUN4MXcjs = require('./chunk-N2SUN4MX.cjs');
3
+ var _chunkLX2OMRQ4cjs = require('./chunk-LX2OMRQ4.cjs');
4
+ require('./chunk-XEHEGODS.cjs');
4
5
 
5
6
 
6
7
  var _chunkDVVMF6NDcjs = require('./chunk-DVVMF6ND.cjs');
@@ -26,4 +27,4 @@ _chunkOS76JPG2cjs.init_cjs_shims.call(void 0, );
26
27
 
27
28
 
28
29
 
29
- exports.createCompilerContext = _chunkN2SUN4MXcjs.createCompilerContext; exports.defineAppJson = _chunkBT7FLFCCcjs.defineAppJson; exports.defineComponentJson = _chunkBT7FLFCCcjs.defineComponentJson; exports.defineConfig = _chunkDVVMF6NDcjs.defineConfig; exports.definePageJson = _chunkBT7FLFCCcjs.definePageJson; exports.defineSitemapJson = _chunkBT7FLFCCcjs.defineSitemapJson; exports.defineThemeJson = _chunkBT7FLFCCcjs.defineThemeJson;
30
+ exports.createCompilerContext = _chunkLX2OMRQ4cjs.createCompilerContext; exports.defineAppJson = _chunkBT7FLFCCcjs.defineAppJson; exports.defineComponentJson = _chunkBT7FLFCCcjs.defineComponentJson; exports.defineConfig = _chunkDVVMF6NDcjs.defineConfig; exports.definePageJson = _chunkBT7FLFCCcjs.definePageJson; exports.defineSitemapJson = _chunkBT7FLFCCcjs.defineSitemapJson; exports.defineThemeJson = _chunkBT7FLFCCcjs.defineThemeJson;
package/dist/index.d.cts CHANGED
@@ -1,12 +1,14 @@
1
- import { L as LoadConfigOptions, C as CompilerContext } from './config-j03AZAws.cjs';
2
- export { W as WeappViteConfig, a as defineAppJson, c as defineComponentJson, d as defineConfig, b as definePageJson, e as defineSitemapJson, f as defineThemeJson } from './config-j03AZAws.cjs';
1
+ import { L as LoadConfigOptions, C as CompilerContext } from './config-DNP6NeTc.cjs';
2
+ export { W as WeappViteConfig, a as defineAppJson, c as defineComponentJson, d as defineConfig, b as definePageJson, e as defineSitemapJson, f as defineThemeJson } from './config-DNP6NeTc.cjs';
3
3
  export { RolldownBuild, RolldownOptions, RolldownOutput, RolldownPlugin, RolldownPluginOption, WatchOptions as RolldownWatchOptions, RolldownWatcher } from 'rolldown';
4
4
  export { ConfigEnv, InlineConfig, Plugin, PluginOption, ResolvedConfig, UserConfig, UserConfigExport, UserConfigFnObject, ViteDevServer } from 'vite';
5
5
  export { App, Component, Page, Sitemap, Theme } from '@weapp-core/schematics';
6
+ import './routes-C9hKJjXs.cjs';
7
+ import './types-g_G_na7r.cjs';
6
8
  import 'tsdown';
9
+ import '@weapp-vite/web';
7
10
  import 'vite-plugin-performance';
8
11
  import 'vite-tsconfig-paths';
9
- import './types-3q1Qq6Fe.cjs';
10
12
  import 'p-queue';
11
13
  import 'package-manager-detector';
12
14
  import 'pkg-types';
package/dist/index.d.ts CHANGED
@@ -1,12 +1,14 @@
1
- import { L as LoadConfigOptions, C as CompilerContext } from './config-BMJAZP6e.js';
2
- export { W as WeappViteConfig, a as defineAppJson, c as defineComponentJson, d as defineConfig, b as definePageJson, e as defineSitemapJson, f as defineThemeJson } from './config-BMJAZP6e.js';
1
+ import { L as LoadConfigOptions, C as CompilerContext } from './config-jhY9Idrt.js';
2
+ export { W as WeappViteConfig, a as defineAppJson, c as defineComponentJson, d as defineConfig, b as definePageJson, e as defineSitemapJson, f as defineThemeJson } from './config-jhY9Idrt.js';
3
3
  export { RolldownBuild, RolldownOptions, RolldownOutput, RolldownPlugin, RolldownPluginOption, WatchOptions as RolldownWatchOptions, RolldownWatcher } from 'rolldown';
4
4
  export { ConfigEnv, InlineConfig, Plugin, PluginOption, ResolvedConfig, UserConfig, UserConfigExport, UserConfigFnObject, ViteDevServer } from 'vite';
5
5
  export { App, Component, Page, Sitemap, Theme } from '@weapp-core/schematics';
6
+ import './routes-C9hKJjXs.js';
7
+ import './types-g_G_na7r.js';
6
8
  import 'tsdown';
9
+ import '@weapp-vite/web';
7
10
  import 'vite-plugin-performance';
8
11
  import 'vite-tsconfig-paths';
9
- import './types-3q1Qq6Fe.js';
10
12
  import 'p-queue';
11
13
  import 'package-manager-detector';
12
14
  import 'pkg-types';
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  createCompilerContext
3
- } from "./chunk-JGSE2EOU.mjs";
3
+ } from "./chunk-KW3QAG67.mjs";
4
+ import "./chunk-UT7K35VH.mjs";
4
5
  import {
5
6
  defineConfig
6
7
  } from "./chunk-HVMR6H5Z.mjs";
package/dist/json.d.cts CHANGED
@@ -1,11 +1,13 @@
1
1
  export { App, Component, Page, Sitemap, Theme } from '@weapp-core/schematics';
2
- export { a as defineAppJson, c as defineComponentJson, b as definePageJson, e as defineSitemapJson, f as defineThemeJson } from './config-j03AZAws.cjs';
3
- import 'vite';
2
+ export { a as defineAppJson, c as defineComponentJson, b as definePageJson, e as defineSitemapJson, f as defineThemeJson } from './config-DNP6NeTc.cjs';
4
3
  import 'rolldown';
4
+ import 'vite';
5
+ import './routes-C9hKJjXs.cjs';
6
+ import './types-g_G_na7r.cjs';
5
7
  import 'tsdown';
8
+ import '@weapp-vite/web';
6
9
  import 'vite-plugin-performance';
7
10
  import 'vite-tsconfig-paths';
8
- import './types-3q1Qq6Fe.cjs';
9
11
  import 'p-queue';
10
12
  import 'package-manager-detector';
11
13
  import 'pkg-types';
package/dist/json.d.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  export { App, Component, Page, Sitemap, Theme } from '@weapp-core/schematics';
2
- export { a as defineAppJson, c as defineComponentJson, b as definePageJson, e as defineSitemapJson, f as defineThemeJson } from './config-BMJAZP6e.js';
3
- import 'vite';
2
+ export { a as defineAppJson, c as defineComponentJson, b as definePageJson, e as defineSitemapJson, f as defineThemeJson } from './config-jhY9Idrt.js';
4
3
  import 'rolldown';
4
+ import 'vite';
5
+ import './routes-C9hKJjXs.js';
6
+ import './types-g_G_na7r.js';
5
7
  import 'tsdown';
8
+ import '@weapp-vite/web';
6
9
  import 'vite-plugin-performance';
7
10
  import 'vite-tsconfig-paths';
8
- import './types-3q1Qq6Fe.js';
9
11
  import 'p-queue';
10
12
  import 'package-manager-detector';
11
13
  import 'pkg-types';
@@ -0,0 +1,11 @@
1
+ interface AutoRoutesSubPackage {
2
+ root: string;
3
+ pages: string[];
4
+ }
5
+ interface AutoRoutes {
6
+ pages: string[];
7
+ entries: string[];
8
+ subPackages: AutoRoutesSubPackage[];
9
+ }
10
+
11
+ export type { AutoRoutes as A, AutoRoutesSubPackage as a };