@moluoxixi/vite-config 0.0.27 → 0.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.cjs ADDED
@@ -0,0 +1,1218 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
25
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
26
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
27
+ const fs = require("node:fs");
28
+ const path = require("node:path");
29
+ const process$1 = require("node:process");
30
+ require("vue");
31
+ require("dotenv");
32
+ const tailwindcss = require("@tailwindcss/postcss");
33
+ const autoprefixer = require("autoprefixer");
34
+ const vite = require("vite");
35
+ const vitePluginHtml = require("vite-plugin-html");
36
+ const lodashEs = require("lodash-es");
37
+ function getType(obj, type) {
38
+ {
39
+ return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase() === type.toLowerCase();
40
+ }
41
+ }
42
+ async function dynamicImport(modulePromise, exportName = "default") {
43
+ const module2 = await modulePromise;
44
+ if (exportName === "default") {
45
+ return module2.default ?? module2;
46
+ }
47
+ if (!(exportName in module2)) {
48
+ throw new Error(`模块中不存在导出 "${exportName}"`);
49
+ }
50
+ return module2[exportName];
51
+ }
52
+ function isObject(value) {
53
+ return Object.prototype.toString.call(value) === "[object Object]";
54
+ }
55
+ function deepMerge(target, source) {
56
+ if (!isObject(source)) {
57
+ return target;
58
+ }
59
+ return Object.keys(source).reduce((acc, key) => {
60
+ const sourceValue = source[key];
61
+ const targetValue = acc[key];
62
+ if (isObject(sourceValue) && isObject(targetValue)) {
63
+ acc[key] = deepMerge(targetValue, sourceValue);
64
+ } else if (isObject(sourceValue)) {
65
+ acc[key] = deepMerge({}, sourceValue);
66
+ } else {
67
+ acc[key] = sourceValue;
68
+ }
69
+ return acc;
70
+ }, { ...target });
71
+ }
72
+ function validateMutuallyExclusive(values, defaultKey) {
73
+ const keys = Object.keys(values);
74
+ const enabledKeys = [];
75
+ for (const key of keys) {
76
+ if (values[key] === true) {
77
+ enabledKeys.push(key);
78
+ }
79
+ }
80
+ if (enabledKeys.length > 1) {
81
+ const keysStr = enabledKeys.join("、");
82
+ const allKeysStr = keys.join("、");
83
+ const selectedKey = enabledKeys.includes(defaultKey) ? defaultKey : enabledKeys[0];
84
+ console.warn(
85
+ `[validateMutuallyExclusive] ${allKeysStr} 只能启用一个,但当前启用了:${keysStr}。已自动选择:${String(selectedKey)}`
86
+ );
87
+ const result2 = {};
88
+ for (const key of keys) {
89
+ result2[key] = key === selectedKey;
90
+ }
91
+ return result2;
92
+ }
93
+ const hasEnabledKey = enabledKeys.length > 0;
94
+ const result = {};
95
+ for (const key of keys) {
96
+ if (!hasEnabledKey && defaultKey && key === defaultKey) {
97
+ result[key] = true;
98
+ } else {
99
+ result[key] = values[key] ?? false;
100
+ }
101
+ }
102
+ return result;
103
+ }
104
+ function detectFramework(config, rootDir) {
105
+ const root = rootDir || process$1.cwd();
106
+ const packageJsonPath = path.resolve(root, "package.json");
107
+ let vue = config.vue;
108
+ let react = config.react;
109
+ let vitepress = config.vitepress;
110
+ const hasExplicitFramework = vue === true || react === true || vitepress === true;
111
+ if (!hasExplicitFramework) {
112
+ let dependencies = {};
113
+ let devDependencies = {};
114
+ if (fs.existsSync(packageJsonPath)) {
115
+ try {
116
+ const packageJsonContent = fs.readFileSync(packageJsonPath, "utf-8");
117
+ const packageJson = JSON.parse(packageJsonContent);
118
+ dependencies = packageJson.dependencies || {};
119
+ devDependencies = packageJson.devDependencies || {};
120
+ } catch (error) {
121
+ console.warn(`无法读取 package.json: ${packageJsonPath}`, error);
122
+ }
123
+ }
124
+ if (vue === void 0) {
125
+ if (dependencies.vue || devDependencies.vue) {
126
+ vue = true;
127
+ }
128
+ }
129
+ if (react === void 0 && vue !== true) {
130
+ if (dependencies.react || devDependencies.react) {
131
+ react = true;
132
+ }
133
+ }
134
+ if (vitepress === void 0 && vue !== true && react !== true) {
135
+ if (dependencies.vitepress || devDependencies.vitepress) {
136
+ vitepress = true;
137
+ }
138
+ }
139
+ }
140
+ return {
141
+ vue: vue ?? false,
142
+ react: react ?? false,
143
+ vitepress: vitepress ?? false
144
+ };
145
+ }
146
+ function changeHtmlClassPrefix(htmlString = "", oldPrefix = "", newPrefix = "") {
147
+ const regex = new RegExp(
148
+ `(class|style)\\s*:\\s*((["']((${oldPrefix}\\b)-).*["'])|((_normalizeClass|_normalizeStyle)\\(.*(${oldPrefix}\\b)-.*\\)))`,
149
+ "g"
150
+ );
151
+ return htmlString.replace(regex, (match = "") => {
152
+ return match.replace(oldPrefix, newPrefix);
153
+ });
154
+ }
155
+ function changeSelectorPrefix(cssString = "", oldPrefix = "", newPrefix = "") {
156
+ const regex = new RegExp(`(\\.${oldPrefix}\\b|#${oldPrefix}\\b|--${oldPrefix}\\b)`, "g");
157
+ return cssString.replace(regex, (match = "") => {
158
+ return match.replace(oldPrefix, newPrefix);
159
+ });
160
+ }
161
+ function addScopedAndReplacePrefixPlugin({
162
+ prefixScoped = "",
163
+ oldPrefix = "",
164
+ newPrefix = "",
165
+ useDevMode = false
166
+ }) {
167
+ let isProduction;
168
+ return {
169
+ name: "addScopedAndReplacePrefix",
170
+ configResolved(config) {
171
+ isProduction = config.command === "build" || config.isProduction;
172
+ },
173
+ transform(code = "", id = "") {
174
+ if (!isProduction && !useDevMode)
175
+ return code;
176
+ if (!oldPrefix || !newPrefix)
177
+ return code;
178
+ if (id.includes("node_modules"))
179
+ return code;
180
+ const cssLangs = ["css", "scss", "less", "stylus", "styl"];
181
+ let newCode = code;
182
+ if (id.endsWith(".vue")) {
183
+ newCode = changeHtmlClassPrefix(newCode, oldPrefix, newPrefix);
184
+ } else if (cssLangs.some((lang) => id.endsWith(`.${lang}`))) {
185
+ if (oldPrefix && newPrefix) {
186
+ newCode = changeSelectorPrefix(newCode, oldPrefix, newPrefix);
187
+ }
188
+ if (prefixScoped) {
189
+ newCode = `${newCode}${prefixScoped}{${newCode}}`;
190
+ }
191
+ return newCode;
192
+ }
193
+ return newCode;
194
+ }
195
+ };
196
+ }
197
+ async function getViteConfig(Config, params) {
198
+ const configResult = typeof Config === "function" ? Config(params) : Config;
199
+ const config = configResult;
200
+ const { mode = "base" } = params || {};
201
+ const rootPath = config.rootPath || process.cwd();
202
+ const modeConfig = config.mode || {};
203
+ const baseConfig = modeConfig.base || {};
204
+ const currentModeConfig = modeConfig[mode] || {};
205
+ const viteEnv = { ...baseConfig, ...currentModeConfig };
206
+ const isDev = mode === "development";
207
+ const {
208
+ autoImport = config.autoImport ?? true,
209
+ autoComponent = config.autoComponent ?? true,
210
+ compression = config.compression ?? true,
211
+ imagemin = config.imagemin ?? true,
212
+ codeInspector = config.codeInspector ?? true,
213
+ port = config.port,
214
+ visualizer = config.visualizer ?? false,
215
+ autoRoutes = config.autoRoutes ?? false,
216
+ cdn = config.cdn ?? false,
217
+ pageRoutes = config.pageRoutes ?? false,
218
+ pwa = config.pwa ?? false,
219
+ devtools = config.devtools,
220
+ open = config.open,
221
+ qiankunDevMode = config.qiankunDevMode,
222
+ qiankun = config.qiankun,
223
+ namespace = config.namespace,
224
+ dropConsole = config.dropConsole,
225
+ vue: vueRaw = config.vue,
226
+ react: reactRaw = config.react,
227
+ vitepress: vitepressRaw = config.vitepress
228
+ } = viteEnv;
229
+ const frameworkResult = detectFramework(
230
+ {
231
+ vue: vueRaw,
232
+ react: reactRaw,
233
+ vitepress: vitepressRaw
234
+ },
235
+ rootPath
236
+ );
237
+ const { vue, react, vitepress } = validateMutuallyExclusive(
238
+ frameworkResult,
239
+ "vue"
240
+ );
241
+ const appTitle = config.appTitle;
242
+ const appCode = config.appCode;
243
+ const isVueOrVitepress = vue || vitepress;
244
+ const envSystemCode = isDev && !qiankunDevMode ? "el" : namespace ?? appCode;
245
+ const plugins = [
246
+ vitePluginHtml.createHtmlPlugin({
247
+ inject: {
248
+ data: {
249
+ title: appTitle
250
+ }
251
+ }
252
+ })
253
+ ];
254
+ if (vue) {
255
+ const pluginVue = await dynamicImport(import("@vitejs/plugin-vue"));
256
+ plugins.push(pluginVue());
257
+ }
258
+ if (react) {
259
+ const pluginReact = await dynamicImport(import("@vitejs/plugin-react"));
260
+ plugins.push(pluginReact());
261
+ }
262
+ if (isVueOrVitepress) {
263
+ const vueJsx = await dynamicImport(import("@vitejs/plugin-vue-jsx"));
264
+ plugins.push(vueJsx());
265
+ }
266
+ if (pageRoutes) {
267
+ const Pages = await dynamicImport(import("vite-plugin-pages"));
268
+ const extensions = [];
269
+ if (vue) {
270
+ extensions.push("vue");
271
+ }
272
+ if (react) {
273
+ extensions.push("tsx", "jsx");
274
+ }
275
+ plugins.push(Pages(
276
+ deepMerge(
277
+ {
278
+ dirs: "src/pages",
279
+ extensions,
280
+ exclude: [
281
+ "**/components/**",
282
+ "**/__tests__/**"
283
+ ]
284
+ },
285
+ pageRoutes
286
+ )
287
+ ));
288
+ }
289
+ if (isDev && devtools && isVueOrVitepress) {
290
+ const vueDevTools = await dynamicImport(import("vite-plugin-vue-devtools"));
291
+ plugins.push(vueDevTools());
292
+ }
293
+ if (autoImport && isVueOrVitepress) {
294
+ const AutoImport = await dynamicImport(import("unplugin-auto-import/vite"));
295
+ const ElementPlusResolverModule = await dynamicImport(import("unplugin-vue-components/resolvers"));
296
+ const { ElementPlusResolver } = ElementPlusResolverModule;
297
+ plugins.push(AutoImport(
298
+ deepMerge(
299
+ {
300
+ imports: ["vue"],
301
+ resolvers: [ElementPlusResolver()],
302
+ dts: path.resolve(rootPath, "./typings/auto-imports.d.ts")
303
+ },
304
+ autoImport
305
+ )
306
+ ));
307
+ }
308
+ if (autoComponent && isVueOrVitepress) {
309
+ const Components = await dynamicImport(import("unplugin-vue-components/vite"));
310
+ const ElementPlusResolverModule = await dynamicImport(import("unplugin-vue-components/resolvers"));
311
+ const { ElementPlusResolver } = ElementPlusResolverModule;
312
+ plugins.push(Components(
313
+ deepMerge(
314
+ {
315
+ resolvers: [ElementPlusResolver()],
316
+ globs: [],
317
+ dts: path.resolve(rootPath, "./typings/components.d.ts")
318
+ },
319
+ autoComponent
320
+ )
321
+ ));
322
+ }
323
+ if (compression) {
324
+ const viteCompression = await dynamicImport(import("vite-plugin-compression"));
325
+ const compressionPlugin = viteCompression;
326
+ plugins.push(compressionPlugin(
327
+ deepMerge(
328
+ {
329
+ algorithm: "brotliCompress",
330
+ verbose: true,
331
+ disable: false,
332
+ ext: ".gz",
333
+ threshold: 10240,
334
+ deleteOriginFile: false
335
+ },
336
+ compression
337
+ )
338
+ ));
339
+ }
340
+ if (imagemin) {
341
+ const viteImagemin = await dynamicImport(import("vite-plugin-imagemin"));
342
+ const imageminPlugin = viteImagemin;
343
+ plugins.push(imageminPlugin(
344
+ deepMerge(
345
+ {
346
+ gifsicle: { optimizationLevel: 7, interlaced: false },
347
+ optipng: { optimizationLevel: 7 },
348
+ mozjpeg: { quality: 20 },
349
+ pngquant: { quality: [0.8, 0.9], speed: 4 },
350
+ svgo: {
351
+ plugins: [{ name: "removeViewBox" }, { name: "removeEmptyAttrs", active: false }]
352
+ }
353
+ },
354
+ imagemin
355
+ )
356
+ ));
357
+ }
358
+ if (cdn) {
359
+ const importToCDN = await dynamicImport(import("vite-plugin-cdn-import"));
360
+ const { modules: modules2 } = await dynamicImport(Promise.resolve().then(() => index$1));
361
+ plugins.push(importToCDN(
362
+ deepMerge(
363
+ {
364
+ enableInDevMode: false,
365
+ prodUrl: "/{name}@{version}{path}",
366
+ modules: modules2,
367
+ generateScriptTag: (_name, scriptUrl) => {
368
+ const esmArr = ["esm", ".mjs"];
369
+ const isESM = esmArr.some((item) => scriptUrl.includes(item));
370
+ if (isESM) {
371
+ return {
372
+ attrs: {
373
+ src: scriptUrl,
374
+ type: "module",
375
+ crossorigin: "anonymous"
376
+ },
377
+ injectTo: "head"
378
+ };
379
+ } else {
380
+ return {
381
+ attrs: {
382
+ src: scriptUrl,
383
+ crossorigin: "anonymous"
384
+ },
385
+ injectTo: "head"
386
+ };
387
+ }
388
+ }
389
+ },
390
+ cdn
391
+ )
392
+ ));
393
+ }
394
+ if (visualizer) {
395
+ const visualizerModule = await dynamicImport(import("rollup-plugin-visualizer"));
396
+ const { visualizer: visualizerPlugin } = visualizerModule;
397
+ plugins.push(visualizerPlugin(
398
+ deepMerge(
399
+ {
400
+ open: true
401
+ },
402
+ visualizer
403
+ )
404
+ ));
405
+ }
406
+ if (pwa) {
407
+ const pwaModule = await dynamicImport(import("vite-plugin-pwa"));
408
+ const { VitePWA } = pwaModule;
409
+ plugins.push(VitePWA(
410
+ deepMerge(
411
+ {
412
+ strategies: "generateSW",
413
+ registerType: "autoUpdate",
414
+ // 开发模式下也启用
415
+ devOptions: {
416
+ enabled: true
417
+ },
418
+ includeAssets: ["favicon.ico", "apple-touch-icon.png", "mask-icon.svg"],
419
+ manifest: {
420
+ id: appCode ? `/${appCode}/` : "/",
421
+ start_url: appCode ? `/${appCode}/` : "/",
422
+ name: appTitle || "应用",
423
+ short_name: appTitle || "应用",
424
+ description: "渐进式 Web 应用",
425
+ display: "standalone",
426
+ background_color: "#ffffff",
427
+ theme_color: "#BA42BF"
428
+ }
429
+ },
430
+ pwa
431
+ )
432
+ ));
433
+ }
434
+ if (isDev && codeInspector) {
435
+ const codeInspectorModule = await dynamicImport(import("code-inspector-plugin"));
436
+ const { codeInspectorPlugin } = codeInspectorModule;
437
+ plugins.push(codeInspectorPlugin(
438
+ deepMerge(
439
+ {
440
+ bundler: "vite",
441
+ showSwitch: true
442
+ },
443
+ codeInspector
444
+ )
445
+ ));
446
+ }
447
+ if (qiankun) {
448
+ const qiankunPlugin = await dynamicImport(import("vite-plugin-qiankun"));
449
+ const qiankunPluginFn = qiankunPlugin;
450
+ plugins.push(qiankunPluginFn(envSystemCode || "el", { useDevMode: qiankunDevMode }));
451
+ if (appCode) {
452
+ plugins.push(addScopedAndReplacePrefixPlugin({
453
+ prefixScoped: `div[data-qiankun='${envSystemCode}']`,
454
+ oldPrefix: "el",
455
+ newPrefix: appCode,
456
+ useDevMode: qiankunDevMode
457
+ }));
458
+ }
459
+ }
460
+ if (autoRoutes && isVueOrVitepress) {
461
+ const AutoRoutesPlugin = await dynamicImport(Promise.resolve().then(() => index));
462
+ plugins.push(AutoRoutesPlugin(
463
+ deepMerge(
464
+ {
465
+ root: rootPath,
466
+ routeConfig: {
467
+ views: ["/src/views/**/index.vue", "!/src/views/**/components/*"],
468
+ examples: "/src/examples/**/index.vue",
469
+ componentExamples: {
470
+ glob: ["/src/components/**/Example.vue", "!/src/components/**/components/*"],
471
+ baseRoute: "组件示例"
472
+ }
473
+ },
474
+ dts: path.resolve(rootPath, "./typings/auto-routes.d.ts")
475
+ },
476
+ autoRoutes
477
+ )
478
+ ));
479
+ }
480
+ const defaultConfig = {
481
+ plugins,
482
+ esbuild: {
483
+ pure: !isDev && dropConsole ? ["console.log", "console.info", "console.debug"] : []
484
+ },
485
+ build: {
486
+ sourcemap: isDev,
487
+ outDir: appCode || "dist",
488
+ cssCodeSplit: true,
489
+ chunkSizeWarningLimit: 1500,
490
+ minify: "esbuild",
491
+ rollupOptions: {
492
+ external: [],
493
+ output: {
494
+ globals: {},
495
+ chunkFileNames: "static/js/[name]-[hash].js",
496
+ entryFileNames: "static/js/[name]-[hash].js",
497
+ assetFileNames: "static/[ext]/[name]-[hash].[ext]",
498
+ manualChunks: (id) => {
499
+ if (id.includes("node_modules")) {
500
+ if (id.includes("lodash-es")) {
501
+ return "lodash-vendor";
502
+ }
503
+ if (id.includes("element-plus")) {
504
+ return "el-vendor";
505
+ }
506
+ if (id.includes("@vue") || id.includes("vue")) {
507
+ return "vue-vendor";
508
+ }
509
+ if (id.includes("antd") || id.includes("@ant-design")) {
510
+ return "antd-vendor";
511
+ }
512
+ if (id.includes("react-dom")) {
513
+ return "react-dom-vendor";
514
+ }
515
+ if (id.includes("react")) {
516
+ return "react-vendor";
517
+ }
518
+ return "vendor";
519
+ }
520
+ }
521
+ }
522
+ }
523
+ },
524
+ define: {
525
+ __SYSTEM_CODE__: JSON.stringify(envSystemCode),
526
+ process: deepMerge({
527
+ env: {
528
+ VUE_APP_VXE_ENV: "production"
529
+ }
530
+ }, process)
531
+ },
532
+ css: {
533
+ preprocessorOptions: {
534
+ scss: {
535
+ api: "modern-compiler"
536
+ }
537
+ },
538
+ postcss: {
539
+ plugins: [tailwindcss(), autoprefixer()]
540
+ },
541
+ devSourcemap: isDev
542
+ },
543
+ resolve: {
544
+ extensions: [".js", ".jsx", ".ts", ".tsx", ".vue"],
545
+ alias: {
546
+ "@": path.resolve(rootPath, "./src")
547
+ }
548
+ },
549
+ server: {
550
+ host: "0.0.0.0",
551
+ port,
552
+ open,
553
+ cors: true,
554
+ proxy: {}
555
+ }
556
+ };
557
+ if (!vitepress && appCode) {
558
+ defaultConfig.base = `/${appCode}`;
559
+ }
560
+ const viteConfig = typeof config.viteConfig === "function" ? config.viteConfig(params) : config.viteConfig;
561
+ const viteConfigPluginNames = ((viteConfig == null ? void 0 : viteConfig.plugins) || []).map((i) => {
562
+ const plugin = Array.isArray(i) ? i[0] : i;
563
+ return plugin == null ? void 0 : plugin.name;
564
+ }).filter((name) => Boolean(name));
565
+ const defaultPluginNamesMap = (defaultConfig.plugins || []).reduce((nameMap, i) => {
566
+ const plugin = Array.isArray(i) ? i[0] : i;
567
+ const name = plugin == null ? void 0 : plugin.name;
568
+ if (name) {
569
+ nameMap[name] = i;
570
+ }
571
+ return nameMap;
572
+ }, {});
573
+ const uniquePlugin = [];
574
+ Object.keys(defaultPluginNamesMap).forEach((name) => {
575
+ if (!viteConfigPluginNames.includes(name)) {
576
+ uniquePlugin.push(defaultPluginNamesMap[name]);
577
+ }
578
+ });
579
+ defaultConfig.plugins = uniquePlugin;
580
+ return vite.mergeConfig(defaultConfig, viteConfig || {});
581
+ }
582
+ function createViteConfig(Config) {
583
+ return vite.defineConfig(async (params) => await getViteConfig(Config, params));
584
+ }
585
+ function wrapperEnv(env) {
586
+ const result = {};
587
+ for (const key in env) {
588
+ if (Object.prototype.hasOwnProperty.call(env, key)) {
589
+ const value = env[key].trim();
590
+ if (value === "true" || value === "false") {
591
+ result[key] = value === "true";
592
+ } else if (!Number.isNaN(Number(value))) {
593
+ result[key] = Number(value);
594
+ } else if (value === "") {
595
+ result[key] = null;
596
+ } else {
597
+ result[key] = value;
598
+ }
599
+ }
600
+ }
601
+ return result;
602
+ }
603
+ function getCamelCase(str) {
604
+ return str.replace(/[-_]+/g, " ").replace(/(?:^|\s)\w/g, (match) => match.toUpperCase()).replace(/\s+/g, "");
605
+ }
606
+ function getCdnModules(modules2) {
607
+ function getPath(str) {
608
+ if (!str)
609
+ return "";
610
+ return str.startsWith("/") ? str : `/${str}`;
611
+ }
612
+ return modules2.map((item) => {
613
+ if (typeof item === "string") {
614
+ return {
615
+ name: item,
616
+ var: getCamelCase(item),
617
+ path: ""
618
+ };
619
+ } else {
620
+ return item;
621
+ }
622
+ }).map((item) => {
623
+ return {
624
+ name: item.name,
625
+ var: item.var || getCamelCase(item.name),
626
+ path: getPath(item.path),
627
+ css: getPath(item.css)
628
+ };
629
+ });
630
+ }
631
+ const modules = getCdnModules([]);
632
+ const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
633
+ __proto__: null,
634
+ modules
635
+ }, Symbol.toStringTag, { value: "Module" }));
636
+ function resolvePatternsToAbsolute(patterns, rootDir) {
637
+ return patterns.map((p) => vite.normalizePath(path.isAbsolute(p) ? p : path.resolve(rootDir, p)));
638
+ }
639
+ function extractStaticPrefixFromGlob(absPattern) {
640
+ const special = ["*", "?", "{", "}", "!", "(", ")", "[", "]"];
641
+ const idx = absPattern.split("").findIndex((ch) => special.includes(ch));
642
+ return idx === -1 ? absPattern : absPattern.slice(0, idx);
643
+ }
644
+ function createMatcher(prefixes) {
645
+ return (absFile) => prefixes.some((prefix) => absFile.startsWith(prefix));
646
+ }
647
+ class VirtualModuleState {
648
+ constructor() {
649
+ /** 标记服务器是否正在关闭,避免关闭阶段再触发无效操作 */
650
+ __publicField(this, "isServerClosing", false);
651
+ /** 标记初始化是否完成,初始化期间的变化会被延迟处理 */
652
+ __publicField(this, "isInitialized", false);
653
+ /** 标记初始化期间是否有文件变化,初始化完成后会处理这些变化 */
654
+ __publicField(this, "hasPendingChange", false);
655
+ /** HMR 热更新的防抖函数,lodash-es debounce 返回的函数有 cancel 方法,可以手动取消 */
656
+ __publicField(this, "hmrDebouncedInvalidate");
657
+ /** watchChange 钩子的防抖函数,用于清理模块缓存 */
658
+ __publicField(this, "watchChangeDebouncedClear");
659
+ /** 文件监听器的防抖函数 */
660
+ __publicField(this, "watcherDebouncedInvalidate");
661
+ }
662
+ /**
663
+ * 清理所有防抖定时器
664
+ * 在服务器关闭时调用,确保不会有待执行的防抖任务
665
+ */
666
+ clearAll() {
667
+ var _a, _b, _c;
668
+ (_a = this.hmrDebouncedInvalidate) == null ? void 0 : _a.cancel();
669
+ (_b = this.watchChangeDebouncedClear) == null ? void 0 : _b.cancel();
670
+ (_c = this.watcherDebouncedInvalidate) == null ? void 0 : _c.cancel();
671
+ }
672
+ }
673
+ function invalidateModules(server, virtualModuleId, moduleCache) {
674
+ const ids = Array.from(moduleCache.keys()).filter(
675
+ (k) => k === virtualModuleId || k.startsWith(`${virtualModuleId}/`)
676
+ );
677
+ const mods = [];
678
+ for (const vid of ids) {
679
+ moduleCache.delete(vid);
680
+ const mod = server.moduleGraph.getModuleById(vid);
681
+ if (mod) {
682
+ server.moduleGraph.invalidateModule(mod);
683
+ mods.push(mod);
684
+ }
685
+ }
686
+ return mods;
687
+ }
688
+ function sendHmrUpdate(server, mods) {
689
+ var _a;
690
+ if (mods.length === 0) {
691
+ server == null ? void 0 : server.ws.send({ type: "full-reload" });
692
+ return;
693
+ }
694
+ try {
695
+ for (const mod of mods) {
696
+ try {
697
+ (_a = server.reloadModule) == null ? void 0 : _a.call(server, mod);
698
+ } catch {
699
+ }
700
+ }
701
+ server == null ? void 0 : server.ws.send({
702
+ type: "update",
703
+ updates: mods.map((mod) => ({
704
+ type: "js-update",
705
+ path: mod.url,
706
+ acceptedPath: mod.url,
707
+ timestamp: Date.now()
708
+ }))
709
+ });
710
+ } catch {
711
+ server == null ? void 0 : server.ws.send({ type: "full-reload" });
712
+ }
713
+ }
714
+ function setupFileWatcher(options) {
715
+ var _a;
716
+ const { server, watchPatterns, isWatchedPath, onInvalidate, debounceMs, onInitialized } = options;
717
+ let watcherReady = false;
718
+ let netReady = false;
719
+ let enabled = false;
720
+ const debouncedInvalidate = lodashEs.debounce(onInvalidate, debounceMs, {
721
+ trailing: true,
722
+ leading: false
723
+ });
724
+ const maybeEnable = () => {
725
+ var _a2;
726
+ if (enabled || !watcherReady || !netReady)
727
+ return;
728
+ enabled = true;
729
+ try {
730
+ if (watchPatterns.length > 0)
731
+ server.watcher.add(watchPatterns);
732
+ } catch {
733
+ }
734
+ const handleFileChange = (eventName, file) => {
735
+ if (eventName === "change" || eventName === "unlink" || eventName === "unlinkDir" || watcherReady && (eventName === "add" || eventName === "addDir")) {
736
+ const abs = vite.normalizePath(
737
+ path.isAbsolute(file) ? file : path.resolve(server.config.root, file)
738
+ );
739
+ if (isWatchedPath(abs))
740
+ debouncedInvalidate();
741
+ }
742
+ };
743
+ server.watcher.on("all", handleFileChange);
744
+ const cleanup = () => {
745
+ debouncedInvalidate.cancel();
746
+ server.watcher.off("all", handleFileChange);
747
+ };
748
+ server.watcher.once("close", cleanup);
749
+ (_a2 = server.httpServer) == null ? void 0 : _a2.once("close", cleanup);
750
+ onInitialized == null ? void 0 : onInitialized();
751
+ };
752
+ server.watcher.once("ready", () => {
753
+ watcherReady = true;
754
+ maybeEnable();
755
+ });
756
+ (_a = server.httpServer) == null ? void 0 : _a.once("listening", () => {
757
+ netReady = true;
758
+ maybeEnable();
759
+ });
760
+ const wsAny = server.ws;
761
+ if (typeof (wsAny == null ? void 0 : wsAny.on) === "function") {
762
+ const connectionHandler = () => {
763
+ var _a2, _b;
764
+ netReady = true;
765
+ maybeEnable();
766
+ try {
767
+ (_a2 = wsAny.off) == null ? void 0 : _a2.call(wsAny, "connection", connectionHandler);
768
+ } catch {
769
+ }
770
+ try {
771
+ (_b = wsAny.removeListener) == null ? void 0 : _b.call(wsAny, "connection", connectionHandler);
772
+ } catch {
773
+ }
774
+ };
775
+ wsAny.on("connection", connectionHandler);
776
+ }
777
+ }
778
+ function writeDtsFile(config, rootDir, dts, generateDts) {
779
+ if (dts === false || !generateDts)
780
+ return;
781
+ try {
782
+ const dtsPath = typeof dts === "string" ? path.isAbsolute(dts) ? dts : path.resolve(rootDir, dts) : path.resolve(rootDir, "./src/typings/virtual-module.d.ts");
783
+ const content = generateDts({ config });
784
+ const normalized = vite.normalizePath(dtsPath);
785
+ const dir = path.dirname(normalized);
786
+ fs.mkdirSync(dir, { recursive: true });
787
+ fs.writeFileSync(normalized, content, "utf-8");
788
+ } catch {
789
+ }
790
+ }
791
+ function callUserHook(hook, context, ...args) {
792
+ if (!hook)
793
+ return void 0;
794
+ if (typeof hook === "function") {
795
+ return hook.call(context, ...args);
796
+ } else if (hook.handler) {
797
+ return hook.handler.call(context, ...args);
798
+ }
799
+ return void 0;
800
+ }
801
+ function createVirtualPlugin(userConfig) {
802
+ const {
803
+ virtualModuleId,
804
+ dts,
805
+ root,
806
+ watch,
807
+ debounceMs = 2e3,
808
+ ...restConfig
809
+ } = userConfig;
810
+ const VIRTUAL_MODULE_ID = virtualModuleId;
811
+ const {
812
+ resolveId,
813
+ load,
814
+ configResolved,
815
+ configureServer,
816
+ handleHotUpdate,
817
+ watchChange,
818
+ generateModule,
819
+ generateDts,
820
+ ...restHooks
821
+ } = restConfig;
822
+ const moduleCache = /* @__PURE__ */ new Map();
823
+ const state = new VirtualModuleState();
824
+ let resolvedViteConfig;
825
+ let watchPatterns = [];
826
+ let isWatchedPath = () => true;
827
+ const performInvalidate = (server) => {
828
+ if (state.isServerClosing)
829
+ return;
830
+ const mods = invalidateModules(server, VIRTUAL_MODULE_ID, moduleCache);
831
+ sendHmrUpdate(server, mods);
832
+ };
833
+ const handleFileChange = (server) => {
834
+ if (!state.isInitialized) {
835
+ state.hasPendingChange = true;
836
+ return;
837
+ }
838
+ performInvalidate(server);
839
+ };
840
+ return {
841
+ /**
842
+ * 解析虚拟模块 ID
843
+ * 当 import 语句引用虚拟模块时,Vite 会调用此方法
844
+ * @param args - resolveId 的所有参数
845
+ * @returns 如果匹配虚拟模块 ID,返回该 ID;否则返回 undefined
846
+ */
847
+ resolveId(...args) {
848
+ const [id] = args;
849
+ if (id === VIRTUAL_MODULE_ID || id.startsWith(`${VIRTUAL_MODULE_ID}/`))
850
+ return id;
851
+ return callUserHook(resolveId, this, ...args);
852
+ },
853
+ /**
854
+ * 配置解析完成钩子
855
+ * 在 Vite 配置解析完成后调用,用于初始化监听路径和生成类型声明文件
856
+ * @param args - configResolved 的所有参数
857
+ */
858
+ configResolved(...args) {
859
+ const [config] = args;
860
+ resolvedViteConfig = config;
861
+ const rootDir = root || config.root;
862
+ const patterns = Array.isArray(watch) ? watch : watch ? [watch] : [];
863
+ watchPatterns = resolvePatternsToAbsolute(patterns, rootDir);
864
+ const watchPrefixes = watchPatterns.map(extractStaticPrefixFromGlob);
865
+ isWatchedPath = watchPrefixes.length === 0 ? () => true : createMatcher(watchPrefixes);
866
+ writeDtsFile(config, rootDir, dts, generateDts);
867
+ callUserHook(configResolved, this, ...args);
868
+ },
869
+ /**
870
+ * 配置开发服务器钩子
871
+ * 在开发服务器启动时调用,用于设置文件监听、信号处理和清理逻辑
872
+ * @param args - configureServer 的所有参数
873
+ */
874
+ configureServer(...args) {
875
+ var _a;
876
+ const [server] = args;
877
+ const handleSignal = () => {
878
+ var _a2;
879
+ if (state.isServerClosing)
880
+ return;
881
+ state.isServerClosing = true;
882
+ Promise.resolve((_a2 = server == null ? void 0 : server.close) == null ? void 0 : _a2.call(server)).finally(() => {
883
+ try {
884
+ process$1.exit(0);
885
+ } catch {
886
+ }
887
+ });
888
+ };
889
+ process$1.once("SIGINT", handleSignal);
890
+ process$1.once("SIGTERM", handleSignal);
891
+ (_a = server.httpServer) == null ? void 0 : _a.once("close", () => {
892
+ state.isServerClosing = true;
893
+ state.clearAll();
894
+ });
895
+ setupFileWatcher({
896
+ server,
897
+ watchPatterns,
898
+ isWatchedPath,
899
+ onInvalidate: () => handleFileChange(server),
900
+ debounceMs,
901
+ onInitialized: () => {
902
+ state.isInitialized = true;
903
+ if (state.hasPendingChange) {
904
+ state.hasPendingChange = false;
905
+ setTimeout(() => {
906
+ if (!state.isServerClosing)
907
+ performInvalidate(server);
908
+ }, 0);
909
+ }
910
+ }
911
+ });
912
+ callUserHook(configureServer, this, ...args);
913
+ },
914
+ /**
915
+ * 处理热更新钩子
916
+ * 当 Vite 检测到文件变化时调用,用于触发虚拟模块的失效和更新
917
+ * @param args - handleHotUpdate 的所有参数
918
+ * @returns 空数组,表示不阻止其他插件的处理
919
+ * @remarks
920
+ * - 使用防抖机制避免频繁触发
921
+ * - 初始化期间的变化会被延迟处理
922
+ * - 只处理匹配监听路径的文件变化
923
+ */
924
+ handleHotUpdate(...args) {
925
+ const [ctx] = args;
926
+ const { server } = ctx;
927
+ const rootDir = root || (resolvedViteConfig == null ? void 0 : resolvedViteConfig.root) || server.config.root;
928
+ const abs = vite.normalizePath(
929
+ path.isAbsolute(ctx.file) ? ctx.file : path.resolve(rootDir, ctx.file)
930
+ );
931
+ if (!isWatchedPath(abs) || state.isServerClosing)
932
+ return;
933
+ if (!state.isInitialized) {
934
+ state.hasPendingChange = true;
935
+ return [];
936
+ }
937
+ if (!state.hmrDebouncedInvalidate) {
938
+ state.hmrDebouncedInvalidate = lodashEs.debounce(
939
+ () => {
940
+ if (state.isServerClosing)
941
+ return;
942
+ performInvalidate(server);
943
+ },
944
+ debounceMs,
945
+ { trailing: true, leading: false }
946
+ );
947
+ }
948
+ state.hmrDebouncedInvalidate();
949
+ return callUserHook(handleHotUpdate, this, ...args) || [];
950
+ },
951
+ /**
952
+ * 监听文件变化钩子
953
+ * 当 Vite 的依赖预构建或文件系统检测到变化时调用
954
+ * 主要用于清理模块缓存,让下次加载时重新生成
955
+ * @param args - watchChange 的所有参数
956
+ * @remarks
957
+ * - 与 handleHotUpdate 不同,此钩子主要用于清理缓存,不触发 HMR
958
+ * - 使用防抖机制避免频繁清理
959
+ * - 初始化期间的变化会被延迟处理
960
+ */
961
+ watchChange(...args) {
962
+ try {
963
+ const [id] = args;
964
+ const rootDir = root || (resolvedViteConfig == null ? void 0 : resolvedViteConfig.root) || process$1.cwd();
965
+ const absId = vite.normalizePath(path.isAbsolute(id) ? id : path.resolve(rootDir, id));
966
+ if (!isWatchedPath(absId) || state.isServerClosing) {
967
+ return;
968
+ }
969
+ if (!state.isInitialized) {
970
+ state.hasPendingChange = true;
971
+ return;
972
+ }
973
+ if (!state.watchChangeDebouncedClear) {
974
+ state.watchChangeDebouncedClear = lodashEs.debounce(
975
+ () => {
976
+ if (state.isServerClosing)
977
+ return;
978
+ for (const k of Array.from(moduleCache.keys())) {
979
+ if (k === VIRTUAL_MODULE_ID || k.startsWith(`${VIRTUAL_MODULE_ID}/`))
980
+ moduleCache.delete(k);
981
+ }
982
+ },
983
+ debounceMs,
984
+ { trailing: true, leading: false }
985
+ );
986
+ }
987
+ state.watchChangeDebouncedClear();
988
+ return callUserHook(watchChange, this, ...args);
989
+ } catch {
990
+ }
991
+ },
992
+ /**
993
+ * 加载虚拟模块内容
994
+ * 当 import 语句引用虚拟模块时,Vite 会调用此方法获取模块代码
995
+ * @param args - load 的所有参数
996
+ * @returns 模块代码字符串,如果 ID 不匹配则返回 undefined
997
+ * @remarks
998
+ * - 支持同步和异步的 generateModule 函数
999
+ * - 生成的代码会被缓存,直到模块被失效
1000
+ * - 子路径导入(如 'virtual:routes/sub')会传入完整 ID 给 generateModule
1001
+ */
1002
+ async load(...args) {
1003
+ const [id] = args;
1004
+ if (id === VIRTUAL_MODULE_ID || id.startsWith(`${VIRTUAL_MODULE_ID}/`)) {
1005
+ const code = getType(generateModule, "asyncfunction") ? await generateModule({ id, config: resolvedViteConfig }) : generateModule({ id, config: resolvedViteConfig });
1006
+ moduleCache.set(id, code);
1007
+ return code;
1008
+ }
1009
+ return await callUserHook(load, this, ...args);
1010
+ },
1011
+ // 使用 rest 参数包含所有其他未使用的钩子(包括 name, transform, enforce 等)
1012
+ ...restHooks
1013
+ };
1014
+ }
1015
+ function cleanRoute(route) {
1016
+ const cleaned = { ...route };
1017
+ if (cleaned.children) {
1018
+ if (Array.isArray(cleaned.children) && cleaned.children.length > 0) {
1019
+ cleaned.children = cleaned.children.map(cleanRoute);
1020
+ } else {
1021
+ delete cleaned.children;
1022
+ }
1023
+ }
1024
+ return cleaned;
1025
+ }
1026
+ function findParentRouteHandle(modules2, parentPath) {
1027
+ for (const route of modules2) {
1028
+ if (route.path === parentPath) {
1029
+ return route;
1030
+ }
1031
+ if (route.children) {
1032
+ const found = findParentRouteHandle(route.children, parentPath);
1033
+ if (found)
1034
+ return found;
1035
+ }
1036
+ }
1037
+ return void 0;
1038
+ }
1039
+ function parseModulePath(modulePath) {
1040
+ const pathArr = modulePath.split("/").filter((item) => item && !item.includes("."));
1041
+ if (pathArr.at(-1) === "src") {
1042
+ pathArr.pop();
1043
+ }
1044
+ const componentName = pathArr.at(-1);
1045
+ const path2 = `/${pathArr.join("/")}`;
1046
+ const parentPath = `/${pathArr.slice(0, -1).join("/")}`;
1047
+ return { pathArr, componentName, path: path2, parentPath };
1048
+ }
1049
+ function processComponent(componentLoader, componentName, eager) {
1050
+ if (eager) {
1051
+ return {
1052
+ component: componentLoader,
1053
+ metaTitle: (componentLoader == null ? void 0 : componentLoader.name) || componentName
1054
+ };
1055
+ }
1056
+ return {
1057
+ component: typeof componentLoader === "function" ? componentLoader : componentLoader,
1058
+ metaTitle: componentName
1059
+ };
1060
+ }
1061
+ function generateRoutes(files, prefix = "", baseRoute, eager = false) {
1062
+ const newBaseRoute = typeof baseRoute === "string" ? { name: baseRoute } : baseRoute;
1063
+ const modules2 = newBaseRoute ? [newBaseRoute] : [];
1064
+ const fileKeys = Object.keys(files);
1065
+ if (fileKeys.length === 0) {
1066
+ return [];
1067
+ }
1068
+ return fileKeys.sort((a, b) => {
1069
+ const aLength = a.split("/").length;
1070
+ const bLength = b.split("/").length;
1071
+ return bLength > aLength ? -1 : 1;
1072
+ }).reduce((modules22 = [], modulePath) => {
1073
+ const componentLoader = files[modulePath];
1074
+ if (!componentLoader || modulePath === "install") {
1075
+ return modules22;
1076
+ }
1077
+ const { path: path2, parentPath, componentName } = parseModulePath(modulePath);
1078
+ if (!componentName) {
1079
+ return modules22;
1080
+ }
1081
+ let parentRoute;
1082
+ if (newBaseRoute) {
1083
+ newBaseRoute.children = newBaseRoute.children || [];
1084
+ newBaseRoute.name = newBaseRoute.name || prefix;
1085
+ newBaseRoute.path = `/${(newBaseRoute.path || parentPath).split("/").filter((item) => item && !item.includes(".")).join("/")}`;
1086
+ parentRoute = newBaseRoute;
1087
+ } else {
1088
+ parentRoute = findParentRouteHandle(modules22, parentPath);
1089
+ }
1090
+ const { component, metaTitle } = processComponent(componentLoader, componentName, eager);
1091
+ const routeItem = {
1092
+ path: path2,
1093
+ name: componentName,
1094
+ meta: {
1095
+ title: metaTitle
1096
+ },
1097
+ component
1098
+ };
1099
+ if (parentRoute) {
1100
+ if (!parentRoute.children) {
1101
+ parentRoute.children = [];
1102
+ }
1103
+ parentRoute.children.push(routeItem);
1104
+ } else {
1105
+ modules22.push(routeItem);
1106
+ }
1107
+ return modules22;
1108
+ }, modules2).map(cleanRoute).filter((route) => {
1109
+ return !(route.children && Array.isArray(route.children) && route.children.length === 0);
1110
+ });
1111
+ }
1112
+ function findDefaultRouteHandle(routes) {
1113
+ var _a, _b, _c;
1114
+ if (!routes || routes.length === 0) {
1115
+ return "";
1116
+ }
1117
+ for (const route of routes) {
1118
+ if ((_a = route.meta) == null ? void 0 : _a.default) {
1119
+ return route.path || "";
1120
+ }
1121
+ if ((_b = route.children) == null ? void 0 : _b.length) {
1122
+ const childPath = findDefaultRouteHandle(route.children);
1123
+ if (childPath) {
1124
+ return childPath;
1125
+ }
1126
+ }
1127
+ }
1128
+ return ((_c = routes[0]) == null ? void 0 : _c.path) || "";
1129
+ }
1130
+ function extractGlob(globVal) {
1131
+ return globVal.glob || globVal;
1132
+ }
1133
+ function getEagerOption(globVal, globalEager) {
1134
+ return globVal.eager ?? globalEager ?? false;
1135
+ }
1136
+ function generateImportCode(varName, glob, eager) {
1137
+ if (eager) {
1138
+ return `const ${varName} = import.meta.glob(${JSON.stringify(glob)}, { eager: true, import: 'default' });
1139
+ `;
1140
+ }
1141
+ return `const ${varName} = import.meta.glob(${JSON.stringify(glob)});
1142
+ `;
1143
+ }
1144
+ function createAutoRoutesPlugin({ routeConfig, virtualModuleId, dts, root, eager: globalEager }) {
1145
+ const VIRTUAL_MODULE_ID = virtualModuleId || "virtual:auto-routes";
1146
+ const watchGlobs = Object.values(routeConfig).flatMap((globVal) => {
1147
+ const g = extractGlob(globVal);
1148
+ return Array.isArray(g) ? g : [g];
1149
+ });
1150
+ return createVirtualPlugin(
1151
+ {
1152
+ name: "vite-plugin-auto-routes",
1153
+ virtualModuleId: VIRTUAL_MODULE_ID,
1154
+ dts,
1155
+ root,
1156
+ watch: watchGlobs,
1157
+ enforce: "pre",
1158
+ // 生成虚拟模块代码:仅负责产出字符串,监听/HMR/缓存由工厂统一处理
1159
+ generateModule: () => {
1160
+ const imports = [];
1161
+ const routes = [];
1162
+ Object.entries(routeConfig).forEach(([prefix, globVal], index2) => {
1163
+ const varName = `files${index2}`;
1164
+ const glob = extractGlob(globVal);
1165
+ const eager = getEagerOption(globVal, globalEager);
1166
+ const baseRoute = globVal.baseRoute;
1167
+ const baseRouteParam = baseRoute !== void 0 ? JSON.stringify(baseRoute) : "undefined";
1168
+ imports.push(generateImportCode(varName, glob, eager));
1169
+ routes.push(`...generateRoutes(${varName}, '${prefix}',${baseRouteParam}, ${eager})`);
1170
+ });
1171
+ const routesCode = routes.length > 0 ? `[${routes.join(",\n")}]` : "[]";
1172
+ return `
1173
+ ${imports.join("\n")}
1174
+ ${findParentRouteHandle}
1175
+ ${parseModulePath}
1176
+ ${processComponent}
1177
+ ${cleanRoute}
1178
+ ${findDefaultRouteHandle}
1179
+
1180
+ const findParentRoute = ${findParentRouteHandle}
1181
+ // 用于routes
1182
+ const generateRoutes = ${generateRoutes};
1183
+ // 用于导出
1184
+ const findDefaultRoute = ${findDefaultRouteHandle};
1185
+
1186
+ const routes = ${routesCode}.flat().filter(Boolean);
1187
+
1188
+ export { routes, findDefaultRoute };
1189
+ export default routes;
1190
+ `;
1191
+ },
1192
+ // 生成类型声明文件
1193
+ generateDts: () => `// 此文件由ViteConfig自动生成,请勿手动修改
1194
+ declare module 'virtual:auto-routes' {
1195
+ interface RouteModule {
1196
+ path: string
1197
+ name: string
1198
+ meta?: any
1199
+ component: () => Promise<any>
1200
+ children?: RouteModule[]
1201
+ }
1202
+
1203
+ const routes: RouteModule[]
1204
+ const findDefaultRoute: (routes: any[]) => string
1205
+ export { findDefaultRoute, routes }
1206
+ export default routes
1207
+ }`
1208
+ }
1209
+ );
1210
+ }
1211
+ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1212
+ __proto__: null,
1213
+ default: createAutoRoutesPlugin
1214
+ }, Symbol.toStringTag, { value: "Module" }));
1215
+ exports.ViteConfig = createViteConfig;
1216
+ exports.default = createViteConfig;
1217
+ exports.getViteConfig = getViteConfig;
1218
+ exports.wrapperEnv = wrapperEnv;