weapp-vite 3.0.1 → 3.0.2
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/dist/auto-import-components/resolvers.cjs +7 -8
- package/dist/auto-import-components/resolvers.mjs +1 -2
- package/dist/{chunk-XWG2K7KD.mjs → chunk-HYF6JF4U.mjs} +1 -2
- package/dist/chunk-I7VYO5OF.cjs +15 -0
- package/dist/{chunk-3PDVWG3J.cjs → chunk-ILAIINMU.cjs} +7 -8
- package/dist/{chunk-AXQXIKIF.mjs → chunk-J4FW3JHK.mjs} +2 -3
- package/dist/{chunk-MOS2LLUH.mjs → chunk-PRR5DJHJ.mjs} +1 -2
- package/dist/{chunk-VMKFJAQK.cjs → chunk-RJF2LDZW.cjs} +2 -3
- package/dist/{chunk-FAXOYXBI.cjs → chunk-TQKIOJUX.cjs} +1843 -1531
- package/dist/{chunk-STCFYYUS.mjs → chunk-WC7SBOSS.mjs} +1006 -694
- package/dist/cli.cjs +192 -51
- package/dist/cli.mjs +152 -11
- package/dist/{config-CCFoPOGU.d.cts → config-CmnUGB9g.d.cts} +66 -11
- package/dist/{config-PWMAoAbY.d.ts → config-nkS0_6JW.d.ts} +66 -11
- package/dist/config.cjs +4 -5
- package/dist/config.d.cts +2 -1
- package/dist/config.d.ts +2 -1
- package/dist/config.mjs +3 -4
- package/dist/index.cjs +7 -8
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.mjs +4 -5
- package/dist/json.cjs +3 -4
- package/dist/json.d.cts +2 -1
- package/dist/json.d.ts +2 -1
- package/dist/json.mjs +2 -3
- package/dist/types.cjs +18 -0
- package/dist/types.d.cts +57 -0
- package/dist/types.d.ts +57 -0
- package/dist/types.mjs +18 -0
- package/dist/volar.cjs +2 -3
- package/dist/volar.mjs +1 -2
- package/package.json +21 -8
- package/dist/auto-import-components/resolvers.cjs.map +0 -1
- package/dist/auto-import-components/resolvers.mjs.map +0 -1
- package/dist/chunk-3PDVWG3J.cjs.map +0 -1
- package/dist/chunk-AXQXIKIF.mjs.map +0 -1
- package/dist/chunk-FAXOYXBI.cjs.map +0 -1
- package/dist/chunk-JOVYVHI7.cjs +0 -16
- package/dist/chunk-JOVYVHI7.cjs.map +0 -1
- package/dist/chunk-MOS2LLUH.mjs.map +0 -1
- package/dist/chunk-STCFYYUS.mjs.map +0 -1
- package/dist/chunk-VMKFJAQK.cjs.map +0 -1
- package/dist/chunk-XWG2K7KD.mjs.map +0 -1
- package/dist/cli.cjs.map +0 -1
- package/dist/cli.mjs.map +0 -1
- package/dist/config.cjs.map +0 -1
- package/dist/config.mjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/json.cjs.map +0 -1
- package/dist/json.mjs.map +0 -1
- package/dist/volar.cjs.map +0 -1
- package/dist/volar.mjs.map +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -3,14 +3,14 @@ import {
|
|
|
3
3
|
createCompilerContext,
|
|
4
4
|
logger_default,
|
|
5
5
|
require_Reflect
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-WC7SBOSS.mjs";
|
|
7
|
+
import "./chunk-HYF6JF4U.mjs";
|
|
8
|
+
import "./chunk-PRR5DJHJ.mjs";
|
|
9
9
|
import {
|
|
10
10
|
__name,
|
|
11
11
|
__toESM,
|
|
12
12
|
init_esm_shims
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-J4FW3JHK.mjs";
|
|
14
14
|
|
|
15
15
|
// src/cli.ts
|
|
16
16
|
init_esm_shims();
|
|
@@ -621,6 +621,138 @@ var CAC = class extends EventEmitter {
|
|
|
621
621
|
};
|
|
622
622
|
var cac = /* @__PURE__ */ __name((name = "") => new CAC(name), "cac");
|
|
623
623
|
|
|
624
|
+
// ../../node_modules/.pnpm/package-manager-detector@1.1.0/node_modules/package-manager-detector/dist/commands.mjs
|
|
625
|
+
init_esm_shims();
|
|
626
|
+
function npmRun(agent) {
|
|
627
|
+
return (args) => {
|
|
628
|
+
if (args.length > 1) {
|
|
629
|
+
return [agent, "run", args[0], "--", ...args.slice(1)];
|
|
630
|
+
} else {
|
|
631
|
+
return [agent, "run", args[0]];
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
__name(npmRun, "npmRun");
|
|
636
|
+
function denoExecute() {
|
|
637
|
+
return (args) => {
|
|
638
|
+
return ["deno", "run", `npm:${args[0]}`, ...args.slice(1)];
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
__name(denoExecute, "denoExecute");
|
|
642
|
+
var npm = {
|
|
643
|
+
"agent": ["npm", 0],
|
|
644
|
+
"run": npmRun("npm"),
|
|
645
|
+
"install": ["npm", "i", 0],
|
|
646
|
+
"frozen": ["npm", "ci", 0],
|
|
647
|
+
"global": ["npm", "i", "-g", 0],
|
|
648
|
+
"add": ["npm", "i", 0],
|
|
649
|
+
"upgrade": ["npm", "update", 0],
|
|
650
|
+
"upgrade-interactive": null,
|
|
651
|
+
"execute": ["npx", 0],
|
|
652
|
+
"execute-local": ["npx", 0],
|
|
653
|
+
"uninstall": ["npm", "uninstall", 0],
|
|
654
|
+
"global_uninstall": ["npm", "uninstall", "-g", 0]
|
|
655
|
+
};
|
|
656
|
+
var yarn = {
|
|
657
|
+
"agent": ["yarn", 0],
|
|
658
|
+
"run": ["yarn", "run", 0],
|
|
659
|
+
"install": ["yarn", "install", 0],
|
|
660
|
+
"frozen": ["yarn", "install", "--frozen-lockfile", 0],
|
|
661
|
+
"global": ["yarn", "global", "add", 0],
|
|
662
|
+
"add": ["yarn", "add", 0],
|
|
663
|
+
"upgrade": ["yarn", "upgrade", 0],
|
|
664
|
+
"upgrade-interactive": ["yarn", "upgrade-interactive", 0],
|
|
665
|
+
"execute": ["npx", 0],
|
|
666
|
+
"execute-local": ["yarn", "exec", 0],
|
|
667
|
+
"uninstall": ["yarn", "remove", 0],
|
|
668
|
+
"global_uninstall": ["yarn", "global", "remove", 0]
|
|
669
|
+
};
|
|
670
|
+
var yarnBerry = {
|
|
671
|
+
...yarn,
|
|
672
|
+
"frozen": ["yarn", "install", "--immutable", 0],
|
|
673
|
+
"upgrade": ["yarn", "up", 0],
|
|
674
|
+
"upgrade-interactive": ["yarn", "up", "-i", 0],
|
|
675
|
+
"execute": ["yarn", "dlx", 0],
|
|
676
|
+
"execute-local": ["yarn", "exec", 0],
|
|
677
|
+
// Yarn 2+ removed 'global', see https://github.com/yarnpkg/berry/issues/821
|
|
678
|
+
"global": ["npm", "i", "-g", 0],
|
|
679
|
+
"global_uninstall": ["npm", "uninstall", "-g", 0]
|
|
680
|
+
};
|
|
681
|
+
var pnpm = {
|
|
682
|
+
"agent": ["pnpm", 0],
|
|
683
|
+
"run": ["pnpm", "run", 0],
|
|
684
|
+
"install": ["pnpm", "i", 0],
|
|
685
|
+
"frozen": ["pnpm", "i", "--frozen-lockfile", 0],
|
|
686
|
+
"global": ["pnpm", "add", "-g", 0],
|
|
687
|
+
"add": ["pnpm", "add", 0],
|
|
688
|
+
"upgrade": ["pnpm", "update", 0],
|
|
689
|
+
"upgrade-interactive": ["pnpm", "update", "-i", 0],
|
|
690
|
+
"execute": ["pnpm", "dlx", 0],
|
|
691
|
+
"execute-local": ["pnpm", "exec", 0],
|
|
692
|
+
"uninstall": ["pnpm", "remove", 0],
|
|
693
|
+
"global_uninstall": ["pnpm", "remove", "--global", 0]
|
|
694
|
+
};
|
|
695
|
+
var bun = {
|
|
696
|
+
"agent": ["bun", 0],
|
|
697
|
+
"run": ["bun", "run", 0],
|
|
698
|
+
"install": ["bun", "install", 0],
|
|
699
|
+
"frozen": ["bun", "install", "--frozen-lockfile", 0],
|
|
700
|
+
"global": ["bun", "add", "-g", 0],
|
|
701
|
+
"add": ["bun", "add", 0],
|
|
702
|
+
"upgrade": ["bun", "update", 0],
|
|
703
|
+
"upgrade-interactive": ["bun", "update", 0],
|
|
704
|
+
"execute": ["bun", "x", 0],
|
|
705
|
+
"execute-local": ["bun", "x", 0],
|
|
706
|
+
"uninstall": ["bun", "remove", 0],
|
|
707
|
+
"global_uninstall": ["bun", "remove", "-g", 0]
|
|
708
|
+
};
|
|
709
|
+
var deno = {
|
|
710
|
+
"agent": ["deno", 0],
|
|
711
|
+
"run": ["deno", "task", 0],
|
|
712
|
+
"install": ["deno", "install", 0],
|
|
713
|
+
"frozen": ["deno", "install", "--frozen", 0],
|
|
714
|
+
"global": ["deno", "install", "-g", 0],
|
|
715
|
+
"add": ["deno", "add", 0],
|
|
716
|
+
"upgrade": ["deno", "outdated", "--update", 0],
|
|
717
|
+
"upgrade-interactive": ["deno", "outdated", "--update", 0],
|
|
718
|
+
"execute": denoExecute(),
|
|
719
|
+
"execute-local": ["deno", "task", "--eval", 0],
|
|
720
|
+
"uninstall": ["deno", "remove", 0],
|
|
721
|
+
"global_uninstall": ["deno", "uninstall", "-g", 0]
|
|
722
|
+
};
|
|
723
|
+
var COMMANDS = {
|
|
724
|
+
"npm": npm,
|
|
725
|
+
"yarn": yarn,
|
|
726
|
+
"yarn@berry": yarnBerry,
|
|
727
|
+
"pnpm": pnpm,
|
|
728
|
+
// pnpm v6.x or below
|
|
729
|
+
"pnpm@6": {
|
|
730
|
+
...pnpm,
|
|
731
|
+
run: npmRun("pnpm")
|
|
732
|
+
},
|
|
733
|
+
"bun": bun,
|
|
734
|
+
"deno": deno
|
|
735
|
+
};
|
|
736
|
+
function resolveCommand(agent, command, args) {
|
|
737
|
+
const value = COMMANDS[agent][command];
|
|
738
|
+
return constructCommand(value, args);
|
|
739
|
+
}
|
|
740
|
+
__name(resolveCommand, "resolveCommand");
|
|
741
|
+
function constructCommand(value, args) {
|
|
742
|
+
if (value == null)
|
|
743
|
+
return null;
|
|
744
|
+
const list = typeof value === "function" ? value(args) : value.flatMap((v) => {
|
|
745
|
+
if (typeof v === "number")
|
|
746
|
+
return args;
|
|
747
|
+
return [v];
|
|
748
|
+
});
|
|
749
|
+
return {
|
|
750
|
+
command: list[0],
|
|
751
|
+
args: list.slice(1)
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
__name(constructCommand, "constructCommand");
|
|
755
|
+
|
|
624
756
|
// src/cli.ts
|
|
625
757
|
import path2 from "pathe";
|
|
626
758
|
import { loadConfigFromFile } from "vite";
|
|
@@ -708,10 +840,20 @@ function loadConfig() {
|
|
|
708
840
|
}
|
|
709
841
|
__name(loadConfig, "loadConfig");
|
|
710
842
|
var logBuildAppFinishOnlyShowOnce = false;
|
|
711
|
-
function logBuildAppFinish() {
|
|
843
|
+
function logBuildAppFinish(configService) {
|
|
712
844
|
if (!logBuildAppFinishOnlyShowOnce) {
|
|
845
|
+
const { command, args } = resolveCommand(configService.packageManager.agent, "run", [
|
|
846
|
+
"open"
|
|
847
|
+
]) ?? {
|
|
848
|
+
command: "npm",
|
|
849
|
+
args: [
|
|
850
|
+
"run",
|
|
851
|
+
"open"
|
|
852
|
+
]
|
|
853
|
+
};
|
|
854
|
+
const devCommand = `${command} ${args.join(" ")}`;
|
|
713
855
|
logger_default.success("\u5E94\u7528\u6784\u5EFA\u5B8C\u6210\uFF01\u9884\u89C8\u65B9\u5F0F ( `2` \u79CD\u9009\u5176\u4E00\u5373\u53EF)\uFF1A");
|
|
714
|
-
logger_default.info(
|
|
856
|
+
logger_default.info(`\u6267\u884C \`${devCommand}\` \u53EF\u4EE5\u76F4\u63A5\u5728 \`\u5FAE\u4FE1\u5F00\u53D1\u8005\u5DE5\u5177\` \u91CC\u6253\u5F00\u5F53\u524D\u5E94\u7528`);
|
|
715
857
|
logger_default.info("\u6216\u624B\u52A8\u6253\u5F00\u5FAE\u4FE1\u5F00\u53D1\u8005\u5DE5\u5177\uFF0C\u5BFC\u5165\u6839\u76EE\u5F55(`project.config.json` \u6587\u4EF6\u6240\u5728\u7684\u76EE\u5F55)\uFF0C\u5373\u53EF\u9884\u89C8\u6548\u679C");
|
|
716
858
|
logBuildAppFinishOnlyShowOnce = true;
|
|
717
859
|
}
|
|
@@ -750,7 +892,7 @@ cli.option("-c, --config <file>", `[string] use specified config file`).option("
|
|
|
750
892
|
}).option("-l, --logLevel <level>", `[string] info | warn | error | silent`).option("--clearScreen", `[boolean] allow/disable clear screen when logging`).option("-d, --debug [feat]", `[string | boolean] show debug logs`).option("-f, --filter <filter>", `[string] filter debug logs`).option("-m, --mode <mode>", `[string] set env mode`);
|
|
751
893
|
cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--skipNpm", `[boolean] if skip npm build`).option("-o, --open", `[boolean] open ide`).action(async (root, options) => {
|
|
752
894
|
filterDuplicateOptions(options);
|
|
753
|
-
const { buildService, npmService } = await createCompilerContext({
|
|
895
|
+
const { buildService, npmService, configService } = await createCompilerContext({
|
|
754
896
|
cwd: root,
|
|
755
897
|
mode: options.mode,
|
|
756
898
|
isDev: true
|
|
@@ -759,14 +901,14 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
|
|
|
759
901
|
if (!options.skipNpm) {
|
|
760
902
|
await npmService.build();
|
|
761
903
|
}
|
|
762
|
-
logBuildAppFinish();
|
|
904
|
+
logBuildAppFinish(configService);
|
|
763
905
|
if (options.open) {
|
|
764
906
|
await openIde();
|
|
765
907
|
}
|
|
766
908
|
});
|
|
767
909
|
cli.command("build [root]", "build for production").option("--target <target>", `[string] transpile target (default: 'modules')`).option("--outDir <dir>", `[string] output directory (default: dist)`).option("--sourcemap [output]", `[boolean | "inline" | "hidden"] output source maps for build (default: false)`).option("--minify [minifier]", `[boolean | "terser" | "esbuild"] enable/disable minification, or specify minifier to use (default: esbuild)`).option("--emptyOutDir", `[boolean] force empty outDir when it's outside of root`).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--skipNpm", `[boolean] if skip npm build`).option("-o, --open", `[boolean] open ide`).action(async (root, options) => {
|
|
768
910
|
filterDuplicateOptions(options);
|
|
769
|
-
const { buildService, npmService } = await createCompilerContext({
|
|
911
|
+
const { buildService, npmService, configService } = await createCompilerContext({
|
|
770
912
|
cwd: root,
|
|
771
913
|
mode: options.mode
|
|
772
914
|
});
|
|
@@ -774,7 +916,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
|
|
|
774
916
|
if (!options.skipNpm) {
|
|
775
917
|
await npmService.build();
|
|
776
918
|
}
|
|
777
|
-
logBuildAppFinish();
|
|
919
|
+
logBuildAppFinish(configService);
|
|
778
920
|
if (options.open) {
|
|
779
921
|
await openIde();
|
|
780
922
|
}
|
|
@@ -834,4 +976,3 @@ cli.command("create [outDir]", "create project").option("-t, --template <type>",
|
|
|
834
976
|
cli.help();
|
|
835
977
|
cli.version(VERSION);
|
|
836
978
|
cli.parse();
|
|
837
|
-
//# sourceMappingURL=cli.mjs.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UserConfig as UserConfig$1, InlineConfig, UserConfigFnObject, UserConfigExport } from 'vite';
|
|
2
2
|
import { a as Resolver, R as ResolvedValue } from './types-dS68tjL6.cjs';
|
|
3
3
|
import { Options } from 'tsup';
|
|
4
4
|
import { PluginOptions } from 'vite-tsconfig-paths';
|
|
5
5
|
import { Theme, Sitemap, App, Page, Component } from '@weapp-core/schematics';
|
|
6
|
+
import { DetectResult } from 'package-manager-detector';
|
|
6
7
|
import { PackageJson } from 'pkg-types';
|
|
7
8
|
import { RollupWatcher, RollupOutput } from 'rollup';
|
|
8
9
|
import { MemoryEmitResultFile } from 'ts-morph';
|
|
@@ -33,6 +34,7 @@ interface ComponentEntry extends BaseEntry {
|
|
|
33
34
|
templatePath: string;
|
|
34
35
|
json?: Component;
|
|
35
36
|
}
|
|
37
|
+
type EntryJsonFragment = Omit<BaseEntry, 'path' | 'type'>;
|
|
36
38
|
|
|
37
39
|
interface Alias {
|
|
38
40
|
find: string | RegExp;
|
|
@@ -43,6 +45,27 @@ interface ResolvedAlias {
|
|
|
43
45
|
replacement: string;
|
|
44
46
|
}
|
|
45
47
|
interface AliasOptions {
|
|
48
|
+
/**
|
|
49
|
+
* @example
|
|
50
|
+
* ```js
|
|
51
|
+
entries: [
|
|
52
|
+
{
|
|
53
|
+
find: '@',
|
|
54
|
+
replacement: path.resolve(import.meta.dirname, 'components'),
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
* ```
|
|
58
|
+
这样你就可以在 json 里面使用:
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"usingComponents": {
|
|
62
|
+
"navigation-bar": "@/navigation-bar/navigation-bar",
|
|
63
|
+
"ice-avatar": "@/avatar/avatar"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
* 详见[json别名](/guide/alias.html#json-别名)文档
|
|
68
|
+
*/
|
|
46
69
|
entries?: readonly Alias[] | {
|
|
47
70
|
[find: string]: string;
|
|
48
71
|
};
|
|
@@ -73,6 +96,9 @@ type GenerateFilenamesOptions = Partial<{
|
|
|
73
96
|
component: string;
|
|
74
97
|
}>;
|
|
75
98
|
interface GenerateOptions {
|
|
99
|
+
/**
|
|
100
|
+
* 生成文件的扩展名
|
|
101
|
+
*/
|
|
76
102
|
extensions?: GenerateExtensionsOptions;
|
|
77
103
|
/**
|
|
78
104
|
* 默认生成文件的相对路径
|
|
@@ -89,7 +115,13 @@ interface CopyOptions {
|
|
|
89
115
|
}
|
|
90
116
|
type CopyGlobs = string[] | ((subPackageMeta?: SubPackageMetaValue | undefined) => string[]);
|
|
91
117
|
interface AutoImportComponents {
|
|
118
|
+
/**
|
|
119
|
+
* 自动导入组件
|
|
120
|
+
*/
|
|
92
121
|
globs?: string[];
|
|
122
|
+
/**
|
|
123
|
+
* 自动导入组件解析器
|
|
124
|
+
*/
|
|
93
125
|
resolvers?: Resolver[];
|
|
94
126
|
}
|
|
95
127
|
type EnhanceWxmlOptions = ScanWxmlOptions & HandleWxmlOptions;
|
|
@@ -122,30 +154,47 @@ interface BuildNpmPackageMeta {
|
|
|
122
154
|
interface WeappViteConfig {
|
|
123
155
|
/**
|
|
124
156
|
* @description 应用入口目录 (app.json 所在的目录)
|
|
125
|
-
* 默认 js
|
|
157
|
+
* 默认 js 模板在根目录 `.`,ts 模板在 `miniprogram` 目录,当然你可以把所有代码放在 `src` 目录下,并设置此选项为 `src`
|
|
158
|
+
* @default '.''
|
|
126
159
|
*/
|
|
127
160
|
srcRoot?: string;
|
|
128
161
|
/**
|
|
129
|
-
* json
|
|
162
|
+
* @group json 配置
|
|
163
|
+
* 文件引入别名
|
|
130
164
|
*/
|
|
131
165
|
jsonAlias?: AliasOptions;
|
|
132
166
|
/**
|
|
133
|
-
*
|
|
167
|
+
*
|
|
168
|
+
* @group 构建 npm
|
|
134
169
|
*/
|
|
135
170
|
npm?: {
|
|
171
|
+
/**
|
|
172
|
+
* @description 是否开启构建 npm 功能, 默认为 true
|
|
173
|
+
* @default true
|
|
174
|
+
*/
|
|
136
175
|
enable?: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* @description 是否开启缓存,默认为 true
|
|
178
|
+
* @default true
|
|
179
|
+
*/
|
|
137
180
|
cache?: boolean;
|
|
181
|
+
/**
|
|
182
|
+
* @description 构建 npm 的配置,可以配置这个选项给 tsup,让不同的包走不同的配置
|
|
183
|
+
*/
|
|
138
184
|
tsup?: (options: Options, pkgMeta: BuildNpmPackageMeta) => Options | undefined;
|
|
139
185
|
};
|
|
140
186
|
/**
|
|
187
|
+
* @group 生成脚手架配置
|
|
141
188
|
* weapp-vite generate 相关的配置
|
|
142
189
|
*/
|
|
143
190
|
generate?: GenerateOptions;
|
|
144
191
|
/**
|
|
145
|
-
*
|
|
192
|
+
* @group 插件集成
|
|
193
|
+
* 传递给内置 [`vite-tsconfig-paths`](https://www.npmjs.com/package/vite-tsconfig-paths) 插件的参数
|
|
146
194
|
*/
|
|
147
195
|
tsconfigPaths?: PluginOptions;
|
|
148
196
|
/**
|
|
197
|
+
* @group 分包配置
|
|
149
198
|
* 分包是否独立的 rollup 编译上下文
|
|
150
199
|
* 默认情况下,当一个分包设置了 independent: true 之后会默认启用
|
|
151
200
|
* 可以设置 key: 为 root, value: {independent:true} 来强制启用 独立的 rollup 编译上下文
|
|
@@ -159,13 +208,15 @@ interface WeappViteConfig {
|
|
|
159
208
|
*/
|
|
160
209
|
copy?: CopyOptions;
|
|
161
210
|
/**
|
|
162
|
-
*
|
|
211
|
+
* @description 额外的 wxml 文件
|
|
212
|
+
* 把这个方法,扫描到的 `wxml` 添加到额外的 `wxml` 文件列表, **处理** 之后输出到最终的产物中
|
|
163
213
|
* @param wxmlFilePath
|
|
164
|
-
* @returns
|
|
214
|
+
* @returns boolean
|
|
165
215
|
*/
|
|
166
216
|
isAdditionalWxml?: (wxmlFilePath: string) => boolean;
|
|
167
217
|
/**
|
|
168
|
-
* 编译目标平台
|
|
218
|
+
* @description 编译目标平台
|
|
219
|
+
* @ignore
|
|
169
220
|
*/
|
|
170
221
|
platform?: MpPlatform;
|
|
171
222
|
/**
|
|
@@ -173,6 +224,9 @@ interface WeappViteConfig {
|
|
|
173
224
|
*/
|
|
174
225
|
enhance?: EnhanceOptions;
|
|
175
226
|
}
|
|
227
|
+
type UserConfig = UserConfig$1 & {
|
|
228
|
+
weapp?: WeappViteConfig;
|
|
229
|
+
};
|
|
176
230
|
interface ProjectConfig {
|
|
177
231
|
miniprogramRoot?: string;
|
|
178
232
|
srcMiniprogramRoot?: string;
|
|
@@ -263,6 +317,7 @@ declare class ConfigService {
|
|
|
263
317
|
* esbuild 定义的环境变量
|
|
264
318
|
*/
|
|
265
319
|
defineEnv: Record<string, any>;
|
|
320
|
+
packageManager: DetectResult;
|
|
266
321
|
constructor();
|
|
267
322
|
get defineImportMetaEnv(): Record<string, any>;
|
|
268
323
|
setDefineEnv(key: string, value: any): void;
|
|
@@ -486,9 +541,9 @@ declare module 'vite' {
|
|
|
486
541
|
weapp?: WeappViteConfig;
|
|
487
542
|
}
|
|
488
543
|
}
|
|
489
|
-
declare function defineConfig(config: UserConfig): UserConfig;
|
|
490
|
-
declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
|
|
544
|
+
declare function defineConfig(config: UserConfig$1): UserConfig$1;
|
|
545
|
+
declare function defineConfig(config: Promise<UserConfig$1>): Promise<UserConfig$1>;
|
|
491
546
|
declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
|
|
492
547
|
declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
|
493
548
|
|
|
494
|
-
export { CompilerContext as C, type LoadConfigOptions as L, defineAppJson as a, definePageJson as b, defineComponentJson as c, defineConfig as d, defineSitemapJson as e, defineThemeJson as f };
|
|
549
|
+
export { type Alias as A, type BuildNpmPackageMeta as B, CompilerContext as C, type Entry as E, type GenerateExtensionsOptions as G, type HandleWxmlOptions as H, type LoadConfigOptions as L, type MpPlatform as M, type ProjectConfig as P, type ResolvedAlias as R, type SubPackageMetaValue as S, type UserConfig as U, type WxmlDep 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 SubPackage as h, type GenerateDirsOptions as i, type GenerateFilenamesOptions as j, type GenerateOptions as k, type CopyOptions as l, type CopyGlobs as m, type AutoImportComponents as n, type EnhanceWxmlOptions as o, type ScanWxmlOptions as p, type EnhanceOptions as q, type WeappViteConfig as r, type ScanComponentItem as s, type ComponentsMap as t, type BaseEntry as u, type AppEntry as v, type PageEntry as w, type ComponentEntry as x, type EntryJsonFragment as y };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UserConfig as UserConfig$1, InlineConfig, UserConfigFnObject, UserConfigExport } from 'vite';
|
|
2
2
|
import { a as Resolver, R as ResolvedValue } from './types-dS68tjL6.js';
|
|
3
3
|
import { Options } from 'tsup';
|
|
4
4
|
import { PluginOptions } from 'vite-tsconfig-paths';
|
|
5
5
|
import { Theme, Sitemap, App, Page, Component } from '@weapp-core/schematics';
|
|
6
|
+
import { DetectResult } from 'package-manager-detector';
|
|
6
7
|
import { PackageJson } from 'pkg-types';
|
|
7
8
|
import { RollupWatcher, RollupOutput } from 'rollup';
|
|
8
9
|
import { MemoryEmitResultFile } from 'ts-morph';
|
|
@@ -33,6 +34,7 @@ interface ComponentEntry extends BaseEntry {
|
|
|
33
34
|
templatePath: string;
|
|
34
35
|
json?: Component;
|
|
35
36
|
}
|
|
37
|
+
type EntryJsonFragment = Omit<BaseEntry, 'path' | 'type'>;
|
|
36
38
|
|
|
37
39
|
interface Alias {
|
|
38
40
|
find: string | RegExp;
|
|
@@ -43,6 +45,27 @@ interface ResolvedAlias {
|
|
|
43
45
|
replacement: string;
|
|
44
46
|
}
|
|
45
47
|
interface AliasOptions {
|
|
48
|
+
/**
|
|
49
|
+
* @example
|
|
50
|
+
* ```js
|
|
51
|
+
entries: [
|
|
52
|
+
{
|
|
53
|
+
find: '@',
|
|
54
|
+
replacement: path.resolve(import.meta.dirname, 'components'),
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
* ```
|
|
58
|
+
这样你就可以在 json 里面使用:
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"usingComponents": {
|
|
62
|
+
"navigation-bar": "@/navigation-bar/navigation-bar",
|
|
63
|
+
"ice-avatar": "@/avatar/avatar"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
* 详见[json别名](/guide/alias.html#json-别名)文档
|
|
68
|
+
*/
|
|
46
69
|
entries?: readonly Alias[] | {
|
|
47
70
|
[find: string]: string;
|
|
48
71
|
};
|
|
@@ -73,6 +96,9 @@ type GenerateFilenamesOptions = Partial<{
|
|
|
73
96
|
component: string;
|
|
74
97
|
}>;
|
|
75
98
|
interface GenerateOptions {
|
|
99
|
+
/**
|
|
100
|
+
* 生成文件的扩展名
|
|
101
|
+
*/
|
|
76
102
|
extensions?: GenerateExtensionsOptions;
|
|
77
103
|
/**
|
|
78
104
|
* 默认生成文件的相对路径
|
|
@@ -89,7 +115,13 @@ interface CopyOptions {
|
|
|
89
115
|
}
|
|
90
116
|
type CopyGlobs = string[] | ((subPackageMeta?: SubPackageMetaValue | undefined) => string[]);
|
|
91
117
|
interface AutoImportComponents {
|
|
118
|
+
/**
|
|
119
|
+
* 自动导入组件
|
|
120
|
+
*/
|
|
92
121
|
globs?: string[];
|
|
122
|
+
/**
|
|
123
|
+
* 自动导入组件解析器
|
|
124
|
+
*/
|
|
93
125
|
resolvers?: Resolver[];
|
|
94
126
|
}
|
|
95
127
|
type EnhanceWxmlOptions = ScanWxmlOptions & HandleWxmlOptions;
|
|
@@ -122,30 +154,47 @@ interface BuildNpmPackageMeta {
|
|
|
122
154
|
interface WeappViteConfig {
|
|
123
155
|
/**
|
|
124
156
|
* @description 应用入口目录 (app.json 所在的目录)
|
|
125
|
-
* 默认 js
|
|
157
|
+
* 默认 js 模板在根目录 `.`,ts 模板在 `miniprogram` 目录,当然你可以把所有代码放在 `src` 目录下,并设置此选项为 `src`
|
|
158
|
+
* @default '.''
|
|
126
159
|
*/
|
|
127
160
|
srcRoot?: string;
|
|
128
161
|
/**
|
|
129
|
-
* json
|
|
162
|
+
* @group json 配置
|
|
163
|
+
* 文件引入别名
|
|
130
164
|
*/
|
|
131
165
|
jsonAlias?: AliasOptions;
|
|
132
166
|
/**
|
|
133
|
-
*
|
|
167
|
+
*
|
|
168
|
+
* @group 构建 npm
|
|
134
169
|
*/
|
|
135
170
|
npm?: {
|
|
171
|
+
/**
|
|
172
|
+
* @description 是否开启构建 npm 功能, 默认为 true
|
|
173
|
+
* @default true
|
|
174
|
+
*/
|
|
136
175
|
enable?: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* @description 是否开启缓存,默认为 true
|
|
178
|
+
* @default true
|
|
179
|
+
*/
|
|
137
180
|
cache?: boolean;
|
|
181
|
+
/**
|
|
182
|
+
* @description 构建 npm 的配置,可以配置这个选项给 tsup,让不同的包走不同的配置
|
|
183
|
+
*/
|
|
138
184
|
tsup?: (options: Options, pkgMeta: BuildNpmPackageMeta) => Options | undefined;
|
|
139
185
|
};
|
|
140
186
|
/**
|
|
187
|
+
* @group 生成脚手架配置
|
|
141
188
|
* weapp-vite generate 相关的配置
|
|
142
189
|
*/
|
|
143
190
|
generate?: GenerateOptions;
|
|
144
191
|
/**
|
|
145
|
-
*
|
|
192
|
+
* @group 插件集成
|
|
193
|
+
* 传递给内置 [`vite-tsconfig-paths`](https://www.npmjs.com/package/vite-tsconfig-paths) 插件的参数
|
|
146
194
|
*/
|
|
147
195
|
tsconfigPaths?: PluginOptions;
|
|
148
196
|
/**
|
|
197
|
+
* @group 分包配置
|
|
149
198
|
* 分包是否独立的 rollup 编译上下文
|
|
150
199
|
* 默认情况下,当一个分包设置了 independent: true 之后会默认启用
|
|
151
200
|
* 可以设置 key: 为 root, value: {independent:true} 来强制启用 独立的 rollup 编译上下文
|
|
@@ -159,13 +208,15 @@ interface WeappViteConfig {
|
|
|
159
208
|
*/
|
|
160
209
|
copy?: CopyOptions;
|
|
161
210
|
/**
|
|
162
|
-
*
|
|
211
|
+
* @description 额外的 wxml 文件
|
|
212
|
+
* 把这个方法,扫描到的 `wxml` 添加到额外的 `wxml` 文件列表, **处理** 之后输出到最终的产物中
|
|
163
213
|
* @param wxmlFilePath
|
|
164
|
-
* @returns
|
|
214
|
+
* @returns boolean
|
|
165
215
|
*/
|
|
166
216
|
isAdditionalWxml?: (wxmlFilePath: string) => boolean;
|
|
167
217
|
/**
|
|
168
|
-
* 编译目标平台
|
|
218
|
+
* @description 编译目标平台
|
|
219
|
+
* @ignore
|
|
169
220
|
*/
|
|
170
221
|
platform?: MpPlatform;
|
|
171
222
|
/**
|
|
@@ -173,6 +224,9 @@ interface WeappViteConfig {
|
|
|
173
224
|
*/
|
|
174
225
|
enhance?: EnhanceOptions;
|
|
175
226
|
}
|
|
227
|
+
type UserConfig = UserConfig$1 & {
|
|
228
|
+
weapp?: WeappViteConfig;
|
|
229
|
+
};
|
|
176
230
|
interface ProjectConfig {
|
|
177
231
|
miniprogramRoot?: string;
|
|
178
232
|
srcMiniprogramRoot?: string;
|
|
@@ -263,6 +317,7 @@ declare class ConfigService {
|
|
|
263
317
|
* esbuild 定义的环境变量
|
|
264
318
|
*/
|
|
265
319
|
defineEnv: Record<string, any>;
|
|
320
|
+
packageManager: DetectResult;
|
|
266
321
|
constructor();
|
|
267
322
|
get defineImportMetaEnv(): Record<string, any>;
|
|
268
323
|
setDefineEnv(key: string, value: any): void;
|
|
@@ -486,9 +541,9 @@ declare module 'vite' {
|
|
|
486
541
|
weapp?: WeappViteConfig;
|
|
487
542
|
}
|
|
488
543
|
}
|
|
489
|
-
declare function defineConfig(config: UserConfig): UserConfig;
|
|
490
|
-
declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
|
|
544
|
+
declare function defineConfig(config: UserConfig$1): UserConfig$1;
|
|
545
|
+
declare function defineConfig(config: Promise<UserConfig$1>): Promise<UserConfig$1>;
|
|
491
546
|
declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
|
|
492
547
|
declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
|
493
548
|
|
|
494
|
-
export { CompilerContext as C, type LoadConfigOptions as L, defineAppJson as a, definePageJson as b, defineComponentJson as c, defineConfig as d, defineSitemapJson as e, defineThemeJson as f };
|
|
549
|
+
export { type Alias as A, type BuildNpmPackageMeta as B, CompilerContext as C, type Entry as E, type GenerateExtensionsOptions as G, type HandleWxmlOptions as H, type LoadConfigOptions as L, type MpPlatform as M, type ProjectConfig as P, type ResolvedAlias as R, type SubPackageMetaValue as S, type UserConfig as U, type WxmlDep 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 SubPackage as h, type GenerateDirsOptions as i, type GenerateFilenamesOptions as j, type GenerateOptions as k, type CopyOptions as l, type CopyGlobs as m, type AutoImportComponents as n, type EnhanceWxmlOptions as o, type ScanWxmlOptions as p, type EnhanceOptions as q, type WeappViteConfig as r, type ScanComponentItem as s, type ComponentsMap as t, type BaseEntry as u, type AppEntry as v, type PageEntry as w, type ComponentEntry as x, type EntryJsonFragment as y };
|
package/dist/config.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkI7VYO5OFcjs = require('./chunk-I7VYO5OF.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
require('./chunk-
|
|
10
|
+
var _chunkILAIINMUcjs = require('./chunk-ILAIINMU.cjs');
|
|
11
|
+
require('./chunk-RJF2LDZW.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
@@ -16,5 +16,4 @@ require('./chunk-VMKFJAQK.cjs');
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
exports.defineAppJson =
|
|
20
|
-
//# sourceMappingURL=config.cjs.map
|
|
19
|
+
exports.defineAppJson = _chunkILAIINMUcjs.defineAppJson; exports.defineComponentJson = _chunkILAIINMUcjs.defineComponentJson; exports.defineConfig = _chunkI7VYO5OFcjs.defineConfig; exports.definePageJson = _chunkILAIINMUcjs.definePageJson; exports.defineSitemapJson = _chunkILAIINMUcjs.defineSitemapJson; exports.defineThemeJson = _chunkILAIINMUcjs.defineThemeJson;
|
package/dist/config.d.cts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
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-
|
|
2
|
+
export { a as defineAppJson, c as defineComponentJson, d as defineConfig, b as definePageJson, e as defineSitemapJson, f as defineThemeJson } from './config-CmnUGB9g.cjs';
|
|
3
3
|
export { App, Component, Page, Sitemap, Theme } from '@weapp-core/schematics';
|
|
4
4
|
import './types-dS68tjL6.cjs';
|
|
5
5
|
import 'tsup';
|
|
6
6
|
import 'vite-tsconfig-paths';
|
|
7
|
+
import 'package-manager-detector';
|
|
7
8
|
import 'pkg-types';
|
|
8
9
|
import 'rollup';
|
|
9
10
|
import 'ts-morph';
|
package/dist/config.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
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-
|
|
2
|
+
export { a as defineAppJson, c as defineComponentJson, d as defineConfig, b as definePageJson, e as defineSitemapJson, f as defineThemeJson } from './config-nkS0_6JW.js';
|
|
3
3
|
export { App, Component, Page, Sitemap, Theme } from '@weapp-core/schematics';
|
|
4
4
|
import './types-dS68tjL6.js';
|
|
5
5
|
import 'tsup';
|
|
6
6
|
import 'vite-tsconfig-paths';
|
|
7
|
+
import 'package-manager-detector';
|
|
7
8
|
import 'pkg-types';
|
|
8
9
|
import 'rollup';
|
|
9
10
|
import 'ts-morph';
|
package/dist/config.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defineConfig
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HYF6JF4U.mjs";
|
|
4
4
|
import {
|
|
5
5
|
defineAppJson,
|
|
6
6
|
defineComponentJson,
|
|
7
7
|
definePageJson,
|
|
8
8
|
defineSitemapJson,
|
|
9
9
|
defineThemeJson
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-PRR5DJHJ.mjs";
|
|
11
|
+
import "./chunk-J4FW3JHK.mjs";
|
|
12
12
|
export {
|
|
13
13
|
defineAppJson,
|
|
14
14
|
defineComponentJson,
|
|
@@ -17,4 +17,3 @@ export {
|
|
|
17
17
|
defineSitemapJson,
|
|
18
18
|
defineThemeJson
|
|
19
19
|
};
|
|
20
|
-
//# sourceMappingURL=config.mjs.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkTQKIOJUXcjs = require('./chunk-TQKIOJUX.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkI7VYO5OFcjs = require('./chunk-I7VYO5OF.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunkILAIINMUcjs = require('./chunk-ILAIINMU.cjs');
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _chunkRJF2LDZWcjs = require('./chunk-RJF2LDZW.cjs');
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
|
-
|
|
22
|
-
var import_reflect_metadata =
|
|
21
|
+
_chunkRJF2LDZWcjs.init_cjs_shims.call(void 0, );
|
|
22
|
+
var import_reflect_metadata = _chunkRJF2LDZWcjs.__toESM.call(void 0, _chunkTQKIOJUXcjs.require_Reflect.call(void 0, ), 1);
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
@@ -28,5 +28,4 @@ var import_reflect_metadata = _chunkVMKFJAQKcjs.__toESM.call(void 0, _chunkFAXOY
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
exports.createCompilerContext =
|
|
32
|
-
//# sourceMappingURL=index.cjs.map
|
|
31
|
+
exports.createCompilerContext = _chunkTQKIOJUXcjs.createCompilerContext; exports.defineAppJson = _chunkILAIINMUcjs.defineAppJson; exports.defineComponentJson = _chunkILAIINMUcjs.defineComponentJson; exports.defineConfig = _chunkI7VYO5OFcjs.defineConfig; exports.definePageJson = _chunkILAIINMUcjs.definePageJson; exports.defineSitemapJson = _chunkILAIINMUcjs.defineSitemapJson; exports.defineThemeJson = _chunkILAIINMUcjs.defineThemeJson;
|