weapp-vite 7.4.0 → 7.5.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 +51 -1
- package/bin/bootstrap.js +14 -1
- package/dist/adapters-CcHrsYaj.mjs +1 -0
- package/dist/analyze-ZJUvEdaY.mjs +248 -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-BD7VqLCl.d.mts +178 -0
- package/dist/chunkStrategy-DRA5WpB-.mjs +1436 -0
- package/dist/cli-acceptance.d.mts +1 -0
- package/dist/cli-acceptance.mjs +21 -0
- package/dist/cli.mjs +1420 -1554
- package/dist/compatibility.mjs +1 -2
- package/dist/{config-Dbvj5yK7.d.mts → config-V0L-IAJf.d.mts} +87 -30
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +1 -1
- package/dist/{constants-WOsG3Eqd.mjs → constants-DEZdcsMn.mjs} +1 -1
- package/dist/{createContext-UOEgeYnA.mjs → createCompilerContextInstance-DJH_P_nZ.mjs} +31278 -32148
- package/dist/createContext-BqYzHhY9.mjs +12 -0
- package/dist/dashboard/analyze.d.mts +48 -0
- package/dist/dashboard/analyze.mjs +1 -0
- package/dist/dashboard/vite.d.mts +1 -1
- package/dist/dashboard-DvqF3Key.mjs +1842 -0
- package/dist/dashboard.d.mts +3 -2
- package/dist/dashboard.mjs +1 -2
- package/dist/dashboardViteBridge-Dy3nAD4m.mjs +299 -0
- package/dist/dev-fR5GiJRO.mjs +63 -0
- package/dist/devProvider-BGBkw28J.mjs +1050 -0
- package/dist/docs/README.md +51 -1
- 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 +94 -1
- package/dist/docs/testing.md +29 -2
- package/dist/docs/troubleshooting.md +8 -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 +19 -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 +59 -0
- package/dist/doctor.d.mts +144 -0
- package/dist/doctor.mjs +848 -0
- package/dist/eslint.mjs +1 -2
- package/dist/file-DRb4eWqw.mjs +1 -0
- package/dist/{file-giE9UMZa.mjs → file-sC3jD7Fh.mjs} +15 -9
- package/dist/files-BqxFIPRp.mjs +45 -0
- package/dist/getInstance-DiGSzBNI.mjs +28 -0
- package/dist/getInstance-SiE6WZRh.mjs +1 -0
- package/dist/index-C9HjUX5c.d.mts +741 -0
- package/dist/index.d.mts +10 -8
- package/dist/index.mjs +3 -2
- package/dist/json.d.mts +1 -1
- package/dist/json.mjs +1 -2
- package/dist/lifecycle-BROTlwSL.mjs +320 -0
- package/dist/loadConfig-C3BQhz7F.mjs +59 -0
- package/dist/loadConfig-VGtBF4qm.mjs +1 -0
- package/dist/logger-DGn5iEVN.mjs +1 -0
- package/dist/{mcp-BG6TliEg.mjs → mcp-Cj8Maqo6.mjs} +16 -7
- package/dist/mcp-D3Yh24Cj.mjs +529 -0
- package/dist/mcp.d.mts +6 -3
- package/dist/mcp.mjs +1 -2
- package/dist/package-7swhyLmf.mjs +91 -0
- package/dist/path-doV773b7.mjs +103 -0
- package/dist/{platform-DTWs5QRi.mjs → platform-CnkySBKz.mjs} +1 -1
- package/dist/processCleanup-B6KA30Zc.mjs +77 -0
- package/dist/protocol-vg8HGJ4n.mjs +138 -0
- package/dist/{resolvers-icNxkpcy.mjs → resolvers-Dod-euqX.mjs} +4 -1
- package/dist/resolvers.mjs +1 -2
- package/dist/runtime.mjs +1 -2
- package/dist/session-PskhD-nZ.mjs +390 -0
- package/dist/test.d.mts +1 -0
- package/dist/test.mjs +201 -44
- package/dist/types.d.mts +2 -2
- package/dist/{upload-D0RcEWrq.mjs → upload-D4msblBf.mjs} +174 -15
- package/dist/upload-worker.mjs +136 -3
- package/dist/utils-CJSCgEj6.mjs +1094 -0
- package/dist/vite.d.mts +9 -0
- package/dist/vite.mjs +270 -0
- package/dist/volar.d.mts +2 -2
- package/dist/web-apis.mjs +1 -2
- package/package.json +67 -41
- 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
package/dist/eslint.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { createMiniProgramRuntimeConfig, miniProgramRuntimeApiCatalog, miniProgramRuntimePlugin, miniProgramRuntimeRecommended, wevuCompatibilityPlugin, wevuCompatibilityRecommended };
|
|
1
|
+
export { createMiniProgramRuntimeConfig, miniProgramRuntimeApiCatalog, miniProgramRuntimePlugin, miniProgramRuntimeRecommended, wevuCompatibilityPlugin, wevuCompatibilityRecommended } from "@weapp-vite/eslint";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as extractConfigFromVue } from "./file-sC3jD7Fh.mjs";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as supportedCssLangs, i as scriptExtensions, l as getSourceStyleExtensions, n as configExtensions, o as templateExtensions, p as isSourceTemplateExtension, s as vueExtensions, u as getSourceTemplateExtensions } from "./constants-
|
|
1
|
+
import { a as supportedCssLangs, i as scriptExtensions, l as getSourceStyleExtensions, n as configExtensions, o as templateExtensions, p as isSourceTemplateExtension, s as vueExtensions, u as getSourceTemplateExtensions } from "./constants-DEZdcsMn.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
+
import process from "node:process";
|
|
3
4
|
import path from "pathe";
|
|
4
5
|
import { fs } from "@weapp-core/shared/fs";
|
|
5
|
-
import process from "node:process";
|
|
6
6
|
import { recursive } from "merge";
|
|
7
7
|
import { parse } from "vue/compiler-sfc";
|
|
8
8
|
//#region src/utils/file/autoRoutes.ts
|
|
@@ -52,10 +52,9 @@ function resolveAutoRoutesMacroImportPath() {
|
|
|
52
52
|
for (const candidate of fallbackCandidates) if (fs.existsSync(candidate)) return candidate;
|
|
53
53
|
throw new Error("无法解析 auto-routes 模块路径。");
|
|
54
54
|
}
|
|
55
|
-
async function resolveAutoRoutesInlineSnapshot() {
|
|
55
|
+
async function resolveAutoRoutesInlineSnapshot(context) {
|
|
56
56
|
try {
|
|
57
|
-
const
|
|
58
|
-
const compilerContext = getCompilerContext();
|
|
57
|
+
const compilerContext = context ?? (await import("./getInstance-SiE6WZRh.mjs")).getCompilerContext();
|
|
59
58
|
const service = compilerContext.autoRoutesService;
|
|
60
59
|
const reference = service?.getReference?.();
|
|
61
60
|
if (!compilerContext.runtimeState.autoRoutes.loadingAppConfig) await service?.ensureFresh?.();
|
|
@@ -162,6 +161,7 @@ async function touch(filename) {
|
|
|
162
161
|
//#endregion
|
|
163
162
|
//#region src/utils/file/vueConfig.ts
|
|
164
163
|
const vueConfigCache = /* @__PURE__ */ new Map();
|
|
164
|
+
const contextConfigCaches = /* @__PURE__ */ new WeakMap();
|
|
165
165
|
const configMtimeInFlight = /* @__PURE__ */ new Map();
|
|
166
166
|
const NODE_MODULES_RE = /[\\/]node_modules[\\/]/;
|
|
167
167
|
const JSON_MACRO_HINT_RE = /\bdefine(?:App|Page|Component|Sitemap|Theme)Json\s*\(/;
|
|
@@ -193,8 +193,13 @@ async function isVueConfigCacheValid(vueFilePath, cache) {
|
|
|
193
193
|
*/
|
|
194
194
|
async function extractConfigFromVue(vueFilePath, options) {
|
|
195
195
|
try {
|
|
196
|
-
const
|
|
197
|
-
|
|
196
|
+
const context = options?.compilerContext;
|
|
197
|
+
const cache = context ? contextConfigCaches.get(context) ?? /* @__PURE__ */ new Map() : vueConfigCache;
|
|
198
|
+
if (context) contextConfigCaches.set(context, cache);
|
|
199
|
+
const cached = options?.force ? void 0 : cache.get(vueFilePath);
|
|
200
|
+
let autoRoutesInline;
|
|
201
|
+
if (cached?.autoRoutesSignature !== void 0) autoRoutesInline = await resolveAutoRoutesInlineSnapshot(context);
|
|
202
|
+
if (cached && (cached.autoRoutesSignature === void 0 || cached.autoRoutesSignature === JSON.stringify(autoRoutesInline)) && await isVueConfigCacheValid(vueFilePath, cached)) return cached.config;
|
|
198
203
|
const content = options?.source ?? (options?.readSource ? await options.readSource() : await fs.readFile(vueFilePath, "utf-8"));
|
|
199
204
|
if (content === void 0) return;
|
|
200
205
|
const { descriptor, errors } = parse(content, { filename: vueFilePath });
|
|
@@ -216,7 +221,7 @@ async function extractConfigFromVue(vueFilePath, options) {
|
|
|
216
221
|
const { extractJsonMacroFromScriptSetup } = await import("wevu/compiler");
|
|
217
222
|
try {
|
|
218
223
|
const preambleContent = descriptor.script?.content;
|
|
219
|
-
|
|
224
|
+
autoRoutesInline = hasAutoRoutesMacroImport(setupContent) || preambleContent !== void 0 && hasAutoRoutesMacroImport(preambleContent) ? autoRoutesInline ?? await resolveAutoRoutesInlineSnapshot(options?.compilerContext) : void 0;
|
|
220
225
|
const macroEvalPreamble = preambleContent && autoRoutesInline ? inlineAutoRoutesImports(preambleContent, autoRoutesInline) : preambleContent;
|
|
221
226
|
const extracted = await extractJsonMacroFromScriptSetup(autoRoutesInline ? inlineAutoRoutesImports(setupContent, autoRoutesInline) : setupContent, vueFilePath, descriptor.scriptSetup?.lang, { preambleContent: macroEvalPreamble });
|
|
222
227
|
if (extracted.dependencies?.length) macroDependencies.push(...extracted.dependencies);
|
|
@@ -233,8 +238,9 @@ async function extractConfigFromVue(vueFilePath, options) {
|
|
|
233
238
|
}));
|
|
234
239
|
const fileMtimeMs = await getMtimeCached(vueFilePath);
|
|
235
240
|
const hasConfig = Object.keys(mergedConfig).length > 0;
|
|
236
|
-
|
|
241
|
+
cache.set(vueFilePath, {
|
|
237
242
|
config: hasConfig ? mergedConfig : void 0,
|
|
243
|
+
autoRoutesSignature: autoRoutesInline && JSON.stringify(autoRoutesInline),
|
|
238
244
|
fileMtimeMs,
|
|
239
245
|
dependencies: normalizedDependencies,
|
|
240
246
|
dependencyMtimeMs
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { readFile, readdir } from "node:fs/promises";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
//#region src/doctor/files.ts
|
|
5
|
+
const excluded = /* @__PURE__ */ new Set([
|
|
6
|
+
"node_modules",
|
|
7
|
+
".git",
|
|
8
|
+
".weapp-vite",
|
|
9
|
+
".codex-tmp",
|
|
10
|
+
"dist",
|
|
11
|
+
"coverage"
|
|
12
|
+
]);
|
|
13
|
+
/** 不跟随符号链接;快照只包含所选目录内的普通文件。 */
|
|
14
|
+
async function readDoctorFiles(root, source = false) {
|
|
15
|
+
const result = [];
|
|
16
|
+
async function visit(directory) {
|
|
17
|
+
for (const entry of await readdir(directory, { withFileTypes: true })) {
|
|
18
|
+
if (entry.isSymbolicLink()) throw new Error("扫描范围含符号链接,无法证明覆盖完整");
|
|
19
|
+
const absolute = path.join(directory, entry.name);
|
|
20
|
+
if (entry.isDirectory()) {
|
|
21
|
+
if (!source || !excluded.has(entry.name)) await visit(absolute);
|
|
22
|
+
} else if (entry.isFile()) {
|
|
23
|
+
const bytes = await readFile(absolute);
|
|
24
|
+
result.push({
|
|
25
|
+
path: path.relative(root, absolute).split(path.sep).join("/"),
|
|
26
|
+
size: bytes.length,
|
|
27
|
+
sha256: createHash("sha256").update(bytes).digest("hex"),
|
|
28
|
+
text: /\.(?:json|[cm]?[jt]sx?|vue|wxml|axml|swan|ttml|jxml|wxss|acss|css|wxs|sjs)$/.test(entry.name) ? bytes.toString("utf8") : void 0
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
await visit(root);
|
|
34
|
+
return result.sort((a, b) => a.path.localeCompare(b.path));
|
|
35
|
+
}
|
|
36
|
+
function objectValue(value) {
|
|
37
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
38
|
+
}
|
|
39
|
+
function parseObject(text) {
|
|
40
|
+
const value = text === void 0 ? void 0 : objectValue(JSON.parse(text));
|
|
41
|
+
if (!value) throw new Error("需要 JSON 对象");
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { parseObject as n, readDoctorFiles as r, objectValue as t };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { t as createCompilerContextInstance } from "./createCompilerContextInstance-DJH_P_nZ.mjs";
|
|
2
|
+
//#region src/context/getInstance.ts
|
|
3
|
+
const compilerContextMap = /* @__PURE__ */ new Map();
|
|
4
|
+
const DEFAULT_KEY = "default";
|
|
5
|
+
let activeCompilerContextKey = DEFAULT_KEY;
|
|
6
|
+
function setActiveCompilerContextKey(key) {
|
|
7
|
+
activeCompilerContextKey = key;
|
|
8
|
+
}
|
|
9
|
+
function getCompilerContext(key = activeCompilerContextKey) {
|
|
10
|
+
let ctx = compilerContextMap.get(key);
|
|
11
|
+
if (!ctx) {
|
|
12
|
+
ctx = createCompilerContextInstance();
|
|
13
|
+
compilerContextMap.set(key, ctx);
|
|
14
|
+
setActiveCompilerContextKey(key);
|
|
15
|
+
}
|
|
16
|
+
return ctx;
|
|
17
|
+
}
|
|
18
|
+
function resetCompilerContext(key) {
|
|
19
|
+
if (key) {
|
|
20
|
+
compilerContextMap.delete(key);
|
|
21
|
+
if (activeCompilerContextKey === key) activeCompilerContextKey = DEFAULT_KEY;
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
compilerContextMap.clear();
|
|
25
|
+
activeCompilerContextKey = DEFAULT_KEY;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { resetCompilerContext as n, setActiveCompilerContextKey as r, getCompilerContext as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as getCompilerContext } from "./getInstance-DiGSzBNI.mjs";
|