weapp-vite 3.0.0 → 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 -7
- package/dist/auto-import-components/resolvers.mjs +1 -1
- package/dist/{chunk-54NJAAHW.mjs → chunk-HYF6JF4U.mjs} +1 -1
- package/dist/{chunk-QAOZGE4P.cjs → chunk-I7VYO5OF.cjs} +3 -3
- package/dist/{chunk-KT4ZGCA4.cjs → chunk-ILAIINMU.cjs} +7 -7
- package/dist/{chunk-MBYCEEYQ.mjs → chunk-J4FW3JHK.mjs} +2 -2
- package/dist/{chunk-RLY54DWG.mjs → chunk-PRR5DJHJ.mjs} +1 -1
- package/dist/{chunk-TZP4YYUL.cjs → chunk-RJF2LDZW.cjs} +2 -2
- package/dist/{chunk-7E6I5K2P.cjs → chunk-TQKIOJUX.cjs} +1894 -1536
- package/dist/{chunk-VGP6FV6Q.mjs → chunk-WC7SBOSS.mjs} +1060 -702
- package/dist/cli.cjs +192 -50
- package/dist/cli.mjs +152 -10
- package/dist/{config-DzXsLdA5.d.cts → config-CmnUGB9g.d.cts} +69 -12
- package/dist/{config-Gvt9DtKU.d.ts → config-nkS0_6JW.d.ts} +69 -12
- package/dist/config.cjs +4 -4
- package/dist/config.d.cts +2 -1
- package/dist/config.d.ts +2 -1
- package/dist/config.mjs +3 -3
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.mjs +4 -4
- package/dist/json.cjs +3 -3
- package/dist/json.d.cts +2 -1
- package/dist/json.d.ts +2 -1
- package/dist/json.mjs +2 -2
- 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 -2
- package/dist/volar.mjs +1 -1
- package/package.json +21 -7
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
|
}
|
|
@@ -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,28 +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
|
+
*/
|
|
175
|
+
enable?: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* @description 是否开启缓存,默认为 true
|
|
178
|
+
* @default true
|
|
179
|
+
*/
|
|
180
|
+
cache?: boolean;
|
|
181
|
+
/**
|
|
182
|
+
* @description 构建 npm 的配置,可以配置这个选项给 tsup,让不同的包走不同的配置
|
|
183
|
+
*/
|
|
136
184
|
tsup?: (options: Options, pkgMeta: BuildNpmPackageMeta) => Options | undefined;
|
|
137
185
|
};
|
|
138
186
|
/**
|
|
187
|
+
* @group 生成脚手架配置
|
|
139
188
|
* weapp-vite generate 相关的配置
|
|
140
189
|
*/
|
|
141
190
|
generate?: GenerateOptions;
|
|
142
191
|
/**
|
|
143
|
-
*
|
|
192
|
+
* @group 插件集成
|
|
193
|
+
* 传递给内置 [`vite-tsconfig-paths`](https://www.npmjs.com/package/vite-tsconfig-paths) 插件的参数
|
|
144
194
|
*/
|
|
145
195
|
tsconfigPaths?: PluginOptions;
|
|
146
196
|
/**
|
|
197
|
+
* @group 分包配置
|
|
147
198
|
* 分包是否独立的 rollup 编译上下文
|
|
148
199
|
* 默认情况下,当一个分包设置了 independent: true 之后会默认启用
|
|
149
200
|
* 可以设置 key: 为 root, value: {independent:true} 来强制启用 独立的 rollup 编译上下文
|
|
@@ -157,13 +208,15 @@ interface WeappViteConfig {
|
|
|
157
208
|
*/
|
|
158
209
|
copy?: CopyOptions;
|
|
159
210
|
/**
|
|
160
|
-
*
|
|
211
|
+
* @description 额外的 wxml 文件
|
|
212
|
+
* 把这个方法,扫描到的 `wxml` 添加到额外的 `wxml` 文件列表, **处理** 之后输出到最终的产物中
|
|
161
213
|
* @param wxmlFilePath
|
|
162
|
-
* @returns
|
|
214
|
+
* @returns boolean
|
|
163
215
|
*/
|
|
164
216
|
isAdditionalWxml?: (wxmlFilePath: string) => boolean;
|
|
165
217
|
/**
|
|
166
|
-
* 编译目标平台
|
|
218
|
+
* @description 编译目标平台
|
|
219
|
+
* @ignore
|
|
167
220
|
*/
|
|
168
221
|
platform?: MpPlatform;
|
|
169
222
|
/**
|
|
@@ -171,6 +224,9 @@ interface WeappViteConfig {
|
|
|
171
224
|
*/
|
|
172
225
|
enhance?: EnhanceOptions;
|
|
173
226
|
}
|
|
227
|
+
type UserConfig = UserConfig$1 & {
|
|
228
|
+
weapp?: WeappViteConfig;
|
|
229
|
+
};
|
|
174
230
|
interface ProjectConfig {
|
|
175
231
|
miniprogramRoot?: string;
|
|
176
232
|
srcMiniprogramRoot?: string;
|
|
@@ -261,6 +317,7 @@ declare class ConfigService {
|
|
|
261
317
|
* esbuild 定义的环境变量
|
|
262
318
|
*/
|
|
263
319
|
defineEnv: Record<string, any>;
|
|
320
|
+
packageManager: DetectResult;
|
|
264
321
|
constructor();
|
|
265
322
|
get defineImportMetaEnv(): Record<string, any>;
|
|
266
323
|
setDefineEnv(key: string, value: any): void;
|
|
@@ -312,7 +369,7 @@ declare class NpmService {
|
|
|
312
369
|
get dependenciesCacheHash(): string;
|
|
313
370
|
isMiniprogramPackage(pkg: PackageJson): boolean;
|
|
314
371
|
shouldSkipBuild(outDir: string, isOutdated: boolean): Promise<boolean>;
|
|
315
|
-
writeDependenciesCache(subPackage?: SubPackage): Promise<void
|
|
372
|
+
writeDependenciesCache(subPackage?: SubPackage): Promise<void> | undefined;
|
|
316
373
|
readDependenciesCache(subPackage?: SubPackage): Promise<any>;
|
|
317
374
|
checkDependenciesCacheOutdate(subPackage?: SubPackage): Promise<boolean>;
|
|
318
375
|
bundleBuild({ index, name, options, outDir, subPackage }: {
|
|
@@ -484,9 +541,9 @@ declare module 'vite' {
|
|
|
484
541
|
weapp?: WeappViteConfig;
|
|
485
542
|
}
|
|
486
543
|
}
|
|
487
|
-
declare function defineConfig(config: UserConfig): UserConfig;
|
|
488
|
-
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>;
|
|
489
546
|
declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
|
|
490
547
|
declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
|
491
548
|
|
|
492
|
-
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,28 +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
|
+
*/
|
|
175
|
+
enable?: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* @description 是否开启缓存,默认为 true
|
|
178
|
+
* @default true
|
|
179
|
+
*/
|
|
180
|
+
cache?: boolean;
|
|
181
|
+
/**
|
|
182
|
+
* @description 构建 npm 的配置,可以配置这个选项给 tsup,让不同的包走不同的配置
|
|
183
|
+
*/
|
|
136
184
|
tsup?: (options: Options, pkgMeta: BuildNpmPackageMeta) => Options | undefined;
|
|
137
185
|
};
|
|
138
186
|
/**
|
|
187
|
+
* @group 生成脚手架配置
|
|
139
188
|
* weapp-vite generate 相关的配置
|
|
140
189
|
*/
|
|
141
190
|
generate?: GenerateOptions;
|
|
142
191
|
/**
|
|
143
|
-
*
|
|
192
|
+
* @group 插件集成
|
|
193
|
+
* 传递给内置 [`vite-tsconfig-paths`](https://www.npmjs.com/package/vite-tsconfig-paths) 插件的参数
|
|
144
194
|
*/
|
|
145
195
|
tsconfigPaths?: PluginOptions;
|
|
146
196
|
/**
|
|
197
|
+
* @group 分包配置
|
|
147
198
|
* 分包是否独立的 rollup 编译上下文
|
|
148
199
|
* 默认情况下,当一个分包设置了 independent: true 之后会默认启用
|
|
149
200
|
* 可以设置 key: 为 root, value: {independent:true} 来强制启用 独立的 rollup 编译上下文
|
|
@@ -157,13 +208,15 @@ interface WeappViteConfig {
|
|
|
157
208
|
*/
|
|
158
209
|
copy?: CopyOptions;
|
|
159
210
|
/**
|
|
160
|
-
*
|
|
211
|
+
* @description 额外的 wxml 文件
|
|
212
|
+
* 把这个方法,扫描到的 `wxml` 添加到额外的 `wxml` 文件列表, **处理** 之后输出到最终的产物中
|
|
161
213
|
* @param wxmlFilePath
|
|
162
|
-
* @returns
|
|
214
|
+
* @returns boolean
|
|
163
215
|
*/
|
|
164
216
|
isAdditionalWxml?: (wxmlFilePath: string) => boolean;
|
|
165
217
|
/**
|
|
166
|
-
* 编译目标平台
|
|
218
|
+
* @description 编译目标平台
|
|
219
|
+
* @ignore
|
|
167
220
|
*/
|
|
168
221
|
platform?: MpPlatform;
|
|
169
222
|
/**
|
|
@@ -171,6 +224,9 @@ interface WeappViteConfig {
|
|
|
171
224
|
*/
|
|
172
225
|
enhance?: EnhanceOptions;
|
|
173
226
|
}
|
|
227
|
+
type UserConfig = UserConfig$1 & {
|
|
228
|
+
weapp?: WeappViteConfig;
|
|
229
|
+
};
|
|
174
230
|
interface ProjectConfig {
|
|
175
231
|
miniprogramRoot?: string;
|
|
176
232
|
srcMiniprogramRoot?: string;
|
|
@@ -261,6 +317,7 @@ declare class ConfigService {
|
|
|
261
317
|
* esbuild 定义的环境变量
|
|
262
318
|
*/
|
|
263
319
|
defineEnv: Record<string, any>;
|
|
320
|
+
packageManager: DetectResult;
|
|
264
321
|
constructor();
|
|
265
322
|
get defineImportMetaEnv(): Record<string, any>;
|
|
266
323
|
setDefineEnv(key: string, value: any): void;
|
|
@@ -312,7 +369,7 @@ declare class NpmService {
|
|
|
312
369
|
get dependenciesCacheHash(): string;
|
|
313
370
|
isMiniprogramPackage(pkg: PackageJson): boolean;
|
|
314
371
|
shouldSkipBuild(outDir: string, isOutdated: boolean): Promise<boolean>;
|
|
315
|
-
writeDependenciesCache(subPackage?: SubPackage): Promise<void
|
|
372
|
+
writeDependenciesCache(subPackage?: SubPackage): Promise<void> | undefined;
|
|
316
373
|
readDependenciesCache(subPackage?: SubPackage): Promise<any>;
|
|
317
374
|
checkDependenciesCacheOutdate(subPackage?: SubPackage): Promise<boolean>;
|
|
318
375
|
bundleBuild({ index, name, options, outDir, subPackage }: {
|
|
@@ -484,9 +541,9 @@ declare module 'vite' {
|
|
|
484
541
|
weapp?: WeappViteConfig;
|
|
485
542
|
}
|
|
486
543
|
}
|
|
487
|
-
declare function defineConfig(config: UserConfig): UserConfig;
|
|
488
|
-
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>;
|
|
489
546
|
declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
|
|
490
547
|
declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
|
491
548
|
|
|
492
|
-
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,4 +16,4 @@ require('./chunk-TZP4YYUL.cjs');
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
exports.defineAppJson =
|
|
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,
|