weapp-vite 7.4.0 → 7.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -3
- package/THIRD_PARTY_NOTICES.md +60 -0
- package/bin/bootstrap.js +14 -1
- package/dist/action-B3YZMA-h.mjs +255 -0
- package/dist/action-BELcDNNv.mjs +139 -0
- package/dist/action-BOk3vGI7.mjs +1110 -0
- package/dist/action-DlC6JYpt.mjs +95 -0
- package/dist/action-zEDY7oh_.mjs +247 -0
- package/dist/adapters-CcHrsYaj.mjs +1 -0
- package/dist/analyze-DN79YOAH.mjs +184 -0
- package/dist/artifacts-BOyC9Fy-.mjs +106 -0
- package/dist/assets-C5_YYXNk.mjs +637 -0
- package/dist/auto-import-components/resolvers.mjs +1 -2
- package/dist/auto-import-presets/wevu-router.mjs +1 -2
- package/dist/auto-import-presets/wevu.mjs +1 -2
- package/dist/auto-routes.mjs +2 -1
- package/dist/budget-CTLOHwgI.d.mts +177 -0
- package/dist/budget-EOeEycc_.mjs +65 -0
- package/dist/builtProject-C29udgXY.mjs +541 -0
- package/dist/chunkStrategy-DY_LZIIe.mjs +1448 -0
- package/dist/classifier-DBJY__kg.mjs +88 -0
- package/dist/cli-acceptance.d.mts +1 -0
- package/dist/cli-acceptance.mjs +21 -0
- package/dist/cli.mjs +519 -5049
- package/dist/compatibility.mjs +1 -2
- package/dist/{config-Dbvj5yK7.d.mts → config-Bf6DWhyb.d.mts} +220 -76
- package/dist/config.d.mts +3 -3
- package/dist/config.mjs +1 -1
- package/dist/{constants-WOsG3Eqd.mjs → constants-DEZdcsMn.mjs} +1 -1
- package/dist/{createContext-UOEgeYnA.mjs → createCompilerContextInstance-aYwi8wQt.mjs} +36862 -32020
- package/dist/createContext-tApLtII-.mjs +15 -0
- package/dist/dashboard/analyze.d.mts +48 -0
- package/dist/dashboard/analyze.mjs +3 -0
- package/dist/dashboard/vite.d.mts +1 -1
- package/dist/dashboard.d.mts +3 -2
- package/dist/dashboard.mjs +1748 -1
- package/dist/dashboardTransport-C_Y6jMp-.mjs +16 -0
- package/dist/dashboardViteBridge-DCGR43aM.mjs +302 -0
- package/dist/dev-C2fgr_Xd.mjs +67 -0
- package/dist/devProvider-D-hTfsEO.mjs +3027 -0
- package/dist/docs/README.md +59 -3
- package/dist/docs/ai-workflows.md +4 -0
- package/dist/docs/doctor.md +38 -0
- package/dist/docs/getting-started.md +3 -1
- package/dist/docs/index.md +3 -1
- package/dist/docs/mcp.md +104 -1
- package/dist/docs/testing.md +29 -2
- package/dist/docs/troubleshooting.md +16 -0
- package/dist/docs/uni-app-component-libraries.md +8 -7
- package/dist/docs/upload.md +40 -3
- package/dist/docs/vite-plugin.md +171 -0
- package/dist/docs/vue-sfc.md +42 -0
- package/dist/docs/weapp-config.md +54 -0
- package/dist/docs/wevu-authoring.md +10 -0
- package/dist/doctor-worker.d.mts +1 -0
- package/dist/doctor-worker.mjs +60 -0
- package/dist/doctor.d.mts +144 -0
- package/dist/doctor.mjs +850 -0
- package/dist/engine-C66J0HLz.mjs +54 -0
- package/dist/eslint.mjs +1 -2
- package/dist/{file-giE9UMZa.mjs → file-CcIOmqhC.mjs} +58 -24
- package/dist/file-DtcteQ4G.mjs +1 -0
- package/dist/files-BqxFIPRp.mjs +45 -0
- package/dist/forwardConsole-B0Reo8Lf.mjs +511 -0
- package/dist/getInstance-BAIaU2y9.mjs +1 -0
- package/dist/getInstance-Dt9IQDKr.mjs +28 -0
- package/dist/history-BIiRCzbq.mjs +784 -0
- package/dist/i18n.d.mts +1 -1
- package/dist/index-D5rgBzYZ.d.mts +740 -0
- package/dist/index.d.mts +12 -10
- package/dist/index.mjs +3 -2
- package/dist/json.d.mts +1 -1
- package/dist/json.mjs +1 -2
- package/dist/lib-DjccSI1B.mjs +143 -0
- package/dist/lifecycle-C36WSbQS.mjs +413 -0
- package/dist/loadConfig-BWIsDXR4.mjs +59 -0
- package/dist/loadConfig-D-BpBgsk.mjs +1 -0
- package/dist/logBuildAppFinish-ChjwATMv.mjs +57 -0
- package/dist/logger-DGn5iEVN.mjs +1 -0
- package/dist/mcp-CYgX9HpO.mjs +86 -0
- package/dist/{mcp-BG6TliEg.mjs → mcp-Cj8Maqo6.mjs} +16 -7
- package/dist/mcp.d.mts +6 -3
- package/dist/mcp.mjs +1 -2
- package/dist/mcpClient-DVLvFLZv.mjs +287 -0
- package/dist/metadata-hwF7QRcS.mjs +59 -0
- package/dist/nodeEnv-BmH8UZPR.mjs +7 -0
- package/dist/openIde-CroqOgk5.mjs +648 -0
- package/dist/options-jqFwfD1G.mjs +34 -0
- package/dist/package-Cmakyy3J.mjs +4 -0
- package/dist/path-CYYIQGS7.mjs +44 -0
- package/dist/{platform-DTWs5QRi.mjs → platform-CnkySBKz.mjs} +1 -1
- package/dist/processCleanup-BQn2kTcK.mjs +19 -0
- package/dist/protocol-Cg6Jdlvb.mjs +141 -0
- package/dist/reader-sh_POQ9-.mjs +93 -0
- package/dist/realpathScope-Tf9mz-fh.mjs +23 -0
- package/dist/report-hyonPGbZ.mjs +107 -0
- package/dist/resolvedId-CiDl7SC1.mjs +60 -0
- package/dist/{resolvers-icNxkpcy.mjs → resolvers-Dod-euqX.mjs} +4 -1
- package/dist/resolvers.mjs +1 -2
- package/dist/runtime-CLUhQsdA.mjs +43 -0
- package/dist/{runtime-Ee2HY6gR.d.mts → runtime-DpVf714f.d.mts} +1 -1
- package/dist/runtime.d.mts +1 -1
- package/dist/runtime.mjs +1 -2
- package/dist/schematics-kO26eQRT.mjs +91 -0
- package/dist/session-D3zsdzIy.mjs +452 -0
- package/dist/test.d.mts +1 -0
- package/dist/test.mjs +204 -45
- package/dist/{types-CgZn5X6j.d.mts → types-D-kfuyVa.d.mts} +1 -2
- package/dist/types-D0FFexRF.d.mts +39 -0
- package/dist/types.d.mts +3 -3
- package/dist/{upload-D0RcEWrq.mjs → upload-DozK8UdN.mjs} +278 -15
- package/dist/upload-worker.mjs +136 -3
- package/dist/utils-Dy51PYAC.mjs +1034 -0
- package/dist/vite.d.mts +9 -0
- package/dist/vite.mjs +309 -0
- package/dist/volar.d.mts +2 -2
- package/dist/web-apis.mjs +1 -2
- package/dist/wxs-BT8btflA.mjs +112 -0
- package/dist/wxs-Z4VQDeJ_.mjs +1 -0
- package/package.json +80 -48
- package/dist/adapters-BwnMMIZR.mjs +0 -2
- package/dist/dashboard-BzaVesmQ.mjs +0 -558
- package/dist/file-D19nbDoN.mjs +0 -2
- package/dist/getInstance-CYF1vl5l.mjs +0 -2
- package/dist/index-DbqVupg0.d.mts +0 -246
- package/dist/logger-mt4mSTqV.mjs +0 -2
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
import { t as resolveRealpath } from "./realpathScope-Tf9mz-fh.mjs";
|
|
2
|
+
import { n as loadHostRolldownBuild } from "./engine-C66J0HLz.mjs";
|
|
3
|
+
import { a as hasOwn, i as resolveWeappLibEntries, o as waitForBuildTasks } from "./lib-DjccSI1B.mjs";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
import process from "node:process";
|
|
6
|
+
import path from "pathe";
|
|
7
|
+
import "@weapp-core/shared";
|
|
8
|
+
import { fs } from "@weapp-core/shared/fs";
|
|
9
|
+
import { mkdtemp, readFile, readdir, rm } from "node:fs/promises";
|
|
10
|
+
import os from "node:os";
|
|
11
|
+
import { resolveModule } from "local-pkg";
|
|
12
|
+
import { spawn } from "node:child_process";
|
|
13
|
+
import { dts } from "rolldown-plugin-dts";
|
|
14
|
+
//#region src/runtime/libDts/compilerOptions.ts
|
|
15
|
+
function serializeCompilerOptions(tsInstance, options) {
|
|
16
|
+
const serialized = { ...options };
|
|
17
|
+
const protocol = tsInstance.server.protocol;
|
|
18
|
+
const enumOptions = {
|
|
19
|
+
jsx: [tsInstance.JsxEmit, protocol.JsxEmit],
|
|
20
|
+
module: [tsInstance.ModuleKind, protocol.ModuleKind],
|
|
21
|
+
moduleResolution: [tsInstance.ModuleResolutionKind, protocol.ModuleResolutionKind],
|
|
22
|
+
target: [tsInstance.ScriptTarget, protocol.ScriptTarget]
|
|
23
|
+
};
|
|
24
|
+
for (const [name, [numericEnum, jsonEnum]] of Object.entries(enumOptions)) {
|
|
25
|
+
const value = options[name];
|
|
26
|
+
if (typeof value === "number") {
|
|
27
|
+
const member = Object.keys(jsonEnum).find((key) => numericEnum[key] === value);
|
|
28
|
+
if (member !== void 0) serialized[name] = jsonEnum[member];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (options.newLine === tsInstance.NewLineKind.CarriageReturnLineFeed) serialized.newLine = protocol.NewLineKind.Crlf.toLowerCase();
|
|
32
|
+
else if (options.newLine === tsInstance.NewLineKind.LineFeed) serialized.newLine = protocol.NewLineKind.Lf.toLowerCase();
|
|
33
|
+
for (const [name, numericEnum] of Object.entries({
|
|
34
|
+
moduleDetection: tsInstance.ModuleDetectionKind,
|
|
35
|
+
importsNotUsedAsValues: tsInstance.ImportsNotUsedAsValues
|
|
36
|
+
})) {
|
|
37
|
+
const value = options[name];
|
|
38
|
+
if (typeof value === "number" && typeof numericEnum[value] === "string") serialized[name] = numericEnum[value].toLowerCase();
|
|
39
|
+
}
|
|
40
|
+
if (options.lib) serialized.lib = options.lib.map((lib) => lib.replace(/^lib\.(.+)\.d\.ts$/i, "$1"));
|
|
41
|
+
return serialized;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/runtime/libDts/rewriteWevuComponent.ts
|
|
45
|
+
function getVueCompilerLib(value) {
|
|
46
|
+
if (Array.isArray(value)) {
|
|
47
|
+
const resolved = value.filter((item) => typeof item === "string");
|
|
48
|
+
return resolved.length > 0 ? resolved : void 0;
|
|
49
|
+
}
|
|
50
|
+
if (typeof value === "string") return value;
|
|
51
|
+
}
|
|
52
|
+
function splitTopLevelTypeArgs(value) {
|
|
53
|
+
const args = [];
|
|
54
|
+
let depth = 0;
|
|
55
|
+
let start = 0;
|
|
56
|
+
let quote = null;
|
|
57
|
+
let escape = false;
|
|
58
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
59
|
+
const char = value[i];
|
|
60
|
+
if (quote) {
|
|
61
|
+
if (escape) {
|
|
62
|
+
escape = false;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (char === "\\") {
|
|
66
|
+
escape = true;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (char === quote) quote = null;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (char === "\"" || char === "'" || char === "`") {
|
|
73
|
+
quote = char;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (char === "<") {
|
|
77
|
+
depth += 1;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (char === ">") {
|
|
81
|
+
if (depth > 0) depth -= 1;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (char === "," && depth === 0) {
|
|
85
|
+
args.push(value.slice(start, i).trim());
|
|
86
|
+
start = i + 1;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const tail = value.slice(start).trim();
|
|
90
|
+
if (tail) args.push(tail);
|
|
91
|
+
return args;
|
|
92
|
+
}
|
|
93
|
+
function findMatchingAngleBracket(value, start) {
|
|
94
|
+
let depth = 1;
|
|
95
|
+
let quote = null;
|
|
96
|
+
let escape = false;
|
|
97
|
+
for (let i = start; i < value.length; i += 1) {
|
|
98
|
+
const char = value[i];
|
|
99
|
+
if (quote) {
|
|
100
|
+
if (escape) {
|
|
101
|
+
escape = false;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (char === "\\") {
|
|
105
|
+
escape = true;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (char === quote) quote = null;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (char === "\"" || char === "'" || char === "`") {
|
|
112
|
+
quote = char;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (char === "<") {
|
|
116
|
+
depth += 1;
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (char === ">") {
|
|
120
|
+
depth -= 1;
|
|
121
|
+
if (depth === 0) return i;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return -1;
|
|
125
|
+
}
|
|
126
|
+
function rewriteVueComponentTypeToWevu(content) {
|
|
127
|
+
const token = "import(\"vue\").DefineComponent<";
|
|
128
|
+
const tokenSingle = "import('vue').DefineComponent<";
|
|
129
|
+
if (!content.includes(token) && !content.includes(tokenSingle)) return content;
|
|
130
|
+
let result = "";
|
|
131
|
+
let index = 0;
|
|
132
|
+
while (index < content.length) {
|
|
133
|
+
const nextDouble = content.indexOf(token, index);
|
|
134
|
+
const nextSingle = content.indexOf(tokenSingle, index);
|
|
135
|
+
const next = nextDouble === -1 ? nextSingle : nextSingle === -1 ? nextDouble : Math.min(nextDouble, nextSingle);
|
|
136
|
+
if (next === -1) {
|
|
137
|
+
result += content.slice(index);
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
const match = next === nextDouble ? token : tokenSingle;
|
|
141
|
+
result += content.slice(index, next);
|
|
142
|
+
const start = next + match.length;
|
|
143
|
+
const end = findMatchingAngleBracket(content, start);
|
|
144
|
+
if (end === -1) {
|
|
145
|
+
result += content.slice(next);
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
const args = splitTopLevelTypeArgs(content.slice(start, end));
|
|
149
|
+
while (args.length < 5) args.push("any");
|
|
150
|
+
result += `import(\"wevu\").WevuComponentConstructor<${args.slice(0, 5).join(", ")}>`;
|
|
151
|
+
index = end + 1;
|
|
152
|
+
}
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
155
|
+
function getVueCompilerLibOrUndefined(value) {
|
|
156
|
+
return getVueCompilerLib(value);
|
|
157
|
+
}
|
|
158
|
+
function shouldRewriteWevuComponentType(value) {
|
|
159
|
+
if (Array.isArray(value)) return value.includes("wevu");
|
|
160
|
+
if (typeof value === "string") return value === "wevu";
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/runtime/libDts/shared.ts
|
|
165
|
+
const DTS_INPUT_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
166
|
+
".ts",
|
|
167
|
+
".tsx",
|
|
168
|
+
".mts",
|
|
169
|
+
".cts"
|
|
170
|
+
]);
|
|
171
|
+
const NUMERIC_SUFFIX_RE = /^\d+$/;
|
|
172
|
+
const EMPTY_EXPORT_RE = /^export\s*\{\s*\};?\s*$/;
|
|
173
|
+
const DTS_OUTPUT_FILE_RE = /\.d\.(?:m|c)?ts$/;
|
|
174
|
+
const DTS_MAP_OUTPUT_FILE_RE = /\.d\.(?:m|c)?ts\.map$/;
|
|
175
|
+
const SOURCE_MAPPING_URL_RE = /# sourceMappingURL=.*$/gm;
|
|
176
|
+
function isBundledDtsEntry(entryPath) {
|
|
177
|
+
const ext = path.extname(entryPath);
|
|
178
|
+
if (entryPath.endsWith(".d.ts")) return true;
|
|
179
|
+
return DTS_INPUT_EXTENSIONS.has(ext);
|
|
180
|
+
}
|
|
181
|
+
function getStubContent(entryPath) {
|
|
182
|
+
if (entryPath.endsWith(".vue")) return "declare const _default: any\nexport default _default\n";
|
|
183
|
+
return "export {}\n";
|
|
184
|
+
}
|
|
185
|
+
async function ensureStub(entry, outDir) {
|
|
186
|
+
const outputPath = path.resolve(outDir, `${entry.outputBase}.d.ts`);
|
|
187
|
+
if (await fs.pathExists(outputPath)) return;
|
|
188
|
+
await fs.ensureDir(path.dirname(outputPath));
|
|
189
|
+
await fs.writeFile(outputPath, getStubContent(entry.input));
|
|
190
|
+
}
|
|
191
|
+
async function findDeconflictedDtsPath(expectedPath) {
|
|
192
|
+
const dir = path.dirname(expectedPath);
|
|
193
|
+
if (!await fs.pathExists(dir)) return;
|
|
194
|
+
const baseName = path.basename(expectedPath, ".d.ts");
|
|
195
|
+
const entries = await fs.readdir(dir);
|
|
196
|
+
let bestMatch;
|
|
197
|
+
let bestIndex = Number.POSITIVE_INFINITY;
|
|
198
|
+
for (const name of entries) {
|
|
199
|
+
if (!name.startsWith(baseName) || !name.endsWith(".d.ts")) continue;
|
|
200
|
+
if (name === `${baseName}.d.ts`) continue;
|
|
201
|
+
const suffix = name.slice(baseName.length, -5);
|
|
202
|
+
if (!NUMERIC_SUFFIX_RE.test(suffix)) continue;
|
|
203
|
+
const index = Number.parseInt(suffix, 10);
|
|
204
|
+
if (Number.isNaN(index) || index >= bestIndex) continue;
|
|
205
|
+
bestIndex = index;
|
|
206
|
+
bestMatch = path.join(dir, name);
|
|
207
|
+
}
|
|
208
|
+
return bestMatch;
|
|
209
|
+
}
|
|
210
|
+
async function isStubDts(filePath) {
|
|
211
|
+
const content = await fs.readFile(filePath, "utf8");
|
|
212
|
+
return EMPTY_EXPORT_RE.test(content.trim());
|
|
213
|
+
}
|
|
214
|
+
async function normalizeRolldownDtsOutput(entries, outDir) {
|
|
215
|
+
await Promise.all(entries.map(async (entry) => {
|
|
216
|
+
const expectedPath = path.resolve(outDir, `${entry.outputBase}.d.ts`);
|
|
217
|
+
const candidate = await findDeconflictedDtsPath(expectedPath);
|
|
218
|
+
if (!candidate) return;
|
|
219
|
+
if (!(!await fs.pathExists(expectedPath) || await isStubDts(expectedPath))) return;
|
|
220
|
+
await fs.ensureDir(path.dirname(expectedPath));
|
|
221
|
+
await fs.copy(candidate, expectedPath);
|
|
222
|
+
if (candidate !== expectedPath) await fs.remove(candidate);
|
|
223
|
+
}));
|
|
224
|
+
}
|
|
225
|
+
function normalizePath(value) {
|
|
226
|
+
return value.split(path.sep).join("/");
|
|
227
|
+
}
|
|
228
|
+
function resolveRelativeBase(entryPath, libRoot, cwd) {
|
|
229
|
+
const relativeToRoot = path.relative(libRoot, entryPath);
|
|
230
|
+
if (!relativeToRoot.startsWith("..") && !path.isAbsolute(relativeToRoot)) return normalizePath(relativeToRoot);
|
|
231
|
+
return normalizePath(path.relative(cwd, entryPath));
|
|
232
|
+
}
|
|
233
|
+
function runVueTsc(binPath, projectPath, cwd) {
|
|
234
|
+
return new Promise((resolve, reject) => {
|
|
235
|
+
const child = spawn(process.execPath, [
|
|
236
|
+
binPath,
|
|
237
|
+
"--project",
|
|
238
|
+
projectPath
|
|
239
|
+
], {
|
|
240
|
+
cwd,
|
|
241
|
+
stdio: "inherit"
|
|
242
|
+
});
|
|
243
|
+
child.on("error", reject);
|
|
244
|
+
child.on("close", (code) => {
|
|
245
|
+
if (code === 0) {
|
|
246
|
+
resolve();
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
reject(/* @__PURE__ */ new Error(`[lib] vue-tsc 生成 dts 失败,退出码 ${code ?? "null"}`));
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
async function resolveInternalTsconfig(cwd, tsconfig) {
|
|
254
|
+
if (tsconfig === false) return;
|
|
255
|
+
if (tsconfig) {
|
|
256
|
+
const resolved = path.isAbsolute(tsconfig) ? tsconfig : path.resolve(cwd, tsconfig);
|
|
257
|
+
if (!await fs.pathExists(resolved)) throw new Error(`[lib] internal 方案未找到 tsconfig:${resolved}`);
|
|
258
|
+
return resolved;
|
|
259
|
+
}
|
|
260
|
+
const defaultPath = path.resolve(cwd, "tsconfig.json");
|
|
261
|
+
return await fs.pathExists(defaultPath) ? defaultPath : void 0;
|
|
262
|
+
}
|
|
263
|
+
async function tsconfigHasProjectReferences(tsconfigPath) {
|
|
264
|
+
if (!tsconfigPath) return false;
|
|
265
|
+
try {
|
|
266
|
+
const config = await fs.readJson(tsconfigPath);
|
|
267
|
+
return Array.isArray(config?.references) && config.references.length > 0;
|
|
268
|
+
} catch {
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
function ensureModuleResolution(ts, compilerOptions) {
|
|
273
|
+
if (compilerOptions.moduleResolution) return;
|
|
274
|
+
const moduleKind = typeof compilerOptions.module === "number" ? compilerOptions.module : (compilerOptions.target ?? ts.ScriptTarget.ES5) >= ts.ScriptTarget.ES2015 ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS;
|
|
275
|
+
let moduleResolution;
|
|
276
|
+
switch (moduleKind) {
|
|
277
|
+
case ts.ModuleKind.CommonJS:
|
|
278
|
+
moduleResolution = ts.ModuleResolutionKind.Node10;
|
|
279
|
+
break;
|
|
280
|
+
case ts.ModuleKind.Node16:
|
|
281
|
+
moduleResolution = ts.ModuleResolutionKind.Node16;
|
|
282
|
+
break;
|
|
283
|
+
case ts.ModuleKind.NodeNext:
|
|
284
|
+
moduleResolution = ts.ModuleResolutionKind.NodeNext;
|
|
285
|
+
break;
|
|
286
|
+
default: moduleResolution = ts.version.startsWith("5") ? ts.ModuleResolutionKind.Bundler : ts.ModuleResolutionKind.Classic;
|
|
287
|
+
}
|
|
288
|
+
compilerOptions.moduleResolution = moduleResolution;
|
|
289
|
+
}
|
|
290
|
+
function isDtsOutputFile(filePath) {
|
|
291
|
+
return DTS_OUTPUT_FILE_RE.test(filePath) && !filePath.endsWith(".map");
|
|
292
|
+
}
|
|
293
|
+
function isDtsMapOutputFile(filePath) {
|
|
294
|
+
return DTS_MAP_OUTPUT_FILE_RE.test(filePath);
|
|
295
|
+
}
|
|
296
|
+
function replaceSourceMappingUrl(content, mapFileName) {
|
|
297
|
+
return content.replace(SOURCE_MAPPING_URL_RE, `# sourceMappingURL=${mapFileName}`);
|
|
298
|
+
}
|
|
299
|
+
function resolveVueSourceFile(program, filePath) {
|
|
300
|
+
const normalized = normalizePath(filePath);
|
|
301
|
+
const candidates = [
|
|
302
|
+
filePath,
|
|
303
|
+
normalized,
|
|
304
|
+
`${filePath}.ts`,
|
|
305
|
+
`${filePath}.js`,
|
|
306
|
+
`${filePath}.tsx`,
|
|
307
|
+
`${filePath}.jsx`,
|
|
308
|
+
`${normalized}.ts`,
|
|
309
|
+
`${normalized}.js`,
|
|
310
|
+
`${normalized}.tsx`,
|
|
311
|
+
`${normalized}.jsx`
|
|
312
|
+
];
|
|
313
|
+
for (const candidate of candidates) {
|
|
314
|
+
const sourceFile = program.getSourceFile(candidate);
|
|
315
|
+
if (sourceFile) return sourceFile;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
//#endregion
|
|
319
|
+
//#region src/runtime/libDts/volar.ts
|
|
320
|
+
const require = createRequire(import.meta.url);
|
|
321
|
+
function resolveAdapter() {
|
|
322
|
+
const modulePath = require.resolve("weapp-vite/volar");
|
|
323
|
+
return {
|
|
324
|
+
modulePath,
|
|
325
|
+
implementationPath: createRequire(modulePath).resolve("@weapp-vite/volar")
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
function resolveVueTscVolarPlugins(options, cwd) {
|
|
329
|
+
const plugins = options.plugins?.map((plugin) => {
|
|
330
|
+
const name = typeof plugin === "string" ? plugin : plugin.name;
|
|
331
|
+
const modulePath = require.resolve(name, { paths: [cwd] });
|
|
332
|
+
return typeof plugin === "string" ? modulePath : {
|
|
333
|
+
...plugin,
|
|
334
|
+
name: modulePath
|
|
335
|
+
};
|
|
336
|
+
});
|
|
337
|
+
if (options.lib !== "wevu") return plugins;
|
|
338
|
+
const { modulePath, implementationPath } = resolveAdapter();
|
|
339
|
+
const normalized = (plugins ?? []).map((plugin) => {
|
|
340
|
+
if ((typeof plugin === "string" ? plugin : plugin.name) !== implementationPath) return plugin;
|
|
341
|
+
return typeof plugin === "string" ? modulePath : {
|
|
342
|
+
...plugin,
|
|
343
|
+
name: modulePath
|
|
344
|
+
};
|
|
345
|
+
});
|
|
346
|
+
let registered = false;
|
|
347
|
+
const resolved = normalized.filter((plugin) => {
|
|
348
|
+
if ((typeof plugin === "string" ? plugin : plugin.name) !== modulePath) return true;
|
|
349
|
+
if (registered) return false;
|
|
350
|
+
registered = true;
|
|
351
|
+
return true;
|
|
352
|
+
});
|
|
353
|
+
if (!registered) resolved.push(modulePath);
|
|
354
|
+
return resolved;
|
|
355
|
+
}
|
|
356
|
+
function resolveInternalVolarPlugins(plugins, lib) {
|
|
357
|
+
if (lib !== "wevu") return plugins;
|
|
358
|
+
const { modulePath } = resolveAdapter();
|
|
359
|
+
const factory = require(modulePath);
|
|
360
|
+
let registered = false;
|
|
361
|
+
const resolved = plugins.filter((plugin) => {
|
|
362
|
+
if (plugin !== factory) return true;
|
|
363
|
+
if (registered) return false;
|
|
364
|
+
registered = true;
|
|
365
|
+
return true;
|
|
366
|
+
});
|
|
367
|
+
if (!registered) resolved.push(factory);
|
|
368
|
+
return resolved;
|
|
369
|
+
}
|
|
370
|
+
//#endregion
|
|
371
|
+
//#region src/runtime/libDts/generateVueDts.ts
|
|
372
|
+
const FILE_EXTENSION_RE = /\.[^.]+$/;
|
|
373
|
+
async function generateVueDtsWithVueTsc(configService, libConfig, vueEntries, dtsOptions) {
|
|
374
|
+
const ts = await import("typescript");
|
|
375
|
+
const vueTscPkg = resolveModule("vue-tsc/package.json", { paths: [configService.cwd, process.cwd()] });
|
|
376
|
+
if (!vueTscPkg) throw new Error("[lib] 生成 Vue SFC 的 dts 需要安装 vue-tsc,请先安装后重试。");
|
|
377
|
+
const vueTscBin = path.resolve(path.dirname(vueTscPkg), "bin/vue-tsc.js");
|
|
378
|
+
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "weapp-vite-lib-dts-"));
|
|
379
|
+
const tempOutDir = path.join(tempRoot, "out");
|
|
380
|
+
const tsconfigPath = path.join(tempRoot, "tsconfig.json");
|
|
381
|
+
let libRoot = libConfig.root || configService.absoluteSrcRoot;
|
|
382
|
+
if (vueEntries.some((entry) => {
|
|
383
|
+
const relative = path.relative(libRoot, entry.input);
|
|
384
|
+
return relative.startsWith("..") || path.isAbsolute(relative);
|
|
385
|
+
})) libRoot = configService.cwd;
|
|
386
|
+
const baseVueTsconfig = {
|
|
387
|
+
compilerOptions: {
|
|
388
|
+
declaration: true,
|
|
389
|
+
emitDeclarationOnly: true,
|
|
390
|
+
declarationMap: false,
|
|
391
|
+
outDir: tempOutDir,
|
|
392
|
+
declarationDir: tempOutDir,
|
|
393
|
+
rootDir: libRoot,
|
|
394
|
+
allowJs: true,
|
|
395
|
+
jsx: ts.JsxEmit.Preserve,
|
|
396
|
+
skipLibCheck: true,
|
|
397
|
+
module: ts.ModuleKind.ESNext,
|
|
398
|
+
target: ts.ScriptTarget.ESNext,
|
|
399
|
+
moduleResolution: ts.ModuleResolutionKind.Bundler
|
|
400
|
+
},
|
|
401
|
+
files: vueEntries.map((entry) => entry.input),
|
|
402
|
+
include: vueEntries.map((entry) => entry.input),
|
|
403
|
+
vueCompilerOptions: { lib: "wevu" }
|
|
404
|
+
};
|
|
405
|
+
const vueTscOptions = dtsOptions?.vueTsc;
|
|
406
|
+
const vueTsconfig = {
|
|
407
|
+
...baseVueTsconfig,
|
|
408
|
+
...vueTscOptions?.tsconfig,
|
|
409
|
+
compilerOptions: {
|
|
410
|
+
...baseVueTsconfig.compilerOptions,
|
|
411
|
+
...vueTscOptions?.compilerOptions
|
|
412
|
+
},
|
|
413
|
+
vueCompilerOptions: {
|
|
414
|
+
...baseVueTsconfig.vueCompilerOptions,
|
|
415
|
+
...vueTscOptions?.vueCompilerOptions
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
const rewriteWevuComponentType = shouldRewriteWevuComponentType(getVueCompilerLibOrUndefined(vueTsconfig.vueCompilerOptions?.lib));
|
|
419
|
+
try {
|
|
420
|
+
vueTsconfig.vueCompilerOptions.plugins = resolveVueTscVolarPlugins(vueTsconfig.vueCompilerOptions, configService.cwd);
|
|
421
|
+
await fs.ensureDir(tempOutDir);
|
|
422
|
+
await fs.writeJson(tsconfigPath, {
|
|
423
|
+
...vueTsconfig,
|
|
424
|
+
compilerOptions: serializeCompilerOptions(ts, vueTsconfig.compilerOptions)
|
|
425
|
+
}, { spaces: 2 });
|
|
426
|
+
await runVueTsc(vueTscBin, tsconfigPath, configService.cwd);
|
|
427
|
+
await waitForBuildTasks(vueEntries.map(async (entry) => {
|
|
428
|
+
const relativeBase = resolveRelativeBase(entry.input, libRoot, configService.cwd);
|
|
429
|
+
const candidate = path.join(tempOutDir, `${relativeBase.replace(FILE_EXTENSION_RE, "")}.d.ts`);
|
|
430
|
+
const candidateWithExt = path.join(tempOutDir, `${relativeBase}.d.ts`);
|
|
431
|
+
const sourcePath = await fs.pathExists(candidate) ? candidate : await fs.pathExists(candidateWithExt) ? candidateWithExt : void 0;
|
|
432
|
+
if (!sourcePath) throw new Error(`[lib] 生成 Vue SFC dts 失败,未找到输出:${relativeBase}`);
|
|
433
|
+
const outputPath = path.resolve(configService.outDir, `${entry.outputBase}.d.ts`);
|
|
434
|
+
await fs.ensureDir(path.dirname(outputPath));
|
|
435
|
+
const content = await fs.readFile(sourcePath, "utf8");
|
|
436
|
+
const normalized = rewriteWevuComponentType ? rewriteVueComponentTypeToWevu(content) : content;
|
|
437
|
+
await fs.writeFile(outputPath, normalized);
|
|
438
|
+
}));
|
|
439
|
+
} finally {
|
|
440
|
+
await fs.remove(tempRoot);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
async function generateVueDtsWithInternal(configService, vueEntries, dtsOptions, onWatchFile) {
|
|
444
|
+
const languageCorePkg = resolveModule("@vue/language-core/package.json", { paths: [configService.cwd, process.cwd()] });
|
|
445
|
+
const volarTsPkg = resolveModule("@volar/typescript/package.json", { paths: [configService.cwd, process.cwd()] });
|
|
446
|
+
const tsPkg = resolveModule("typescript/package.json", { paths: [configService.cwd, process.cwd()] });
|
|
447
|
+
if (!languageCorePkg || !volarTsPkg || !tsPkg) throw new Error("[lib] internal 方案生成 Vue SFC dts 需要安装 typescript、@vue/language-core 与 @volar/typescript。");
|
|
448
|
+
const ts = await import("typescript");
|
|
449
|
+
const { CompilerOptionsResolver, createParsedCommandLine, createVueLanguagePlugin, getDefaultCompilerOptions } = await import("@vue/language-core");
|
|
450
|
+
const { proxyCreateProgram } = await import("@volar/typescript");
|
|
451
|
+
const internalOptions = dtsOptions?.internal;
|
|
452
|
+
const tsconfigPath = await resolveInternalTsconfig(configService.cwd, internalOptions?.tsconfig);
|
|
453
|
+
const configHost = {
|
|
454
|
+
useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,
|
|
455
|
+
readDirectory: ts.sys.readDirectory,
|
|
456
|
+
fileExists: ts.sys.fileExists,
|
|
457
|
+
readFile: ts.sys.readFile,
|
|
458
|
+
getCurrentDirectory: ts.sys.getCurrentDirectory,
|
|
459
|
+
onUnRecoverableConfigFileDiagnostic: () => {}
|
|
460
|
+
};
|
|
461
|
+
const parsedVue = tsconfigPath ? createParsedCommandLine(ts, configHost, normalizePath(tsconfigPath)) : void 0;
|
|
462
|
+
const parsedTs = tsconfigPath ? ts.getParsedCommandLineOfConfigFile(tsconfigPath, void 0, configHost) : void 0;
|
|
463
|
+
const compilerOptions = {
|
|
464
|
+
...parsedVue?.options ?? parsedTs?.options ?? {},
|
|
465
|
+
...internalOptions?.compilerOptions ?? {}
|
|
466
|
+
};
|
|
467
|
+
compilerOptions.noEmit = false;
|
|
468
|
+
compilerOptions.declaration = true;
|
|
469
|
+
compilerOptions.emitDeclarationOnly = true;
|
|
470
|
+
compilerOptions.allowNonTsExtensions = true;
|
|
471
|
+
compilerOptions.allowArbitraryExtensions = true;
|
|
472
|
+
compilerOptions.skipLibCheck = true;
|
|
473
|
+
compilerOptions.checkJs = false;
|
|
474
|
+
compilerOptions.target ??= ts.ScriptTarget.ESNext;
|
|
475
|
+
ensureModuleResolution(ts, compilerOptions);
|
|
476
|
+
const baseVueOptions = parsedVue?.vueOptions ?? getDefaultCompilerOptions();
|
|
477
|
+
const { plugins: rawPlugins, ...rawOptions } = internalOptions?.vueCompilerOptions ?? {};
|
|
478
|
+
let plugins = baseVueOptions.plugins;
|
|
479
|
+
if (rawPlugins !== void 0) {
|
|
480
|
+
const resolver = new CompilerOptionsResolver(ts, configHost.readFile);
|
|
481
|
+
resolver.addConfig({ plugins: rawPlugins }, normalizePath(configService.cwd));
|
|
482
|
+
plugins = resolver.plugins;
|
|
483
|
+
}
|
|
484
|
+
const vueCompilerOptions = {
|
|
485
|
+
...baseVueOptions,
|
|
486
|
+
lib: "wevu",
|
|
487
|
+
...rawOptions
|
|
488
|
+
};
|
|
489
|
+
vueCompilerOptions.plugins = resolveInternalVolarPlugins(plugins, vueCompilerOptions.lib);
|
|
490
|
+
const rewriteWevuComponentType = shouldRewriteWevuComponentType(vueCompilerOptions.lib);
|
|
491
|
+
const rootNames = Array.from(/* @__PURE__ */ new Set([...(parsedTs?.fileNames ?? []).map((file) => path.isAbsolute(file) ? file : path.resolve(configService.cwd, file)), ...vueEntries.map((entry) => entry.input)])).map(normalizePath);
|
|
492
|
+
const host = ts.createCompilerHost(compilerOptions);
|
|
493
|
+
const program = proxyCreateProgram(ts, ts.createProgram, (tsInstance, options) => {
|
|
494
|
+
return { languagePlugins: [createVueLanguagePlugin(tsInstance, options.options, vueCompilerOptions, (id) => id)] };
|
|
495
|
+
})({
|
|
496
|
+
host,
|
|
497
|
+
rootNames,
|
|
498
|
+
options: compilerOptions,
|
|
499
|
+
projectReferences: parsedTs?.projectReferences
|
|
500
|
+
});
|
|
501
|
+
if (onWatchFile) {
|
|
502
|
+
if (tsconfigPath) onWatchFile(tsconfigPath);
|
|
503
|
+
for (const source of program.getSourceFiles()) if (!program.isSourceFileDefaultLibrary(source)) onWatchFile(source.fileName);
|
|
504
|
+
}
|
|
505
|
+
await waitForBuildTasks(vueEntries.map(async (entry) => {
|
|
506
|
+
const sourceFile = resolveVueSourceFile(program, entry.input);
|
|
507
|
+
if (!sourceFile) throw new Error(`[lib] internal 方案生成 Vue SFC dts 失败,未找到源文件:${entry.input}`);
|
|
508
|
+
const outputs = [];
|
|
509
|
+
const emitResult = program.emit(sourceFile, (filePath, content) => {
|
|
510
|
+
outputs.push({
|
|
511
|
+
path: filePath,
|
|
512
|
+
content
|
|
513
|
+
});
|
|
514
|
+
}, void 0, true);
|
|
515
|
+
if (emitResult.emitSkipped && emitResult.diagnostics.length > 0) {
|
|
516
|
+
const hostForDiagnostics = ts.createCompilerHost(compilerOptions);
|
|
517
|
+
throw new Error(ts.formatDiagnosticsWithColorAndContext(emitResult.diagnostics, hostForDiagnostics));
|
|
518
|
+
}
|
|
519
|
+
const dtsOutput = outputs.find((output) => isDtsOutputFile(output.path));
|
|
520
|
+
if (!dtsOutput) throw new Error(`[lib] internal 方案生成 Vue SFC dts 失败,未找到输出:${entry.input}`);
|
|
521
|
+
const mapOutput = outputs.find((output) => isDtsMapOutputFile(output.path));
|
|
522
|
+
const outputPath = path.resolve(configService.outDir, `${entry.outputBase}.d.ts`);
|
|
523
|
+
await fs.ensureDir(path.dirname(outputPath));
|
|
524
|
+
let content = dtsOutput.content;
|
|
525
|
+
if (rewriteWevuComponentType) content = rewriteVueComponentTypeToWevu(content);
|
|
526
|
+
if (mapOutput) {
|
|
527
|
+
const mapPath = path.resolve(configService.outDir, `${entry.outputBase}.d.ts.map`);
|
|
528
|
+
await fs.writeFile(mapPath, mapOutput.content);
|
|
529
|
+
content = replaceSourceMappingUrl(content, path.basename(mapPath));
|
|
530
|
+
}
|
|
531
|
+
await fs.writeFile(outputPath, content);
|
|
532
|
+
}));
|
|
533
|
+
}
|
|
534
|
+
//#endregion
|
|
535
|
+
//#region src/runtime/libDts.ts
|
|
536
|
+
async function generateLibDts(configService, onWatchFile) {
|
|
537
|
+
const libConfig = configService.weappLibConfig;
|
|
538
|
+
if (!libConfig) return;
|
|
539
|
+
if (!libConfig.enabled) return;
|
|
540
|
+
const dtsOptions = libConfig.dts;
|
|
541
|
+
if (dtsOptions?.enabled === false) return;
|
|
542
|
+
const entries = await resolveWeappLibEntries(configService, libConfig);
|
|
543
|
+
if (entries.length === 0) return;
|
|
544
|
+
const vueEntries = entries.filter((entry) => entry.input.endsWith(".vue"));
|
|
545
|
+
const tsEntries = entries.filter((entry) => !entry.input.endsWith(".vue") && isBundledDtsEntry(entry.input));
|
|
546
|
+
const input = {};
|
|
547
|
+
for (const entry of tsEntries) input[entry.outputBase] = resolveRealpath(entry.input);
|
|
548
|
+
if (Object.keys(input).length > 0) {
|
|
549
|
+
const tsconfigPath = path.resolve(configService.cwd, "tsconfig.json");
|
|
550
|
+
const hasTsconfig = await fs.pathExists(tsconfigPath);
|
|
551
|
+
const userRolldownOptions = dtsOptions?.rolldown ?? {};
|
|
552
|
+
const hasUserTsconfig = hasOwn(userRolldownOptions, "tsconfig");
|
|
553
|
+
const hasUserBuild = hasOwn(userRolldownOptions, "build");
|
|
554
|
+
const userTsconfig = userRolldownOptions.tsconfig;
|
|
555
|
+
const resolvedTsconfig = hasUserTsconfig ? typeof userTsconfig === "string" || userTsconfig === false ? userTsconfig : hasTsconfig ? tsconfigPath : false : hasTsconfig ? tsconfigPath : false;
|
|
556
|
+
const canonicalTsconfig = typeof resolvedTsconfig === "string" ? resolveRealpath(path.resolve(configService.cwd, resolvedTsconfig)) : resolvedTsconfig;
|
|
557
|
+
const shouldUseBuildMode = !hasUserBuild && await tsconfigHasProjectReferences(canonicalTsconfig);
|
|
558
|
+
const compilerOptions = {
|
|
559
|
+
allowImportingTsExtensions: true,
|
|
560
|
+
allowJs: true,
|
|
561
|
+
...userRolldownOptions.compilerOptions
|
|
562
|
+
};
|
|
563
|
+
const { build } = await loadHostRolldownBuild();
|
|
564
|
+
if (typeof canonicalTsconfig === "string") onWatchFile?.(canonicalTsconfig);
|
|
565
|
+
await build({
|
|
566
|
+
input,
|
|
567
|
+
plugins: [dts({
|
|
568
|
+
...userRolldownOptions,
|
|
569
|
+
newContext: true,
|
|
570
|
+
tsconfig: canonicalTsconfig,
|
|
571
|
+
build: shouldUseBuildMode ? true : userRolldownOptions.build,
|
|
572
|
+
compilerOptions,
|
|
573
|
+
cwd: resolveRealpath(configService.cwd),
|
|
574
|
+
emitDtsOnly: true,
|
|
575
|
+
vue: false
|
|
576
|
+
}), {
|
|
577
|
+
name: "weapp-vite:lib-dts-inputs",
|
|
578
|
+
buildEnd() {
|
|
579
|
+
for (const id of this.getModuleIds()) if (path.isAbsolute(id)) onWatchFile?.(id);
|
|
580
|
+
}
|
|
581
|
+
}],
|
|
582
|
+
output: {
|
|
583
|
+
dir: configService.outDir,
|
|
584
|
+
entryFileNames: "[name].d.ts"
|
|
585
|
+
},
|
|
586
|
+
write: true
|
|
587
|
+
});
|
|
588
|
+
await normalizeRolldownDtsOutput(tsEntries, configService.outDir);
|
|
589
|
+
}
|
|
590
|
+
if (vueEntries.length > 0) {
|
|
591
|
+
if (dtsOptions?.mode === "vue-tsc") await generateVueDtsWithVueTsc(configService, libConfig, vueEntries, dtsOptions);
|
|
592
|
+
else await generateVueDtsWithInternal(configService, vueEntries, dtsOptions, onWatchFile);
|
|
593
|
+
}
|
|
594
|
+
await waitForBuildTasks(entries.map((entry) => ensureStub(entry, configService.outDir)));
|
|
595
|
+
if (vueEntries.length > 0) {
|
|
596
|
+
if (shouldRewriteWevuComponentType(dtsOptions?.mode === "vue-tsc" ? getVueCompilerLibOrUndefined(dtsOptions?.vueTsc?.vueCompilerOptions?.lib) : getVueCompilerLibOrUndefined(dtsOptions?.internal?.vueCompilerOptions?.lib))) await waitForBuildTasks(vueEntries.map(async (entry) => {
|
|
597
|
+
const outputPath = path.resolve(configService.outDir, `${entry.outputBase}.d.ts`);
|
|
598
|
+
if (!await fs.pathExists(outputPath)) return;
|
|
599
|
+
const content = await fs.readFile(outputPath, "utf8");
|
|
600
|
+
const normalized = rewriteVueComponentTypeToWevu(content);
|
|
601
|
+
if (normalized !== content) await fs.writeFile(outputPath, normalized);
|
|
602
|
+
}));
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
//#endregion
|
|
606
|
+
//#region src/runtime/libDts/assets.ts
|
|
607
|
+
/** 声明编译器仅写入会话临时目录,最终产物由宿主统一 emit/write。 */
|
|
608
|
+
async function prepareLibDtsAssets(service, onWatchFile) {
|
|
609
|
+
const temporaryRoot = await mkdtemp(path.join(os.tmpdir(), "weapp-vite-lib-assets-"));
|
|
610
|
+
const assets = [];
|
|
611
|
+
async function collect(directory) {
|
|
612
|
+
for (const entry of await readdir(directory, { withFileTypes: true })) {
|
|
613
|
+
const file = path.join(directory, entry.name);
|
|
614
|
+
if (entry.isDirectory()) await collect(file);
|
|
615
|
+
else if (entry.isFile()) assets.push({
|
|
616
|
+
type: "asset",
|
|
617
|
+
fileName: path.relative(temporaryRoot, file),
|
|
618
|
+
source: await readFile(file)
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
try {
|
|
623
|
+
await generateLibDts({
|
|
624
|
+
...service,
|
|
625
|
+
outDir: temporaryRoot
|
|
626
|
+
}, onWatchFile);
|
|
627
|
+
await collect(temporaryRoot);
|
|
628
|
+
return assets;
|
|
629
|
+
} finally {
|
|
630
|
+
await rm(temporaryRoot, {
|
|
631
|
+
recursive: true,
|
|
632
|
+
force: true
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
//#endregion
|
|
637
|
+
export { prepareLibDtsAssets };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { TDesignResolver, UviewPlusResolver, VantResolver, WeuiResolver, WotUiResolver };
|
|
1
|
+
export { a as TDesignResolver, i as UviewPlusResolver, r as VantResolver, n as WeuiResolver, t as WotUiResolver } from "../resolvers-Dod-euqX.mjs";
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { wevuRouter as default };
|
|
1
|
+
export { t as default } from "../wevu-router-Dg1LnBlg.mjs";
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { wevu as default };
|
|
1
|
+
export { t as default } from "../wevu-BQWUU7br.mjs";
|
package/dist/auto-routes.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { V as getRouteRuntimeGlobalKeys } from "./createCompilerContextInstance-aYwi8wQt.mjs";
|
|
2
|
+
import { t as getCompilerContext } from "./getInstance-Dt9IQDKr.mjs";
|
|
2
3
|
//#region src/auto-routes.ts
|
|
3
4
|
const ROUTE_RUNTIME_OVERRIDE_KEY = Symbol.for("weapp-vite.route-runtime");
|
|
4
5
|
function createGetter(resolver) {
|