weapp-vite 5.2.3 → 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.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-D7SAXpSN.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
  * 自动导入组件
@@ -125,6 +156,27 @@ interface AutoImportComponents {
125
156
  * 自动导入组件解析器
126
157
  */
127
158
  resolvers?: Resolver[];
159
+ /**
160
+ * 自动导入组件清单输出路径,默认输出到 `vite.config.ts` 同级目录的 `auto-import-components.json`
161
+ * - `true` 或未指定: 按默认路径输出
162
+ * - 传入字符串: 指定输出路径 (支持绝对/相对路径)
163
+ * - `false`: 不生成清单文件
164
+ */
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;
128
180
  }
129
181
  type EnhanceWxmlOptions = ScanWxmlOptions & HandleWxmlOptions;
130
182
  interface ScanWxmlOptions {
@@ -153,6 +205,7 @@ interface BuildNpmPackageMeta {
153
205
  name: string;
154
206
  entry: InputOption;
155
207
  }
208
+ type JsFormat = 'cjs' | 'esm';
156
209
  interface WeappViteConfig {
157
210
  /**
158
211
  * @description 应用入口目录 (app.json 所在的目录)
@@ -160,6 +213,12 @@ interface WeappViteConfig {
160
213
  * @default '.'
161
214
  */
162
215
  srcRoot?: string;
216
+ /**
217
+ * @description 是否启用自动路由模块 (`weapp-vite/auto-routes`)
218
+ * 默认关闭,需要显式启用后才会扫描 `pages/` 目录并生成路由清单。
219
+ * @default false
220
+ */
221
+ autoRoutes?: boolean;
163
222
  /**
164
223
  * @description 插件入口目录 (plugin.json 所在的目录)
165
224
  * @default undefined
@@ -214,6 +273,11 @@ interface WeappViteConfig {
214
273
  * 默认情况下包括大部分的图片资源格式
215
274
  */
216
275
  copy?: CopyOptions;
276
+ /**
277
+ * @group Web 运行时
278
+ * 浏览器端运行时相关配置
279
+ */
280
+ web?: WeappWebConfig;
217
281
  /**
218
282
  * @description 额外的 wxml 文件
219
283
  * 把这个方法,扫描到的 `wxml` 添加到额外的 `wxml` 文件列表, **处理** 之后输出到最终的产物中
@@ -227,6 +291,28 @@ interface WeappViteConfig {
227
291
  */
228
292
  platform?: MpPlatform;
229
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`
230
316
  * 增强配置
231
317
  */
232
318
  enhance?: EnhanceOptions;
@@ -355,7 +441,9 @@ interface LoadConfigResult {
355
441
  packageJsonPath: string;
356
442
  platform: MpPlatform;
357
443
  srcRoot: string;
444
+ configFilePath?: string;
358
445
  currentSubPackageRoot?: string;
446
+ weappWeb?: ResolvedWeappWebConfig;
359
447
  }
360
448
  interface PackageInfo {
361
449
  name: string;
@@ -374,6 +462,7 @@ interface ConfigService {
374
462
  load: (options?: Partial<LoadConfigOptions>) => Promise<LoadConfigResult>;
375
463
  mergeWorkers: (...configs: Partial<InlineConfig>[]) => InlineConfig;
376
464
  merge: (subPackageMeta?: SubPackageMetaValue, ...configs: Partial<InlineConfig | undefined>[]) => InlineConfig;
465
+ mergeWeb: (...configs: Partial<InlineConfig | undefined>[]) => InlineConfig | undefined;
377
466
  readonly defineImportMetaEnv: Record<string, any>;
378
467
  readonly cwd: string;
379
468
  readonly isDev: boolean;
@@ -390,11 +479,24 @@ interface ConfigService {
390
479
  readonly mode: string;
391
480
  readonly aliasEntries: ResolvedAlias[];
392
481
  readonly platform: MpPlatform;
482
+ readonly configFilePath?: string;
483
+ readonly weappWebConfig?: ResolvedWeappWebConfig;
393
484
  relativeCwd: (p: string) => string;
394
485
  relativeSrcRoot: (p: string) => string;
395
486
  relativeAbsoluteSrcRoot: (p: string) => string;
396
487
  readonly currentSubPackageRoot?: string;
397
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
+ }
398
500
 
399
501
  type HashInput = string | Buffer;
400
502
  declare class FileCache<T extends object> {
@@ -486,6 +588,16 @@ interface SidecarWatcher {
486
588
  }
487
589
 
488
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
+ };
489
601
  autoImport: {
490
602
  registry: Map<string, LocalAutoImportMatch>;
491
603
  matcher?: (input: string) => boolean;
@@ -548,6 +660,14 @@ interface WatcherService {
548
660
  closeAll: () => void;
549
661
  }
550
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
+
551
671
  interface WxmlService {
552
672
  depsMap: Map<string, Set<string>>;
553
673
  tokenMap: Map<string, ScanWxmlResult>;
@@ -572,6 +692,21 @@ interface AutoImportService {
572
692
  resolve: (componentName: string, importerBaseName?: string) => AutoImportMatch | undefined;
573
693
  filter: (id: string, meta?: SubPackageMetaValue) => boolean;
574
694
  getRegisteredLocalComponents: () => LocalAutoImportMatch[];
695
+ awaitManifestWrites: () => Promise<void>;
696
+ }
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;
575
710
  }
576
711
 
577
712
  interface CompilerContext {
@@ -581,11 +716,18 @@ interface CompilerContext {
581
716
  wxmlService: WxmlService;
582
717
  jsonService: JsonService;
583
718
  watcherService: WatcherService;
719
+ webService: WebService;
584
720
  autoImportService: AutoImportService;
721
+ autoRoutesService: AutoRoutesService;
585
722
  buildService: BuildService;
586
723
  scanService: ScanService;
587
724
  }
588
725
 
726
+ interface WeappVitePluginApi {
727
+ ctx: CompilerContext;
728
+ }
729
+ type ChangeEvent = 'create' | 'update' | 'delete';
730
+
589
731
  type ReturnSelf<T> = (config: T) => T;
590
732
  type ConfigFn<T> = T | ((ctx: CompilerContext) => T);
591
733
  type DefineJsonFn<T> = ReturnSelf<ConfigFn<T>>;
@@ -605,4 +747,4 @@ declare function defineConfig(config: Promise<UserConfig$1>): Promise<UserConfig
605
747
  declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
606
748
  declare function defineConfig(config: UserConfigExport): UserConfigExport;
607
749
 
608
- 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 { a as defineAppJson, c as defineComponentJson, d as defineConfig, b as definePageJson, e as defineSitemapJson, f as defineThemeJson } from './config-CEyL0Mum.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-D7SAXpSN.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 { a as defineAppJson, c as defineComponentJson, d as defineConfig, b as definePageJson, e as defineSitemapJson, f as defineThemeJson } from './config-9I2A4BU9.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-D7SAXpSN.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 _chunkGMCAZZQYcjs = require('./chunk-GMCAZZQY.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 = _chunkGMCAZZQYcjs.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-CEyL0Mum.cjs';
2
- export { a as defineAppJson, c as defineComponentJson, d as defineConfig, b as definePageJson, e as defineSitemapJson, f as defineThemeJson } from './config-CEyL0Mum.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-D7SAXpSN.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-9I2A4BU9.js';
2
- export { a as defineAppJson, c as defineComponentJson, d as defineConfig, b as definePageJson, e as defineSitemapJson, f as defineThemeJson } from './config-9I2A4BU9.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-D7SAXpSN.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-UTHLNBNC.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-CEyL0Mum.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-D7SAXpSN.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-9I2A4BU9.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-D7SAXpSN.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 };
@@ -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 };
@@ -2,7 +2,13 @@ interface ResolvedValue {
2
2
  name: string;
3
3
  from: string;
4
4
  }
5
- type Resolver = (componentName: string, baseName: string) => ResolvedValue | void;
5
+ interface Resolver {
6
+ (componentName: string, baseName: string): ResolvedValue | void;
7
+ /**
8
+ * 解析器静态可用的组件映射
9
+ */
10
+ components?: Record<string, string>;
11
+ }
6
12
  interface ResolveOptions {
7
13
  name: string;
8
14
  prefix: string;
@@ -16,4 +22,4 @@ interface Options {
16
22
  }
17
23
  type CreateResolver = (options?: Options) => Resolver;
18
24
 
19
- export type { CreateResolver as C, Options as O, Resolver as R, ResolvedValue as a };
25
+ export type { CreateResolver as C, Options as O, ResolvedValue as R, Resolver as a };
@@ -2,7 +2,13 @@ interface ResolvedValue {
2
2
  name: string;
3
3
  from: string;
4
4
  }
5
- type Resolver = (componentName: string, baseName: string) => ResolvedValue | void;
5
+ interface Resolver {
6
+ (componentName: string, baseName: string): ResolvedValue | void;
7
+ /**
8
+ * 解析器静态可用的组件映射
9
+ */
10
+ components?: Record<string, string>;
11
+ }
6
12
  interface ResolveOptions {
7
13
  name: string;
8
14
  prefix: string;
@@ -16,4 +22,4 @@ interface Options {
16
22
  }
17
23
  type CreateResolver = (options?: Options) => Resolver;
18
24
 
19
- export type { CreateResolver as C, Options as O, Resolver as R, ResolvedValue as a };
25
+ export type { CreateResolver as C, Options as O, ResolvedValue as R, Resolver as a };
package/dist/types.cjs CHANGED
@@ -17,3 +17,6 @@ _chunkOS76JPG2cjs.init_cjs_shims.call(void 0, );
17
17
 
18
18
  // src/types/plugin.ts
19
19
  _chunkOS76JPG2cjs.init_cjs_shims.call(void 0, );
20
+
21
+ // src/types/routes.ts
22
+ _chunkOS76JPG2cjs.init_cjs_shims.call(void 0, );
package/dist/types.d.cts CHANGED
@@ -1,10 +1,11 @@
1
- import { C as CompilerContext } from './config-CEyL0Mum.cjs';
2
- export { A as Alias, g as AliasOptions, K as AppEntry, v as AutoImportComponents, I as BaseEntry, B as BuildNpmPackageMeta, O as ComponentEntry, F as ComponentsMap, u as CopyGlobs, t as CopyOptions, x as EnhanceOptions, E as EnhanceWxmlOptions, J as Entry, Q as EntryJsonFragment, h as GenerateDirsOptions, G as GenerateExtensionsOptions, j as GenerateFileType, i as GenerateFilenamesOptions, s as GenerateOptions, o as GenerateTemplate, k as GenerateTemplateContext, p as GenerateTemplateEntry, n as GenerateTemplateFactory, l as GenerateTemplateFileSource, m as GenerateTemplateInlineSource, q as GenerateTemplateScope, r as GenerateTemplatesConfig, H as HandleWxmlOptions, M as MpPlatform, N as PageEntry, P as ProjectConfig, R as ResolvedAlias, D as ScanComponentItem, w as ScanWxmlOptions, S as SubPackage, y as SubPackageMetaValue, U as UserConfig, W as WeappViteConfig, z as WxmlDep } from './config-CEyL0Mum.cjs';
1
+ export { A as Alias, g as AliasOptions, O as AppEntry, w as AutoImportComponents, K as BaseEntry, B as BuildNpmPackageMeta, Y as ChangeEvent, T as ComponentEntry, I as ComponentsMap, u as CopyGlobs, t as CopyOptions, y as EnhanceOptions, E as EnhanceWxmlOptions, N as Entry, V as EntryJsonFragment, h as GenerateDirsOptions, G as GenerateExtensionsOptions, j as GenerateFileType, i as GenerateFilenamesOptions, s as GenerateOptions, o as GenerateTemplate, k as GenerateTemplateContext, p as GenerateTemplateEntry, n as GenerateTemplateFactory, l as GenerateTemplateFileSource, m as GenerateTemplateInlineSource, q as GenerateTemplateScope, r as GenerateTemplatesConfig, H as HandleWxmlOptions, J as JsFormat, M as MpPlatform, Q as PageEntry, P as ProjectConfig, R as ResolvedAlias, F as ScanComponentItem, x as ScanWxmlOptions, S as SubPackage, z as SubPackageMetaValue, U as UserConfig, W as WeappViteConfig, X as WeappVitePluginApi, v as WeappWebConfig, D as WxmlDep } from './config-DNP6NeTc.cjs';
3
2
  export { RolldownBuild, RolldownOptions, RolldownOutput, RolldownPlugin, RolldownPluginOption, WatchOptions as RolldownWatchOptions, RolldownWatcher } from 'rolldown';
4
3
  export { ConfigEnv, InlineConfig, Plugin, PluginOption, ResolvedConfig, ViteDevServer } from 'vite';
5
- export { R as Resolver } from './types-D7SAXpSN.cjs';
4
+ export { A as AutoRoutes, a as AutoRoutesSubPackage } from './routes-C9hKJjXs.cjs';
5
+ export { a as Resolver } from './types-g_G_na7r.cjs';
6
6
  export { Options as NpmBuildOptions } from 'tsdown';
7
7
  import '@weapp-core/schematics';
8
+ import '@weapp-vite/web';
8
9
  import 'vite-plugin-performance';
9
10
  import 'vite-tsconfig-paths';
10
11
  import 'p-queue';
@@ -12,10 +13,3 @@ import 'package-manager-detector';
12
13
  import 'pkg-types';
13
14
  import 'node:buffer';
14
15
  import 'lru-cache';
15
-
16
- interface WeappVitePluginApi {
17
- ctx: CompilerContext;
18
- }
19
- type ChangeEvent = 'create' | 'update' | 'delete';
20
-
21
- export type { ChangeEvent, WeappVitePluginApi };
package/dist/types.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- import { C as CompilerContext } from './config-9I2A4BU9.js';
2
- export { A as Alias, g as AliasOptions, K as AppEntry, v as AutoImportComponents, I as BaseEntry, B as BuildNpmPackageMeta, O as ComponentEntry, F as ComponentsMap, u as CopyGlobs, t as CopyOptions, x as EnhanceOptions, E as EnhanceWxmlOptions, J as Entry, Q as EntryJsonFragment, h as GenerateDirsOptions, G as GenerateExtensionsOptions, j as GenerateFileType, i as GenerateFilenamesOptions, s as GenerateOptions, o as GenerateTemplate, k as GenerateTemplateContext, p as GenerateTemplateEntry, n as GenerateTemplateFactory, l as GenerateTemplateFileSource, m as GenerateTemplateInlineSource, q as GenerateTemplateScope, r as GenerateTemplatesConfig, H as HandleWxmlOptions, M as MpPlatform, N as PageEntry, P as ProjectConfig, R as ResolvedAlias, D as ScanComponentItem, w as ScanWxmlOptions, S as SubPackage, y as SubPackageMetaValue, U as UserConfig, W as WeappViteConfig, z as WxmlDep } from './config-9I2A4BU9.js';
1
+ export { A as Alias, g as AliasOptions, O as AppEntry, w as AutoImportComponents, K as BaseEntry, B as BuildNpmPackageMeta, Y as ChangeEvent, T as ComponentEntry, I as ComponentsMap, u as CopyGlobs, t as CopyOptions, y as EnhanceOptions, E as EnhanceWxmlOptions, N as Entry, V as EntryJsonFragment, h as GenerateDirsOptions, G as GenerateExtensionsOptions, j as GenerateFileType, i as GenerateFilenamesOptions, s as GenerateOptions, o as GenerateTemplate, k as GenerateTemplateContext, p as GenerateTemplateEntry, n as GenerateTemplateFactory, l as GenerateTemplateFileSource, m as GenerateTemplateInlineSource, q as GenerateTemplateScope, r as GenerateTemplatesConfig, H as HandleWxmlOptions, J as JsFormat, M as MpPlatform, Q as PageEntry, P as ProjectConfig, R as ResolvedAlias, F as ScanComponentItem, x as ScanWxmlOptions, S as SubPackage, z as SubPackageMetaValue, U as UserConfig, W as WeappViteConfig, X as WeappVitePluginApi, v as WeappWebConfig, D as WxmlDep } from './config-jhY9Idrt.js';
3
2
  export { RolldownBuild, RolldownOptions, RolldownOutput, RolldownPlugin, RolldownPluginOption, WatchOptions as RolldownWatchOptions, RolldownWatcher } from 'rolldown';
4
3
  export { ConfigEnv, InlineConfig, Plugin, PluginOption, ResolvedConfig, ViteDevServer } from 'vite';
5
- export { R as Resolver } from './types-D7SAXpSN.js';
4
+ export { A as AutoRoutes, a as AutoRoutesSubPackage } from './routes-C9hKJjXs.js';
5
+ export { a as Resolver } from './types-g_G_na7r.js';
6
6
  export { Options as NpmBuildOptions } from 'tsdown';
7
7
  import '@weapp-core/schematics';
8
+ import '@weapp-vite/web';
8
9
  import 'vite-plugin-performance';
9
10
  import 'vite-tsconfig-paths';
10
11
  import 'p-queue';
@@ -12,10 +13,3 @@ import 'package-manager-detector';
12
13
  import 'pkg-types';
13
14
  import 'node:buffer';
14
15
  import 'lru-cache';
15
-
16
- interface WeappVitePluginApi {
17
- ctx: CompilerContext;
18
- }
19
- type ChangeEvent = 'create' | 'update' | 'delete';
20
-
21
- export type { ChangeEvent, WeappVitePluginApi };
package/dist/types.mjs CHANGED
@@ -17,3 +17,6 @@ init_esm_shims();
17
17
 
18
18
  // src/types/plugin.ts
19
19
  init_esm_shims();
20
+
21
+ // src/types/routes.ts
22
+ init_esm_shims();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite",
3
3
  "type": "module",
4
- "version": "5.2.3",
4
+ "version": "5.4.0",
5
5
  "description": "weapp-vite 一个现代化的小程序打包工具",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -55,6 +55,11 @@
55
55
  "import": "./dist/auto-import-components/resolvers.mjs",
56
56
  "require": "./dist/auto-import-components/resolvers.cjs"
57
57
  },
58
+ "./auto-routes": {
59
+ "types": "./dist/auto-routes.d.ts",
60
+ "import": "./dist/auto-routes.mjs",
61
+ "require": "./dist/auto-routes.cjs"
62
+ },
58
63
  "./client": {
59
64
  "types": "./client.d.ts"
60
65
  },
@@ -88,47 +93,48 @@
88
93
  "debug": "^4.4.3",
89
94
  "fdir": "^6.5.0",
90
95
  "fs-extra": "^11.3.2",
91
- "oxc-parser": "^0.94.0",
96
+ "oxc-parser": "^0.95.0",
92
97
  "oxc-walker": "^0.5.2",
93
98
  "pathe": "^2.0.3",
94
99
  "picomatch": "^4.0.3",
95
100
  "postcss": "^8.5.6",
96
- "rolldown": "1.0.0-beta.42",
97
- "tsdown": "^0.15.6",
98
- "vite": "npm:rolldown-vite@^7.1.16",
101
+ "rolldown": "1.0.0-beta.43",
102
+ "tsdown": "^0.15.7",
103
+ "vite": "npm:rolldown-vite@^7.1.17",
99
104
  "vite-tsconfig-paths": "^5.1.4",
100
105
  "@weapp-core/init": "3.0.1",
101
- "@weapp-core/schematics": "4.0.0",
102
- "@weapp-core/logger": "2.0.0",
103
106
  "@weapp-core/shared": "2.0.1",
107
+ "@weapp-core/logger": "2.0.0",
104
108
  "@weapp-vite/volar": "0.0.1",
105
- "rolldown-require": "1.0.3",
109
+ "@weapp-vite/web": "0.0.2",
110
+ "rolldown-require": "1.0.4",
106
111
  "vite-plugin-performance": "1.0.0",
107
- "weapp-ide-cli": "4.0.0"
112
+ "weapp-ide-cli": "4.0.0",
113
+ "@weapp-core/schematics": "4.0.0"
108
114
  },
109
115
  "publishConfig": {
110
116
  "access": "public",
111
117
  "registry": "https://registry.npmjs.org"
112
118
  },
113
119
  "devDependencies": {
114
- "@oxc-project/types": "^0.94.0",
120
+ "@oxc-project/types": "^0.95.0",
115
121
  "@types/semver": "^7.7.1",
116
122
  "bundle-require": "^5.1.0",
117
123
  "cac": "^6.7.14",
118
124
  "chokidar": "^4.0.3",
119
125
  "del": "^8.0.1",
120
- "esbuild": "^0.25.10",
126
+ "esbuild": "^0.25.11",
121
127
  "estree-walker": "^3.0.3",
122
128
  "htmlparser2": "^10.0.0",
123
129
  "local-pkg": "^1.1.2",
124
130
  "lru-cache": "^11.2.2",
125
131
  "magic-string": "^0.30.19",
126
132
  "p-queue": "^9.0.0",
127
- "package-manager-detector": "^1.4.0",
133
+ "package-manager-detector": "^1.4.1",
128
134
  "resolve.exports": "^2.0.3",
129
135
  "rimraf": "6.0.1",
130
136
  "semver": "^7.7.3",
131
- "ts-morph": "^27.0.0",
137
+ "ts-morph": "^27.0.2",
132
138
  "vue": "^3.5.22"
133
139
  },
134
140
  "scripts": {