weapp-vite 6.7.3 → 6.7.5
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 +1 -0
- package/dist/auto-import-components/resolvers.mjs +1 -1
- package/dist/auto-routes.d.ts +10 -2
- package/dist/auto-routes.mjs +41 -7
- package/dist/{chunk-LVU2OZUF.mjs → chunk-6YAZCQOZ.mjs} +2 -2
- package/dist/chunk-BGBLJUWD.mjs +41 -0
- package/dist/{chunk-IWKOTXCO.mjs → chunk-KV5GZOAZ.mjs} +1 -1
- package/dist/{chunk-2Q4QRCG5.mjs → chunk-O2IN5LBB.mjs} +1 -1
- package/dist/{chunk-QBSVUTNO.mjs → chunk-QD76G22N.mjs} +2 -2
- package/dist/{chunk-O2O4C4LW.mjs → chunk-RJ6CSAFO.mjs} +1771 -690
- package/dist/{chunk-BEN5LCG4.mjs → chunk-T6RSV6FP.mjs} +2 -2
- package/dist/{chunk-XEK4R57H.mjs → chunk-W3UG2WZQ.mjs} +1 -1
- package/dist/{chunk-3STNMT72.mjs → chunk-XIEFUUA5.mjs} +1 -1
- package/dist/{chunk-O4WHKAL4.mjs → chunk-XQYQD5CM.mjs} +1 -1
- package/dist/{chunk-S2D6SRQW.mjs → chunk-Z53O6PMZ.mjs} +2 -2
- package/dist/cli.mjs +275 -243
- package/dist/{config-D2DJI97q.d.ts → config-BngmcXkt.d.ts} +65 -3
- package/dist/config.d.ts +2 -2
- package/dist/config.mjs +16 -4
- package/dist/{file-5JL4CYT6.mjs → file-VKNW65BI.mjs} +2 -2
- package/dist/{getInstance-KJI2GBVQ.mjs → getInstance-XOXPBWVW.mjs} +5 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +22 -10
- package/dist/json.d.ts +2 -2
- package/dist/json.mjs +2 -2
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.mjs +3 -3
- package/dist/{routes-C9hKJjXs.d.ts → routes-74eLuiqj.d.ts} +1 -0
- package/dist/runtime.mjs +2 -2
- package/dist/types.d.ts +2 -2
- package/dist/types.mjs +2 -2
- package/dist/volar.mjs +1 -1
- package/modules/analyze-dashboard/assets/vue.js +1 -1
- package/package.json +14 -13
|
@@ -14,16 +14,19 @@ import {
|
|
|
14
14
|
templateExtensions,
|
|
15
15
|
touch,
|
|
16
16
|
vueExtensions
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-Z53O6PMZ.mjs";
|
|
18
|
+
import {
|
|
19
|
+
applyWeappViteHostMeta
|
|
20
|
+
} from "./chunk-BGBLJUWD.mjs";
|
|
18
21
|
import {
|
|
19
22
|
configureLogger,
|
|
20
23
|
default as default2
|
|
21
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-XIEFUUA5.mjs";
|
|
22
25
|
import {
|
|
23
26
|
__commonJS,
|
|
24
27
|
__toESM,
|
|
25
28
|
init_esm_shims
|
|
26
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-QD76G22N.mjs";
|
|
27
30
|
|
|
28
31
|
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/debug.js
|
|
29
32
|
var require_debug = __commonJS({
|
|
@@ -2547,7 +2550,7 @@ function extractPropertiesObject(node) {
|
|
|
2547
2550
|
}
|
|
2548
2551
|
return propMap;
|
|
2549
2552
|
}
|
|
2550
|
-
function resolveOptionsObjectExpression(
|
|
2553
|
+
function resolveOptionsObjectExpression(path82, node) {
|
|
2551
2554
|
if (!node) {
|
|
2552
2555
|
return void 0;
|
|
2553
2556
|
}
|
|
@@ -2555,7 +2558,7 @@ function resolveOptionsObjectExpression(path81, node) {
|
|
|
2555
2558
|
return node;
|
|
2556
2559
|
}
|
|
2557
2560
|
if (node.type === "Identifier") {
|
|
2558
|
-
const binding =
|
|
2561
|
+
const binding = path82.scope.getBinding(node.name);
|
|
2559
2562
|
const bindingPath = binding?.path;
|
|
2560
2563
|
if (bindingPath?.isVariableDeclarator()) {
|
|
2561
2564
|
const init = bindingPath.node.init;
|
|
@@ -2566,7 +2569,7 @@ function resolveOptionsObjectExpression(path81, node) {
|
|
|
2566
2569
|
return void 0;
|
|
2567
2570
|
}
|
|
2568
2571
|
if (node.type === "TSAsExpression" || node.type === "TSSatisfiesExpression" || node.type === "TSNonNullExpression") {
|
|
2569
|
-
return resolveOptionsObjectExpression(
|
|
2572
|
+
return resolveOptionsObjectExpression(path82, node.expression);
|
|
2570
2573
|
}
|
|
2571
2574
|
return void 0;
|
|
2572
2575
|
}
|
|
@@ -2590,12 +2593,12 @@ function extractComponentProps(code) {
|
|
|
2590
2593
|
const ast = parse(code, BABEL_TS_MODULE_PARSER_OPTIONS);
|
|
2591
2594
|
let props = /* @__PURE__ */ new Map();
|
|
2592
2595
|
traverse(ast, {
|
|
2593
|
-
CallExpression(
|
|
2596
|
+
CallExpression(path82) {
|
|
2594
2597
|
if (props.size > 0) {
|
|
2595
2598
|
return;
|
|
2596
2599
|
}
|
|
2597
|
-
const [options] =
|
|
2598
|
-
const optionsObject = resolveOptionsObjectExpression(
|
|
2600
|
+
const [options] = path82.node.arguments;
|
|
2601
|
+
const optionsObject = resolveOptionsObjectExpression(path82, options);
|
|
2599
2602
|
if (!optionsObject) {
|
|
2600
2603
|
return;
|
|
2601
2604
|
}
|
|
@@ -2766,12 +2769,12 @@ function extractComponentPropsFromDts(code) {
|
|
|
2766
2769
|
errorRecovery: true
|
|
2767
2770
|
});
|
|
2768
2771
|
traverse(ast, {
|
|
2769
|
-
TSInterfaceDeclaration(
|
|
2772
|
+
TSInterfaceDeclaration(path82) {
|
|
2770
2773
|
if (props.size > 0) {
|
|
2771
|
-
|
|
2774
|
+
path82.stop();
|
|
2772
2775
|
return;
|
|
2773
2776
|
}
|
|
2774
|
-
for (const member of
|
|
2777
|
+
for (const member of path82.node.body.body) {
|
|
2775
2778
|
if (member.type !== "TSPropertySignature") {
|
|
2776
2779
|
continue;
|
|
2777
2780
|
}
|
|
@@ -2782,22 +2785,22 @@ function extractComponentPropsFromDts(code) {
|
|
|
2782
2785
|
const typeNode = unwrapTypeAnnotation(member.typeAnnotation);
|
|
2783
2786
|
if (typeNode?.type === "TSTypeLiteral") {
|
|
2784
2787
|
props = extractFromPropertiesTypeLiteral(typeNode);
|
|
2785
|
-
|
|
2788
|
+
path82.stop();
|
|
2786
2789
|
return;
|
|
2787
2790
|
}
|
|
2788
2791
|
}
|
|
2789
|
-
const extracted = extractFromPropsInterfaceMembers(
|
|
2792
|
+
const extracted = extractFromPropsInterfaceMembers(path82.node);
|
|
2790
2793
|
if (extracted.size > 0) {
|
|
2791
2794
|
props = extracted;
|
|
2792
|
-
|
|
2795
|
+
path82.stop();
|
|
2793
2796
|
}
|
|
2794
2797
|
},
|
|
2795
|
-
ClassDeclaration(
|
|
2798
|
+
ClassDeclaration(path82) {
|
|
2796
2799
|
if (props.size > 0) {
|
|
2797
|
-
|
|
2800
|
+
path82.stop();
|
|
2798
2801
|
return;
|
|
2799
2802
|
}
|
|
2800
|
-
for (const member of
|
|
2803
|
+
for (const member of path82.node.body.body) {
|
|
2801
2804
|
if (member.type !== "ClassProperty" && member.type !== "ClassAccessorProperty") {
|
|
2802
2805
|
continue;
|
|
2803
2806
|
}
|
|
@@ -2808,7 +2811,7 @@ function extractComponentPropsFromDts(code) {
|
|
|
2808
2811
|
const typeNode = unwrapTypeAnnotation(member.typeAnnotation);
|
|
2809
2812
|
if (typeNode?.type === "TSTypeLiteral") {
|
|
2810
2813
|
props = extractFromPropertiesTypeLiteral(typeNode);
|
|
2811
|
-
|
|
2814
|
+
path82.stop();
|
|
2812
2815
|
return;
|
|
2813
2816
|
}
|
|
2814
2817
|
}
|
|
@@ -3018,6 +3021,13 @@ var JSON_TYPE_ALIASES = {
|
|
|
3018
3021
|
Null: "null",
|
|
3019
3022
|
Any: "any"
|
|
3020
3023
|
};
|
|
3024
|
+
function mergeTypeCandidates(candidates) {
|
|
3025
|
+
const merged = candidates.filter((item) => Boolean(item)).flatMap((item) => item.split("|").map((part) => part.trim()).filter(Boolean));
|
|
3026
|
+
if (merged.length === 0) {
|
|
3027
|
+
return void 0;
|
|
3028
|
+
}
|
|
3029
|
+
return Array.from(new Set(merged)).join(" | ");
|
|
3030
|
+
}
|
|
3021
3031
|
function normalizeJsonPropertyType(raw) {
|
|
3022
3032
|
if (typeof raw === "string") {
|
|
3023
3033
|
const key = raw.trim();
|
|
@@ -3028,12 +3038,10 @@ function normalizeJsonPropertyType(raw) {
|
|
|
3028
3038
|
return normalized.length > 0 ? normalized.join(" | ") : void 0;
|
|
3029
3039
|
}
|
|
3030
3040
|
if (raw && typeof raw === "object") {
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
return normalizeJsonPropertyType(raw.optionalTypes);
|
|
3036
|
-
}
|
|
3041
|
+
return mergeTypeCandidates([
|
|
3042
|
+
raw.type !== void 0 ? normalizeJsonPropertyType(raw.type) : void 0,
|
|
3043
|
+
Array.isArray(raw.optionalTypes) ? normalizeJsonPropertyType(raw.optionalTypes) : void 0
|
|
3044
|
+
]);
|
|
3037
3045
|
}
|
|
3038
3046
|
return void 0;
|
|
3039
3047
|
}
|
|
@@ -3049,7 +3057,7 @@ function extractJsonPropMetadata(json) {
|
|
|
3049
3057
|
}
|
|
3050
3058
|
for (const [propName, rawConfig] of Object.entries(properties)) {
|
|
3051
3059
|
const config = rawConfig ?? {};
|
|
3052
|
-
const type = normalizeJsonPropertyType(
|
|
3060
|
+
const type = normalizeJsonPropertyType(rawConfig) ?? "any";
|
|
3053
3061
|
props.set(propName, type);
|
|
3054
3062
|
const description = config.description;
|
|
3055
3063
|
if (typeof description === "string" && description.trim().length > 0) {
|
|
@@ -7155,28 +7163,6 @@ function isCSSRequest(request) {
|
|
|
7155
7163
|
function isRegexp(value) {
|
|
7156
7164
|
return Object.prototype.toString.call(value) === "[object RegExp]";
|
|
7157
7165
|
}
|
|
7158
|
-
function regExpTest(arr, str, options) {
|
|
7159
|
-
if (!Array.isArray(arr)) {
|
|
7160
|
-
throw new TypeError("paramater 'arr' should be an Array of Regexp | String");
|
|
7161
|
-
}
|
|
7162
|
-
for (const item of arr) {
|
|
7163
|
-
if (typeof item === "string") {
|
|
7164
|
-
if (options?.exact) {
|
|
7165
|
-
if (str === item) {
|
|
7166
|
-
return true;
|
|
7167
|
-
}
|
|
7168
|
-
} else if (str.includes(item)) {
|
|
7169
|
-
return true;
|
|
7170
|
-
}
|
|
7171
|
-
} else if (isRegexp(item)) {
|
|
7172
|
-
item.lastIndex = 0;
|
|
7173
|
-
if (item.test(str)) {
|
|
7174
|
-
return true;
|
|
7175
|
-
}
|
|
7176
|
-
}
|
|
7177
|
-
}
|
|
7178
|
-
return false;
|
|
7179
|
-
}
|
|
7180
7166
|
|
|
7181
7167
|
// src/utils/resolvedId.ts
|
|
7182
7168
|
init_esm_shims();
|
|
@@ -8077,6 +8063,8 @@ init_esm_shims();
|
|
|
8077
8063
|
// src/runtime/autoRoutesPlugin/routes/format.ts
|
|
8078
8064
|
init_esm_shims();
|
|
8079
8065
|
var INDENT = " ";
|
|
8066
|
+
var TS_STRING_PLACEHOLDER = "${string}";
|
|
8067
|
+
var TS_PATH_PLACEHOLDER = "${Path}";
|
|
8080
8068
|
function formatTuple(values, baseIndent = "") {
|
|
8081
8069
|
if (values.length === 0) {
|
|
8082
8070
|
return "[]";
|
|
@@ -8099,6 +8087,7 @@ function formatSubPackagesTuple(subPackages, baseIndent = "") {
|
|
|
8099
8087
|
lines.push(`${fieldIndent}readonly root: ${JSON.stringify(pkg.root)};`);
|
|
8100
8088
|
const pages = formatTuple(pkg.pages, fieldIndent);
|
|
8101
8089
|
lines.push(`${fieldIndent}readonly pages: ${pages};`);
|
|
8090
|
+
lines.push(`${fieldIndent}[k: string]: unknown;`);
|
|
8102
8091
|
lines.push(`${objectIndent}}${index < subPackages.length - 1 ? "," : ""}`);
|
|
8103
8092
|
});
|
|
8104
8093
|
lines.push(`${baseIndent}]`);
|
|
@@ -8114,6 +8103,8 @@ function createTypedRouterDefinition(routes) {
|
|
|
8114
8103
|
"// oxlint-disable",
|
|
8115
8104
|
"// ------",
|
|
8116
8105
|
"// \u7531 weapp-vite \u81EA\u52A8\u751F\u6210\uFF0C\u8BF7\u52FF\u7F16\u8F91\u3002",
|
|
8106
|
+
"import 'wevu/router';",
|
|
8107
|
+
"",
|
|
8117
8108
|
"declare module 'weapp-vite/auto-routes' {",
|
|
8118
8109
|
` export type AutoRoutesPages = ${pagesType};`,
|
|
8119
8110
|
` export type AutoRoutesEntries = ${entriesType};`,
|
|
@@ -8124,12 +8115,33 @@ function createTypedRouterDefinition(routes) {
|
|
|
8124
8115
|
" readonly entries: AutoRoutesEntries;",
|
|
8125
8116
|
" readonly subPackages: AutoRoutesSubPackages;",
|
|
8126
8117
|
" }",
|
|
8118
|
+
" export type AutoRouteEntry = AutoRoutesEntries[number];",
|
|
8119
|
+
` export type AutoRoutesRelativeUrl = \`./${TS_STRING_PLACEHOLDER}\` | \`../${TS_STRING_PLACEHOLDER}\`;`,
|
|
8120
|
+
` export type AutoRoutesAbsoluteUrl<Path extends string> = Path | \`/${TS_PATH_PLACEHOLDER}\` | \`${TS_PATH_PLACEHOLDER}?${TS_STRING_PLACEHOLDER}\` | \`/${TS_PATH_PLACEHOLDER}?${TS_STRING_PLACEHOLDER}\`;`,
|
|
8121
|
+
" export type AutoRoutesUrl = AutoRoutesAbsoluteUrl<AutoRouteEntry> | AutoRoutesRelativeUrl;",
|
|
8122
|
+
" export type AutoRouteNavigateOption = {",
|
|
8123
|
+
" readonly url: AutoRoutesUrl;",
|
|
8124
|
+
" } & Record<string, any>;",
|
|
8125
|
+
" export interface AutoRoutesWxRouter {",
|
|
8126
|
+
" switchTab: (option: AutoRouteNavigateOption) => unknown;",
|
|
8127
|
+
" reLaunch: (option: AutoRouteNavigateOption) => unknown;",
|
|
8128
|
+
" redirectTo: (option: AutoRouteNavigateOption) => unknown;",
|
|
8129
|
+
" navigateTo: (option: AutoRouteNavigateOption) => unknown;",
|
|
8130
|
+
" navigateBack: (option?: Record<string, any>) => unknown;",
|
|
8131
|
+
" }",
|
|
8127
8132
|
" export const routes: AutoRoutes;",
|
|
8128
8133
|
" export const pages: AutoRoutesPages;",
|
|
8129
8134
|
" export const entries: AutoRoutesEntries;",
|
|
8130
8135
|
" export const subPackages: AutoRoutesSubPackages;",
|
|
8136
|
+
" export const wxRouter: AutoRoutesWxRouter;",
|
|
8131
8137
|
" export default routes;",
|
|
8132
8138
|
"}",
|
|
8139
|
+
"",
|
|
8140
|
+
"declare module 'wevu/router' {",
|
|
8141
|
+
" interface WevuTypedRouterRouteMap {",
|
|
8142
|
+
" entries: import('weapp-vite/auto-routes').AutoRoutesEntries[number];",
|
|
8143
|
+
" }",
|
|
8144
|
+
"}",
|
|
8133
8145
|
""
|
|
8134
8146
|
].join("\n");
|
|
8135
8147
|
}
|
|
@@ -8291,7 +8303,26 @@ async function scanRoutes(ctx, candidatesMap) {
|
|
|
8291
8303
|
"const pages = routes.pages;",
|
|
8292
8304
|
"const entries = routes.entries;",
|
|
8293
8305
|
"const subPackages = routes.subPackages;",
|
|
8294
|
-
"
|
|
8306
|
+
"const resolveMiniProgramGlobal = () => (globalThis.wx ?? globalThis.tt ?? globalThis.my);",
|
|
8307
|
+
"const callRouteMethod = (methodName, option) => {",
|
|
8308
|
+
" const miniProgramGlobal = resolveMiniProgramGlobal();",
|
|
8309
|
+
" const routeMethod = miniProgramGlobal?.[methodName];",
|
|
8310
|
+
' if (typeof routeMethod !== "function") {',
|
|
8311
|
+
' throw new Error("[weapp-vite] \u5F53\u524D\u8FD0\u884C\u73AF\u5883\u4E0D\u652F\u6301\u8DEF\u7531\u65B9\u6CD5: " + methodName);',
|
|
8312
|
+
" }",
|
|
8313
|
+
" if (option === undefined) {",
|
|
8314
|
+
" return routeMethod.call(miniProgramGlobal);",
|
|
8315
|
+
" }",
|
|
8316
|
+
" return routeMethod.call(miniProgramGlobal, option);",
|
|
8317
|
+
"};",
|
|
8318
|
+
"const wxRouter = {",
|
|
8319
|
+
' switchTab(option) { return callRouteMethod("switchTab", option); },',
|
|
8320
|
+
' reLaunch(option) { return callRouteMethod("reLaunch", option); },',
|
|
8321
|
+
' redirectTo(option) { return callRouteMethod("redirectTo", option); },',
|
|
8322
|
+
' navigateTo(option) { return callRouteMethod("navigateTo", option); },',
|
|
8323
|
+
' navigateBack(option) { return callRouteMethod("navigateBack", option); },',
|
|
8324
|
+
"};",
|
|
8325
|
+
"export { routes, pages, entries, subPackages, wxRouter };",
|
|
8295
8326
|
"export default routes;"
|
|
8296
8327
|
].join("\n");
|
|
8297
8328
|
return {
|
|
@@ -8350,22 +8381,22 @@ function matchesRouteFile(ctx, candidate) {
|
|
|
8350
8381
|
if (!pathWithoutQuery) {
|
|
8351
8382
|
return false;
|
|
8352
8383
|
}
|
|
8353
|
-
const
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
|
|
8357
|
-
const relative3 = toPosixPath(path20.relative(
|
|
8358
|
-
if (!relative3 || relative3.startsWith("..")) {
|
|
8384
|
+
const normalizedSrcRoot = normalizePath(configService.absoluteSrcRoot);
|
|
8385
|
+
const normalizedCandidate = normalizePath(
|
|
8386
|
+
path20.isAbsolute(pathWithoutQuery) ? pathWithoutQuery : path20.resolve(configService.cwd, pathWithoutQuery)
|
|
8387
|
+
);
|
|
8388
|
+
const relative3 = toPosixPath(path20.relative(normalizedSrcRoot, normalizedCandidate));
|
|
8389
|
+
if (!relative3 || relative3.startsWith("..") || path20.isAbsolute(relative3)) {
|
|
8359
8390
|
return false;
|
|
8360
8391
|
}
|
|
8361
8392
|
const isPagesPath = relative3.startsWith("pages/") || relative3.includes("/pages/");
|
|
8362
8393
|
if (!isPagesPath) {
|
|
8363
8394
|
return false;
|
|
8364
8395
|
}
|
|
8365
|
-
if (isConfigFile(
|
|
8396
|
+
if (isConfigFile(normalizedCandidate)) {
|
|
8366
8397
|
return true;
|
|
8367
8398
|
}
|
|
8368
|
-
if (isVueFile(
|
|
8399
|
+
if (isVueFile(normalizedCandidate) || isScriptFile(normalizedCandidate) || isTemplateFile(normalizedCandidate) || isStyleFile(normalizedCandidate)) {
|
|
8369
8400
|
return true;
|
|
8370
8401
|
}
|
|
8371
8402
|
return false;
|
|
@@ -8414,7 +8445,7 @@ async function updateCandidateFromFile(ctx, stateCandidates, filePath, event, ma
|
|
|
8414
8445
|
if (!ctx.configService) {
|
|
8415
8446
|
return false;
|
|
8416
8447
|
}
|
|
8417
|
-
if (event === "rename") {
|
|
8448
|
+
if (event === "rename" || event === "create" || event === "delete") {
|
|
8418
8449
|
markNeedsFullRescan?.();
|
|
8419
8450
|
return true;
|
|
8420
8451
|
}
|
|
@@ -8424,13 +8455,11 @@ async function updateCandidateFromFile(ctx, stateCandidates, filePath, event, ma
|
|
|
8424
8455
|
return true;
|
|
8425
8456
|
}
|
|
8426
8457
|
const absolutePath = path20.isAbsolute(pathWithoutQuery) ? pathWithoutQuery : path20.resolve(ctx.configService.cwd, pathWithoutQuery);
|
|
8427
|
-
|
|
8428
|
-
|
|
8429
|
-
|
|
8430
|
-
|
|
8431
|
-
|
|
8432
|
-
const relativeBase = toPosixPath(path20.relative(ctx.configService.absoluteSrcRoot, base));
|
|
8433
|
-
if (!relativeBase || relativeBase.startsWith("..")) {
|
|
8458
|
+
const normalizedSrcRoot = normalizePath(ctx.configService.absoluteSrcRoot);
|
|
8459
|
+
const normalizedAbsolutePath = normalizePath(absolutePath);
|
|
8460
|
+
const base = removeExtensionDeep5(normalizedAbsolutePath);
|
|
8461
|
+
const relativeBase = toPosixPath(path20.relative(normalizedSrcRoot, base));
|
|
8462
|
+
if (!relativeBase || relativeBase.startsWith("..") || path20.isAbsolute(relativeBase)) {
|
|
8434
8463
|
markNeedsFullRescan?.();
|
|
8435
8464
|
return true;
|
|
8436
8465
|
}
|
|
@@ -8487,7 +8516,26 @@ function createAutoRoutesService(ctx) {
|
|
|
8487
8516
|
"const pages = routes.pages;",
|
|
8488
8517
|
"const entries = routes.entries;",
|
|
8489
8518
|
"const subPackages = routes.subPackages;",
|
|
8490
|
-
"
|
|
8519
|
+
"const resolveMiniProgramGlobal = () => (globalThis.wx ?? globalThis.tt ?? globalThis.my);",
|
|
8520
|
+
"const callRouteMethod = (methodName, option) => {",
|
|
8521
|
+
" const miniProgramGlobal = resolveMiniProgramGlobal();",
|
|
8522
|
+
" const routeMethod = miniProgramGlobal?.[methodName];",
|
|
8523
|
+
' if (typeof routeMethod !== "function") {',
|
|
8524
|
+
' throw new Error("[weapp-vite] \u5F53\u524D\u8FD0\u884C\u73AF\u5883\u4E0D\u652F\u6301\u8DEF\u7531\u65B9\u6CD5: " + methodName);',
|
|
8525
|
+
" }",
|
|
8526
|
+
" if (option === undefined) {",
|
|
8527
|
+
" return routeMethod.call(miniProgramGlobal);",
|
|
8528
|
+
" }",
|
|
8529
|
+
" return routeMethod.call(miniProgramGlobal, option);",
|
|
8530
|
+
"};",
|
|
8531
|
+
"const wxRouter = {",
|
|
8532
|
+
' switchTab(option) { return callRouteMethod("switchTab", option); },',
|
|
8533
|
+
' reLaunch(option) { return callRouteMethod("reLaunch", option); },',
|
|
8534
|
+
' redirectTo(option) { return callRouteMethod("redirectTo", option); },',
|
|
8535
|
+
' navigateTo(option) { return callRouteMethod("navigateTo", option); },',
|
|
8536
|
+
' navigateBack(option) { return callRouteMethod("navigateBack", option); },',
|
|
8537
|
+
"};",
|
|
8538
|
+
"export { routes, pages, entries, subPackages, wxRouter };",
|
|
8491
8539
|
"export default routes;"
|
|
8492
8540
|
].join("\n");
|
|
8493
8541
|
updateWatchTargets(state.watchFiles, /* @__PURE__ */ new Set());
|
|
@@ -14337,17 +14385,17 @@ function withTrailingSlash(input = "", respectQueryAndFragment) {
|
|
|
14337
14385
|
if (hasTrailingSlash(input, true)) {
|
|
14338
14386
|
return input || "/";
|
|
14339
14387
|
}
|
|
14340
|
-
let
|
|
14388
|
+
let path82 = input;
|
|
14341
14389
|
let fragment = "";
|
|
14342
14390
|
const fragmentIndex = input.indexOf("#");
|
|
14343
14391
|
if (fragmentIndex !== -1) {
|
|
14344
|
-
|
|
14392
|
+
path82 = input.slice(0, fragmentIndex);
|
|
14345
14393
|
fragment = input.slice(fragmentIndex);
|
|
14346
|
-
if (!
|
|
14394
|
+
if (!path82) {
|
|
14347
14395
|
return fragment;
|
|
14348
14396
|
}
|
|
14349
14397
|
}
|
|
14350
|
-
const [s0, ...s] =
|
|
14398
|
+
const [s0, ...s] = path82.split("?");
|
|
14351
14399
|
return s0 + "/" + (s.length > 0 ? `?${s.join("?")}` : "") + fragment;
|
|
14352
14400
|
}
|
|
14353
14401
|
function isNonEmptyURL(url) {
|
|
@@ -14375,8 +14423,8 @@ import path22, { dirname } from "path";
|
|
|
14375
14423
|
import v8 from "v8";
|
|
14376
14424
|
import { format, inspect } from "util";
|
|
14377
14425
|
var BUILTIN_MODULES = new Set(builtinModules);
|
|
14378
|
-
function normalizeSlash(
|
|
14379
|
-
return
|
|
14426
|
+
function normalizeSlash(path82) {
|
|
14427
|
+
return path82.replace(/\\/g, "/");
|
|
14380
14428
|
}
|
|
14381
14429
|
var own$1 = {}.hasOwnProperty;
|
|
14382
14430
|
var classRegExp = /^([A-Z][a-z\d]*)+$/;
|
|
@@ -14489,8 +14537,8 @@ codes.ERR_INVALID_PACKAGE_CONFIG = createError(
|
|
|
14489
14537
|
* @param {string} [base]
|
|
14490
14538
|
* @param {string} [message]
|
|
14491
14539
|
*/
|
|
14492
|
-
(
|
|
14493
|
-
return `Invalid package config ${
|
|
14540
|
+
(path82, base, message) => {
|
|
14541
|
+
return `Invalid package config ${path82}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
|
|
14494
14542
|
},
|
|
14495
14543
|
Error
|
|
14496
14544
|
);
|
|
@@ -14522,8 +14570,8 @@ codes.ERR_MODULE_NOT_FOUND = createError(
|
|
|
14522
14570
|
* @param {string} base
|
|
14523
14571
|
* @param {boolean} [exactUrl]
|
|
14524
14572
|
*/
|
|
14525
|
-
(
|
|
14526
|
-
return `Cannot find ${exactUrl ? "module" : "package"} '${
|
|
14573
|
+
(path82, base, exactUrl = false) => {
|
|
14574
|
+
return `Cannot find ${exactUrl ? "module" : "package"} '${path82}' imported from ${base}`;
|
|
14527
14575
|
},
|
|
14528
14576
|
Error
|
|
14529
14577
|
);
|
|
@@ -14574,8 +14622,8 @@ codes.ERR_UNKNOWN_FILE_EXTENSION = createError(
|
|
|
14574
14622
|
* @param {string} extension
|
|
14575
14623
|
* @param {string} path
|
|
14576
14624
|
*/
|
|
14577
|
-
(extension,
|
|
14578
|
-
return `Unknown file extension "${extension}" for ${
|
|
14625
|
+
(extension, path82) => {
|
|
14626
|
+
return `Unknown file extension "${extension}" for ${path82}`;
|
|
14579
14627
|
},
|
|
14580
14628
|
TypeError
|
|
14581
14629
|
);
|
|
@@ -14946,9 +14994,9 @@ Default "index" lookups for the main are deprecated for ES modules.`,
|
|
|
14946
14994
|
);
|
|
14947
14995
|
}
|
|
14948
14996
|
}
|
|
14949
|
-
function tryStatSync(
|
|
14997
|
+
function tryStatSync(path82) {
|
|
14950
14998
|
try {
|
|
14951
|
-
return statSync(
|
|
14999
|
+
return statSync(path82);
|
|
14952
15000
|
} catch {
|
|
14953
15001
|
}
|
|
14954
15002
|
}
|
|
@@ -15867,7 +15915,7 @@ function findUpSync(name, {
|
|
|
15867
15915
|
directory = path23.dirname(directory);
|
|
15868
15916
|
}
|
|
15869
15917
|
}
|
|
15870
|
-
function _resolve2(
|
|
15918
|
+
function _resolve2(path82, options = {}) {
|
|
15871
15919
|
if (options.platform === "auto" || !options.platform)
|
|
15872
15920
|
options.platform = process3.platform === "win32" ? "win32" : "posix";
|
|
15873
15921
|
if (process3.versions.pnp) {
|
|
@@ -15876,11 +15924,11 @@ function _resolve2(path81, options = {}) {
|
|
|
15876
15924
|
paths.push(process3.cwd());
|
|
15877
15925
|
const targetRequire = createRequire5(import.meta.url);
|
|
15878
15926
|
try {
|
|
15879
|
-
return targetRequire.resolve(
|
|
15927
|
+
return targetRequire.resolve(path82, { paths });
|
|
15880
15928
|
} catch {
|
|
15881
15929
|
}
|
|
15882
15930
|
}
|
|
15883
|
-
const modulePath = resolvePathSync(
|
|
15931
|
+
const modulePath = resolvePathSync(path82, {
|
|
15884
15932
|
url: options.paths
|
|
15885
15933
|
});
|
|
15886
15934
|
if (options.platform === "win32")
|
|
@@ -15951,10 +15999,10 @@ var findUp = quansync2({
|
|
|
15951
15999
|
async: findUp$1
|
|
15952
16000
|
});
|
|
15953
16001
|
var loadPackageJSON = quansync2(function* (cwd = process3.cwd()) {
|
|
15954
|
-
const
|
|
15955
|
-
if (!
|
|
16002
|
+
const path82 = yield findUp("package.json", { cwd });
|
|
16003
|
+
if (!path82 || !fs13.existsSync(path82))
|
|
15956
16004
|
return null;
|
|
15957
|
-
return JSON.parse(yield readFile(
|
|
16005
|
+
return JSON.parse(yield readFile(path82));
|
|
15958
16006
|
});
|
|
15959
16007
|
var loadPackageJSONSync = loadPackageJSON.sync;
|
|
15960
16008
|
var isPackageListed = quansync2(function* (name, cwd) {
|
|
@@ -21313,44 +21361,44 @@ var optArgSync = (opt = {}) => optArgT(opt);
|
|
|
21313
21361
|
init_esm_shims();
|
|
21314
21362
|
import { parse as parse4, resolve } from "path";
|
|
21315
21363
|
import { inspect as inspect2 } from "util";
|
|
21316
|
-
var pathArg = (
|
|
21317
|
-
const type = typeof
|
|
21364
|
+
var pathArg = (path82, opt = {}) => {
|
|
21365
|
+
const type = typeof path82;
|
|
21318
21366
|
if (type !== "string") {
|
|
21319
|
-
const ctor =
|
|
21320
|
-
const received = ctor && ctor.name ? `an instance of ${ctor.name}` : type === "object" ? inspect2(
|
|
21367
|
+
const ctor = path82 && type === "object" && path82.constructor;
|
|
21368
|
+
const received = ctor && ctor.name ? `an instance of ${ctor.name}` : type === "object" ? inspect2(path82) : `type ${type} ${path82}`;
|
|
21321
21369
|
const msg = `The "path" argument must be of type string. Received ${received}`;
|
|
21322
21370
|
throw Object.assign(new TypeError(msg), {
|
|
21323
|
-
path:
|
|
21371
|
+
path: path82,
|
|
21324
21372
|
code: "ERR_INVALID_ARG_TYPE"
|
|
21325
21373
|
});
|
|
21326
21374
|
}
|
|
21327
|
-
if (/\0/.test(
|
|
21375
|
+
if (/\0/.test(path82)) {
|
|
21328
21376
|
const msg = "path must be a string without null bytes";
|
|
21329
21377
|
throw Object.assign(new TypeError(msg), {
|
|
21330
|
-
path:
|
|
21378
|
+
path: path82,
|
|
21331
21379
|
code: "ERR_INVALID_ARG_VALUE"
|
|
21332
21380
|
});
|
|
21333
21381
|
}
|
|
21334
|
-
|
|
21335
|
-
const { root } = parse4(
|
|
21336
|
-
if (
|
|
21382
|
+
path82 = resolve(path82);
|
|
21383
|
+
const { root } = parse4(path82);
|
|
21384
|
+
if (path82 === root && opt.preserveRoot !== false) {
|
|
21337
21385
|
const msg = "refusing to remove root directory without preserveRoot:false";
|
|
21338
21386
|
throw Object.assign(new Error(msg), {
|
|
21339
|
-
path:
|
|
21387
|
+
path: path82,
|
|
21340
21388
|
code: "ERR_PRESERVE_ROOT"
|
|
21341
21389
|
});
|
|
21342
21390
|
}
|
|
21343
21391
|
if (process.platform === "win32") {
|
|
21344
21392
|
const badWinChars = /[*|"<>?:]/;
|
|
21345
|
-
const { root: root2 } = parse4(
|
|
21346
|
-
if (badWinChars.test(
|
|
21393
|
+
const { root: root2 } = parse4(path82);
|
|
21394
|
+
if (badWinChars.test(path82.substring(root2.length))) {
|
|
21347
21395
|
throw Object.assign(new Error("Illegal characters in path."), {
|
|
21348
|
-
path:
|
|
21396
|
+
path: path82,
|
|
21349
21397
|
code: "EINVAL"
|
|
21350
21398
|
});
|
|
21351
21399
|
}
|
|
21352
21400
|
}
|
|
21353
|
-
return
|
|
21401
|
+
return path82;
|
|
21354
21402
|
};
|
|
21355
21403
|
var path_arg_default = pathArg;
|
|
21356
21404
|
|
|
@@ -21365,11 +21413,11 @@ init_esm_shims();
|
|
|
21365
21413
|
import { readdirSync as rdSync } from "fs";
|
|
21366
21414
|
import fsPromises2 from "fs/promises";
|
|
21367
21415
|
import { chmodSync, mkdirSync, renameSync, rmdirSync, rmSync, statSync as statSync2, lstatSync, unlinkSync } from "fs";
|
|
21368
|
-
var readdirSync = (
|
|
21416
|
+
var readdirSync = (path82) => rdSync(path82, { withFileTypes: true });
|
|
21369
21417
|
var promises2 = {
|
|
21370
21418
|
chmod: fsPromises2.chmod,
|
|
21371
21419
|
mkdir: fsPromises2.mkdir,
|
|
21372
|
-
readdir: (
|
|
21420
|
+
readdir: (path82) => fsPromises2.readdir(path82, { withFileTypes: true }),
|
|
21373
21421
|
rename: fsPromises2.rename,
|
|
21374
21422
|
rm: fsPromises2.rm,
|
|
21375
21423
|
rmdir: fsPromises2.rmdir,
|
|
@@ -21384,10 +21432,10 @@ import { parse as parse5, resolve as resolve2 } from "path";
|
|
|
21384
21432
|
// ../../node_modules/.pnpm/rimraf@6.1.3/node_modules/rimraf/dist/esm/readdir-or-error.js
|
|
21385
21433
|
init_esm_shims();
|
|
21386
21434
|
var { readdir } = promises2;
|
|
21387
|
-
var readdirOrError = (
|
|
21388
|
-
var readdirOrErrorSync = (
|
|
21435
|
+
var readdirOrError = (path82) => readdir(path82).catch((er) => er);
|
|
21436
|
+
var readdirOrErrorSync = (path82) => {
|
|
21389
21437
|
try {
|
|
21390
|
-
return readdirSync(
|
|
21438
|
+
return readdirSync(path82);
|
|
21391
21439
|
} catch (er) {
|
|
21392
21440
|
return er;
|
|
21393
21441
|
}
|
|
@@ -21423,17 +21471,17 @@ var ignoreENOENTSync = (fn, rethrow) => {
|
|
|
21423
21471
|
|
|
21424
21472
|
// ../../node_modules/.pnpm/rimraf@6.1.3/node_modules/rimraf/dist/esm/rimraf-posix.js
|
|
21425
21473
|
var { lstat, rmdir, unlink } = promises2;
|
|
21426
|
-
var rimrafPosix = async (
|
|
21474
|
+
var rimrafPosix = async (path82, opt) => {
|
|
21427
21475
|
opt?.signal?.throwIfAborted();
|
|
21428
|
-
return await ignoreENOENT(lstat(
|
|
21476
|
+
return await ignoreENOENT(lstat(path82).then((stat5) => rimrafPosixDir(path82, opt, stat5))) ?? true;
|
|
21429
21477
|
};
|
|
21430
|
-
var rimrafPosixSync = (
|
|
21478
|
+
var rimrafPosixSync = (path82, opt) => {
|
|
21431
21479
|
opt?.signal?.throwIfAborted();
|
|
21432
|
-
return ignoreENOENTSync(() => rimrafPosixDirSync(
|
|
21480
|
+
return ignoreENOENTSync(() => rimrafPosixDirSync(path82, opt, lstatSync(path82))) ?? true;
|
|
21433
21481
|
};
|
|
21434
|
-
var rimrafPosixDir = async (
|
|
21482
|
+
var rimrafPosixDir = async (path82, opt, ent) => {
|
|
21435
21483
|
opt?.signal?.throwIfAborted();
|
|
21436
|
-
const entries = ent.isDirectory() ? await readdirOrError(
|
|
21484
|
+
const entries = ent.isDirectory() ? await readdirOrError(path82) : null;
|
|
21437
21485
|
if (!Array.isArray(entries)) {
|
|
21438
21486
|
if (entries) {
|
|
21439
21487
|
if (errorCode(entries) === "ENOENT") {
|
|
@@ -21443,28 +21491,28 @@ var rimrafPosixDir = async (path81, opt, ent) => {
|
|
|
21443
21491
|
throw entries;
|
|
21444
21492
|
}
|
|
21445
21493
|
}
|
|
21446
|
-
if (opt.filter && !await opt.filter(
|
|
21494
|
+
if (opt.filter && !await opt.filter(path82, ent)) {
|
|
21447
21495
|
return false;
|
|
21448
21496
|
}
|
|
21449
|
-
await ignoreENOENT(unlink(
|
|
21497
|
+
await ignoreENOENT(unlink(path82));
|
|
21450
21498
|
return true;
|
|
21451
21499
|
}
|
|
21452
|
-
const removedAll = (await Promise.all(entries.map((ent2) => rimrafPosixDir(resolve2(
|
|
21500
|
+
const removedAll = (await Promise.all(entries.map((ent2) => rimrafPosixDir(resolve2(path82, ent2.name), opt, ent2)))).every((v2) => v2 === true);
|
|
21453
21501
|
if (!removedAll) {
|
|
21454
21502
|
return false;
|
|
21455
21503
|
}
|
|
21456
|
-
if (opt.preserveRoot === false &&
|
|
21504
|
+
if (opt.preserveRoot === false && path82 === parse5(path82).root) {
|
|
21457
21505
|
return false;
|
|
21458
21506
|
}
|
|
21459
|
-
if (opt.filter && !await opt.filter(
|
|
21507
|
+
if (opt.filter && !await opt.filter(path82, ent)) {
|
|
21460
21508
|
return false;
|
|
21461
21509
|
}
|
|
21462
|
-
await ignoreENOENT(rmdir(
|
|
21510
|
+
await ignoreENOENT(rmdir(path82));
|
|
21463
21511
|
return true;
|
|
21464
21512
|
};
|
|
21465
|
-
var rimrafPosixDirSync = (
|
|
21513
|
+
var rimrafPosixDirSync = (path82, opt, ent) => {
|
|
21466
21514
|
opt?.signal?.throwIfAborted();
|
|
21467
|
-
const entries = ent.isDirectory() ? readdirOrErrorSync(
|
|
21515
|
+
const entries = ent.isDirectory() ? readdirOrErrorSync(path82) : null;
|
|
21468
21516
|
if (!Array.isArray(entries)) {
|
|
21469
21517
|
if (entries) {
|
|
21470
21518
|
if (errorCode(entries) === "ENOENT") {
|
|
@@ -21474,27 +21522,27 @@ var rimrafPosixDirSync = (path81, opt, ent) => {
|
|
|
21474
21522
|
throw entries;
|
|
21475
21523
|
}
|
|
21476
21524
|
}
|
|
21477
|
-
if (opt.filter && !opt.filter(
|
|
21525
|
+
if (opt.filter && !opt.filter(path82, ent)) {
|
|
21478
21526
|
return false;
|
|
21479
21527
|
}
|
|
21480
|
-
ignoreENOENTSync(() => unlinkSync(
|
|
21528
|
+
ignoreENOENTSync(() => unlinkSync(path82));
|
|
21481
21529
|
return true;
|
|
21482
21530
|
}
|
|
21483
21531
|
let removedAll = true;
|
|
21484
21532
|
for (const ent2 of entries) {
|
|
21485
|
-
const p = resolve2(
|
|
21533
|
+
const p = resolve2(path82, ent2.name);
|
|
21486
21534
|
removedAll = rimrafPosixDirSync(p, opt, ent2) && removedAll;
|
|
21487
21535
|
}
|
|
21488
|
-
if (opt.preserveRoot === false &&
|
|
21536
|
+
if (opt.preserveRoot === false && path82 === parse5(path82).root) {
|
|
21489
21537
|
return false;
|
|
21490
21538
|
}
|
|
21491
21539
|
if (!removedAll) {
|
|
21492
21540
|
return false;
|
|
21493
21541
|
}
|
|
21494
|
-
if (opt.filter && !opt.filter(
|
|
21542
|
+
if (opt.filter && !opt.filter(path82, ent)) {
|
|
21495
21543
|
return false;
|
|
21496
21544
|
}
|
|
21497
|
-
ignoreENOENTSync(() => rmdirSync(
|
|
21545
|
+
ignoreENOENTSync(() => rmdirSync(path82));
|
|
21498
21546
|
return true;
|
|
21499
21547
|
};
|
|
21500
21548
|
|
|
@@ -21505,28 +21553,28 @@ import { parse as parse8, resolve as resolve5 } from "path";
|
|
|
21505
21553
|
// ../../node_modules/.pnpm/rimraf@6.1.3/node_modules/rimraf/dist/esm/fix-eperm.js
|
|
21506
21554
|
init_esm_shims();
|
|
21507
21555
|
var { chmod } = promises2;
|
|
21508
|
-
var fixEPERM = (fn) => async (
|
|
21556
|
+
var fixEPERM = (fn) => async (path82) => {
|
|
21509
21557
|
try {
|
|
21510
|
-
return void await ignoreENOENT(fn(
|
|
21558
|
+
return void await ignoreENOENT(fn(path82));
|
|
21511
21559
|
} catch (er) {
|
|
21512
21560
|
if (errorCode(er) === "EPERM") {
|
|
21513
|
-
if (!await ignoreENOENT(chmod(
|
|
21561
|
+
if (!await ignoreENOENT(chmod(path82, 438).then(() => true), er)) {
|
|
21514
21562
|
return;
|
|
21515
21563
|
}
|
|
21516
|
-
return void await fn(
|
|
21564
|
+
return void await fn(path82);
|
|
21517
21565
|
}
|
|
21518
21566
|
throw er;
|
|
21519
21567
|
}
|
|
21520
21568
|
};
|
|
21521
|
-
var fixEPERMSync = (fn) => (
|
|
21569
|
+
var fixEPERMSync = (fn) => (path82) => {
|
|
21522
21570
|
try {
|
|
21523
|
-
return void ignoreENOENTSync(() => fn(
|
|
21571
|
+
return void ignoreENOENTSync(() => fn(path82));
|
|
21524
21572
|
} catch (er) {
|
|
21525
21573
|
if (errorCode(er) === "EPERM") {
|
|
21526
|
-
if (!ignoreENOENTSync(() => (chmodSync(
|
|
21574
|
+
if (!ignoreENOENTSync(() => (chmodSync(path82, 438), true), er)) {
|
|
21527
21575
|
return;
|
|
21528
21576
|
}
|
|
21529
|
-
return void fn(
|
|
21577
|
+
return void fn(path82);
|
|
21530
21578
|
}
|
|
21531
21579
|
throw er;
|
|
21532
21580
|
}
|
|
@@ -21540,21 +21588,21 @@ var RATE = 1.2;
|
|
|
21540
21588
|
var MAXRETRIES = 10;
|
|
21541
21589
|
var codes2 = /* @__PURE__ */ new Set(["EMFILE", "ENFILE", "EBUSY"]);
|
|
21542
21590
|
var retryBusy = (fn) => {
|
|
21543
|
-
const method = async (
|
|
21591
|
+
const method = async (path82, opt, backoff = 1, total = 0) => {
|
|
21544
21592
|
const mbo = opt.maxBackoff || MAXBACKOFF;
|
|
21545
21593
|
const rate = opt.backoff || RATE;
|
|
21546
21594
|
const max = opt.maxRetries || MAXRETRIES;
|
|
21547
21595
|
let retries = 0;
|
|
21548
21596
|
while (true) {
|
|
21549
21597
|
try {
|
|
21550
|
-
return await fn(
|
|
21598
|
+
return await fn(path82);
|
|
21551
21599
|
} catch (er) {
|
|
21552
|
-
if (isFsError(er) && er.path ===
|
|
21600
|
+
if (isFsError(er) && er.path === path82 && codes2.has(er.code)) {
|
|
21553
21601
|
backoff = Math.ceil(backoff * rate);
|
|
21554
21602
|
total = backoff + total;
|
|
21555
21603
|
if (total < mbo) {
|
|
21556
21604
|
await setTimeout2(backoff);
|
|
21557
|
-
return method(
|
|
21605
|
+
return method(path82, opt, backoff, total);
|
|
21558
21606
|
}
|
|
21559
21607
|
if (retries < max) {
|
|
21560
21608
|
retries++;
|
|
@@ -21568,14 +21616,14 @@ var retryBusy = (fn) => {
|
|
|
21568
21616
|
return method;
|
|
21569
21617
|
};
|
|
21570
21618
|
var retryBusySync = (fn) => {
|
|
21571
|
-
const method = (
|
|
21619
|
+
const method = (path82, opt) => {
|
|
21572
21620
|
const max = opt.maxRetries || MAXRETRIES;
|
|
21573
21621
|
let retries = 0;
|
|
21574
21622
|
while (true) {
|
|
21575
21623
|
try {
|
|
21576
|
-
return fn(
|
|
21624
|
+
return fn(path82);
|
|
21577
21625
|
} catch (er) {
|
|
21578
|
-
if (isFsError(er) && er.path ===
|
|
21626
|
+
if (isFsError(er) && er.path === path82 && codes2.has(er.code) && retries < max) {
|
|
21579
21627
|
retries++;
|
|
21580
21628
|
continue;
|
|
21581
21629
|
}
|
|
@@ -21595,16 +21643,16 @@ init_esm_shims();
|
|
|
21595
21643
|
import { tmpdir } from "os";
|
|
21596
21644
|
import { parse as parse6, resolve as resolve3 } from "path";
|
|
21597
21645
|
var { stat } = promises2;
|
|
21598
|
-
var isDirSync = (
|
|
21646
|
+
var isDirSync = (path82) => {
|
|
21599
21647
|
try {
|
|
21600
|
-
return statSync2(
|
|
21648
|
+
return statSync2(path82).isDirectory();
|
|
21601
21649
|
} catch {
|
|
21602
21650
|
return false;
|
|
21603
21651
|
}
|
|
21604
21652
|
};
|
|
21605
|
-
var isDir = (
|
|
21606
|
-
var win32DefaultTmp = async (
|
|
21607
|
-
const { root } = parse6(
|
|
21653
|
+
var isDir = (path82) => stat(path82).then((st2) => st2.isDirectory(), () => false);
|
|
21654
|
+
var win32DefaultTmp = async (path82) => {
|
|
21655
|
+
const { root } = parse6(path82);
|
|
21608
21656
|
const tmp = tmpdir();
|
|
21609
21657
|
const { root: tmpRoot } = parse6(tmp);
|
|
21610
21658
|
if (root.toLowerCase() === tmpRoot.toLowerCase()) {
|
|
@@ -21616,8 +21664,8 @@ var win32DefaultTmp = async (path81) => {
|
|
|
21616
21664
|
}
|
|
21617
21665
|
return root;
|
|
21618
21666
|
};
|
|
21619
|
-
var win32DefaultTmpSync = (
|
|
21620
|
-
const { root } = parse6(
|
|
21667
|
+
var win32DefaultTmpSync = (path82) => {
|
|
21668
|
+
const { root } = parse6(path82);
|
|
21621
21669
|
const tmp = tmpdir();
|
|
21622
21670
|
const { root: tmpRoot } = parse6(tmp);
|
|
21623
21671
|
if (root.toLowerCase() === tmpRoot.toLowerCase()) {
|
|
@@ -21636,22 +21684,22 @@ var defaultTmpSync = process.platform === "win32" ? win32DefaultTmpSync : posixD
|
|
|
21636
21684
|
|
|
21637
21685
|
// ../../node_modules/.pnpm/rimraf@6.1.3/node_modules/rimraf/dist/esm/rimraf-move-remove.js
|
|
21638
21686
|
var { lstat: lstat2, rename, unlink: unlink2, rmdir: rmdir2 } = promises2;
|
|
21639
|
-
var uniqueFilename = (
|
|
21687
|
+
var uniqueFilename = (path82) => `.${basename(path82)}.${Math.random()}`;
|
|
21640
21688
|
var unlinkFixEPERM = fixEPERM(unlink2);
|
|
21641
21689
|
var unlinkFixEPERMSync = fixEPERMSync(unlinkSync);
|
|
21642
|
-
var rimrafMoveRemove = async (
|
|
21690
|
+
var rimrafMoveRemove = async (path82, opt) => {
|
|
21643
21691
|
opt?.signal?.throwIfAborted();
|
|
21644
|
-
return await ignoreENOENT(lstat2(
|
|
21692
|
+
return await ignoreENOENT(lstat2(path82).then((stat5) => rimrafMoveRemoveDir(path82, opt, stat5))) ?? true;
|
|
21645
21693
|
};
|
|
21646
|
-
var rimrafMoveRemoveDir = async (
|
|
21694
|
+
var rimrafMoveRemoveDir = async (path82, opt, ent) => {
|
|
21647
21695
|
opt?.signal?.throwIfAborted();
|
|
21648
21696
|
if (!opt.tmp) {
|
|
21649
|
-
return rimrafMoveRemoveDir(
|
|
21697
|
+
return rimrafMoveRemoveDir(path82, { ...opt, tmp: await defaultTmp(path82) }, ent);
|
|
21650
21698
|
}
|
|
21651
|
-
if (
|
|
21699
|
+
if (path82 === opt.tmp && parse7(path82).root !== path82) {
|
|
21652
21700
|
throw new Error("cannot delete temp directory used for deletion");
|
|
21653
21701
|
}
|
|
21654
|
-
const entries = ent.isDirectory() ? await readdirOrError(
|
|
21702
|
+
const entries = ent.isDirectory() ? await readdirOrError(path82) : null;
|
|
21655
21703
|
if (!Array.isArray(entries)) {
|
|
21656
21704
|
if (entries) {
|
|
21657
21705
|
if (errorCode(entries) === "ENOENT") {
|
|
@@ -21661,44 +21709,44 @@ var rimrafMoveRemoveDir = async (path81, opt, ent) => {
|
|
|
21661
21709
|
throw entries;
|
|
21662
21710
|
}
|
|
21663
21711
|
}
|
|
21664
|
-
if (opt.filter && !await opt.filter(
|
|
21712
|
+
if (opt.filter && !await opt.filter(path82, ent)) {
|
|
21665
21713
|
return false;
|
|
21666
21714
|
}
|
|
21667
|
-
await ignoreENOENT(tmpUnlink(
|
|
21715
|
+
await ignoreENOENT(tmpUnlink(path82, opt.tmp, unlinkFixEPERM));
|
|
21668
21716
|
return true;
|
|
21669
21717
|
}
|
|
21670
|
-
const removedAll = (await Promise.all(entries.map((ent2) => rimrafMoveRemoveDir(resolve4(
|
|
21718
|
+
const removedAll = (await Promise.all(entries.map((ent2) => rimrafMoveRemoveDir(resolve4(path82, ent2.name), opt, ent2)))).every((v2) => v2 === true);
|
|
21671
21719
|
if (!removedAll) {
|
|
21672
21720
|
return false;
|
|
21673
21721
|
}
|
|
21674
|
-
if (opt.preserveRoot === false &&
|
|
21722
|
+
if (opt.preserveRoot === false && path82 === parse7(path82).root) {
|
|
21675
21723
|
return false;
|
|
21676
21724
|
}
|
|
21677
|
-
if (opt.filter && !await opt.filter(
|
|
21725
|
+
if (opt.filter && !await opt.filter(path82, ent)) {
|
|
21678
21726
|
return false;
|
|
21679
21727
|
}
|
|
21680
|
-
await ignoreENOENT(tmpUnlink(
|
|
21728
|
+
await ignoreENOENT(tmpUnlink(path82, opt.tmp, rmdir2));
|
|
21681
21729
|
return true;
|
|
21682
21730
|
};
|
|
21683
|
-
var tmpUnlink = async (
|
|
21684
|
-
const tmpFile = resolve4(tmp, uniqueFilename(
|
|
21685
|
-
await rename(
|
|
21731
|
+
var tmpUnlink = async (path82, tmp, rm2) => {
|
|
21732
|
+
const tmpFile = resolve4(tmp, uniqueFilename(path82));
|
|
21733
|
+
await rename(path82, tmpFile);
|
|
21686
21734
|
return await rm2(tmpFile);
|
|
21687
21735
|
};
|
|
21688
|
-
var rimrafMoveRemoveSync = (
|
|
21736
|
+
var rimrafMoveRemoveSync = (path82, opt) => {
|
|
21689
21737
|
opt?.signal?.throwIfAborted();
|
|
21690
|
-
return ignoreENOENTSync(() => rimrafMoveRemoveDirSync(
|
|
21738
|
+
return ignoreENOENTSync(() => rimrafMoveRemoveDirSync(path82, opt, lstatSync(path82))) ?? true;
|
|
21691
21739
|
};
|
|
21692
|
-
var rimrafMoveRemoveDirSync = (
|
|
21740
|
+
var rimrafMoveRemoveDirSync = (path82, opt, ent) => {
|
|
21693
21741
|
opt?.signal?.throwIfAborted();
|
|
21694
21742
|
if (!opt.tmp) {
|
|
21695
|
-
return rimrafMoveRemoveDirSync(
|
|
21743
|
+
return rimrafMoveRemoveDirSync(path82, { ...opt, tmp: defaultTmpSync(path82) }, ent);
|
|
21696
21744
|
}
|
|
21697
21745
|
const tmp = opt.tmp;
|
|
21698
|
-
if (
|
|
21746
|
+
if (path82 === opt.tmp && parse7(path82).root !== path82) {
|
|
21699
21747
|
throw new Error("cannot delete temp directory used for deletion");
|
|
21700
21748
|
}
|
|
21701
|
-
const entries = ent.isDirectory() ? readdirOrErrorSync(
|
|
21749
|
+
const entries = ent.isDirectory() ? readdirOrErrorSync(path82) : null;
|
|
21702
21750
|
if (!Array.isArray(entries)) {
|
|
21703
21751
|
if (entries) {
|
|
21704
21752
|
if (errorCode(entries) === "ENOENT") {
|
|
@@ -21708,32 +21756,32 @@ var rimrafMoveRemoveDirSync = (path81, opt, ent) => {
|
|
|
21708
21756
|
throw entries;
|
|
21709
21757
|
}
|
|
21710
21758
|
}
|
|
21711
|
-
if (opt.filter && !opt.filter(
|
|
21759
|
+
if (opt.filter && !opt.filter(path82, ent)) {
|
|
21712
21760
|
return false;
|
|
21713
21761
|
}
|
|
21714
|
-
ignoreENOENTSync(() => tmpUnlinkSync(
|
|
21762
|
+
ignoreENOENTSync(() => tmpUnlinkSync(path82, tmp, unlinkFixEPERMSync));
|
|
21715
21763
|
return true;
|
|
21716
21764
|
}
|
|
21717
21765
|
let removedAll = true;
|
|
21718
21766
|
for (const ent2 of entries) {
|
|
21719
|
-
const p = resolve4(
|
|
21767
|
+
const p = resolve4(path82, ent2.name);
|
|
21720
21768
|
removedAll = rimrafMoveRemoveDirSync(p, opt, ent2) && removedAll;
|
|
21721
21769
|
}
|
|
21722
21770
|
if (!removedAll) {
|
|
21723
21771
|
return false;
|
|
21724
21772
|
}
|
|
21725
|
-
if (opt.preserveRoot === false &&
|
|
21773
|
+
if (opt.preserveRoot === false && path82 === parse7(path82).root) {
|
|
21726
21774
|
return false;
|
|
21727
21775
|
}
|
|
21728
|
-
if (opt.filter && !opt.filter(
|
|
21776
|
+
if (opt.filter && !opt.filter(path82, ent)) {
|
|
21729
21777
|
return false;
|
|
21730
21778
|
}
|
|
21731
|
-
ignoreENOENTSync(() => tmpUnlinkSync(
|
|
21779
|
+
ignoreENOENTSync(() => tmpUnlinkSync(path82, tmp, rmdirSync));
|
|
21732
21780
|
return true;
|
|
21733
21781
|
};
|
|
21734
|
-
var tmpUnlinkSync = (
|
|
21735
|
-
const tmpFile = resolve4(tmp, uniqueFilename(
|
|
21736
|
-
renameSync(
|
|
21782
|
+
var tmpUnlinkSync = (path82, tmp, rmSync2) => {
|
|
21783
|
+
const tmpFile = resolve4(tmp, uniqueFilename(path82));
|
|
21784
|
+
renameSync(path82, tmpFile);
|
|
21737
21785
|
return rmSync2(tmpFile);
|
|
21738
21786
|
};
|
|
21739
21787
|
|
|
@@ -21743,26 +21791,26 @@ var rimrafWindowsFile = retryBusy(fixEPERM(unlink3));
|
|
|
21743
21791
|
var rimrafWindowsFileSync = retryBusySync(fixEPERMSync(unlinkSync));
|
|
21744
21792
|
var rimrafWindowsDirRetry = retryBusy(fixEPERM(rmdir3));
|
|
21745
21793
|
var rimrafWindowsDirRetrySync = retryBusySync(fixEPERMSync(rmdirSync));
|
|
21746
|
-
var rimrafWindowsDirMoveRemoveFallback = async (
|
|
21794
|
+
var rimrafWindowsDirMoveRemoveFallback = async (path82, { filter: filter2, ...opt }) => {
|
|
21747
21795
|
opt?.signal?.throwIfAborted();
|
|
21748
21796
|
try {
|
|
21749
|
-
await rimrafWindowsDirRetry(
|
|
21797
|
+
await rimrafWindowsDirRetry(path82, opt);
|
|
21750
21798
|
return true;
|
|
21751
21799
|
} catch (er) {
|
|
21752
21800
|
if (errorCode(er) === "ENOTEMPTY") {
|
|
21753
|
-
return rimrafMoveRemove(
|
|
21801
|
+
return rimrafMoveRemove(path82, opt);
|
|
21754
21802
|
}
|
|
21755
21803
|
throw er;
|
|
21756
21804
|
}
|
|
21757
21805
|
};
|
|
21758
|
-
var rimrafWindowsDirMoveRemoveFallbackSync = (
|
|
21806
|
+
var rimrafWindowsDirMoveRemoveFallbackSync = (path82, { filter: filter2, ...opt }) => {
|
|
21759
21807
|
opt?.signal?.throwIfAborted();
|
|
21760
21808
|
try {
|
|
21761
|
-
rimrafWindowsDirRetrySync(
|
|
21809
|
+
rimrafWindowsDirRetrySync(path82, opt);
|
|
21762
21810
|
return true;
|
|
21763
21811
|
} catch (er) {
|
|
21764
21812
|
if (errorCode(er) === "ENOTEMPTY") {
|
|
21765
|
-
return rimrafMoveRemoveSync(
|
|
21813
|
+
return rimrafMoveRemoveSync(path82, opt);
|
|
21766
21814
|
}
|
|
21767
21815
|
throw er;
|
|
21768
21816
|
}
|
|
@@ -21770,17 +21818,17 @@ var rimrafWindowsDirMoveRemoveFallbackSync = (path81, { filter: filter2, ...opt
|
|
|
21770
21818
|
var START = /* @__PURE__ */ Symbol("start");
|
|
21771
21819
|
var CHILD = /* @__PURE__ */ Symbol("child");
|
|
21772
21820
|
var FINISH = /* @__PURE__ */ Symbol("finish");
|
|
21773
|
-
var rimrafWindows = async (
|
|
21821
|
+
var rimrafWindows = async (path82, opt) => {
|
|
21774
21822
|
opt?.signal?.throwIfAborted();
|
|
21775
|
-
return await ignoreENOENT(lstat3(
|
|
21823
|
+
return await ignoreENOENT(lstat3(path82).then((stat5) => rimrafWindowsDir(path82, opt, stat5, START))) ?? true;
|
|
21776
21824
|
};
|
|
21777
|
-
var rimrafWindowsSync = (
|
|
21825
|
+
var rimrafWindowsSync = (path82, opt) => {
|
|
21778
21826
|
opt?.signal?.throwIfAborted();
|
|
21779
|
-
return ignoreENOENTSync(() => rimrafWindowsDirSync(
|
|
21827
|
+
return ignoreENOENTSync(() => rimrafWindowsDirSync(path82, opt, lstatSync(path82), START)) ?? true;
|
|
21780
21828
|
};
|
|
21781
|
-
var rimrafWindowsDir = async (
|
|
21829
|
+
var rimrafWindowsDir = async (path82, opt, ent, state = START) => {
|
|
21782
21830
|
opt?.signal?.throwIfAborted();
|
|
21783
|
-
const entries = ent.isDirectory() ? await readdirOrError(
|
|
21831
|
+
const entries = ent.isDirectory() ? await readdirOrError(path82) : null;
|
|
21784
21832
|
if (!Array.isArray(entries)) {
|
|
21785
21833
|
if (entries) {
|
|
21786
21834
|
if (errorCode(entries) === "ENOENT") {
|
|
@@ -21790,32 +21838,32 @@ var rimrafWindowsDir = async (path81, opt, ent, state = START) => {
|
|
|
21790
21838
|
throw entries;
|
|
21791
21839
|
}
|
|
21792
21840
|
}
|
|
21793
|
-
if (opt.filter && !await opt.filter(
|
|
21841
|
+
if (opt.filter && !await opt.filter(path82, ent)) {
|
|
21794
21842
|
return false;
|
|
21795
21843
|
}
|
|
21796
|
-
await ignoreENOENT(rimrafWindowsFile(
|
|
21844
|
+
await ignoreENOENT(rimrafWindowsFile(path82, opt));
|
|
21797
21845
|
return true;
|
|
21798
21846
|
}
|
|
21799
21847
|
const s = state === START ? CHILD : state;
|
|
21800
|
-
const removedAll = (await Promise.all(entries.map((ent2) => rimrafWindowsDir(resolve5(
|
|
21848
|
+
const removedAll = (await Promise.all(entries.map((ent2) => rimrafWindowsDir(resolve5(path82, ent2.name), opt, ent2, s)))).every((v2) => v2 === true);
|
|
21801
21849
|
if (state === START) {
|
|
21802
|
-
return rimrafWindowsDir(
|
|
21850
|
+
return rimrafWindowsDir(path82, opt, ent, FINISH);
|
|
21803
21851
|
} else if (state === FINISH) {
|
|
21804
|
-
if (opt.preserveRoot === false &&
|
|
21852
|
+
if (opt.preserveRoot === false && path82 === parse8(path82).root) {
|
|
21805
21853
|
return false;
|
|
21806
21854
|
}
|
|
21807
21855
|
if (!removedAll) {
|
|
21808
21856
|
return false;
|
|
21809
21857
|
}
|
|
21810
|
-
if (opt.filter && !await opt.filter(
|
|
21858
|
+
if (opt.filter && !await opt.filter(path82, ent)) {
|
|
21811
21859
|
return false;
|
|
21812
21860
|
}
|
|
21813
|
-
await ignoreENOENT(rimrafWindowsDirMoveRemoveFallback(
|
|
21861
|
+
await ignoreENOENT(rimrafWindowsDirMoveRemoveFallback(path82, opt));
|
|
21814
21862
|
}
|
|
21815
21863
|
return true;
|
|
21816
21864
|
};
|
|
21817
|
-
var rimrafWindowsDirSync = (
|
|
21818
|
-
const entries = ent.isDirectory() ? readdirOrErrorSync(
|
|
21865
|
+
var rimrafWindowsDirSync = (path82, opt, ent, state = START) => {
|
|
21866
|
+
const entries = ent.isDirectory() ? readdirOrErrorSync(path82) : null;
|
|
21819
21867
|
if (!Array.isArray(entries)) {
|
|
21820
21868
|
if (entries) {
|
|
21821
21869
|
if (errorCode(entries) === "ENOENT") {
|
|
@@ -21825,31 +21873,31 @@ var rimrafWindowsDirSync = (path81, opt, ent, state = START) => {
|
|
|
21825
21873
|
throw entries;
|
|
21826
21874
|
}
|
|
21827
21875
|
}
|
|
21828
|
-
if (opt.filter && !opt.filter(
|
|
21876
|
+
if (opt.filter && !opt.filter(path82, ent)) {
|
|
21829
21877
|
return false;
|
|
21830
21878
|
}
|
|
21831
|
-
ignoreENOENTSync(() => rimrafWindowsFileSync(
|
|
21879
|
+
ignoreENOENTSync(() => rimrafWindowsFileSync(path82, opt));
|
|
21832
21880
|
return true;
|
|
21833
21881
|
}
|
|
21834
21882
|
let removedAll = true;
|
|
21835
21883
|
for (const ent2 of entries) {
|
|
21836
21884
|
const s = state === START ? CHILD : state;
|
|
21837
|
-
const p = resolve5(
|
|
21885
|
+
const p = resolve5(path82, ent2.name);
|
|
21838
21886
|
removedAll = rimrafWindowsDirSync(p, opt, ent2, s) && removedAll;
|
|
21839
21887
|
}
|
|
21840
21888
|
if (state === START) {
|
|
21841
|
-
return rimrafWindowsDirSync(
|
|
21889
|
+
return rimrafWindowsDirSync(path82, opt, ent, FINISH);
|
|
21842
21890
|
} else if (state === FINISH) {
|
|
21843
|
-
if (opt.preserveRoot === false &&
|
|
21891
|
+
if (opt.preserveRoot === false && path82 === parse8(path82).root) {
|
|
21844
21892
|
return false;
|
|
21845
21893
|
}
|
|
21846
21894
|
if (!removedAll) {
|
|
21847
21895
|
return false;
|
|
21848
21896
|
}
|
|
21849
|
-
if (opt.filter && !opt.filter(
|
|
21897
|
+
if (opt.filter && !opt.filter(path82, ent)) {
|
|
21850
21898
|
return false;
|
|
21851
21899
|
}
|
|
21852
|
-
ignoreENOENTSync(() => rimrafWindowsDirMoveRemoveFallbackSync(
|
|
21900
|
+
ignoreENOENTSync(() => rimrafWindowsDirMoveRemoveFallbackSync(path82, opt));
|
|
21853
21901
|
}
|
|
21854
21902
|
return true;
|
|
21855
21903
|
};
|
|
@@ -21861,16 +21909,16 @@ var rimrafManualSync = process.platform === "win32" ? rimrafWindowsSync : rimraf
|
|
|
21861
21909
|
// ../../node_modules/.pnpm/rimraf@6.1.3/node_modules/rimraf/dist/esm/rimraf-native.js
|
|
21862
21910
|
init_esm_shims();
|
|
21863
21911
|
var { rm } = promises2;
|
|
21864
|
-
var rimrafNative = async (
|
|
21865
|
-
await rm(
|
|
21912
|
+
var rimrafNative = async (path82, opt) => {
|
|
21913
|
+
await rm(path82, {
|
|
21866
21914
|
...opt,
|
|
21867
21915
|
force: true,
|
|
21868
21916
|
recursive: true
|
|
21869
21917
|
});
|
|
21870
21918
|
return true;
|
|
21871
21919
|
};
|
|
21872
|
-
var rimrafNativeSync = (
|
|
21873
|
-
rmSync(
|
|
21920
|
+
var rimrafNativeSync = (path82, opt) => {
|
|
21921
|
+
rmSync(path82, {
|
|
21874
21922
|
...opt,
|
|
21875
21923
|
force: true,
|
|
21876
21924
|
recursive: true
|
|
@@ -21886,26 +21934,26 @@ var useNative = !hasNative || process.platform === "win32" ? () => false : (opt)
|
|
|
21886
21934
|
var useNativeSync = !hasNative || process.platform === "win32" ? () => false : (opt) => !opt?.signal && !opt?.filter;
|
|
21887
21935
|
|
|
21888
21936
|
// ../../node_modules/.pnpm/rimraf@6.1.3/node_modules/rimraf/dist/esm/index.js
|
|
21889
|
-
var wrap = (fn) => async (
|
|
21937
|
+
var wrap = (fn) => async (path82, opt) => {
|
|
21890
21938
|
const options = optArg(opt);
|
|
21891
21939
|
if (options.glob) {
|
|
21892
|
-
|
|
21940
|
+
path82 = await Ze(path82, options.glob);
|
|
21893
21941
|
}
|
|
21894
|
-
if (Array.isArray(
|
|
21895
|
-
return !!(await Promise.all(
|
|
21942
|
+
if (Array.isArray(path82)) {
|
|
21943
|
+
return !!(await Promise.all(path82.map((p) => fn(path_arg_default(p, options), options)))).reduce((a3, b) => a3 && b, true);
|
|
21896
21944
|
} else {
|
|
21897
|
-
return !!await fn(path_arg_default(
|
|
21945
|
+
return !!await fn(path_arg_default(path82, options), options);
|
|
21898
21946
|
}
|
|
21899
21947
|
};
|
|
21900
|
-
var wrapSync = (fn) => (
|
|
21948
|
+
var wrapSync = (fn) => (path82, opt) => {
|
|
21901
21949
|
const options = optArgSync(opt);
|
|
21902
21950
|
if (options.glob) {
|
|
21903
|
-
|
|
21951
|
+
path82 = ts(path82, options.glob);
|
|
21904
21952
|
}
|
|
21905
|
-
if (Array.isArray(
|
|
21906
|
-
return !!
|
|
21953
|
+
if (Array.isArray(path82)) {
|
|
21954
|
+
return !!path82.map((p) => fn(path_arg_default(p, options), options)).reduce((a3, b) => a3 && b, true);
|
|
21907
21955
|
} else {
|
|
21908
|
-
return !!fn(path_arg_default(
|
|
21956
|
+
return !!fn(path_arg_default(path82, options), options);
|
|
21909
21957
|
}
|
|
21910
21958
|
};
|
|
21911
21959
|
var nativeSync = wrapSync(rimrafNativeSync);
|
|
@@ -21926,8 +21974,8 @@ var moveRemoveSync = wrapSync(rimrafMoveRemoveSync);
|
|
|
21926
21974
|
var moveRemove = Object.assign(wrap(rimrafMoveRemove), {
|
|
21927
21975
|
sync: moveRemoveSync
|
|
21928
21976
|
});
|
|
21929
|
-
var rimrafSync = wrapSync((
|
|
21930
|
-
var rimraf_ = wrap((
|
|
21977
|
+
var rimrafSync = wrapSync((path82, opt) => useNativeSync(opt) ? rimrafNativeSync(path82, opt) : rimrafManualSync(path82, opt));
|
|
21978
|
+
var rimraf_ = wrap((path82, opt) => useNative(opt) ? rimrafNative(path82, opt) : rimrafManual(path82, opt));
|
|
21931
21979
|
var rimraf = Object.assign(rimraf_, {
|
|
21932
21980
|
rimraf: rimraf_,
|
|
21933
21981
|
sync: rimrafSync,
|
|
@@ -22121,7 +22169,7 @@ var ReaddirpStream = class extends Readable {
|
|
|
22121
22169
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
22122
22170
|
const statMethod = opts.lstat ? lstat4 : stat2;
|
|
22123
22171
|
if (wantBigintFsStats) {
|
|
22124
|
-
this._stat = (
|
|
22172
|
+
this._stat = (path82) => statMethod(path82, { bigint: true });
|
|
22125
22173
|
} else {
|
|
22126
22174
|
this._stat = statMethod;
|
|
22127
22175
|
}
|
|
@@ -22146,8 +22194,8 @@ var ReaddirpStream = class extends Readable {
|
|
|
22146
22194
|
const par = this.parent;
|
|
22147
22195
|
const fil = par && par.files;
|
|
22148
22196
|
if (fil && fil.length > 0) {
|
|
22149
|
-
const { path:
|
|
22150
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
22197
|
+
const { path: path82, depth } = par;
|
|
22198
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path82));
|
|
22151
22199
|
const awaited = await Promise.all(slice);
|
|
22152
22200
|
for (const entry of awaited) {
|
|
22153
22201
|
if (!entry)
|
|
@@ -22187,20 +22235,20 @@ var ReaddirpStream = class extends Readable {
|
|
|
22187
22235
|
this.reading = false;
|
|
22188
22236
|
}
|
|
22189
22237
|
}
|
|
22190
|
-
async _exploreDir(
|
|
22238
|
+
async _exploreDir(path82, depth) {
|
|
22191
22239
|
let files;
|
|
22192
22240
|
try {
|
|
22193
|
-
files = await readdir2(
|
|
22241
|
+
files = await readdir2(path82, this._rdOptions);
|
|
22194
22242
|
} catch (error) {
|
|
22195
22243
|
this._onError(error);
|
|
22196
22244
|
}
|
|
22197
|
-
return { files, depth, path:
|
|
22245
|
+
return { files, depth, path: path82 };
|
|
22198
22246
|
}
|
|
22199
|
-
async _formatEntry(dirent,
|
|
22247
|
+
async _formatEntry(dirent, path82) {
|
|
22200
22248
|
let entry;
|
|
22201
22249
|
const basename4 = this._isDirent ? dirent.name : dirent;
|
|
22202
22250
|
try {
|
|
22203
|
-
const fullPath = presolve(pjoin(
|
|
22251
|
+
const fullPath = presolve(pjoin(path82, basename4));
|
|
22204
22252
|
entry = { path: prelative(this._root, fullPath), fullPath, basename: basename4 };
|
|
22205
22253
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
22206
22254
|
} catch (err) {
|
|
@@ -22601,16 +22649,16 @@ var delFromSet = (main, prop, item) => {
|
|
|
22601
22649
|
};
|
|
22602
22650
|
var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
|
|
22603
22651
|
var FsWatchInstances = /* @__PURE__ */ new Map();
|
|
22604
|
-
function createFsWatchInstance(
|
|
22652
|
+
function createFsWatchInstance(path82, options, listener, errHandler, emitRaw) {
|
|
22605
22653
|
const handleEvent = (rawEvent, evPath) => {
|
|
22606
|
-
listener(
|
|
22607
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
22608
|
-
if (evPath &&
|
|
22609
|
-
fsWatchBroadcast(sp.resolve(
|
|
22654
|
+
listener(path82);
|
|
22655
|
+
emitRaw(rawEvent, evPath, { watchedPath: path82 });
|
|
22656
|
+
if (evPath && path82 !== evPath) {
|
|
22657
|
+
fsWatchBroadcast(sp.resolve(path82, evPath), KEY_LISTENERS, sp.join(path82, evPath));
|
|
22610
22658
|
}
|
|
22611
22659
|
};
|
|
22612
22660
|
try {
|
|
22613
|
-
return fs_watch(
|
|
22661
|
+
return fs_watch(path82, {
|
|
22614
22662
|
persistent: options.persistent
|
|
22615
22663
|
}, handleEvent);
|
|
22616
22664
|
} catch (error) {
|
|
@@ -22626,12 +22674,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
|
22626
22674
|
listener(val1, val2, val3);
|
|
22627
22675
|
});
|
|
22628
22676
|
};
|
|
22629
|
-
var setFsWatchListener = (
|
|
22677
|
+
var setFsWatchListener = (path82, fullPath, options, handlers) => {
|
|
22630
22678
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
22631
22679
|
let cont = FsWatchInstances.get(fullPath);
|
|
22632
22680
|
let watcher;
|
|
22633
22681
|
if (!options.persistent) {
|
|
22634
|
-
watcher = createFsWatchInstance(
|
|
22682
|
+
watcher = createFsWatchInstance(path82, options, listener, errHandler, rawEmitter);
|
|
22635
22683
|
if (!watcher)
|
|
22636
22684
|
return;
|
|
22637
22685
|
return watcher.close.bind(watcher);
|
|
@@ -22642,7 +22690,7 @@ var setFsWatchListener = (path81, fullPath, options, handlers) => {
|
|
|
22642
22690
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
22643
22691
|
} else {
|
|
22644
22692
|
watcher = createFsWatchInstance(
|
|
22645
|
-
|
|
22693
|
+
path82,
|
|
22646
22694
|
options,
|
|
22647
22695
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
22648
22696
|
errHandler,
|
|
@@ -22657,7 +22705,7 @@ var setFsWatchListener = (path81, fullPath, options, handlers) => {
|
|
|
22657
22705
|
cont.watcherUnusable = true;
|
|
22658
22706
|
if (isWindows && error.code === "EPERM") {
|
|
22659
22707
|
try {
|
|
22660
|
-
const fd = await open(
|
|
22708
|
+
const fd = await open(path82, "r");
|
|
22661
22709
|
await fd.close();
|
|
22662
22710
|
broadcastErr(error);
|
|
22663
22711
|
} catch (err) {
|
|
@@ -22688,7 +22736,7 @@ var setFsWatchListener = (path81, fullPath, options, handlers) => {
|
|
|
22688
22736
|
};
|
|
22689
22737
|
};
|
|
22690
22738
|
var FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
22691
|
-
var setFsWatchFileListener = (
|
|
22739
|
+
var setFsWatchFileListener = (path82, fullPath, options, handlers) => {
|
|
22692
22740
|
const { listener, rawEmitter } = handlers;
|
|
22693
22741
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
22694
22742
|
const copts = cont && cont.options;
|
|
@@ -22710,7 +22758,7 @@ var setFsWatchFileListener = (path81, fullPath, options, handlers) => {
|
|
|
22710
22758
|
});
|
|
22711
22759
|
const currmtime = curr.mtimeMs;
|
|
22712
22760
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
22713
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
22761
|
+
foreach(cont.listeners, (listener2) => listener2(path82, curr));
|
|
22714
22762
|
}
|
|
22715
22763
|
})
|
|
22716
22764
|
};
|
|
@@ -22740,13 +22788,13 @@ var NodeFsHandler = class {
|
|
|
22740
22788
|
* @param listener on fs change
|
|
22741
22789
|
* @returns closer for the watcher instance
|
|
22742
22790
|
*/
|
|
22743
|
-
_watchWithNodeFs(
|
|
22791
|
+
_watchWithNodeFs(path82, listener) {
|
|
22744
22792
|
const opts = this.fsw.options;
|
|
22745
|
-
const directory = sp.dirname(
|
|
22746
|
-
const basename4 = sp.basename(
|
|
22793
|
+
const directory = sp.dirname(path82);
|
|
22794
|
+
const basename4 = sp.basename(path82);
|
|
22747
22795
|
const parent = this.fsw._getWatchedDir(directory);
|
|
22748
22796
|
parent.add(basename4);
|
|
22749
|
-
const absolutePath = sp.resolve(
|
|
22797
|
+
const absolutePath = sp.resolve(path82);
|
|
22750
22798
|
const options = {
|
|
22751
22799
|
persistent: opts.persistent
|
|
22752
22800
|
};
|
|
@@ -22756,12 +22804,12 @@ var NodeFsHandler = class {
|
|
|
22756
22804
|
if (opts.usePolling) {
|
|
22757
22805
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
22758
22806
|
options.interval = enableBin && isBinaryPath(basename4) ? opts.binaryInterval : opts.interval;
|
|
22759
|
-
closer = setFsWatchFileListener(
|
|
22807
|
+
closer = setFsWatchFileListener(path82, absolutePath, options, {
|
|
22760
22808
|
listener,
|
|
22761
22809
|
rawEmitter: this.fsw._emitRaw
|
|
22762
22810
|
});
|
|
22763
22811
|
} else {
|
|
22764
|
-
closer = setFsWatchListener(
|
|
22812
|
+
closer = setFsWatchListener(path82, absolutePath, options, {
|
|
22765
22813
|
listener,
|
|
22766
22814
|
errHandler: this._boundHandleError,
|
|
22767
22815
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -22783,7 +22831,7 @@ var NodeFsHandler = class {
|
|
|
22783
22831
|
let prevStats = stats;
|
|
22784
22832
|
if (parent.has(basename4))
|
|
22785
22833
|
return;
|
|
22786
|
-
const listener = async (
|
|
22834
|
+
const listener = async (path82, newStats) => {
|
|
22787
22835
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
|
|
22788
22836
|
return;
|
|
22789
22837
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -22797,11 +22845,11 @@ var NodeFsHandler = class {
|
|
|
22797
22845
|
this.fsw._emit(EV.CHANGE, file, newStats2);
|
|
22798
22846
|
}
|
|
22799
22847
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
22800
|
-
this.fsw._closeFile(
|
|
22848
|
+
this.fsw._closeFile(path82);
|
|
22801
22849
|
prevStats = newStats2;
|
|
22802
22850
|
const closer2 = this._watchWithNodeFs(file, listener);
|
|
22803
22851
|
if (closer2)
|
|
22804
|
-
this.fsw._addPathCloser(
|
|
22852
|
+
this.fsw._addPathCloser(path82, closer2);
|
|
22805
22853
|
} else {
|
|
22806
22854
|
prevStats = newStats2;
|
|
22807
22855
|
}
|
|
@@ -22833,7 +22881,7 @@ var NodeFsHandler = class {
|
|
|
22833
22881
|
* @param item basename of this item
|
|
22834
22882
|
* @returns true if no more processing is needed for this entry.
|
|
22835
22883
|
*/
|
|
22836
|
-
async _handleSymlink(entry, directory,
|
|
22884
|
+
async _handleSymlink(entry, directory, path82, item) {
|
|
22837
22885
|
if (this.fsw.closed) {
|
|
22838
22886
|
return;
|
|
22839
22887
|
}
|
|
@@ -22843,7 +22891,7 @@ var NodeFsHandler = class {
|
|
|
22843
22891
|
this.fsw._incrReadyCount();
|
|
22844
22892
|
let linkPath;
|
|
22845
22893
|
try {
|
|
22846
|
-
linkPath = await fsrealpath(
|
|
22894
|
+
linkPath = await fsrealpath(path82);
|
|
22847
22895
|
} catch (e) {
|
|
22848
22896
|
this.fsw._emitReady();
|
|
22849
22897
|
return true;
|
|
@@ -22853,12 +22901,12 @@ var NodeFsHandler = class {
|
|
|
22853
22901
|
if (dir.has(item)) {
|
|
22854
22902
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
22855
22903
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
22856
|
-
this.fsw._emit(EV.CHANGE,
|
|
22904
|
+
this.fsw._emit(EV.CHANGE, path82, entry.stats);
|
|
22857
22905
|
}
|
|
22858
22906
|
} else {
|
|
22859
22907
|
dir.add(item);
|
|
22860
22908
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
22861
|
-
this.fsw._emit(EV.ADD,
|
|
22909
|
+
this.fsw._emit(EV.ADD, path82, entry.stats);
|
|
22862
22910
|
}
|
|
22863
22911
|
this.fsw._emitReady();
|
|
22864
22912
|
return true;
|
|
@@ -22888,9 +22936,9 @@ var NodeFsHandler = class {
|
|
|
22888
22936
|
return;
|
|
22889
22937
|
}
|
|
22890
22938
|
const item = entry.path;
|
|
22891
|
-
let
|
|
22939
|
+
let path82 = sp.join(directory, item);
|
|
22892
22940
|
current2.add(item);
|
|
22893
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
22941
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path82, item)) {
|
|
22894
22942
|
return;
|
|
22895
22943
|
}
|
|
22896
22944
|
if (this.fsw.closed) {
|
|
@@ -22899,8 +22947,8 @@ var NodeFsHandler = class {
|
|
|
22899
22947
|
}
|
|
22900
22948
|
if (item === target || !target && !previous.has(item)) {
|
|
22901
22949
|
this.fsw._incrReadyCount();
|
|
22902
|
-
|
|
22903
|
-
this._addToNodeFs(
|
|
22950
|
+
path82 = sp.join(dir, sp.relative(dir, path82));
|
|
22951
|
+
this._addToNodeFs(path82, initialAdd, wh, depth + 1);
|
|
22904
22952
|
}
|
|
22905
22953
|
}).on(EV.ERROR, this._boundHandleError);
|
|
22906
22954
|
return new Promise((resolve8, reject) => {
|
|
@@ -22969,13 +23017,13 @@ var NodeFsHandler = class {
|
|
|
22969
23017
|
* @param depth Child path actually targeted for watch
|
|
22970
23018
|
* @param target Child path actually targeted for watch
|
|
22971
23019
|
*/
|
|
22972
|
-
async _addToNodeFs(
|
|
23020
|
+
async _addToNodeFs(path82, initialAdd, priorWh, depth, target) {
|
|
22973
23021
|
const ready = this.fsw._emitReady;
|
|
22974
|
-
if (this.fsw._isIgnored(
|
|
23022
|
+
if (this.fsw._isIgnored(path82) || this.fsw.closed) {
|
|
22975
23023
|
ready();
|
|
22976
23024
|
return false;
|
|
22977
23025
|
}
|
|
22978
|
-
const wh = this.fsw._getWatchHelpers(
|
|
23026
|
+
const wh = this.fsw._getWatchHelpers(path82);
|
|
22979
23027
|
if (priorWh) {
|
|
22980
23028
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
22981
23029
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -22991,8 +23039,8 @@ var NodeFsHandler = class {
|
|
|
22991
23039
|
const follow = this.fsw.options.followSymlinks;
|
|
22992
23040
|
let closer;
|
|
22993
23041
|
if (stats.isDirectory()) {
|
|
22994
|
-
const absPath = sp.resolve(
|
|
22995
|
-
const targetPath = follow ? await fsrealpath(
|
|
23042
|
+
const absPath = sp.resolve(path82);
|
|
23043
|
+
const targetPath = follow ? await fsrealpath(path82) : path82;
|
|
22996
23044
|
if (this.fsw.closed)
|
|
22997
23045
|
return;
|
|
22998
23046
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -23002,29 +23050,29 @@ var NodeFsHandler = class {
|
|
|
23002
23050
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
23003
23051
|
}
|
|
23004
23052
|
} else if (stats.isSymbolicLink()) {
|
|
23005
|
-
const targetPath = follow ? await fsrealpath(
|
|
23053
|
+
const targetPath = follow ? await fsrealpath(path82) : path82;
|
|
23006
23054
|
if (this.fsw.closed)
|
|
23007
23055
|
return;
|
|
23008
23056
|
const parent = sp.dirname(wh.watchPath);
|
|
23009
23057
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
23010
23058
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
23011
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
23059
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path82, wh, targetPath);
|
|
23012
23060
|
if (this.fsw.closed)
|
|
23013
23061
|
return;
|
|
23014
23062
|
if (targetPath !== void 0) {
|
|
23015
|
-
this.fsw._symlinkPaths.set(sp.resolve(
|
|
23063
|
+
this.fsw._symlinkPaths.set(sp.resolve(path82), targetPath);
|
|
23016
23064
|
}
|
|
23017
23065
|
} else {
|
|
23018
23066
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
23019
23067
|
}
|
|
23020
23068
|
ready();
|
|
23021
23069
|
if (closer)
|
|
23022
|
-
this.fsw._addPathCloser(
|
|
23070
|
+
this.fsw._addPathCloser(path82, closer);
|
|
23023
23071
|
return false;
|
|
23024
23072
|
} catch (error) {
|
|
23025
23073
|
if (this.fsw._handleError(error)) {
|
|
23026
23074
|
ready();
|
|
23027
|
-
return
|
|
23075
|
+
return path82;
|
|
23028
23076
|
}
|
|
23029
23077
|
}
|
|
23030
23078
|
}
|
|
@@ -23067,24 +23115,24 @@ function createPattern(matcher) {
|
|
|
23067
23115
|
}
|
|
23068
23116
|
return () => false;
|
|
23069
23117
|
}
|
|
23070
|
-
function normalizePath3(
|
|
23071
|
-
if (typeof
|
|
23118
|
+
function normalizePath3(path82) {
|
|
23119
|
+
if (typeof path82 !== "string")
|
|
23072
23120
|
throw new Error("string expected");
|
|
23073
|
-
|
|
23074
|
-
|
|
23121
|
+
path82 = sp2.normalize(path82);
|
|
23122
|
+
path82 = path82.replace(/\\/g, "/");
|
|
23075
23123
|
let prepend = false;
|
|
23076
|
-
if (
|
|
23124
|
+
if (path82.startsWith("//"))
|
|
23077
23125
|
prepend = true;
|
|
23078
|
-
|
|
23126
|
+
path82 = path82.replace(DOUBLE_SLASH_RE, "/");
|
|
23079
23127
|
if (prepend)
|
|
23080
|
-
|
|
23081
|
-
return
|
|
23128
|
+
path82 = "/" + path82;
|
|
23129
|
+
return path82;
|
|
23082
23130
|
}
|
|
23083
23131
|
function matchPatterns(patterns, testString, stats) {
|
|
23084
|
-
const
|
|
23132
|
+
const path82 = normalizePath3(testString);
|
|
23085
23133
|
for (let index = 0; index < patterns.length; index++) {
|
|
23086
23134
|
const pattern = patterns[index];
|
|
23087
|
-
if (pattern(
|
|
23135
|
+
if (pattern(path82, stats)) {
|
|
23088
23136
|
return true;
|
|
23089
23137
|
}
|
|
23090
23138
|
}
|
|
@@ -23122,19 +23170,19 @@ var toUnix = (string) => {
|
|
|
23122
23170
|
}
|
|
23123
23171
|
return str;
|
|
23124
23172
|
};
|
|
23125
|
-
var normalizePathToUnix = (
|
|
23126
|
-
var normalizeIgnored = (cwd = "") => (
|
|
23127
|
-
if (typeof
|
|
23128
|
-
return normalizePathToUnix(sp2.isAbsolute(
|
|
23173
|
+
var normalizePathToUnix = (path82) => toUnix(sp2.normalize(toUnix(path82)));
|
|
23174
|
+
var normalizeIgnored = (cwd = "") => (path82) => {
|
|
23175
|
+
if (typeof path82 === "string") {
|
|
23176
|
+
return normalizePathToUnix(sp2.isAbsolute(path82) ? path82 : sp2.join(cwd, path82));
|
|
23129
23177
|
} else {
|
|
23130
|
-
return
|
|
23178
|
+
return path82;
|
|
23131
23179
|
}
|
|
23132
23180
|
};
|
|
23133
|
-
var getAbsolutePath = (
|
|
23134
|
-
if (sp2.isAbsolute(
|
|
23135
|
-
return
|
|
23181
|
+
var getAbsolutePath = (path82, cwd) => {
|
|
23182
|
+
if (sp2.isAbsolute(path82)) {
|
|
23183
|
+
return path82;
|
|
23136
23184
|
}
|
|
23137
|
-
return sp2.join(cwd,
|
|
23185
|
+
return sp2.join(cwd, path82);
|
|
23138
23186
|
};
|
|
23139
23187
|
var EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
23140
23188
|
var DirEntry = class {
|
|
@@ -23199,10 +23247,10 @@ var WatchHelper = class {
|
|
|
23199
23247
|
dirParts;
|
|
23200
23248
|
followSymlinks;
|
|
23201
23249
|
statMethod;
|
|
23202
|
-
constructor(
|
|
23250
|
+
constructor(path82, follow, fsw) {
|
|
23203
23251
|
this.fsw = fsw;
|
|
23204
|
-
const watchPath =
|
|
23205
|
-
this.path =
|
|
23252
|
+
const watchPath = path82;
|
|
23253
|
+
this.path = path82 = path82.replace(REPLACER_RE, "");
|
|
23206
23254
|
this.watchPath = watchPath;
|
|
23207
23255
|
this.fullWatchPath = sp2.resolve(watchPath);
|
|
23208
23256
|
this.dirParts = [];
|
|
@@ -23342,20 +23390,20 @@ var FSWatcher = class extends EventEmitter {
|
|
|
23342
23390
|
this._closePromise = void 0;
|
|
23343
23391
|
let paths = unifyPaths(paths_);
|
|
23344
23392
|
if (cwd) {
|
|
23345
|
-
paths = paths.map((
|
|
23346
|
-
const absPath = getAbsolutePath(
|
|
23393
|
+
paths = paths.map((path82) => {
|
|
23394
|
+
const absPath = getAbsolutePath(path82, cwd);
|
|
23347
23395
|
return absPath;
|
|
23348
23396
|
});
|
|
23349
23397
|
}
|
|
23350
|
-
paths.forEach((
|
|
23351
|
-
this._removeIgnoredPath(
|
|
23398
|
+
paths.forEach((path82) => {
|
|
23399
|
+
this._removeIgnoredPath(path82);
|
|
23352
23400
|
});
|
|
23353
23401
|
this._userIgnored = void 0;
|
|
23354
23402
|
if (!this._readyCount)
|
|
23355
23403
|
this._readyCount = 0;
|
|
23356
23404
|
this._readyCount += paths.length;
|
|
23357
|
-
Promise.all(paths.map(async (
|
|
23358
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
23405
|
+
Promise.all(paths.map(async (path82) => {
|
|
23406
|
+
const res = await this._nodeFsHandler._addToNodeFs(path82, !_internal, void 0, 0, _origAdd);
|
|
23359
23407
|
if (res)
|
|
23360
23408
|
this._emitReady();
|
|
23361
23409
|
return res;
|
|
@@ -23377,17 +23425,17 @@ var FSWatcher = class extends EventEmitter {
|
|
|
23377
23425
|
return this;
|
|
23378
23426
|
const paths = unifyPaths(paths_);
|
|
23379
23427
|
const { cwd } = this.options;
|
|
23380
|
-
paths.forEach((
|
|
23381
|
-
if (!sp2.isAbsolute(
|
|
23428
|
+
paths.forEach((path82) => {
|
|
23429
|
+
if (!sp2.isAbsolute(path82) && !this._closers.has(path82)) {
|
|
23382
23430
|
if (cwd)
|
|
23383
|
-
|
|
23384
|
-
|
|
23431
|
+
path82 = sp2.join(cwd, path82);
|
|
23432
|
+
path82 = sp2.resolve(path82);
|
|
23385
23433
|
}
|
|
23386
|
-
this._closePath(
|
|
23387
|
-
this._addIgnoredPath(
|
|
23388
|
-
if (this._watched.has(
|
|
23434
|
+
this._closePath(path82);
|
|
23435
|
+
this._addIgnoredPath(path82);
|
|
23436
|
+
if (this._watched.has(path82)) {
|
|
23389
23437
|
this._addIgnoredPath({
|
|
23390
|
-
path:
|
|
23438
|
+
path: path82,
|
|
23391
23439
|
recursive: true
|
|
23392
23440
|
});
|
|
23393
23441
|
}
|
|
@@ -23451,38 +23499,38 @@ var FSWatcher = class extends EventEmitter {
|
|
|
23451
23499
|
* @param stats arguments to be passed with event
|
|
23452
23500
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
23453
23501
|
*/
|
|
23454
|
-
async _emit(event,
|
|
23502
|
+
async _emit(event, path82, stats) {
|
|
23455
23503
|
if (this.closed)
|
|
23456
23504
|
return;
|
|
23457
23505
|
const opts = this.options;
|
|
23458
23506
|
if (isWindows)
|
|
23459
|
-
|
|
23507
|
+
path82 = sp2.normalize(path82);
|
|
23460
23508
|
if (opts.cwd)
|
|
23461
|
-
|
|
23462
|
-
const args = [
|
|
23509
|
+
path82 = sp2.relative(opts.cwd, path82);
|
|
23510
|
+
const args = [path82];
|
|
23463
23511
|
if (stats != null)
|
|
23464
23512
|
args.push(stats);
|
|
23465
23513
|
const awf = opts.awaitWriteFinish;
|
|
23466
23514
|
let pw;
|
|
23467
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
23515
|
+
if (awf && (pw = this._pendingWrites.get(path82))) {
|
|
23468
23516
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
23469
23517
|
return this;
|
|
23470
23518
|
}
|
|
23471
23519
|
if (opts.atomic) {
|
|
23472
23520
|
if (event === EVENTS.UNLINK) {
|
|
23473
|
-
this._pendingUnlinks.set(
|
|
23521
|
+
this._pendingUnlinks.set(path82, [event, ...args]);
|
|
23474
23522
|
setTimeout(() => {
|
|
23475
|
-
this._pendingUnlinks.forEach((entry,
|
|
23523
|
+
this._pendingUnlinks.forEach((entry, path83) => {
|
|
23476
23524
|
this.emit(...entry);
|
|
23477
23525
|
this.emit(EVENTS.ALL, ...entry);
|
|
23478
|
-
this._pendingUnlinks.delete(
|
|
23526
|
+
this._pendingUnlinks.delete(path83);
|
|
23479
23527
|
});
|
|
23480
23528
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
23481
23529
|
return this;
|
|
23482
23530
|
}
|
|
23483
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
23531
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path82)) {
|
|
23484
23532
|
event = EVENTS.CHANGE;
|
|
23485
|
-
this._pendingUnlinks.delete(
|
|
23533
|
+
this._pendingUnlinks.delete(path82);
|
|
23486
23534
|
}
|
|
23487
23535
|
}
|
|
23488
23536
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -23500,16 +23548,16 @@ var FSWatcher = class extends EventEmitter {
|
|
|
23500
23548
|
this.emitWithAll(event, args);
|
|
23501
23549
|
}
|
|
23502
23550
|
};
|
|
23503
|
-
this._awaitWriteFinish(
|
|
23551
|
+
this._awaitWriteFinish(path82, awf.stabilityThreshold, event, awfEmit);
|
|
23504
23552
|
return this;
|
|
23505
23553
|
}
|
|
23506
23554
|
if (event === EVENTS.CHANGE) {
|
|
23507
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
23555
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path82, 50);
|
|
23508
23556
|
if (isThrottled)
|
|
23509
23557
|
return this;
|
|
23510
23558
|
}
|
|
23511
23559
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
23512
|
-
const fullPath = opts.cwd ? sp2.join(opts.cwd,
|
|
23560
|
+
const fullPath = opts.cwd ? sp2.join(opts.cwd, path82) : path82;
|
|
23513
23561
|
let stats2;
|
|
23514
23562
|
try {
|
|
23515
23563
|
stats2 = await stat4(fullPath);
|
|
@@ -23540,23 +23588,23 @@ var FSWatcher = class extends EventEmitter {
|
|
|
23540
23588
|
* @param timeout duration of time to suppress duplicate actions
|
|
23541
23589
|
* @returns tracking object or false if action should be suppressed
|
|
23542
23590
|
*/
|
|
23543
|
-
_throttle(actionType,
|
|
23591
|
+
_throttle(actionType, path82, timeout) {
|
|
23544
23592
|
if (!this._throttled.has(actionType)) {
|
|
23545
23593
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
23546
23594
|
}
|
|
23547
23595
|
const action = this._throttled.get(actionType);
|
|
23548
23596
|
if (!action)
|
|
23549
23597
|
throw new Error("invalid throttle");
|
|
23550
|
-
const actionPath = action.get(
|
|
23598
|
+
const actionPath = action.get(path82);
|
|
23551
23599
|
if (actionPath) {
|
|
23552
23600
|
actionPath.count++;
|
|
23553
23601
|
return false;
|
|
23554
23602
|
}
|
|
23555
23603
|
let timeoutObject;
|
|
23556
23604
|
const clear = () => {
|
|
23557
|
-
const item = action.get(
|
|
23605
|
+
const item = action.get(path82);
|
|
23558
23606
|
const count = item ? item.count : 0;
|
|
23559
|
-
action.delete(
|
|
23607
|
+
action.delete(path82);
|
|
23560
23608
|
clearTimeout(timeoutObject);
|
|
23561
23609
|
if (item)
|
|
23562
23610
|
clearTimeout(item.timeoutObject);
|
|
@@ -23564,7 +23612,7 @@ var FSWatcher = class extends EventEmitter {
|
|
|
23564
23612
|
};
|
|
23565
23613
|
timeoutObject = setTimeout(clear, timeout);
|
|
23566
23614
|
const thr = { timeoutObject, clear, count: 0 };
|
|
23567
|
-
action.set(
|
|
23615
|
+
action.set(path82, thr);
|
|
23568
23616
|
return thr;
|
|
23569
23617
|
}
|
|
23570
23618
|
_incrReadyCount() {
|
|
@@ -23578,44 +23626,44 @@ var FSWatcher = class extends EventEmitter {
|
|
|
23578
23626
|
* @param event
|
|
23579
23627
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
23580
23628
|
*/
|
|
23581
|
-
_awaitWriteFinish(
|
|
23629
|
+
_awaitWriteFinish(path82, threshold, event, awfEmit) {
|
|
23582
23630
|
const awf = this.options.awaitWriteFinish;
|
|
23583
23631
|
if (typeof awf !== "object")
|
|
23584
23632
|
return;
|
|
23585
23633
|
const pollInterval = awf.pollInterval;
|
|
23586
23634
|
let timeoutHandler;
|
|
23587
|
-
let fullPath =
|
|
23588
|
-
if (this.options.cwd && !sp2.isAbsolute(
|
|
23589
|
-
fullPath = sp2.join(this.options.cwd,
|
|
23635
|
+
let fullPath = path82;
|
|
23636
|
+
if (this.options.cwd && !sp2.isAbsolute(path82)) {
|
|
23637
|
+
fullPath = sp2.join(this.options.cwd, path82);
|
|
23590
23638
|
}
|
|
23591
23639
|
const now = /* @__PURE__ */ new Date();
|
|
23592
23640
|
const writes = this._pendingWrites;
|
|
23593
23641
|
function awaitWriteFinishFn(prevStat) {
|
|
23594
23642
|
statcb(fullPath, (err, curStat) => {
|
|
23595
|
-
if (err || !writes.has(
|
|
23643
|
+
if (err || !writes.has(path82)) {
|
|
23596
23644
|
if (err && err.code !== "ENOENT")
|
|
23597
23645
|
awfEmit(err);
|
|
23598
23646
|
return;
|
|
23599
23647
|
}
|
|
23600
23648
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
23601
23649
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
23602
|
-
writes.get(
|
|
23650
|
+
writes.get(path82).lastChange = now2;
|
|
23603
23651
|
}
|
|
23604
|
-
const pw = writes.get(
|
|
23652
|
+
const pw = writes.get(path82);
|
|
23605
23653
|
const df = now2 - pw.lastChange;
|
|
23606
23654
|
if (df >= threshold) {
|
|
23607
|
-
writes.delete(
|
|
23655
|
+
writes.delete(path82);
|
|
23608
23656
|
awfEmit(void 0, curStat);
|
|
23609
23657
|
} else {
|
|
23610
23658
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
23611
23659
|
}
|
|
23612
23660
|
});
|
|
23613
23661
|
}
|
|
23614
|
-
if (!writes.has(
|
|
23615
|
-
writes.set(
|
|
23662
|
+
if (!writes.has(path82)) {
|
|
23663
|
+
writes.set(path82, {
|
|
23616
23664
|
lastChange: now,
|
|
23617
23665
|
cancelWait: () => {
|
|
23618
|
-
writes.delete(
|
|
23666
|
+
writes.delete(path82);
|
|
23619
23667
|
clearTimeout(timeoutHandler);
|
|
23620
23668
|
return event;
|
|
23621
23669
|
}
|
|
@@ -23626,8 +23674,8 @@ var FSWatcher = class extends EventEmitter {
|
|
|
23626
23674
|
/**
|
|
23627
23675
|
* Determines whether user has asked to ignore this path.
|
|
23628
23676
|
*/
|
|
23629
|
-
_isIgnored(
|
|
23630
|
-
if (this.options.atomic && DOT_RE.test(
|
|
23677
|
+
_isIgnored(path82, stats) {
|
|
23678
|
+
if (this.options.atomic && DOT_RE.test(path82))
|
|
23631
23679
|
return true;
|
|
23632
23680
|
if (!this._userIgnored) {
|
|
23633
23681
|
const { cwd } = this.options;
|
|
@@ -23637,17 +23685,17 @@ var FSWatcher = class extends EventEmitter {
|
|
|
23637
23685
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
23638
23686
|
this._userIgnored = anymatch(list, void 0);
|
|
23639
23687
|
}
|
|
23640
|
-
return this._userIgnored(
|
|
23688
|
+
return this._userIgnored(path82, stats);
|
|
23641
23689
|
}
|
|
23642
|
-
_isntIgnored(
|
|
23643
|
-
return !this._isIgnored(
|
|
23690
|
+
_isntIgnored(path82, stat5) {
|
|
23691
|
+
return !this._isIgnored(path82, stat5);
|
|
23644
23692
|
}
|
|
23645
23693
|
/**
|
|
23646
23694
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
23647
23695
|
* @param path file or directory pattern being watched
|
|
23648
23696
|
*/
|
|
23649
|
-
_getWatchHelpers(
|
|
23650
|
-
return new WatchHelper(
|
|
23697
|
+
_getWatchHelpers(path82) {
|
|
23698
|
+
return new WatchHelper(path82, this.options.followSymlinks, this);
|
|
23651
23699
|
}
|
|
23652
23700
|
// Directory helpers
|
|
23653
23701
|
// -----------------
|
|
@@ -23679,63 +23727,63 @@ var FSWatcher = class extends EventEmitter {
|
|
|
23679
23727
|
* @param item base path of item/directory
|
|
23680
23728
|
*/
|
|
23681
23729
|
_remove(directory, item, isDirectory) {
|
|
23682
|
-
const
|
|
23683
|
-
const fullPath = sp2.resolve(
|
|
23684
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
23685
|
-
if (!this._throttle("remove",
|
|
23730
|
+
const path82 = sp2.join(directory, item);
|
|
23731
|
+
const fullPath = sp2.resolve(path82);
|
|
23732
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path82) || this._watched.has(fullPath);
|
|
23733
|
+
if (!this._throttle("remove", path82, 100))
|
|
23686
23734
|
return;
|
|
23687
23735
|
if (!isDirectory && this._watched.size === 1) {
|
|
23688
23736
|
this.add(directory, item, true);
|
|
23689
23737
|
}
|
|
23690
|
-
const wp = this._getWatchedDir(
|
|
23738
|
+
const wp = this._getWatchedDir(path82);
|
|
23691
23739
|
const nestedDirectoryChildren = wp.getChildren();
|
|
23692
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
23740
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path82, nested));
|
|
23693
23741
|
const parent = this._getWatchedDir(directory);
|
|
23694
23742
|
const wasTracked = parent.has(item);
|
|
23695
23743
|
parent.remove(item);
|
|
23696
23744
|
if (this._symlinkPaths.has(fullPath)) {
|
|
23697
23745
|
this._symlinkPaths.delete(fullPath);
|
|
23698
23746
|
}
|
|
23699
|
-
let relPath =
|
|
23747
|
+
let relPath = path82;
|
|
23700
23748
|
if (this.options.cwd)
|
|
23701
|
-
relPath = sp2.relative(this.options.cwd,
|
|
23749
|
+
relPath = sp2.relative(this.options.cwd, path82);
|
|
23702
23750
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
23703
23751
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
23704
23752
|
if (event === EVENTS.ADD)
|
|
23705
23753
|
return;
|
|
23706
23754
|
}
|
|
23707
|
-
this._watched.delete(
|
|
23755
|
+
this._watched.delete(path82);
|
|
23708
23756
|
this._watched.delete(fullPath);
|
|
23709
23757
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
23710
|
-
if (wasTracked && !this._isIgnored(
|
|
23711
|
-
this._emit(eventName,
|
|
23712
|
-
this._closePath(
|
|
23758
|
+
if (wasTracked && !this._isIgnored(path82))
|
|
23759
|
+
this._emit(eventName, path82);
|
|
23760
|
+
this._closePath(path82);
|
|
23713
23761
|
}
|
|
23714
23762
|
/**
|
|
23715
23763
|
* Closes all watchers for a path
|
|
23716
23764
|
*/
|
|
23717
|
-
_closePath(
|
|
23718
|
-
this._closeFile(
|
|
23719
|
-
const dir = sp2.dirname(
|
|
23720
|
-
this._getWatchedDir(dir).remove(sp2.basename(
|
|
23765
|
+
_closePath(path82) {
|
|
23766
|
+
this._closeFile(path82);
|
|
23767
|
+
const dir = sp2.dirname(path82);
|
|
23768
|
+
this._getWatchedDir(dir).remove(sp2.basename(path82));
|
|
23721
23769
|
}
|
|
23722
23770
|
/**
|
|
23723
23771
|
* Closes only file-specific watchers
|
|
23724
23772
|
*/
|
|
23725
|
-
_closeFile(
|
|
23726
|
-
const closers = this._closers.get(
|
|
23773
|
+
_closeFile(path82) {
|
|
23774
|
+
const closers = this._closers.get(path82);
|
|
23727
23775
|
if (!closers)
|
|
23728
23776
|
return;
|
|
23729
23777
|
closers.forEach((closer) => closer());
|
|
23730
|
-
this._closers.delete(
|
|
23778
|
+
this._closers.delete(path82);
|
|
23731
23779
|
}
|
|
23732
|
-
_addPathCloser(
|
|
23780
|
+
_addPathCloser(path82, closer) {
|
|
23733
23781
|
if (!closer)
|
|
23734
23782
|
return;
|
|
23735
|
-
let list = this._closers.get(
|
|
23783
|
+
let list = this._closers.get(path82);
|
|
23736
23784
|
if (!list) {
|
|
23737
23785
|
list = [];
|
|
23738
|
-
this._closers.set(
|
|
23786
|
+
this._closers.set(path82, list);
|
|
23739
23787
|
}
|
|
23740
23788
|
list.push(closer);
|
|
23741
23789
|
}
|
|
@@ -24203,7 +24251,7 @@ function isMetadataYarnClassic(metadataPath) {
|
|
|
24203
24251
|
}
|
|
24204
24252
|
|
|
24205
24253
|
// src/runtime/config/createConfigService.ts
|
|
24206
|
-
import
|
|
24254
|
+
import path72 from "pathe";
|
|
24207
24255
|
|
|
24208
24256
|
// src/platform.ts
|
|
24209
24257
|
init_esm_shims();
|
|
@@ -25383,7 +25431,7 @@ function mergeInlineConfig(config, injectBuiltinAliases, ...configs) {
|
|
|
25383
25431
|
// src/runtime/config/internal/merge/miniprogram.ts
|
|
25384
25432
|
init_esm_shims();
|
|
25385
25433
|
import { defu as defu5 } from "@weapp-core/shared";
|
|
25386
|
-
import
|
|
25434
|
+
import path71 from "pathe";
|
|
25387
25435
|
|
|
25388
25436
|
// src/runtime/config/internal/merge/plugins.ts
|
|
25389
25437
|
init_esm_shims();
|
|
@@ -25684,10 +25732,12 @@ import path43 from "pathe";
|
|
|
25684
25732
|
var AUTO_ROUTES_ID = "weapp-vite/auto-routes";
|
|
25685
25733
|
var VIRTUAL_MODULE_ID = "virtual:weapp-vite-auto-routes";
|
|
25686
25734
|
var RESOLVED_VIRTUAL_ID = "\0weapp-vite:auto-routes";
|
|
25735
|
+
var ROUTE_WATCHER_KEY = "__auto-routes-vue-watcher__";
|
|
25687
25736
|
function createAutoRoutesPlugin(ctx) {
|
|
25688
25737
|
const service = ctx.autoRoutesService;
|
|
25689
25738
|
let resolvedConfig;
|
|
25690
25739
|
const autoRoutesAliasTargets = /* @__PURE__ */ new Set();
|
|
25740
|
+
let routeWatcherStarted = false;
|
|
25691
25741
|
const normalizeTargetId = (id) => {
|
|
25692
25742
|
return path43.normalize(normalizeFsResolvedId(id));
|
|
25693
25743
|
};
|
|
@@ -25733,16 +25783,72 @@ function createAutoRoutesPlugin(ctx) {
|
|
|
25733
25783
|
if (!pathWithoutQuery) {
|
|
25734
25784
|
return false;
|
|
25735
25785
|
}
|
|
25736
|
-
const
|
|
25737
|
-
|
|
25738
|
-
|
|
25739
|
-
|
|
25740
|
-
const relative3 = toPosixPath(path43.relative(
|
|
25741
|
-
if (!relative3 || relative3.startsWith("..")) {
|
|
25786
|
+
const normalizedSrcRoot = normalizePath(configService.absoluteSrcRoot);
|
|
25787
|
+
const normalizedCandidate = normalizePath(
|
|
25788
|
+
path43.isAbsolute(pathWithoutQuery) ? pathWithoutQuery : path43.resolve(configService.cwd, pathWithoutQuery)
|
|
25789
|
+
);
|
|
25790
|
+
const relative3 = toPosixPath(path43.relative(normalizedSrcRoot, normalizedCandidate));
|
|
25791
|
+
if (!relative3 || relative3.startsWith("..") || path43.isAbsolute(relative3)) {
|
|
25742
25792
|
return false;
|
|
25743
25793
|
}
|
|
25744
25794
|
return relative3 === "pages" || relative3.startsWith("pages/") || relative3.includes("/pages/");
|
|
25745
25795
|
}
|
|
25796
|
+
function startRouteFileWatcher() {
|
|
25797
|
+
if (routeWatcherStarted) {
|
|
25798
|
+
return;
|
|
25799
|
+
}
|
|
25800
|
+
const configService = ctx.configService;
|
|
25801
|
+
if (!configService?.isDev) {
|
|
25802
|
+
return;
|
|
25803
|
+
}
|
|
25804
|
+
if (!service.isEnabled()) {
|
|
25805
|
+
return;
|
|
25806
|
+
}
|
|
25807
|
+
const srcRoot = configService.absoluteSrcRoot;
|
|
25808
|
+
const allowedExtensions = new Set(vueExtensions.map((ext) => `.${ext}`));
|
|
25809
|
+
const watchDirs = [];
|
|
25810
|
+
for (const dir of service.getWatchDirectories()) {
|
|
25811
|
+
watchDirs.push(dir);
|
|
25812
|
+
}
|
|
25813
|
+
const defaultPagesDir = path43.join(srcRoot, "pages");
|
|
25814
|
+
if (!watchDirs.some((d) => normalizePath(d) === normalizePath(defaultPagesDir))) {
|
|
25815
|
+
watchDirs.push(defaultPagesDir);
|
|
25816
|
+
}
|
|
25817
|
+
if (!watchDirs.length) {
|
|
25818
|
+
return;
|
|
25819
|
+
}
|
|
25820
|
+
const isRouteVueFile = (filePath) => {
|
|
25821
|
+
const ext = path43.extname(filePath);
|
|
25822
|
+
return allowedExtensions.has(ext) && isPagesRelatedPath(filePath);
|
|
25823
|
+
};
|
|
25824
|
+
const watcher = chokidar_default.watch(watchDirs, {
|
|
25825
|
+
ignoreInitial: true,
|
|
25826
|
+
persistent: true,
|
|
25827
|
+
awaitWriteFinish: {
|
|
25828
|
+
stabilityThreshold: 80,
|
|
25829
|
+
pollInterval: 20
|
|
25830
|
+
}
|
|
25831
|
+
});
|
|
25832
|
+
watcher.on("add", (filePath) => {
|
|
25833
|
+
if (!isRouteVueFile(filePath)) {
|
|
25834
|
+
return;
|
|
25835
|
+
}
|
|
25836
|
+
default2.info(`[auto-routes:watch] \u65B0\u589E\u8DEF\u7531\u6587\u4EF6 ${configService.relativeCwd(filePath)}`);
|
|
25837
|
+
void service.handleFileChange(filePath, "create");
|
|
25838
|
+
});
|
|
25839
|
+
watcher.on("unlink", (filePath) => {
|
|
25840
|
+
if (!isRouteVueFile(filePath)) {
|
|
25841
|
+
return;
|
|
25842
|
+
}
|
|
25843
|
+
default2.info(`[auto-routes:watch] \u5220\u9664\u8DEF\u7531\u6587\u4EF6 ${configService.relativeCwd(filePath)}`);
|
|
25844
|
+
void service.handleFileChange(filePath, "delete");
|
|
25845
|
+
});
|
|
25846
|
+
const { sidecarWatcherMap } = ctx.runtimeState.watcher;
|
|
25847
|
+
sidecarWatcherMap.set(ROUTE_WATCHER_KEY, {
|
|
25848
|
+
close: () => void watcher.close()
|
|
25849
|
+
});
|
|
25850
|
+
routeWatcherStarted = true;
|
|
25851
|
+
}
|
|
25746
25852
|
return {
|
|
25747
25853
|
name: "weapp-vite:auto-routes",
|
|
25748
25854
|
enforce: "pre",
|
|
@@ -25754,6 +25860,7 @@ function createAutoRoutesPlugin(ctx) {
|
|
|
25754
25860
|
await service.ensureFresh();
|
|
25755
25861
|
refreshAutoRoutesAliasTargets();
|
|
25756
25862
|
addWatchTargets(this);
|
|
25863
|
+
startRouteFileWatcher();
|
|
25757
25864
|
},
|
|
25758
25865
|
resolveId(id) {
|
|
25759
25866
|
if (id === AUTO_ROUTES_ID || id === VIRTUAL_MODULE_ID) {
|
|
@@ -27013,8 +27120,8 @@ function transformWxsCode(code, options) {
|
|
|
27013
27120
|
}
|
|
27014
27121
|
importees.push({ source: value });
|
|
27015
27122
|
};
|
|
27016
|
-
const tryCollectArgument = (
|
|
27017
|
-
const node =
|
|
27123
|
+
const tryCollectArgument = (path82) => {
|
|
27124
|
+
const node = path82.node;
|
|
27018
27125
|
if (t.isStringLiteral(node)) {
|
|
27019
27126
|
maybePushImportee(node.value);
|
|
27020
27127
|
return;
|
|
@@ -27025,7 +27132,7 @@ function transformWxsCode(code, options) {
|
|
|
27025
27132
|
return;
|
|
27026
27133
|
}
|
|
27027
27134
|
try {
|
|
27028
|
-
const evaluated =
|
|
27135
|
+
const evaluated = path82.evaluate();
|
|
27029
27136
|
if (evaluated.confident) {
|
|
27030
27137
|
maybePushImportee(evaluated.value);
|
|
27031
27138
|
}
|
|
@@ -27678,6 +27785,7 @@ init_esm_shims();
|
|
|
27678
27785
|
|
|
27679
27786
|
// src/plugins/core/lifecycle/emit.ts
|
|
27680
27787
|
init_esm_shims();
|
|
27788
|
+
import path53 from "pathe";
|
|
27681
27789
|
|
|
27682
27790
|
// src/utils/weapi.ts
|
|
27683
27791
|
init_esm_shims();
|
|
@@ -27719,6 +27827,11 @@ function createWeapiAccessExpression(globalName) {
|
|
|
27719
27827
|
|
|
27720
27828
|
// src/plugins/core/lifecycle/emit.ts
|
|
27721
27829
|
var platformApiIdentifiers = /* @__PURE__ */ new Set(["wx", "my", "tt", "swan", "jd", "xhs"]);
|
|
27830
|
+
var WINDOWS_SEPARATOR_RE = /\\/g;
|
|
27831
|
+
var NPM_PROTOCOL_RE = /^npm:/;
|
|
27832
|
+
var PLUGIN_PROTOCOL_RE = /^plugin:\/\//;
|
|
27833
|
+
var ABSOLUTE_NPM_PREFIX_RE = /^\/(?:miniprogram_npm|node_modules)\//;
|
|
27834
|
+
var PRETTY_NODE_MODULES_RE = /node_modules\/(?:\.pnpm\/[^/]+\/node_modules\/)?(.+)/;
|
|
27722
27835
|
function resolveInjectWeapiGlobalName(state) {
|
|
27723
27836
|
const injectWeapi = state.ctx.configService.weappViteConfig?.injectWeapi;
|
|
27724
27837
|
if (!injectWeapi) {
|
|
@@ -27735,8 +27848,8 @@ function replacePlatformApiAccess(code, globalName) {
|
|
|
27735
27848
|
try {
|
|
27736
27849
|
const ast = parseJsLike(code);
|
|
27737
27850
|
let mutated = false;
|
|
27738
|
-
const rewritePath = (
|
|
27739
|
-
const object =
|
|
27851
|
+
const rewritePath = (path82) => {
|
|
27852
|
+
const object = path82.node?.object;
|
|
27740
27853
|
if (!object || object.type !== "Identifier") {
|
|
27741
27854
|
return;
|
|
27742
27855
|
}
|
|
@@ -27744,10 +27857,10 @@ function replacePlatformApiAccess(code, globalName) {
|
|
|
27744
27857
|
if (!platformApiIdentifiers.has(identifierName)) {
|
|
27745
27858
|
return;
|
|
27746
27859
|
}
|
|
27747
|
-
if (
|
|
27860
|
+
if (path82.scope?.hasBinding?.(identifierName)) {
|
|
27748
27861
|
return;
|
|
27749
27862
|
}
|
|
27750
|
-
|
|
27863
|
+
path82.node.object = {
|
|
27751
27864
|
type: "Identifier",
|
|
27752
27865
|
name: injectedApiIdentifier2
|
|
27753
27866
|
};
|
|
@@ -27772,13 +27885,13 @@ function hasDependencyPrefix3(dependencies, importee) {
|
|
|
27772
27885
|
if (!dependencies) {
|
|
27773
27886
|
return false;
|
|
27774
27887
|
}
|
|
27775
|
-
const normalizedImportee = importee.replace(
|
|
27888
|
+
const normalizedImportee = importee.replace(WINDOWS_SEPARATOR_RE, "/").replace(NPM_PROTOCOL_RE, "");
|
|
27776
27889
|
const importeeTokens = normalizedImportee.split("/").filter(Boolean);
|
|
27777
27890
|
if (importeeTokens.length === 0) {
|
|
27778
27891
|
return false;
|
|
27779
27892
|
}
|
|
27780
27893
|
return Object.keys(dependencies).some((dep) => {
|
|
27781
|
-
const depTokens = dep.replace(
|
|
27894
|
+
const depTokens = dep.replace(WINDOWS_SEPARATOR_RE, "/").split("/").filter(Boolean);
|
|
27782
27895
|
if (depTokens.length === 0 || depTokens.length > importeeTokens.length) {
|
|
27783
27896
|
return false;
|
|
27784
27897
|
}
|
|
@@ -27790,12 +27903,23 @@ function hasDependencyPrefix3(dependencies, importee) {
|
|
|
27790
27903
|
return true;
|
|
27791
27904
|
});
|
|
27792
27905
|
}
|
|
27906
|
+
function resolveDependencyId(importee) {
|
|
27907
|
+
const normalizedImportee = importee.replace(WINDOWS_SEPARATOR_RE, "/").replace(NPM_PROTOCOL_RE, "").replace(ABSOLUTE_NPM_PREFIX_RE, "");
|
|
27908
|
+
const importeeTokens = normalizedImportee.split("/").filter(Boolean);
|
|
27909
|
+
if (importeeTokens.length === 0) {
|
|
27910
|
+
return "";
|
|
27911
|
+
}
|
|
27912
|
+
if (normalizedImportee.startsWith("@") && importeeTokens.length > 1) {
|
|
27913
|
+
return `${importeeTokens[0]}/${importeeTokens[1]}`;
|
|
27914
|
+
}
|
|
27915
|
+
return importeeTokens[0];
|
|
27916
|
+
}
|
|
27793
27917
|
function normalizeNpmImportForAlipay(importee, dependencies, mode) {
|
|
27794
27918
|
const trimmed = importee.trim();
|
|
27795
|
-
if (!trimmed ||
|
|
27919
|
+
if (!trimmed || PLUGIN_PROTOCOL_RE.test(trimmed)) {
|
|
27796
27920
|
return importee;
|
|
27797
27921
|
}
|
|
27798
|
-
const normalized = trimmed.replace(
|
|
27922
|
+
const normalized = trimmed.replace(NPM_PROTOCOL_RE, "");
|
|
27799
27923
|
if (normalized.startsWith("/miniprogram_npm/") || normalized.startsWith("/node_modules/")) {
|
|
27800
27924
|
return normalizeAlipayNpmImportPath(normalized, mode);
|
|
27801
27925
|
}
|
|
@@ -27809,15 +27933,15 @@ function rewriteChunkNpmImportsForAlipay(code, dependencies, mode) {
|
|
|
27809
27933
|
const ast = parseJsLike(code);
|
|
27810
27934
|
let mutated = false;
|
|
27811
27935
|
traverse(ast, {
|
|
27812
|
-
CallExpression(
|
|
27813
|
-
const callee =
|
|
27936
|
+
CallExpression(path82) {
|
|
27937
|
+
const callee = path82.node?.callee;
|
|
27814
27938
|
if (!callee || callee.type !== "Identifier" || callee.name !== "require") {
|
|
27815
27939
|
return;
|
|
27816
27940
|
}
|
|
27817
|
-
if (
|
|
27941
|
+
if (path82.scope?.hasBinding?.("require")) {
|
|
27818
27942
|
return;
|
|
27819
27943
|
}
|
|
27820
|
-
const args =
|
|
27944
|
+
const args = path82.node.arguments;
|
|
27821
27945
|
if (!Array.isArray(args) || args.length === 0) {
|
|
27822
27946
|
return;
|
|
27823
27947
|
}
|
|
@@ -27881,6 +28005,131 @@ function rewriteBundlePlatformApi(bundle, globalName) {
|
|
|
27881
28005
|
chunk.code = nextCode;
|
|
27882
28006
|
}
|
|
27883
28007
|
}
|
|
28008
|
+
function matchesSubPackageDependency(dependencies, importee, fallbackDependencies) {
|
|
28009
|
+
const normalized = importee.replace(NPM_PROTOCOL_RE, "").replace(ABSOLUTE_NPM_PREFIX_RE, "");
|
|
28010
|
+
if (Array.isArray(dependencies) && dependencies.length > 0) {
|
|
28011
|
+
const dependencyId = resolveDependencyId(normalized);
|
|
28012
|
+
return dependencies.some((pattern) => {
|
|
28013
|
+
if (typeof pattern === "string") {
|
|
28014
|
+
return dependencyId === pattern || normalized === pattern || normalized.startsWith(`${pattern}/`);
|
|
28015
|
+
}
|
|
28016
|
+
pattern.lastIndex = 0;
|
|
28017
|
+
if (pattern.test(dependencyId)) {
|
|
28018
|
+
return true;
|
|
28019
|
+
}
|
|
28020
|
+
pattern.lastIndex = 0;
|
|
28021
|
+
return pattern.test(normalized);
|
|
28022
|
+
});
|
|
28023
|
+
}
|
|
28024
|
+
return hasDependencyPrefix3(fallbackDependencies, normalized);
|
|
28025
|
+
}
|
|
28026
|
+
function normalizeWeappLocalNpmImport(importee) {
|
|
28027
|
+
const normalized = importee.replace(NPM_PROTOCOL_RE, "").replace(ABSOLUTE_NPM_PREFIX_RE, "");
|
|
28028
|
+
const segments = normalized.split("/").filter(Boolean);
|
|
28029
|
+
if (segments.length === 1 || segments.length === 2 && normalized.startsWith("@")) {
|
|
28030
|
+
return `${normalized}/index`;
|
|
28031
|
+
}
|
|
28032
|
+
return normalized;
|
|
28033
|
+
}
|
|
28034
|
+
function getRequireImportLiteral(node) {
|
|
28035
|
+
if (!node) {
|
|
28036
|
+
return null;
|
|
28037
|
+
}
|
|
28038
|
+
if (node.type === "StringLiteral" || node.type === "Literal") {
|
|
28039
|
+
return typeof node.value === "string" ? node.value : null;
|
|
28040
|
+
}
|
|
28041
|
+
if (node.type === "TemplateLiteral" && node.expressions?.length === 0 && node.quasis?.length === 1) {
|
|
28042
|
+
return node.quasis[0]?.value?.cooked ?? null;
|
|
28043
|
+
}
|
|
28044
|
+
return null;
|
|
28045
|
+
}
|
|
28046
|
+
function setRequireImportLiteral(node, nextValue) {
|
|
28047
|
+
if (!node) {
|
|
28048
|
+
return;
|
|
28049
|
+
}
|
|
28050
|
+
if (node.type === "StringLiteral" || node.type === "Literal") {
|
|
28051
|
+
node.value = nextValue;
|
|
28052
|
+
return;
|
|
28053
|
+
}
|
|
28054
|
+
if (node.type === "TemplateLiteral" && node.expressions?.length === 0 && node.quasis?.length === 1) {
|
|
28055
|
+
node.quasis[0].value.raw = nextValue;
|
|
28056
|
+
node.quasis[0].value.cooked = nextValue;
|
|
28057
|
+
}
|
|
28058
|
+
}
|
|
28059
|
+
function toRelativeRuntimeNpmImport(fileName, root, importee) {
|
|
28060
|
+
const normalized = normalizeWeappLocalNpmImport(importee);
|
|
28061
|
+
const relative3 = toPosixPath(path53.relative(path53.dirname(fileName), `${root}/miniprogram_npm/${normalized}`));
|
|
28062
|
+
return relative3.startsWith(".") ? relative3 : `./${relative3}`;
|
|
28063
|
+
}
|
|
28064
|
+
function rewriteChunkNpmImportsToLocalSubPackage(chunk, meta, dependencies) {
|
|
28065
|
+
try {
|
|
28066
|
+
const ast = parseJsLike(chunk.code);
|
|
28067
|
+
let mutated = false;
|
|
28068
|
+
traverse(ast, {
|
|
28069
|
+
CallExpression(path82) {
|
|
28070
|
+
const callee = path82.node?.callee;
|
|
28071
|
+
if (!callee || callee.type !== "Identifier" || callee.name !== "require") {
|
|
28072
|
+
return;
|
|
28073
|
+
}
|
|
28074
|
+
if (path82.scope?.hasBinding?.("require")) {
|
|
28075
|
+
return;
|
|
28076
|
+
}
|
|
28077
|
+
const args = path82.node.arguments;
|
|
28078
|
+
if (!Array.isArray(args) || args.length === 0) {
|
|
28079
|
+
return;
|
|
28080
|
+
}
|
|
28081
|
+
const firstArg = args[0];
|
|
28082
|
+
const currentValue = getRequireImportLiteral(firstArg);
|
|
28083
|
+
if (typeof currentValue !== "string" || !matchesSubPackageDependency(meta.subPackage.dependencies, currentValue, dependencies)) {
|
|
28084
|
+
return;
|
|
28085
|
+
}
|
|
28086
|
+
const nextValue = toRelativeRuntimeNpmImport(chunk.fileName, meta.subPackage.root, currentValue);
|
|
28087
|
+
if (nextValue === currentValue) {
|
|
28088
|
+
return;
|
|
28089
|
+
}
|
|
28090
|
+
setRequireImportLiteral(firstArg, nextValue);
|
|
28091
|
+
mutated = true;
|
|
28092
|
+
}
|
|
28093
|
+
});
|
|
28094
|
+
if (mutated) {
|
|
28095
|
+
chunk.code = generate(ast).code;
|
|
28096
|
+
}
|
|
28097
|
+
} catch {
|
|
28098
|
+
}
|
|
28099
|
+
}
|
|
28100
|
+
function rewriteJsonNpmImportsToLocalSubPackage(bundle, meta, dependencies) {
|
|
28101
|
+
for (const output of Object.values(bundle)) {
|
|
28102
|
+
if (output?.type !== "asset" || typeof output.fileName !== "string" || !output.fileName.endsWith(".json")) {
|
|
28103
|
+
continue;
|
|
28104
|
+
}
|
|
28105
|
+
if (output.fileName === `${meta.subPackage.root}.json` || !output.fileName.startsWith(`${meta.subPackage.root}/`)) {
|
|
28106
|
+
continue;
|
|
28107
|
+
}
|
|
28108
|
+
const source = typeof output.source === "string" ? output.source : output.source?.toString();
|
|
28109
|
+
if (!source) {
|
|
28110
|
+
continue;
|
|
28111
|
+
}
|
|
28112
|
+
try {
|
|
28113
|
+
const parsed = JSON.parse(source);
|
|
28114
|
+
if (!parsed || typeof parsed !== "object" || !parsed.usingComponents || typeof parsed.usingComponents !== "object" || Array.isArray(parsed.usingComponents)) {
|
|
28115
|
+
continue;
|
|
28116
|
+
}
|
|
28117
|
+
let mutated = false;
|
|
28118
|
+
for (const [componentName, importee] of Object.entries(parsed.usingComponents)) {
|
|
28119
|
+
if (typeof importee !== "string" || !matchesSubPackageDependency(meta.subPackage.dependencies, importee, dependencies)) {
|
|
28120
|
+
continue;
|
|
28121
|
+
}
|
|
28122
|
+
parsed.usingComponents[componentName] = toRelativeRuntimeNpmImport(output.fileName, meta.subPackage.root, importee);
|
|
28123
|
+
mutated = true;
|
|
28124
|
+
}
|
|
28125
|
+
if (mutated) {
|
|
28126
|
+
output.source = `${JSON.stringify(parsed, null, 2)}
|
|
28127
|
+
`;
|
|
28128
|
+
}
|
|
28129
|
+
} catch {
|
|
28130
|
+
}
|
|
28131
|
+
}
|
|
28132
|
+
}
|
|
27884
28133
|
function createRenderStartHook(state) {
|
|
27885
28134
|
const { ctx, subPackageMeta, buildTarget } = state;
|
|
27886
28135
|
return function renderStart() {
|
|
@@ -27919,7 +28168,7 @@ function createGenerateBundleHook(state, isPluginBuild) {
|
|
|
27919
28168
|
var matchSubPackage = matchSubPackage2;
|
|
27920
28169
|
const sharedStrategy = configService.weappViteConfig?.chunks?.sharedStrategy ?? DEFAULT_SHARED_CHUNK_STRATEGY;
|
|
27921
28170
|
const shouldLogChunks = configService.weappViteConfig?.chunks?.logOptimization ?? true;
|
|
27922
|
-
const subPackageRoots =
|
|
28171
|
+
const subPackageRoots = [...scanService.subPackageMap.keys()].filter(Boolean);
|
|
27923
28172
|
const duplicateWarningBytes = Number(configService.weappViteConfig?.chunks?.duplicateWarningBytes ?? 0);
|
|
27924
28173
|
const shouldWarnOnDuplicate = Number.isFinite(duplicateWarningBytes) && duplicateWarningBytes > 0;
|
|
27925
28174
|
let redundantBytesTotal = 0;
|
|
@@ -27932,7 +28181,7 @@ function createGenerateBundleHook(state, isPluginBuild) {
|
|
|
27932
28181
|
const resolveSharedChunkLabel = (sharedFileName, finalFileName) => {
|
|
27933
28182
|
const prettifyModuleLabel = (label) => {
|
|
27934
28183
|
const normalized = toPosixPath(label);
|
|
27935
|
-
const match = normalized.match(
|
|
28184
|
+
const match = normalized.match(PRETTY_NODE_MODULES_RE);
|
|
27936
28185
|
return match?.[1] || label;
|
|
27937
28186
|
};
|
|
27938
28187
|
const candidates = [];
|
|
@@ -27957,11 +28206,9 @@ function createGenerateBundleHook(state, isPluginBuild) {
|
|
|
27957
28206
|
if (!chunk) {
|
|
27958
28207
|
return finalFileName;
|
|
27959
28208
|
}
|
|
27960
|
-
const moduleLabels =
|
|
27961
|
-
|
|
27962
|
-
|
|
27963
|
-
)
|
|
27964
|
-
);
|
|
28209
|
+
const moduleLabels = [...new Set(
|
|
28210
|
+
Object.keys(chunk.modules ?? {}).filter((id) => id && !id.startsWith("\0")).map((id) => configService.relativeAbsoluteSrcRoot(id)).filter(Boolean)
|
|
28211
|
+
)];
|
|
27965
28212
|
if (!moduleLabels.length) {
|
|
27966
28213
|
return chunk.fileName || finalFileName;
|
|
27967
28214
|
}
|
|
@@ -28005,7 +28252,7 @@ function createGenerateBundleHook(state, isPluginBuild) {
|
|
|
28005
28252
|
subPackageSet.add(match);
|
|
28006
28253
|
}
|
|
28007
28254
|
}
|
|
28008
|
-
const subPackageList =
|
|
28255
|
+
const subPackageList = [...subPackageSet].join("\u3001") || "\u76F8\u5173\u5206\u5305";
|
|
28009
28256
|
const ignoredHint = ignoredMainImporters?.length ? `\uFF0C\u5FFD\u7565\u4E3B\u5305\u5F15\u7528\uFF1A${ignoredMainImporters.join("\u3001")}` : "";
|
|
28010
28257
|
default2.info(`[\u5206\u5305] \u5206\u5305 ${subPackageList} \u5171\u4EAB\u6A21\u5757\u5DF2\u590D\u5236\u5230\u5404\u81EA weapp-shared/common.js\uFF08${totalReferences} \u5904\u5F15\u7528${ignoredHint}\uFF09`);
|
|
28011
28258
|
if (retainedInMain) {
|
|
@@ -28029,7 +28276,7 @@ function createGenerateBundleHook(state, isPluginBuild) {
|
|
|
28029
28276
|
}
|
|
28030
28277
|
const segments = [];
|
|
28031
28278
|
if (involvedSubs.size) {
|
|
28032
|
-
segments.push(`\u5206\u5305 ${
|
|
28279
|
+
segments.push(`\u5206\u5305 ${[...involvedSubs].join("\u3001")}`);
|
|
28033
28280
|
}
|
|
28034
28281
|
if (hasMainReference) {
|
|
28035
28282
|
segments.push("\u4E3B\u5305");
|
|
@@ -28054,7 +28301,7 @@ function createGenerateBundleHook(state, isPluginBuild) {
|
|
|
28054
28301
|
subPackageSet.add(match);
|
|
28055
28302
|
}
|
|
28056
28303
|
}
|
|
28057
|
-
const subPackageList =
|
|
28304
|
+
const subPackageList = [...subPackageSet].join("\u3001") || "\u76F8\u5173\u5206\u5305";
|
|
28058
28305
|
default2.info(`[\u5206\u5305] \u5206\u5305 ${subPackageList} \u5DF2\u672C\u5730\u5316 ${runtimeFileName} \u4F9D\u8D56\uFF0C\u907F\u514D\u8DE8\u5305 runtime \u5F15\u7528\u3002`);
|
|
28059
28306
|
} : void 0
|
|
28060
28307
|
});
|
|
@@ -28068,6 +28315,22 @@ function createGenerateBundleHook(state, isPluginBuild) {
|
|
|
28068
28315
|
});
|
|
28069
28316
|
if (configService.platform === "alipay") {
|
|
28070
28317
|
rewriteBundleNpmImportsForAlipay(rolldownBundle, configService.packageJson.dependencies, configService.weappViteConfig?.npm?.alipayNpmMode);
|
|
28318
|
+
} else {
|
|
28319
|
+
const subPackageMap = scanService.subPackageMap ?? /* @__PURE__ */ new Map();
|
|
28320
|
+
const localSubPackageMetas = [...subPackageMap.values()].filter((meta) => Array.isArray(meta?.subPackage?.dependencies) && meta.subPackage.dependencies.length > 0);
|
|
28321
|
+
for (const meta of localSubPackageMetas) {
|
|
28322
|
+
for (const output of Object.values(rolldownBundle)) {
|
|
28323
|
+
if (output?.type !== "chunk") {
|
|
28324
|
+
continue;
|
|
28325
|
+
}
|
|
28326
|
+
const chunk = output;
|
|
28327
|
+
if (chunk.fileName === meta.subPackage.root || !chunk.fileName.startsWith(`${meta.subPackage.root}/`)) {
|
|
28328
|
+
continue;
|
|
28329
|
+
}
|
|
28330
|
+
rewriteChunkNpmImportsToLocalSubPackage(chunk, meta, configService.packageJson.dependencies);
|
|
28331
|
+
}
|
|
28332
|
+
rewriteJsonNpmImportsToLocalSubPackage(rolldownBundle, meta, configService.packageJson.dependencies);
|
|
28333
|
+
}
|
|
28071
28334
|
}
|
|
28072
28335
|
const injectWeapiGlobalName = resolveInjectWeapiGlobalName(state);
|
|
28073
28336
|
if (injectWeapiGlobalName) {
|
|
@@ -28105,7 +28368,7 @@ function createBuildEndHook(state) {
|
|
|
28105
28368
|
// src/plugins/core/lifecycle/load.ts
|
|
28106
28369
|
init_esm_shims();
|
|
28107
28370
|
import { removeExtensionDeep as removeExtensionDeep11 } from "@weapp-core/shared";
|
|
28108
|
-
import
|
|
28371
|
+
import path54 from "pathe";
|
|
28109
28372
|
|
|
28110
28373
|
// src/plugins/utils/parse.ts
|
|
28111
28374
|
init_esm_shims();
|
|
@@ -28142,7 +28405,7 @@ function createOptionsHook(state) {
|
|
|
28142
28405
|
let scannedInput;
|
|
28143
28406
|
if (subPackageMeta) {
|
|
28144
28407
|
scannedInput = subPackageMeta.entries.reduce((acc, entry) => {
|
|
28145
|
-
acc[entry] =
|
|
28408
|
+
acc[entry] = path54.resolve(configService.absoluteSrcRoot, entry);
|
|
28146
28409
|
return acc;
|
|
28147
28410
|
}, {});
|
|
28148
28411
|
} else if (configService.weappLibConfig?.enabled) {
|
|
@@ -28285,8 +28548,8 @@ function createLoadHook(state) {
|
|
|
28285
28548
|
try {
|
|
28286
28549
|
const ast = parseJsLike(code);
|
|
28287
28550
|
let mutated = false;
|
|
28288
|
-
const rewritePath = (
|
|
28289
|
-
const object =
|
|
28551
|
+
const rewritePath = (path82) => {
|
|
28552
|
+
const object = path82.node?.object;
|
|
28290
28553
|
if (!object || object.type !== "Identifier") {
|
|
28291
28554
|
return;
|
|
28292
28555
|
}
|
|
@@ -28294,10 +28557,10 @@ function createLoadHook(state) {
|
|
|
28294
28557
|
if (!platformApiIdentifiers3.has(identifierName)) {
|
|
28295
28558
|
return;
|
|
28296
28559
|
}
|
|
28297
|
-
if (
|
|
28560
|
+
if (path82.scope?.hasBinding?.(identifierName)) {
|
|
28298
28561
|
return;
|
|
28299
28562
|
}
|
|
28300
|
-
|
|
28563
|
+
path82.node.object = {
|
|
28301
28564
|
type: "Identifier",
|
|
28302
28565
|
name: injectedApiIdentifier2
|
|
28303
28566
|
};
|
|
@@ -28442,8 +28705,8 @@ function replacePlatformApiAccess2(code, globalName) {
|
|
|
28442
28705
|
try {
|
|
28443
28706
|
const ast = parseJsLike(code);
|
|
28444
28707
|
let mutated = false;
|
|
28445
|
-
const rewritePath = (
|
|
28446
|
-
const object =
|
|
28708
|
+
const rewritePath = (path82) => {
|
|
28709
|
+
const object = path82.node?.object;
|
|
28447
28710
|
if (!object || object.type !== "Identifier") {
|
|
28448
28711
|
return;
|
|
28449
28712
|
}
|
|
@@ -28451,10 +28714,10 @@ function replacePlatformApiAccess2(code, globalName) {
|
|
|
28451
28714
|
if (!platformApiIdentifiers2.has(identifierName)) {
|
|
28452
28715
|
return;
|
|
28453
28716
|
}
|
|
28454
|
-
if (
|
|
28717
|
+
if (path82.scope?.hasBinding?.(identifierName)) {
|
|
28455
28718
|
return;
|
|
28456
28719
|
}
|
|
28457
|
-
|
|
28720
|
+
path82.node.object = {
|
|
28458
28721
|
type: "Identifier",
|
|
28459
28722
|
name: injectedApiIdentifier
|
|
28460
28723
|
};
|
|
@@ -28498,14 +28761,14 @@ function createTransformHook(state) {
|
|
|
28498
28761
|
|
|
28499
28762
|
// src/plugins/core/lifecycle/watch.ts
|
|
28500
28763
|
init_esm_shims();
|
|
28501
|
-
import
|
|
28764
|
+
import path59 from "pathe";
|
|
28502
28765
|
|
|
28503
28766
|
// src/plugins/css/shared/preprocessor.ts
|
|
28504
28767
|
init_esm_shims();
|
|
28505
28768
|
import { createHash as createHash2 } from "crypto";
|
|
28506
28769
|
import { createRequire as createRequire7 } from "module";
|
|
28507
28770
|
import fs25 from "fs-extra";
|
|
28508
|
-
import
|
|
28771
|
+
import path55 from "pathe";
|
|
28509
28772
|
import { preprocessCSS } from "vite";
|
|
28510
28773
|
|
|
28511
28774
|
// src/postcss/index.ts
|
|
@@ -28666,12 +28929,12 @@ async function processCssWithCache(code, configService) {
|
|
|
28666
28929
|
}
|
|
28667
28930
|
function dedupeAndNormalizeDependencies(base, dependencies) {
|
|
28668
28931
|
const seen = /* @__PURE__ */ new Set();
|
|
28669
|
-
const baseDir =
|
|
28932
|
+
const baseDir = path55.dirname(base);
|
|
28670
28933
|
for (const dep of dependencies) {
|
|
28671
28934
|
if (!dep) {
|
|
28672
28935
|
continue;
|
|
28673
28936
|
}
|
|
28674
|
-
const normalized =
|
|
28937
|
+
const normalized = path55.isAbsolute(dep) ? dep : path55.resolve(baseDir, dep);
|
|
28675
28938
|
seen.add(normalized);
|
|
28676
28939
|
}
|
|
28677
28940
|
return Array.from(seen);
|
|
@@ -28769,7 +29032,7 @@ init_esm_shims();
|
|
|
28769
29032
|
// src/plugins/utils/invalidateEntry/cssGraph.ts
|
|
28770
29033
|
init_esm_shims();
|
|
28771
29034
|
import fs26 from "fs";
|
|
28772
|
-
import
|
|
29035
|
+
import path56 from "pathe";
|
|
28773
29036
|
|
|
28774
29037
|
// src/plugins/utils/invalidateEntry/shared.ts
|
|
28775
29038
|
init_esm_shims();
|
|
@@ -28874,7 +29137,7 @@ async function extractCssImportDependencies(ctx, importer) {
|
|
|
28874
29137
|
}
|
|
28875
29138
|
cssImportRE.lastIndex = 0;
|
|
28876
29139
|
const dependencies = /* @__PURE__ */ new Set();
|
|
28877
|
-
const dir =
|
|
29140
|
+
const dir = path56.dirname(importer);
|
|
28878
29141
|
while (true) {
|
|
28879
29142
|
const match = cssImportRE.exec(cssContent);
|
|
28880
29143
|
if (!match) {
|
|
@@ -28886,9 +29149,9 @@ async function extractCssImportDependencies(ctx, importer) {
|
|
|
28886
29149
|
}
|
|
28887
29150
|
if (importProtocols.test(rawSpecifier)) {
|
|
28888
29151
|
if (rawSpecifier.startsWith("/")) {
|
|
28889
|
-
const absolute =
|
|
29152
|
+
const absolute = path56.resolve(ctx.configService.absoluteSrcRoot, rawSpecifier.slice(1));
|
|
28890
29153
|
dependencies.add(absolute);
|
|
28891
|
-
const ext2 =
|
|
29154
|
+
const ext2 = path56.extname(absolute);
|
|
28892
29155
|
if (ext2) {
|
|
28893
29156
|
dependencies.add(absolute.slice(0, -ext2.length));
|
|
28894
29157
|
}
|
|
@@ -28897,7 +29160,7 @@ async function extractCssImportDependencies(ctx, importer) {
|
|
|
28897
29160
|
}
|
|
28898
29161
|
let specifier = rawSpecifier;
|
|
28899
29162
|
if (specifier.startsWith("@/")) {
|
|
28900
|
-
specifier =
|
|
29163
|
+
specifier = path56.join(ctx.configService.absoluteSrcRoot, specifier.slice(2));
|
|
28901
29164
|
} else if (specifier === "@") {
|
|
28902
29165
|
specifier = ctx.configService.absoluteSrcRoot;
|
|
28903
29166
|
}
|
|
@@ -28905,9 +29168,9 @@ async function extractCssImportDependencies(ctx, importer) {
|
|
|
28905
29168
|
specifier = specifier.slice(1);
|
|
28906
29169
|
}
|
|
28907
29170
|
const cleaned = specifier.replace(/[?#].*$/, "");
|
|
28908
|
-
const resolved =
|
|
29171
|
+
const resolved = path56.resolve(dir, cleaned);
|
|
28909
29172
|
dependencies.add(resolved);
|
|
28910
|
-
const ext =
|
|
29173
|
+
const ext = path56.extname(resolved);
|
|
28911
29174
|
if (!ext) {
|
|
28912
29175
|
dependencies.add(resolved);
|
|
28913
29176
|
} else {
|
|
@@ -28926,7 +29189,7 @@ function collectCssImporters(ctx, dependency) {
|
|
|
28926
29189
|
matches2.add(importer);
|
|
28927
29190
|
}
|
|
28928
29191
|
}
|
|
28929
|
-
const ext =
|
|
29192
|
+
const ext = path56.extname(normalizedDependency);
|
|
28930
29193
|
if (ext) {
|
|
28931
29194
|
const base = normalizedDependency.slice(0, -ext.length);
|
|
28932
29195
|
const baseMatches = graph.dependencyToImporters.get(base);
|
|
@@ -28960,7 +29223,7 @@ async function collectAffectedScriptsAndImporters(ctx, startCssFile) {
|
|
|
28960
29223
|
continue;
|
|
28961
29224
|
}
|
|
28962
29225
|
visitedCss.add(current2);
|
|
28963
|
-
const ext =
|
|
29226
|
+
const ext = path56.extname(current2);
|
|
28964
29227
|
if (ext) {
|
|
28965
29228
|
const base = current2.slice(0, -ext.length);
|
|
28966
29229
|
const script = await resolveScriptForCss(scriptCache, base);
|
|
@@ -28987,10 +29250,10 @@ function cleanupCssImporterGraph(ctx, importer) {
|
|
|
28987
29250
|
|
|
28988
29251
|
// src/plugins/utils/invalidateEntry/sidecar.ts
|
|
28989
29252
|
init_esm_shims();
|
|
28990
|
-
import
|
|
29253
|
+
import path57 from "pathe";
|
|
28991
29254
|
async function invalidateEntryForSidecar(ctx, filePath, event = "update") {
|
|
28992
29255
|
const configSuffix = configSuffixes.find((suffix) => filePath.endsWith(suffix));
|
|
28993
|
-
const ext =
|
|
29256
|
+
const ext = path57.extname(filePath);
|
|
28994
29257
|
const normalizedPath = normalizePath(filePath);
|
|
28995
29258
|
let scriptBasePath;
|
|
28996
29259
|
if (configSuffix) {
|
|
@@ -29055,13 +29318,13 @@ async function invalidateEntryForSidecar(ctx, filePath, event = "update") {
|
|
|
29055
29318
|
init_esm_shims();
|
|
29056
29319
|
import fs27 from "fs";
|
|
29057
29320
|
import process7 from "process";
|
|
29058
|
-
import
|
|
29321
|
+
import path58 from "pathe";
|
|
29059
29322
|
function ensureSidecarWatcher(ctx, rootDir) {
|
|
29060
29323
|
if (!ctx.configService.isDev || !rootDir || process7.env.VITEST === "true" || process7.env.NODE_ENV === "test" || process7.env.WEAPP_VITE_DISABLE_SIDECAR_WATCH === "1") {
|
|
29061
29324
|
return;
|
|
29062
29325
|
}
|
|
29063
29326
|
const { sidecarWatcherMap } = ctx.runtimeState.watcher;
|
|
29064
|
-
const absRoot =
|
|
29327
|
+
const absRoot = path58.normalize(rootDir);
|
|
29065
29328
|
if (!fs27.existsSync(absRoot)) {
|
|
29066
29329
|
return;
|
|
29067
29330
|
}
|
|
@@ -29073,7 +29336,7 @@ function ensureSidecarWatcher(ctx, rootDir) {
|
|
|
29073
29336
|
if (!isSidecarFile(filePath)) {
|
|
29074
29337
|
return;
|
|
29075
29338
|
}
|
|
29076
|
-
const ext =
|
|
29339
|
+
const ext = path58.extname(filePath);
|
|
29077
29340
|
const isCssFile = Boolean(ext && watchedCssExts.has(ext));
|
|
29078
29341
|
if (isCssFile && (event === "create" || event === "update")) {
|
|
29079
29342
|
void extractCssImportDependencies(ctx, filePath);
|
|
@@ -29094,9 +29357,9 @@ function ensureSidecarWatcher(ctx, rootDir) {
|
|
|
29094
29357
|
}
|
|
29095
29358
|
};
|
|
29096
29359
|
const patterns = [
|
|
29097
|
-
...configExtensions.map((ext) =>
|
|
29098
|
-
...supportedCssLangs.map((ext) =>
|
|
29099
|
-
...templateExtensions.map((ext) =>
|
|
29360
|
+
...configExtensions.map((ext) => path58.join(absRoot, `**/*.${ext}`)),
|
|
29361
|
+
...supportedCssLangs.map((ext) => path58.join(absRoot, `**/*.${ext}`)),
|
|
29362
|
+
...templateExtensions.map((ext) => path58.join(absRoot, `**/*.${ext}`))
|
|
29100
29363
|
];
|
|
29101
29364
|
const ignoredMatcher = createSidecarIgnoredMatcher(ctx, absRoot);
|
|
29102
29365
|
const watcher = chokidar_default.watch(patterns, {
|
|
@@ -29112,15 +29375,15 @@ function ensureSidecarWatcher(ctx, rootDir) {
|
|
|
29112
29375
|
if (!input) {
|
|
29113
29376
|
return;
|
|
29114
29377
|
}
|
|
29115
|
-
const normalizedPath =
|
|
29378
|
+
const normalizedPath = path58.normalize(input);
|
|
29116
29379
|
if (!options?.silent) {
|
|
29117
29380
|
default2.info(`[watch:${event}] ${ctx.configService.relativeCwd(normalizedPath)}`);
|
|
29118
29381
|
}
|
|
29119
29382
|
handleSidecarChange(event, normalizedPath, isReady);
|
|
29120
29383
|
};
|
|
29121
|
-
watcher.on("add", (
|
|
29122
|
-
watcher.on("change", (
|
|
29123
|
-
watcher.on("unlink", (
|
|
29384
|
+
watcher.on("add", (path82) => forwardChange("create", path82));
|
|
29385
|
+
watcher.on("change", (path82) => forwardChange("update", path82));
|
|
29386
|
+
watcher.on("unlink", (path82) => forwardChange("delete", path82));
|
|
29124
29387
|
watcher.on("raw", (eventName, rawPath, details) => {
|
|
29125
29388
|
if (eventName !== "rename") {
|
|
29126
29389
|
return;
|
|
@@ -29130,7 +29393,7 @@ function ensureSidecarWatcher(ctx, rootDir) {
|
|
|
29130
29393
|
return;
|
|
29131
29394
|
}
|
|
29132
29395
|
const baseDir = typeof details === "object" && details && "watchedPath" in details ? details.watchedPath ?? absRoot : absRoot;
|
|
29133
|
-
const resolved =
|
|
29396
|
+
const resolved = path58.isAbsolute(candidate) ? candidate : path58.resolve(baseDir, candidate);
|
|
29134
29397
|
if (ignoredMatcher(resolved)) {
|
|
29135
29398
|
return;
|
|
29136
29399
|
}
|
|
@@ -29158,22 +29421,22 @@ function ensureSidecarWatcher(ctx, rootDir) {
|
|
|
29158
29421
|
function createSidecarIgnoredMatcher(ctx, rootDir) {
|
|
29159
29422
|
const configService = ctx.configService;
|
|
29160
29423
|
const ignoredRoots = /* @__PURE__ */ new Set();
|
|
29161
|
-
const normalizedRoot =
|
|
29424
|
+
const normalizedRoot = path58.normalize(rootDir);
|
|
29162
29425
|
for (const dirName of defaultIgnoredDirNames) {
|
|
29163
|
-
ignoredRoots.add(
|
|
29426
|
+
ignoredRoots.add(path58.join(normalizedRoot, dirName));
|
|
29164
29427
|
}
|
|
29165
29428
|
if (configService?.mpDistRoot) {
|
|
29166
|
-
ignoredRoots.add(
|
|
29429
|
+
ignoredRoots.add(path58.resolve(configService.cwd, configService.mpDistRoot));
|
|
29167
29430
|
} else {
|
|
29168
|
-
ignoredRoots.add(
|
|
29431
|
+
ignoredRoots.add(path58.join(normalizedRoot, "dist"));
|
|
29169
29432
|
}
|
|
29170
29433
|
if (configService?.outDir) {
|
|
29171
|
-
ignoredRoots.add(
|
|
29434
|
+
ignoredRoots.add(path58.resolve(configService.cwd, configService.outDir));
|
|
29172
29435
|
}
|
|
29173
29436
|
return (candidate) => {
|
|
29174
|
-
const normalized =
|
|
29437
|
+
const normalized = path58.normalize(candidate);
|
|
29175
29438
|
for (const ignored of ignoredRoots) {
|
|
29176
|
-
if (normalized === ignored || normalized.startsWith(`${ignored}${
|
|
29439
|
+
if (normalized === ignored || normalized.startsWith(`${ignored}${path58.sep}`)) {
|
|
29177
29440
|
return true;
|
|
29178
29441
|
}
|
|
29179
29442
|
}
|
|
@@ -29196,7 +29459,7 @@ function createBuildStartHook(state) {
|
|
|
29196
29459
|
ensureSidecarWatcher(ctx, configService.absolutePluginRoot);
|
|
29197
29460
|
}
|
|
29198
29461
|
} else {
|
|
29199
|
-
const rootDir = subPackageMeta ?
|
|
29462
|
+
const rootDir = subPackageMeta ? path59.resolve(configService.absoluteSrcRoot, subPackageMeta.subPackage.root) : configService.absoluteSrcRoot;
|
|
29200
29463
|
ensureSidecarWatcher(ctx, rootDir);
|
|
29201
29464
|
if (!subPackageMeta && configService.absolutePluginRoot) {
|
|
29202
29465
|
ensureSidecarWatcher(ctx, configService.absolutePluginRoot);
|
|
@@ -29227,7 +29490,7 @@ function createWatchChangeHook(state) {
|
|
|
29227
29490
|
}
|
|
29228
29491
|
if (isTemplateFile2 || configSuffix || isStyleFile2) {
|
|
29229
29492
|
const basePath = configSuffix ? normalizedId.slice(0, -configSuffix.length) : (() => {
|
|
29230
|
-
const ext =
|
|
29493
|
+
const ext = path59.extname(normalizedId);
|
|
29231
29494
|
return ext ? normalizedId.slice(0, -ext.length) : normalizedId;
|
|
29232
29495
|
})();
|
|
29233
29496
|
const primaryScript = await findJsEntry(basePath);
|
|
@@ -29266,7 +29529,7 @@ function createWatchChangeHook(state) {
|
|
|
29266
29529
|
let shouldMarkProjectConfigDirty = relativeCwd === projectConfigFileName || relativeCwd === projectPrivateConfigFileName;
|
|
29267
29530
|
if (isMultiPlatformEnabled) {
|
|
29268
29531
|
const projectConfigRoot = typeof multiPlatformConfig === "object" && multiPlatformConfig.projectConfigRoot?.trim() ? multiPlatformConfig.projectConfigRoot.trim() : "config";
|
|
29269
|
-
const platformConfigDir =
|
|
29532
|
+
const platformConfigDir = path59.join(projectConfigRoot, platform);
|
|
29270
29533
|
const platformConfigPrefix = `${platformConfigDir}/`;
|
|
29271
29534
|
shouldMarkProjectConfigDirty = relativeCwd.startsWith(platformConfigPrefix);
|
|
29272
29535
|
}
|
|
@@ -29316,7 +29579,7 @@ function createCoreLifecyclePlugin(state) {
|
|
|
29316
29579
|
|
|
29317
29580
|
// src/plugins/core/requireAnalysis.ts
|
|
29318
29581
|
init_esm_shims();
|
|
29319
|
-
import
|
|
29582
|
+
import path60 from "pathe";
|
|
29320
29583
|
|
|
29321
29584
|
// src/plugins/utils/ast.ts
|
|
29322
29585
|
init_esm_shims();
|
|
@@ -29377,7 +29640,7 @@ function createRequireAnalysisPlugin(state) {
|
|
|
29377
29640
|
return;
|
|
29378
29641
|
}
|
|
29379
29642
|
for (const requireModule of requireTokens) {
|
|
29380
|
-
const absPath =
|
|
29643
|
+
const absPath = path60.resolve(path60.dirname(moduleInfo.id), requireModule.value);
|
|
29381
29644
|
const resolved = await this.resolve(absPath, moduleInfo.id);
|
|
29382
29645
|
if (!resolved) {
|
|
29383
29646
|
continue;
|
|
@@ -29471,11 +29734,11 @@ function weappVite(ctx, subPackageMeta) {
|
|
|
29471
29734
|
// src/plugins/css.ts
|
|
29472
29735
|
init_esm_shims();
|
|
29473
29736
|
import fs28 from "fs-extra";
|
|
29474
|
-
import
|
|
29737
|
+
import path62 from "pathe";
|
|
29475
29738
|
|
|
29476
29739
|
// src/plugins/css/shared/sharedStyles.ts
|
|
29477
29740
|
init_esm_shims();
|
|
29478
|
-
import
|
|
29741
|
+
import path61 from "pathe";
|
|
29479
29742
|
import picomatch2 from "picomatch";
|
|
29480
29743
|
var styleMatcherCache = /* @__PURE__ */ new WeakMap();
|
|
29481
29744
|
function collectSharedStyleEntries(ctx, configService) {
|
|
@@ -29584,7 +29847,7 @@ function findSharedStylesForModule(modulePath, fileName, sharedStyles) {
|
|
|
29584
29847
|
}
|
|
29585
29848
|
function resolveImportSpecifiers(fileName, entries) {
|
|
29586
29849
|
const posixFileName = toPosixPath(fileName);
|
|
29587
|
-
const dir =
|
|
29850
|
+
const dir = path61.posix.dirname(posixFileName);
|
|
29588
29851
|
const seen = /* @__PURE__ */ new Set();
|
|
29589
29852
|
const specifiers = [];
|
|
29590
29853
|
for (const entry of entries) {
|
|
@@ -29592,8 +29855,8 @@ function resolveImportSpecifiers(fileName, entries) {
|
|
|
29592
29855
|
if (target === posixFileName) {
|
|
29593
29856
|
continue;
|
|
29594
29857
|
}
|
|
29595
|
-
const relative3 =
|
|
29596
|
-
let specifier = relative3 ||
|
|
29858
|
+
const relative3 = path61.posix.relative(dir, target);
|
|
29859
|
+
let specifier = relative3 || path61.posix.basename(target);
|
|
29597
29860
|
if (!specifier || specifier === ".") {
|
|
29598
29861
|
continue;
|
|
29599
29862
|
}
|
|
@@ -29697,7 +29960,7 @@ async function handleBundleEntry(bundle, bundleKey, asset2, configService, share
|
|
|
29697
29960
|
};
|
|
29698
29961
|
if (bundleKey.endsWith(".wxss")) {
|
|
29699
29962
|
const [rawOriginal] = asset2.originalFileNames ?? [];
|
|
29700
|
-
const absOriginal = rawOriginal ? toAbsolute(rawOriginal) :
|
|
29963
|
+
const absOriginal = rawOriginal ? toAbsolute(rawOriginal) : path62.resolve(configService.absoluteSrcRoot, bundleKey);
|
|
29701
29964
|
const fileName = configService.relativeOutputPath(absOriginal);
|
|
29702
29965
|
if (fileName) {
|
|
29703
29966
|
emitted.add(toPosixPath(fileName));
|
|
@@ -29916,7 +30179,7 @@ init_esm_shims();
|
|
|
29916
30179
|
init_esm_shims();
|
|
29917
30180
|
import { createRequire as createRequire8 } from "module";
|
|
29918
30181
|
import process8 from "process";
|
|
29919
|
-
import
|
|
30182
|
+
import path63 from "pathe";
|
|
29920
30183
|
|
|
29921
30184
|
// src/plugins/vue/transform/styleRequest.ts
|
|
29922
30185
|
init_esm_shims();
|
|
@@ -30006,7 +30269,7 @@ function ensureWevuInstalled(ctx) {
|
|
|
30006
30269
|
}
|
|
30007
30270
|
const configService = ctx.configService;
|
|
30008
30271
|
const cwd = configService?.cwd ?? process8.cwd();
|
|
30009
|
-
const require3 = createRequire8(
|
|
30272
|
+
const require3 = createRequire8(path63.join(cwd, "package.json"));
|
|
30010
30273
|
try {
|
|
30011
30274
|
require3.resolve("wevu");
|
|
30012
30275
|
wevuInstallState = "present";
|
|
@@ -30095,12 +30358,198 @@ init_esm_shims();
|
|
|
30095
30358
|
// src/plugins/vue/transform/plugin.ts
|
|
30096
30359
|
init_esm_shims();
|
|
30097
30360
|
import fs33 from "fs-extra";
|
|
30098
|
-
import
|
|
30361
|
+
import path68 from "pathe";
|
|
30099
30362
|
import { compileJsxFile as compileJsxFile2, compileVueFile as compileVueFile2 } from "wevu/compiler";
|
|
30100
30363
|
|
|
30364
|
+
// src/plugins/performance/onPageScrollDiagnostics.ts
|
|
30365
|
+
init_esm_shims();
|
|
30366
|
+
function isStaticPropertyName(key) {
|
|
30367
|
+
if (key.type === "Identifier") {
|
|
30368
|
+
return key.name;
|
|
30369
|
+
}
|
|
30370
|
+
if (key.type === "StringLiteral") {
|
|
30371
|
+
return key.value;
|
|
30372
|
+
}
|
|
30373
|
+
return void 0;
|
|
30374
|
+
}
|
|
30375
|
+
function getMemberExpressionPropertyName(node) {
|
|
30376
|
+
if (node.computed) {
|
|
30377
|
+
return node.property.type === "StringLiteral" ? node.property.value : void 0;
|
|
30378
|
+
}
|
|
30379
|
+
return node.property.type === "Identifier" ? node.property.name : void 0;
|
|
30380
|
+
}
|
|
30381
|
+
function isOnPageScrollCallee(callee, hookNames, namespaceImports) {
|
|
30382
|
+
if (callee.type === "Identifier") {
|
|
30383
|
+
return hookNames.has(callee.name);
|
|
30384
|
+
}
|
|
30385
|
+
if (callee.type === "MemberExpression" || callee.type === "OptionalMemberExpression") {
|
|
30386
|
+
const object = callee.object;
|
|
30387
|
+
const propName = getMemberExpressionPropertyName(callee);
|
|
30388
|
+
return object.type === "Identifier" && namespaceImports.has(object.name) && propName === "onPageScroll";
|
|
30389
|
+
}
|
|
30390
|
+
return false;
|
|
30391
|
+
}
|
|
30392
|
+
function getCallExpressionCalleeName(callee) {
|
|
30393
|
+
if (callee.type === "Identifier") {
|
|
30394
|
+
return callee.name;
|
|
30395
|
+
}
|
|
30396
|
+
if (callee.type === "MemberExpression" || callee.type === "OptionalMemberExpression") {
|
|
30397
|
+
return getMemberExpressionPropertyName(callee);
|
|
30398
|
+
}
|
|
30399
|
+
return void 0;
|
|
30400
|
+
}
|
|
30401
|
+
function collectPageScrollInspection(functionPath, node) {
|
|
30402
|
+
const inspection = {
|
|
30403
|
+
empty: node.body.type === "BlockStatement" && node.body.body.length === 0,
|
|
30404
|
+
hasSetDataCall: false,
|
|
30405
|
+
syncApis: /* @__PURE__ */ new Set()
|
|
30406
|
+
};
|
|
30407
|
+
functionPath.traverse({
|
|
30408
|
+
Function(innerPath) {
|
|
30409
|
+
if (innerPath !== functionPath) {
|
|
30410
|
+
innerPath.skip();
|
|
30411
|
+
}
|
|
30412
|
+
},
|
|
30413
|
+
CallExpression(callPath) {
|
|
30414
|
+
const callee = callPath.node.callee;
|
|
30415
|
+
const calleeName = getCallExpressionCalleeName(callee);
|
|
30416
|
+
if (calleeName === "setData") {
|
|
30417
|
+
inspection.hasSetDataCall = true;
|
|
30418
|
+
}
|
|
30419
|
+
if (callee.type === "MemberExpression" || callee.type === "OptionalMemberExpression") {
|
|
30420
|
+
const object = callee.object;
|
|
30421
|
+
if (object.type === "Identifier" && object.name === "wx") {
|
|
30422
|
+
const propertyName = getMemberExpressionPropertyName(callee);
|
|
30423
|
+
if (propertyName && propertyName.endsWith("Sync")) {
|
|
30424
|
+
inspection.syncApis.add(`wx.${propertyName}`);
|
|
30425
|
+
}
|
|
30426
|
+
}
|
|
30427
|
+
}
|
|
30428
|
+
},
|
|
30429
|
+
OptionalCallExpression(callPath) {
|
|
30430
|
+
const callee = callPath.node.callee;
|
|
30431
|
+
const calleeName = getCallExpressionCalleeName(callee);
|
|
30432
|
+
if (calleeName === "setData") {
|
|
30433
|
+
inspection.hasSetDataCall = true;
|
|
30434
|
+
}
|
|
30435
|
+
if (callee.type === "MemberExpression" || callee.type === "OptionalMemberExpression") {
|
|
30436
|
+
const object = callee.object;
|
|
30437
|
+
if (object.type === "Identifier" && object.name === "wx") {
|
|
30438
|
+
const propertyName = getMemberExpressionPropertyName(callee);
|
|
30439
|
+
if (propertyName && propertyName.endsWith("Sync")) {
|
|
30440
|
+
inspection.syncApis.add(`wx.${propertyName}`);
|
|
30441
|
+
}
|
|
30442
|
+
}
|
|
30443
|
+
}
|
|
30444
|
+
}
|
|
30445
|
+
});
|
|
30446
|
+
return inspection;
|
|
30447
|
+
}
|
|
30448
|
+
function createWarningPrefix(filename, line, column) {
|
|
30449
|
+
const pos = typeof line === "number" && typeof column === "number" ? `${line}:${column}` : "?:?";
|
|
30450
|
+
return `[weapp-vite][onPageScroll] ${filename}:${pos}`;
|
|
30451
|
+
}
|
|
30452
|
+
function collectOnPageScrollPerformanceWarnings(code, filename) {
|
|
30453
|
+
let ast;
|
|
30454
|
+
try {
|
|
30455
|
+
ast = parseJsLike(code);
|
|
30456
|
+
} catch {
|
|
30457
|
+
return [];
|
|
30458
|
+
}
|
|
30459
|
+
const onPageScrollHookNames = /* @__PURE__ */ new Set(["onPageScroll"]);
|
|
30460
|
+
const namespaceImports = /* @__PURE__ */ new Set();
|
|
30461
|
+
for (const statement of ast.program.body) {
|
|
30462
|
+
if (statement.type !== "ImportDeclaration" || statement.source.value !== "wevu") {
|
|
30463
|
+
continue;
|
|
30464
|
+
}
|
|
30465
|
+
for (const specifier of statement.specifiers) {
|
|
30466
|
+
if (specifier.type === "ImportSpecifier" && specifier.imported.type === "Identifier" && specifier.imported.name === "onPageScroll") {
|
|
30467
|
+
onPageScrollHookNames.add(specifier.local.name);
|
|
30468
|
+
}
|
|
30469
|
+
if (specifier.type === "ImportNamespaceSpecifier") {
|
|
30470
|
+
namespaceImports.add(specifier.local.name);
|
|
30471
|
+
}
|
|
30472
|
+
}
|
|
30473
|
+
}
|
|
30474
|
+
const warnings = [];
|
|
30475
|
+
const warningSet = /* @__PURE__ */ new Set();
|
|
30476
|
+
const addWarning = (warning) => {
|
|
30477
|
+
if (warningSet.has(warning)) {
|
|
30478
|
+
return;
|
|
30479
|
+
}
|
|
30480
|
+
warningSet.add(warning);
|
|
30481
|
+
warnings.push(warning);
|
|
30482
|
+
};
|
|
30483
|
+
const reportInspection = (functionPath, node, sourceLabel) => {
|
|
30484
|
+
const inspection = collectPageScrollInspection(functionPath, node);
|
|
30485
|
+
const line = node.loc?.start.line;
|
|
30486
|
+
const column = typeof node.loc?.start.column === "number" ? node.loc.start.column + 1 : void 0;
|
|
30487
|
+
const prefix = createWarningPrefix(filename, line, column);
|
|
30488
|
+
if (inspection.empty) {
|
|
30489
|
+
addWarning(`${prefix} \u68C0\u6D4B\u5230\u7A7A\u7684 ${sourceLabel} \u56DE\u8C03\uFF0C\u5EFA\u8BAE\u79FB\u9664\u65E0\u6548\u76D1\u542C\u4EE5\u964D\u4F4E\u6EDA\u52A8\u65F6\u8C03\u5EA6\u5F00\u9500\u3002`);
|
|
30490
|
+
}
|
|
30491
|
+
if (inspection.hasSetDataCall) {
|
|
30492
|
+
addWarning(`${prefix} \u68C0\u6D4B\u5230 ${sourceLabel} \u5185\u8C03\u7528 setData\uFF0C\u5EFA\u8BAE\u6539\u7528\u8282\u6D41\u3001IntersectionObserver \u6216\u5408\u5E76\u66F4\u65B0\u3002`);
|
|
30493
|
+
}
|
|
30494
|
+
for (const syncApi of inspection.syncApis) {
|
|
30495
|
+
addWarning(`${prefix} \u68C0\u6D4B\u5230 ${sourceLabel} \u5185\u8C03\u7528\u540C\u6B65 API\uFF08${syncApi}\uFF09\uFF0C\u53EF\u80FD\u963B\u585E\u6E32\u67D3\u7EBF\u7A0B\u3002`);
|
|
30496
|
+
}
|
|
30497
|
+
};
|
|
30498
|
+
traverse(ast, {
|
|
30499
|
+
ObjectMethod(path82) {
|
|
30500
|
+
const keyName = isStaticPropertyName(path82.node.key);
|
|
30501
|
+
if (keyName !== "onPageScroll") {
|
|
30502
|
+
return;
|
|
30503
|
+
}
|
|
30504
|
+
reportInspection(path82, path82.node, "onPageScroll");
|
|
30505
|
+
},
|
|
30506
|
+
ObjectProperty(path82) {
|
|
30507
|
+
if (path82.node.computed) {
|
|
30508
|
+
return;
|
|
30509
|
+
}
|
|
30510
|
+
const keyName = isStaticPropertyName(path82.node.key);
|
|
30511
|
+
if (keyName !== "onPageScroll") {
|
|
30512
|
+
return;
|
|
30513
|
+
}
|
|
30514
|
+
const value = path82.node.value;
|
|
30515
|
+
if (value.type !== "FunctionExpression" && value.type !== "ArrowFunctionExpression") {
|
|
30516
|
+
return;
|
|
30517
|
+
}
|
|
30518
|
+
reportInspection(path82.get("value"), value, "onPageScroll");
|
|
30519
|
+
},
|
|
30520
|
+
CallExpression(path82) {
|
|
30521
|
+
if (!isOnPageScrollCallee(path82.node.callee, onPageScrollHookNames, namespaceImports)) {
|
|
30522
|
+
return;
|
|
30523
|
+
}
|
|
30524
|
+
const arg0 = path82.node.arguments[0];
|
|
30525
|
+
if (!arg0 || arg0.type === "SpreadElement") {
|
|
30526
|
+
return;
|
|
30527
|
+
}
|
|
30528
|
+
if (arg0.type !== "FunctionExpression" && arg0.type !== "ArrowFunctionExpression") {
|
|
30529
|
+
return;
|
|
30530
|
+
}
|
|
30531
|
+
reportInspection(path82.get("arguments.0"), arg0, "onPageScroll(...)");
|
|
30532
|
+
},
|
|
30533
|
+
OptionalCallExpression(path82) {
|
|
30534
|
+
if (!isOnPageScrollCallee(path82.node.callee, onPageScrollHookNames, namespaceImports)) {
|
|
30535
|
+
return;
|
|
30536
|
+
}
|
|
30537
|
+
const arg0 = path82.node.arguments[0];
|
|
30538
|
+
if (!arg0 || arg0.type === "SpreadElement") {
|
|
30539
|
+
return;
|
|
30540
|
+
}
|
|
30541
|
+
if (arg0.type !== "FunctionExpression" && arg0.type !== "ArrowFunctionExpression") {
|
|
30542
|
+
return;
|
|
30543
|
+
}
|
|
30544
|
+
reportInspection(path82.get("arguments.0"), arg0, "onPageScroll(...)");
|
|
30545
|
+
}
|
|
30546
|
+
});
|
|
30547
|
+
return warnings;
|
|
30548
|
+
}
|
|
30549
|
+
|
|
30101
30550
|
// src/plugins/wevu.ts
|
|
30102
30551
|
init_esm_shims();
|
|
30103
|
-
import
|
|
30552
|
+
import path64 from "pathe";
|
|
30104
30553
|
import {
|
|
30105
30554
|
createPageEntryMatcher,
|
|
30106
30555
|
injectWevuPageFeaturesInJsWithResolver
|
|
@@ -30180,12 +30629,15 @@ function createWevuAutoPageFeaturesPlugin(ctx) {
|
|
|
30180
30629
|
return null;
|
|
30181
30630
|
}
|
|
30182
30631
|
const filename = toAbsoluteId(sourceId, configService, void 0, { base: "cwd" });
|
|
30183
|
-
if (!filename || !
|
|
30632
|
+
if (!filename || !path64.isAbsolute(filename)) {
|
|
30184
30633
|
return null;
|
|
30185
30634
|
}
|
|
30186
30635
|
if (!await pageMatcher.isPageFile(filename)) {
|
|
30187
30636
|
return null;
|
|
30188
30637
|
}
|
|
30638
|
+
for (const warning of collectOnPageScrollPerformanceWarnings(code, filename)) {
|
|
30639
|
+
default2.warn(warning);
|
|
30640
|
+
}
|
|
30189
30641
|
const result = await injectWevuPageFeaturesInJsWithResolver(code, {
|
|
30190
30642
|
id: filename,
|
|
30191
30643
|
resolver: createViteResolverAdapter(
|
|
@@ -32957,7 +33409,7 @@ function scanWxml(wxml, options) {
|
|
|
32957
33409
|
|
|
32958
33410
|
// src/plugins/vue/transform/classStyle.ts
|
|
32959
33411
|
init_esm_shims();
|
|
32960
|
-
import
|
|
33412
|
+
import path65 from "pathe";
|
|
32961
33413
|
import { resolveClassStyleWxsLocation } from "wevu/compiler";
|
|
32962
33414
|
function resolveClassStylePackageRoot(ctx, relativeBase, configService) {
|
|
32963
33415
|
const currentRoot = normalizeRoot(configService.currentSubPackageRoot ?? "");
|
|
@@ -32983,7 +33435,7 @@ function resolveClassStylePackageRoot(ctx, relativeBase, configService) {
|
|
|
32983
33435
|
function resolveClassStyleWxsLocationForBase(ctx, relativeBase, extension, configService) {
|
|
32984
33436
|
const classStyleWxsShared = configService.weappViteConfig?.vue?.template?.classStyleWxsShared ?? true;
|
|
32985
33437
|
const packageRoot = classStyleWxsShared ? resolveClassStylePackageRoot(ctx, relativeBase, configService) : (() => {
|
|
32986
|
-
const dir =
|
|
33438
|
+
const dir = path65.posix.dirname(toPosixPath(relativeBase));
|
|
32987
33439
|
return dir === "." ? "" : dir;
|
|
32988
33440
|
})();
|
|
32989
33441
|
return resolveClassStyleWxsLocation({ relativeBase, extension, packageRoot });
|
|
@@ -33041,6 +33493,92 @@ function createUsingComponentPathResolver(ctx, configService, reExportResolution
|
|
|
33041
33493
|
};
|
|
33042
33494
|
}
|
|
33043
33495
|
|
|
33496
|
+
// src/plugins/vue/transform/wevuPreset.ts
|
|
33497
|
+
init_esm_shims();
|
|
33498
|
+
var PERFORMANCE_PRESET_DEFAULTS = {
|
|
33499
|
+
app: {
|
|
33500
|
+
setData: {
|
|
33501
|
+
strategy: "patch",
|
|
33502
|
+
suspendWhenHidden: true,
|
|
33503
|
+
diagnostics: "fallback",
|
|
33504
|
+
highFrequencyWarning: {
|
|
33505
|
+
enabled: true,
|
|
33506
|
+
devOnly: true
|
|
33507
|
+
}
|
|
33508
|
+
}
|
|
33509
|
+
},
|
|
33510
|
+
component: {
|
|
33511
|
+
setData: {
|
|
33512
|
+
strategy: "patch",
|
|
33513
|
+
suspendWhenHidden: true,
|
|
33514
|
+
diagnostics: "fallback",
|
|
33515
|
+
highFrequencyWarning: {
|
|
33516
|
+
enabled: true,
|
|
33517
|
+
devOnly: true
|
|
33518
|
+
}
|
|
33519
|
+
}
|
|
33520
|
+
}
|
|
33521
|
+
};
|
|
33522
|
+
function getPlainRecord(value) {
|
|
33523
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
33524
|
+
return void 0;
|
|
33525
|
+
}
|
|
33526
|
+
return value;
|
|
33527
|
+
}
|
|
33528
|
+
function mergeDefaults(defaults, options) {
|
|
33529
|
+
if (!defaults) {
|
|
33530
|
+
return options;
|
|
33531
|
+
}
|
|
33532
|
+
if (!options) {
|
|
33533
|
+
return defaults;
|
|
33534
|
+
}
|
|
33535
|
+
const merged = {
|
|
33536
|
+
...defaults,
|
|
33537
|
+
...options
|
|
33538
|
+
};
|
|
33539
|
+
const defaultSetData = getPlainRecord(defaults.setData);
|
|
33540
|
+
const optionSetData = getPlainRecord(options.setData);
|
|
33541
|
+
if (defaultSetData || optionSetData) {
|
|
33542
|
+
merged.setData = {
|
|
33543
|
+
...defaultSetData ?? {},
|
|
33544
|
+
...optionSetData ?? {}
|
|
33545
|
+
};
|
|
33546
|
+
}
|
|
33547
|
+
const defaultOptions3 = getPlainRecord(defaults.options);
|
|
33548
|
+
const optionOptions = getPlainRecord(options.options);
|
|
33549
|
+
if (defaultOptions3 || optionOptions) {
|
|
33550
|
+
merged.options = {
|
|
33551
|
+
...defaultOptions3 ?? {},
|
|
33552
|
+
...optionOptions ?? {}
|
|
33553
|
+
};
|
|
33554
|
+
}
|
|
33555
|
+
return merged;
|
|
33556
|
+
}
|
|
33557
|
+
function mergeWevuDefaults(base, next) {
|
|
33558
|
+
return {
|
|
33559
|
+
app: mergeDefaults(base.app, next.app),
|
|
33560
|
+
component: mergeDefaults(base.component, next.component)
|
|
33561
|
+
};
|
|
33562
|
+
}
|
|
33563
|
+
function resolveWevuPreset(config) {
|
|
33564
|
+
return config?.wevu?.preset;
|
|
33565
|
+
}
|
|
33566
|
+
function resolveWevuDefaultsWithPreset(config) {
|
|
33567
|
+
const userDefaults = config?.wevu?.defaults;
|
|
33568
|
+
const preset = resolveWevuPreset(config);
|
|
33569
|
+
if (preset !== "performance") {
|
|
33570
|
+
return userDefaults;
|
|
33571
|
+
}
|
|
33572
|
+
return mergeWevuDefaults(PERFORMANCE_PRESET_DEFAULTS, userDefaults ?? {});
|
|
33573
|
+
}
|
|
33574
|
+
function isAutoSetDataPickEnabledWithPreset(config) {
|
|
33575
|
+
const explicit = config?.wevu?.autoSetDataPick;
|
|
33576
|
+
if (typeof explicit === "boolean") {
|
|
33577
|
+
return explicit;
|
|
33578
|
+
}
|
|
33579
|
+
return resolveWevuPreset(config) === "performance";
|
|
33580
|
+
}
|
|
33581
|
+
|
|
33044
33582
|
// src/plugins/vue/transform/compileOptions.ts
|
|
33045
33583
|
function createCompileVueFileOptions(ctx, pluginCtx, vuePath, isPage, isApp, configService, state) {
|
|
33046
33584
|
const scopedSlotsCompiler = configService.weappViteConfig?.vue?.template?.scopedSlotsCompiler ?? "auto";
|
|
@@ -33070,7 +33608,7 @@ function createCompileVueFileOptions(ctx, pluginCtx, vuePath, isPage, isApp, con
|
|
|
33070
33608
|
}
|
|
33071
33609
|
}
|
|
33072
33610
|
const jsonConfig = configService.weappViteConfig?.json;
|
|
33073
|
-
const wevuDefaults = configService.weappViteConfig
|
|
33611
|
+
const wevuDefaults = resolveWevuDefaultsWithPreset(configService.weappViteConfig);
|
|
33074
33612
|
const jsonKind = isApp ? "app" : isPage ? "page" : "component";
|
|
33075
33613
|
const templatePlatform = getMiniProgramTemplatePlatform(configService.platform);
|
|
33076
33614
|
return {
|
|
@@ -33224,12 +33762,12 @@ function emitClassStyleWxsAssetIfMissing(ctx, bundle, fileName, source) {
|
|
|
33224
33762
|
// src/plugins/vue/transform/fallbackEntries.ts
|
|
33225
33763
|
init_esm_shims();
|
|
33226
33764
|
import fs31 from "fs-extra";
|
|
33227
|
-
import
|
|
33765
|
+
import path67 from "pathe";
|
|
33228
33766
|
|
|
33229
33767
|
// src/plugins/vue/transform/collectVuePages.ts
|
|
33230
33768
|
init_esm_shims();
|
|
33231
33769
|
import fs30 from "fs-extra";
|
|
33232
|
-
import
|
|
33770
|
+
import path66 from "pathe";
|
|
33233
33771
|
var VUE_LIKE_EXTENSIONS2 = [".vue", ".tsx", ".jsx"];
|
|
33234
33772
|
function isVueLikeFile2(file) {
|
|
33235
33773
|
return VUE_LIKE_EXTENSIONS2.some((ext) => file.endsWith(ext));
|
|
@@ -33247,7 +33785,7 @@ async function collectVuePages(root) {
|
|
|
33247
33785
|
try {
|
|
33248
33786
|
const entries = await fs30.readdir(root);
|
|
33249
33787
|
for (const entry of entries) {
|
|
33250
|
-
const full =
|
|
33788
|
+
const full = path66.join(root, entry);
|
|
33251
33789
|
const stat5 = await fs30.stat(full);
|
|
33252
33790
|
if (stat5.isDirectory()) {
|
|
33253
33791
|
const nested = await collectVuePages(full);
|
|
@@ -33267,7 +33805,7 @@ async function collectFallbackPageEntryIds(configService, scanService) {
|
|
|
33267
33805
|
if (scanService?.appEntry?.json?.pages?.length) {
|
|
33268
33806
|
pageList = scanService.appEntry.json.pages;
|
|
33269
33807
|
} else {
|
|
33270
|
-
const appJsonPath =
|
|
33808
|
+
const appJsonPath = path67.join(configService.cwd, "dist", "app.json");
|
|
33271
33809
|
try {
|
|
33272
33810
|
const appJsonContent = await fs31.readFile(appJsonPath, "utf-8");
|
|
33273
33811
|
const appJson = JSON.parse(appJsonContent);
|
|
@@ -33276,8 +33814,8 @@ async function collectFallbackPageEntryIds(configService, scanService) {
|
|
|
33276
33814
|
}
|
|
33277
33815
|
}
|
|
33278
33816
|
const collectedEntries = /* @__PURE__ */ new Set();
|
|
33279
|
-
pageList.forEach((p) => collectedEntries.add(
|
|
33280
|
-
const extraVueFiles = await collectVuePages(
|
|
33817
|
+
pageList.forEach((p) => collectedEntries.add(path67.join(configService.absoluteSrcRoot, p)));
|
|
33818
|
+
const extraVueFiles = await collectVuePages(path67.join(configService.absoluteSrcRoot, "pages"));
|
|
33281
33819
|
extraVueFiles.forEach((f) => collectedEntries.add(f.slice(0, -4)));
|
|
33282
33820
|
return collectedEntries;
|
|
33283
33821
|
}
|
|
@@ -33297,6 +33835,331 @@ async function injectWevuPageFeaturesInJsWithViteResolver(ctx, source, id, optio
|
|
|
33297
33835
|
});
|
|
33298
33836
|
}
|
|
33299
33837
|
|
|
33838
|
+
// src/plugins/vue/transform/injectSetDataPick.ts
|
|
33839
|
+
init_esm_shims();
|
|
33840
|
+
var TEMPLATE_MUSTACHE_RE = /\{\{([\s\S]*?)\}\}/g;
|
|
33841
|
+
var WX_FOR_TAG_RE = /<[^>]*\bwx:for\s*=\s*(?:"[^"]*"|'[^']*')[^>]*>/g;
|
|
33842
|
+
var WX_FOR_ITEM_RE = /\bwx:for-item\s*=\s*(?:"([^"]+)"|'([^']+)')/;
|
|
33843
|
+
var WX_FOR_INDEX_RE = /\bwx:for-index\s*=\s*(?:"([^"]+)"|'([^']+)')/;
|
|
33844
|
+
var JS_GLOBAL_IDENTIFIERS = /* @__PURE__ */ new Set([
|
|
33845
|
+
"undefined",
|
|
33846
|
+
"NaN",
|
|
33847
|
+
"Infinity",
|
|
33848
|
+
"globalThis",
|
|
33849
|
+
"Math",
|
|
33850
|
+
"Number",
|
|
33851
|
+
"String",
|
|
33852
|
+
"Boolean",
|
|
33853
|
+
"Object",
|
|
33854
|
+
"Array",
|
|
33855
|
+
"Date",
|
|
33856
|
+
"JSON",
|
|
33857
|
+
"RegExp",
|
|
33858
|
+
"Map",
|
|
33859
|
+
"Set",
|
|
33860
|
+
"WeakMap",
|
|
33861
|
+
"WeakSet",
|
|
33862
|
+
"parseInt",
|
|
33863
|
+
"parseFloat",
|
|
33864
|
+
"isNaN",
|
|
33865
|
+
"isFinite",
|
|
33866
|
+
"decodeURI",
|
|
33867
|
+
"decodeURIComponent",
|
|
33868
|
+
"encodeURI",
|
|
33869
|
+
"encodeURIComponent"
|
|
33870
|
+
]);
|
|
33871
|
+
function isAutoSetDataPickEnabled(config) {
|
|
33872
|
+
return isAutoSetDataPickEnabledWithPreset(config);
|
|
33873
|
+
}
|
|
33874
|
+
function isTargetWevuComponentCall(callee) {
|
|
33875
|
+
if (callee.type === "Identifier") {
|
|
33876
|
+
return callee.name === "createWevuComponent" || callee.name === "defineComponent";
|
|
33877
|
+
}
|
|
33878
|
+
if (callee.type !== "MemberExpression" || callee.computed) {
|
|
33879
|
+
return false;
|
|
33880
|
+
}
|
|
33881
|
+
return callee.property.type === "Identifier" && (callee.property.name === "createWevuComponent" || callee.property.name === "defineComponent");
|
|
33882
|
+
}
|
|
33883
|
+
function getObjectPropertyByKey(objectExpression, key) {
|
|
33884
|
+
for (const member of objectExpression.properties) {
|
|
33885
|
+
if (member.type !== "ObjectProperty") {
|
|
33886
|
+
continue;
|
|
33887
|
+
}
|
|
33888
|
+
if (member.key.type === "Identifier" && member.key.name === key) {
|
|
33889
|
+
return member;
|
|
33890
|
+
}
|
|
33891
|
+
if (member.key.type === "StringLiteral" && member.key.value === key) {
|
|
33892
|
+
return member;
|
|
33893
|
+
}
|
|
33894
|
+
}
|
|
33895
|
+
return void 0;
|
|
33896
|
+
}
|
|
33897
|
+
function unwrapExpression(node) {
|
|
33898
|
+
let current2 = node;
|
|
33899
|
+
while (true) {
|
|
33900
|
+
if (current2.type === "TSAsExpression" || current2.type === "TSTypeAssertion" || current2.type === "TSNonNullExpression" || current2.type === "ParenthesizedExpression" || current2.type === "TSSatisfiesExpression") {
|
|
33901
|
+
current2 = current2.expression;
|
|
33902
|
+
continue;
|
|
33903
|
+
}
|
|
33904
|
+
return current2;
|
|
33905
|
+
}
|
|
33906
|
+
}
|
|
33907
|
+
function resolveOptionsObjectExpression2(expression, scope) {
|
|
33908
|
+
if (!expression) {
|
|
33909
|
+
return void 0;
|
|
33910
|
+
}
|
|
33911
|
+
const unwrapped = unwrapExpression(expression);
|
|
33912
|
+
if (unwrapped.type === "ObjectExpression") {
|
|
33913
|
+
return unwrapped;
|
|
33914
|
+
}
|
|
33915
|
+
if (unwrapped.type === "Identifier") {
|
|
33916
|
+
const binding = scope.getBinding(unwrapped.name);
|
|
33917
|
+
if (!binding || !binding.path.isVariableDeclarator()) {
|
|
33918
|
+
return void 0;
|
|
33919
|
+
}
|
|
33920
|
+
const init = binding.path.node.init;
|
|
33921
|
+
if (!init || init.type !== "ObjectExpression" && init.type !== "CallExpression" && init.type !== "Identifier") {
|
|
33922
|
+
return void 0;
|
|
33923
|
+
}
|
|
33924
|
+
return resolveOptionsObjectExpression2(init, binding.path.scope);
|
|
33925
|
+
}
|
|
33926
|
+
if (unwrapped.type === "CallExpression" && unwrapped.callee.type === "MemberExpression" && !unwrapped.callee.computed && unwrapped.callee.object.type === "Identifier" && unwrapped.callee.object.name === "Object" && unwrapped.callee.property.type === "Identifier" && unwrapped.callee.property.name === "assign") {
|
|
33927
|
+
for (let i = unwrapped.arguments.length - 1; i >= 0; i--) {
|
|
33928
|
+
const arg = unwrapped.arguments[i];
|
|
33929
|
+
if (arg.type !== "SpreadElement") {
|
|
33930
|
+
const resolved = resolveOptionsObjectExpression2(arg, scope);
|
|
33931
|
+
if (resolved) {
|
|
33932
|
+
return resolved;
|
|
33933
|
+
}
|
|
33934
|
+
}
|
|
33935
|
+
}
|
|
33936
|
+
}
|
|
33937
|
+
return void 0;
|
|
33938
|
+
}
|
|
33939
|
+
function createPickArrayExpression(keys) {
|
|
33940
|
+
return {
|
|
33941
|
+
type: "ArrayExpression",
|
|
33942
|
+
elements: keys.map((key) => ({ type: "StringLiteral", value: key }))
|
|
33943
|
+
};
|
|
33944
|
+
}
|
|
33945
|
+
function mergePickArrayExpression(arrayExpression, keys) {
|
|
33946
|
+
const existing = /* @__PURE__ */ new Set();
|
|
33947
|
+
for (const element of arrayExpression.elements) {
|
|
33948
|
+
if (element && element.type === "StringLiteral") {
|
|
33949
|
+
existing.add(element.value);
|
|
33950
|
+
}
|
|
33951
|
+
}
|
|
33952
|
+
let changed = false;
|
|
33953
|
+
for (const key of keys) {
|
|
33954
|
+
if (existing.has(key)) {
|
|
33955
|
+
continue;
|
|
33956
|
+
}
|
|
33957
|
+
arrayExpression.elements.push({ type: "StringLiteral", value: key });
|
|
33958
|
+
existing.add(key);
|
|
33959
|
+
changed = true;
|
|
33960
|
+
}
|
|
33961
|
+
return changed;
|
|
33962
|
+
}
|
|
33963
|
+
function injectPickIntoSetDataObject(setDataObject, keys) {
|
|
33964
|
+
const pickProp = getObjectPropertyByKey(setDataObject, "pick");
|
|
33965
|
+
if (!pickProp) {
|
|
33966
|
+
setDataObject.properties.unshift({
|
|
33967
|
+
type: "ObjectProperty",
|
|
33968
|
+
key: { type: "Identifier", name: "pick" },
|
|
33969
|
+
computed: false,
|
|
33970
|
+
shorthand: false,
|
|
33971
|
+
value: createPickArrayExpression(keys)
|
|
33972
|
+
});
|
|
33973
|
+
return true;
|
|
33974
|
+
}
|
|
33975
|
+
if (pickProp.value.type !== "ArrayExpression") {
|
|
33976
|
+
return false;
|
|
33977
|
+
}
|
|
33978
|
+
return mergePickArrayExpression(pickProp.value, keys);
|
|
33979
|
+
}
|
|
33980
|
+
function injectPickIntoOptionsObject(optionsObject, keys) {
|
|
33981
|
+
const setDataProp = getObjectPropertyByKey(optionsObject, "setData");
|
|
33982
|
+
if (!setDataProp) {
|
|
33983
|
+
optionsObject.properties.unshift({
|
|
33984
|
+
type: "ObjectProperty",
|
|
33985
|
+
key: { type: "Identifier", name: "setData" },
|
|
33986
|
+
computed: false,
|
|
33987
|
+
shorthand: false,
|
|
33988
|
+
value: {
|
|
33989
|
+
type: "ObjectExpression",
|
|
33990
|
+
properties: [
|
|
33991
|
+
{
|
|
33992
|
+
type: "ObjectProperty",
|
|
33993
|
+
key: { type: "Identifier", name: "pick" },
|
|
33994
|
+
computed: false,
|
|
33995
|
+
shorthand: false,
|
|
33996
|
+
value: createPickArrayExpression(keys)
|
|
33997
|
+
}
|
|
33998
|
+
]
|
|
33999
|
+
}
|
|
34000
|
+
});
|
|
34001
|
+
return true;
|
|
34002
|
+
}
|
|
34003
|
+
const setDataValue = unwrapExpression(setDataProp.value);
|
|
34004
|
+
if (setDataValue.type === "ObjectExpression") {
|
|
34005
|
+
return injectPickIntoSetDataObject(setDataValue, keys);
|
|
34006
|
+
}
|
|
34007
|
+
if (setDataValue.type === "Identifier" || setDataValue.type === "MemberExpression" || setDataValue.type === "CallExpression") {
|
|
34008
|
+
setDataProp.value = {
|
|
34009
|
+
type: "ObjectExpression",
|
|
34010
|
+
properties: [
|
|
34011
|
+
{
|
|
34012
|
+
type: "ObjectProperty",
|
|
34013
|
+
key: { type: "Identifier", name: "pick" },
|
|
34014
|
+
computed: false,
|
|
34015
|
+
shorthand: false,
|
|
34016
|
+
value: createPickArrayExpression(keys)
|
|
34017
|
+
},
|
|
34018
|
+
{
|
|
34019
|
+
type: "SpreadElement",
|
|
34020
|
+
argument: setDataValue
|
|
34021
|
+
}
|
|
34022
|
+
]
|
|
34023
|
+
};
|
|
34024
|
+
return true;
|
|
34025
|
+
}
|
|
34026
|
+
return false;
|
|
34027
|
+
}
|
|
34028
|
+
function collectLoopScopeAliases(template) {
|
|
34029
|
+
const aliases = /* @__PURE__ */ new Set();
|
|
34030
|
+
const tagMatches = template.match(WX_FOR_TAG_RE) ?? [];
|
|
34031
|
+
for (const tag of tagMatches) {
|
|
34032
|
+
const itemMatch = tag.match(WX_FOR_ITEM_RE);
|
|
34033
|
+
if (itemMatch) {
|
|
34034
|
+
const itemAlias = (itemMatch[1] ?? itemMatch[2] ?? "").trim();
|
|
34035
|
+
if (itemAlias) {
|
|
34036
|
+
aliases.add(itemAlias);
|
|
34037
|
+
}
|
|
34038
|
+
} else {
|
|
34039
|
+
aliases.add("item");
|
|
34040
|
+
}
|
|
34041
|
+
const indexMatch = tag.match(WX_FOR_INDEX_RE);
|
|
34042
|
+
if (indexMatch) {
|
|
34043
|
+
const indexAlias = (indexMatch[1] ?? indexMatch[2] ?? "").trim();
|
|
34044
|
+
if (indexAlias) {
|
|
34045
|
+
aliases.add(indexAlias);
|
|
34046
|
+
}
|
|
34047
|
+
} else {
|
|
34048
|
+
aliases.add("index");
|
|
34049
|
+
}
|
|
34050
|
+
}
|
|
34051
|
+
return aliases;
|
|
34052
|
+
}
|
|
34053
|
+
function extractTemplateExpressions(template) {
|
|
34054
|
+
const expressions = [];
|
|
34055
|
+
let match = TEMPLATE_MUSTACHE_RE.exec(template);
|
|
34056
|
+
while (match) {
|
|
34057
|
+
const expression = (match[1] ?? "").trim();
|
|
34058
|
+
if (expression) {
|
|
34059
|
+
expressions.push(expression);
|
|
34060
|
+
}
|
|
34061
|
+
match = TEMPLATE_MUSTACHE_RE.exec(template);
|
|
34062
|
+
}
|
|
34063
|
+
TEMPLATE_MUSTACHE_RE.lastIndex = 0;
|
|
34064
|
+
return expressions;
|
|
34065
|
+
}
|
|
34066
|
+
function collectIdentifiersFromExpression(expression) {
|
|
34067
|
+
const collected = /* @__PURE__ */ new Set();
|
|
34068
|
+
let ast;
|
|
34069
|
+
try {
|
|
34070
|
+
ast = parse(`const __weappViteExpr = (${expression});`, {
|
|
34071
|
+
...BABEL_TS_MODULE_PARSER_OPTIONS,
|
|
34072
|
+
sourceType: "module"
|
|
34073
|
+
});
|
|
34074
|
+
} catch {
|
|
34075
|
+
return collected;
|
|
34076
|
+
}
|
|
34077
|
+
traverse(ast, {
|
|
34078
|
+
Identifier(path82) {
|
|
34079
|
+
if (!path82.isReferencedIdentifier()) {
|
|
34080
|
+
return;
|
|
34081
|
+
}
|
|
34082
|
+
const name = path82.node.name;
|
|
34083
|
+
if (name === "__weappViteExpr") {
|
|
34084
|
+
return;
|
|
34085
|
+
}
|
|
34086
|
+
if (path82.scope.hasBinding(name, true)) {
|
|
34087
|
+
return;
|
|
34088
|
+
}
|
|
34089
|
+
if (JS_GLOBAL_IDENTIFIERS.has(name)) {
|
|
34090
|
+
return;
|
|
34091
|
+
}
|
|
34092
|
+
collected.add(name);
|
|
34093
|
+
},
|
|
34094
|
+
MemberExpression(path82) {
|
|
34095
|
+
const member = path82.node;
|
|
34096
|
+
if (member.computed || member.object.type !== "ThisExpression" || member.property.type !== "Identifier") {
|
|
34097
|
+
return;
|
|
34098
|
+
}
|
|
34099
|
+
collected.add(member.property.name);
|
|
34100
|
+
},
|
|
34101
|
+
OptionalMemberExpression(path82) {
|
|
34102
|
+
const member = path82.node;
|
|
34103
|
+
if (member.computed || member.object.type !== "ThisExpression" || member.property.type !== "Identifier") {
|
|
34104
|
+
return;
|
|
34105
|
+
}
|
|
34106
|
+
collected.add(member.property.name);
|
|
34107
|
+
}
|
|
34108
|
+
});
|
|
34109
|
+
return collected;
|
|
34110
|
+
}
|
|
34111
|
+
function collectSetDataPickKeysFromTemplate(template) {
|
|
34112
|
+
const templateExpressions = extractTemplateExpressions(template);
|
|
34113
|
+
if (!templateExpressions.length) {
|
|
34114
|
+
return [];
|
|
34115
|
+
}
|
|
34116
|
+
const loopAliases = collectLoopScopeAliases(template);
|
|
34117
|
+
const keys = /* @__PURE__ */ new Set();
|
|
34118
|
+
for (const expression of templateExpressions) {
|
|
34119
|
+
const identifiers = collectIdentifiersFromExpression(expression);
|
|
34120
|
+
for (const identifier3 of identifiers) {
|
|
34121
|
+
if (!loopAliases.has(identifier3)) {
|
|
34122
|
+
keys.add(identifier3);
|
|
34123
|
+
}
|
|
34124
|
+
}
|
|
34125
|
+
}
|
|
34126
|
+
return Array.from(keys).sort((a3, b) => a3.localeCompare(b));
|
|
34127
|
+
}
|
|
34128
|
+
function injectSetDataPickInJs(source, pickKeys) {
|
|
34129
|
+
if (!pickKeys.length) {
|
|
34130
|
+
return { code: source, transformed: false };
|
|
34131
|
+
}
|
|
34132
|
+
const ast = parseJsLike(source);
|
|
34133
|
+
const candidateOptions = /* @__PURE__ */ new Set();
|
|
34134
|
+
traverse(ast, {
|
|
34135
|
+
CallExpression(path82) {
|
|
34136
|
+
if (!isTargetWevuComponentCall(path82.node.callee)) {
|
|
34137
|
+
return;
|
|
34138
|
+
}
|
|
34139
|
+
const firstArg = path82.node.arguments[0];
|
|
34140
|
+
if (!firstArg || firstArg.type === "SpreadElement") {
|
|
34141
|
+
return;
|
|
34142
|
+
}
|
|
34143
|
+
const resolvedOptions = resolveOptionsObjectExpression2(firstArg, path82.scope);
|
|
34144
|
+
if (resolvedOptions) {
|
|
34145
|
+
candidateOptions.add(resolvedOptions);
|
|
34146
|
+
}
|
|
34147
|
+
}
|
|
34148
|
+
});
|
|
34149
|
+
if (!candidateOptions.size) {
|
|
34150
|
+
return { code: source, transformed: false };
|
|
34151
|
+
}
|
|
34152
|
+
let changed = false;
|
|
34153
|
+
for (const optionsObject of candidateOptions) {
|
|
34154
|
+
changed = injectPickIntoOptionsObject(optionsObject, pickKeys) || changed;
|
|
34155
|
+
}
|
|
34156
|
+
if (!changed) {
|
|
34157
|
+
return { code: source, transformed: false };
|
|
34158
|
+
}
|
|
34159
|
+
const generated = generate(ast, { retainLines: true });
|
|
34160
|
+
return { code: generated.code, transformed: true };
|
|
34161
|
+
}
|
|
34162
|
+
|
|
33300
34163
|
// src/plugins/vue/transform/scopedSlot.ts
|
|
33301
34164
|
init_esm_shims();
|
|
33302
34165
|
import { buildClassStyleComputedCode, createJsonMerger as createJsonMerger2, getClassStyleWxsSource, WE_VU_MODULE_ID, WE_VU_RUNTIME_APIS } from "wevu/compiler";
|
|
@@ -33694,6 +34557,13 @@ async function emitVueBundleAssets(bundle, state) {
|
|
|
33694
34557
|
compiled.script = injected.code;
|
|
33695
34558
|
}
|
|
33696
34559
|
}
|
|
34560
|
+
if (!isApp && compiled.script && compiled.template && isAutoSetDataPickEnabled(configService.weappViteConfig)) {
|
|
34561
|
+
const keys = collectSetDataPickKeysFromTemplate(compiled.template);
|
|
34562
|
+
const injectedPick = injectSetDataPickInJs(compiled.script, keys);
|
|
34563
|
+
if (injectedPick.transformed) {
|
|
34564
|
+
compiled.script = injectedPick.code;
|
|
34565
|
+
}
|
|
34566
|
+
}
|
|
33697
34567
|
cached.source = source;
|
|
33698
34568
|
cached.result = compiled;
|
|
33699
34569
|
result = compiled;
|
|
@@ -33803,6 +34673,13 @@ async function emitVueBundleAssets(bundle, state) {
|
|
|
33803
34673
|
result.script = injected.code;
|
|
33804
34674
|
}
|
|
33805
34675
|
}
|
|
34676
|
+
if (result.script && result.template && isAutoSetDataPickEnabled(configService.weappViteConfig)) {
|
|
34677
|
+
const keys = collectSetDataPickKeysFromTemplate(result.template);
|
|
34678
|
+
const injectedPick = injectSetDataPickInJs(result.script, keys);
|
|
34679
|
+
if (injectedPick.transformed) {
|
|
34680
|
+
result.script = injectedPick.code;
|
|
34681
|
+
}
|
|
34682
|
+
}
|
|
33806
34683
|
if (result.template) {
|
|
33807
34684
|
const normalizedTemplate = normalizeVueTemplateForPlatform(result.template, {
|
|
33808
34685
|
platform: configService.platform,
|
|
@@ -33953,7 +34830,7 @@ function createVueTransformPlugin(ctx) {
|
|
|
33953
34830
|
}
|
|
33954
34831
|
const sourceId = getSourceFromVirtualId(id);
|
|
33955
34832
|
const filename = toAbsoluteId(sourceId, configService, void 0, { base: "cwd" });
|
|
33956
|
-
if (!filename || !
|
|
34833
|
+
if (!filename || !path68.isAbsolute(filename)) {
|
|
33957
34834
|
return null;
|
|
33958
34835
|
}
|
|
33959
34836
|
if (typeof this.addWatchFile === "function") {
|
|
@@ -34041,6 +34918,9 @@ function createVueTransformPlugin(ctx) {
|
|
|
34041
34918
|
}
|
|
34042
34919
|
}
|
|
34043
34920
|
if (isPage && result.script) {
|
|
34921
|
+
for (const warning of collectOnPageScrollPerformanceWarnings(result.script, filename)) {
|
|
34922
|
+
default2.warn(warning);
|
|
34923
|
+
}
|
|
34044
34924
|
const injected = await injectWevuPageFeaturesInJsWithViteResolver(this, result.script, filename, {
|
|
34045
34925
|
checkMtime: configService.isDev
|
|
34046
34926
|
});
|
|
@@ -34048,6 +34928,13 @@ function createVueTransformPlugin(ctx) {
|
|
|
34048
34928
|
result.script = injected.code;
|
|
34049
34929
|
}
|
|
34050
34930
|
}
|
|
34931
|
+
if (!isApp && result.script && result.template && isAutoSetDataPickEnabled(configService.weappViteConfig)) {
|
|
34932
|
+
const keys = collectSetDataPickKeysFromTemplate(result.template);
|
|
34933
|
+
const injectedPick = injectSetDataPickInJs(result.script, keys);
|
|
34934
|
+
if (injectedPick.transformed) {
|
|
34935
|
+
result.script = injectedPick.code;
|
|
34936
|
+
}
|
|
34937
|
+
}
|
|
34051
34938
|
compilationCache.set(filename, { result, source, isPage });
|
|
34052
34939
|
const relativeBase = configService.relativeOutputPath(getEntryBasePath(filename));
|
|
34053
34940
|
if (relativeBase) {
|
|
@@ -34186,12 +35073,12 @@ init_esm_shims();
|
|
|
34186
35073
|
import { createHash as createHash3 } from "crypto";
|
|
34187
35074
|
import { removeExtension as removeExtension2 } from "@weapp-core/shared";
|
|
34188
35075
|
import fs34 from "fs-extra";
|
|
34189
|
-
import
|
|
35076
|
+
import path69 from "pathe";
|
|
34190
35077
|
async function resolveWorkerEntry(ctx, entry) {
|
|
34191
35078
|
const { configService, scanService } = ctx;
|
|
34192
|
-
const relativeEntryPath =
|
|
35079
|
+
const relativeEntryPath = path69.join(scanService.workersDir, entry);
|
|
34193
35080
|
const key = removeExtension2(relativeEntryPath);
|
|
34194
|
-
const absoluteEntry =
|
|
35081
|
+
const absoluteEntry = path69.resolve(configService.absoluteSrcRoot, relativeEntryPath);
|
|
34195
35082
|
if (isJsOrTs(entry)) {
|
|
34196
35083
|
const exists = await fs34.pathExists(absoluteEntry);
|
|
34197
35084
|
if (!exists) {
|
|
@@ -34228,12 +35115,12 @@ function createWorkerBuildPlugin(ctx) {
|
|
|
34228
35115
|
options.chunkFileNames = (chunkInfo) => {
|
|
34229
35116
|
const workersDir = scanService.workersDir ?? "";
|
|
34230
35117
|
if (chunkInfo.isDynamicEntry) {
|
|
34231
|
-
return
|
|
35118
|
+
return path69.join(workersDir, "[name].js");
|
|
34232
35119
|
}
|
|
34233
35120
|
const sourceId = chunkInfo.facadeModuleId ?? chunkInfo.moduleIds[0];
|
|
34234
35121
|
const hashBase = typeof sourceId === "string" ? configService.relativeCwd(sourceId) : chunkInfo.name;
|
|
34235
35122
|
const stableHash = createHash3("sha256").update(hashBase).digest("base64url").slice(0, 8);
|
|
34236
|
-
return
|
|
35123
|
+
return path69.join(workersDir, `${chunkInfo.name}-${stableHash}.js`);
|
|
34237
35124
|
};
|
|
34238
35125
|
}
|
|
34239
35126
|
};
|
|
@@ -34249,7 +35136,7 @@ function workers(ctx) {
|
|
|
34249
35136
|
init_esm_shims();
|
|
34250
35137
|
import { removeExtension as removeExtension3 } from "@weapp-core/shared";
|
|
34251
35138
|
import fs35 from "fs-extra";
|
|
34252
|
-
import
|
|
35139
|
+
import path70 from "pathe";
|
|
34253
35140
|
var wxsCodeCache = new L({
|
|
34254
35141
|
max: 512
|
|
34255
35142
|
});
|
|
@@ -34276,13 +35163,13 @@ async function transformWxsFile(state, wxsPath) {
|
|
|
34276
35163
|
if (typeof result?.code === "string") {
|
|
34277
35164
|
code = result.code;
|
|
34278
35165
|
}
|
|
34279
|
-
const dirname5 =
|
|
35166
|
+
const dirname5 = path70.dirname(wxsPath);
|
|
34280
35167
|
await Promise.all(
|
|
34281
35168
|
importees.map(({ source }) => {
|
|
34282
35169
|
return transformWxsFile.call(
|
|
34283
35170
|
this,
|
|
34284
35171
|
state,
|
|
34285
|
-
|
|
35172
|
+
path70.resolve(dirname5, source)
|
|
34286
35173
|
);
|
|
34287
35174
|
})
|
|
34288
35175
|
);
|
|
@@ -34310,7 +35197,7 @@ async function handleWxsDeps(state, deps, absPath) {
|
|
|
34310
35197
|
if (!jsExtensions.includes(dep.attrs.lang) && !arr) {
|
|
34311
35198
|
return;
|
|
34312
35199
|
}
|
|
34313
|
-
const wxsPath =
|
|
35200
|
+
const wxsPath = path70.resolve(path70.dirname(absPath), dep.value);
|
|
34314
35201
|
await transformWxsFile.call(this, state, wxsPath);
|
|
34315
35202
|
})
|
|
34316
35203
|
);
|
|
@@ -34332,7 +35219,7 @@ async function handleWxsDepsFromBundle(state, bundle) {
|
|
|
34332
35219
|
} catch {
|
|
34333
35220
|
return;
|
|
34334
35221
|
}
|
|
34335
|
-
const absPath =
|
|
35222
|
+
const absPath = path70.resolve(state.ctx.configService.absoluteSrcRoot, fileName);
|
|
34336
35223
|
await handleWxsDeps.call(this, state, deps, absPath);
|
|
34337
35224
|
})
|
|
34338
35225
|
);
|
|
@@ -34476,6 +35363,7 @@ function arrangePlugins(config, ctx, subPackageMeta) {
|
|
|
34476
35363
|
}
|
|
34477
35364
|
|
|
34478
35365
|
// src/runtime/config/internal/merge/miniprogram.ts
|
|
35366
|
+
var PACKAGE_NAME_REGEX = /[-/\\^$*+?.()|[\]{}]/g;
|
|
34479
35367
|
function mergeMiniprogram(options, ...configs) {
|
|
34480
35368
|
const {
|
|
34481
35369
|
ctx,
|
|
@@ -34497,7 +35385,7 @@ function mergeMiniprogram(options, ...configs) {
|
|
|
34497
35385
|
if (packageJson?.dependencies) {
|
|
34498
35386
|
external.push(
|
|
34499
35387
|
...Object.keys(packageJson.dependencies).map((pkg) => {
|
|
34500
|
-
return new RegExp(`^${pkg.replace(
|
|
35388
|
+
return new RegExp(`^${pkg.replace(PACKAGE_NAME_REGEX, "\\$&")}(\\/|$)`);
|
|
34501
35389
|
})
|
|
34502
35390
|
);
|
|
34503
35391
|
}
|
|
@@ -34512,17 +35400,17 @@ function mergeMiniprogram(options, ...configs) {
|
|
|
34512
35400
|
};
|
|
34513
35401
|
if (isDev) {
|
|
34514
35402
|
const watchInclude = [
|
|
34515
|
-
|
|
35403
|
+
path71.join(cwd, srcRoot, "**")
|
|
34516
35404
|
];
|
|
34517
35405
|
const pluginRootConfig = config.weapp?.pluginRoot;
|
|
34518
35406
|
if (pluginRootConfig) {
|
|
34519
|
-
const absolutePluginRoot =
|
|
34520
|
-
const relativeToSrc =
|
|
34521
|
-
|
|
35407
|
+
const absolutePluginRoot = path71.resolve(cwd, pluginRootConfig);
|
|
35408
|
+
const relativeToSrc = path71.relative(
|
|
35409
|
+
path71.resolve(cwd, srcRoot),
|
|
34522
35410
|
absolutePluginRoot
|
|
34523
35411
|
);
|
|
34524
|
-
const pluginPatternBase = relativeToSrc.startsWith("..") ? absolutePluginRoot :
|
|
34525
|
-
watchInclude.push(
|
|
35412
|
+
const pluginPatternBase = relativeToSrc.startsWith("..") ? absolutePluginRoot : path71.join(cwd, srcRoot, relativeToSrc);
|
|
35413
|
+
watchInclude.push(path71.join(pluginPatternBase, "**"));
|
|
34526
35414
|
}
|
|
34527
35415
|
const inline = defu5(
|
|
34528
35416
|
config,
|
|
@@ -34536,7 +35424,7 @@ function mergeMiniprogram(options, ...configs) {
|
|
|
34536
35424
|
watch: {
|
|
34537
35425
|
exclude: [
|
|
34538
35426
|
...defaultExcluded,
|
|
34539
|
-
mpDistRoot ?
|
|
35427
|
+
mpDistRoot ? path71.join(cwd, mpDistRoot, "**") : path71.join(cwd, "dist", "**")
|
|
34540
35428
|
],
|
|
34541
35429
|
include: watchInclude
|
|
34542
35430
|
},
|
|
@@ -34554,6 +35442,7 @@ function mergeMiniprogram(options, ...configs) {
|
|
|
34554
35442
|
...inline.define ?? {},
|
|
34555
35443
|
__VITE_IS_MODERN__: "false"
|
|
34556
35444
|
};
|
|
35445
|
+
applyWeappViteHostMeta(inline, "miniprogram");
|
|
34557
35446
|
stripRollupOptions(inline);
|
|
34558
35447
|
arrangePlugins(inline, ctx, subPackageMeta);
|
|
34559
35448
|
injectBuiltinAliases(inline);
|
|
@@ -34580,6 +35469,7 @@ function mergeMiniprogram(options, ...configs) {
|
|
|
34580
35469
|
...inlineConfig.define ?? {},
|
|
34581
35470
|
__VITE_IS_MODERN__: "false"
|
|
34582
35471
|
};
|
|
35472
|
+
applyWeappViteHostMeta(inlineConfig, "miniprogram");
|
|
34583
35473
|
stripRollupOptions(inlineConfig);
|
|
34584
35474
|
arrangePlugins(inlineConfig, ctx, subPackageMeta);
|
|
34585
35475
|
inlineConfig.logLevel = "info";
|
|
@@ -34653,9 +35543,8 @@ function mergeWeb(options, ...configs) {
|
|
|
34653
35543
|
inline.plugins = mergedPlugins;
|
|
34654
35544
|
inline.build ??= {};
|
|
34655
35545
|
inline.build.outDir = web.outDir;
|
|
34656
|
-
|
|
34657
|
-
|
|
34658
|
-
}
|
|
35546
|
+
inline.build.emptyOutDir ??= !isDev;
|
|
35547
|
+
applyWeappViteHostMeta(inline, "web");
|
|
34659
35548
|
inline.define = defu6(inline.define ?? {}, getDefineImportMetaEnv());
|
|
34660
35549
|
injectBuiltinAliases(inline);
|
|
34661
35550
|
return inline;
|
|
@@ -34691,6 +35580,7 @@ function mergeWorkers(options, ...configs) {
|
|
|
34691
35580
|
}
|
|
34692
35581
|
}
|
|
34693
35582
|
);
|
|
35583
|
+
applyWeappViteHostMeta(inline, "miniprogram");
|
|
34694
35584
|
stripRollupOptions(inline);
|
|
34695
35585
|
injectBuiltinAliases(inline);
|
|
34696
35586
|
return inline;
|
|
@@ -34708,6 +35598,7 @@ function mergeWorkers(options, ...configs) {
|
|
|
34708
35598
|
}
|
|
34709
35599
|
}
|
|
34710
35600
|
);
|
|
35601
|
+
applyWeappViteHostMeta(inlineConfig, "miniprogram");
|
|
34711
35602
|
stripRollupOptions(inlineConfig);
|
|
34712
35603
|
inlineConfig.logLevel = "info";
|
|
34713
35604
|
injectBuiltinAliases(inlineConfig);
|
|
@@ -34810,14 +35701,14 @@ function createConfigService(ctx) {
|
|
|
34810
35701
|
if (!pluginRootConfig) {
|
|
34811
35702
|
return void 0;
|
|
34812
35703
|
}
|
|
34813
|
-
return
|
|
35704
|
+
return path72.resolve(options.cwd, pluginRootConfig);
|
|
34814
35705
|
};
|
|
34815
35706
|
const resolvePluginSourceBase = () => {
|
|
34816
35707
|
const absolutePluginRoot = resolveAbsolutePluginRoot();
|
|
34817
35708
|
if (!absolutePluginRoot) {
|
|
34818
35709
|
return void 0;
|
|
34819
35710
|
}
|
|
34820
|
-
return toPosixPath(
|
|
35711
|
+
return toPosixPath(path72.basename(absolutePluginRoot));
|
|
34821
35712
|
};
|
|
34822
35713
|
const resolveAbsolutePluginOutputRoot = () => {
|
|
34823
35714
|
const absolutePluginRoot = resolveAbsolutePluginRoot();
|
|
@@ -34826,19 +35717,19 @@ function createConfigService(ctx) {
|
|
|
34826
35717
|
}
|
|
34827
35718
|
const configured = options.projectConfig?.pluginRoot;
|
|
34828
35719
|
if (configured) {
|
|
34829
|
-
return
|
|
35720
|
+
return path72.resolve(options.cwd, configured);
|
|
34830
35721
|
}
|
|
34831
|
-
const outDir =
|
|
34832
|
-
const pluginBase =
|
|
34833
|
-
return
|
|
35722
|
+
const outDir = path72.resolve(options.cwd, options.mpDistRoot ?? "");
|
|
35723
|
+
const pluginBase = path72.basename(absolutePluginRoot);
|
|
35724
|
+
return path72.resolve(outDir, pluginBase);
|
|
34834
35725
|
};
|
|
34835
35726
|
const resolvePluginOutputBasePosix = () => {
|
|
34836
35727
|
const absoluteOutputRoot = resolveAbsolutePluginOutputRoot();
|
|
34837
35728
|
if (!absoluteOutputRoot) {
|
|
34838
35729
|
return void 0;
|
|
34839
35730
|
}
|
|
34840
|
-
const outDir =
|
|
34841
|
-
const normalized = normalizeRelativePath(
|
|
35731
|
+
const outDir = path72.resolve(options.cwd, options.mpDistRoot ?? "");
|
|
35732
|
+
const normalized = normalizeRelativePath(path72.relative(outDir, absoluteOutputRoot));
|
|
34842
35733
|
if (!normalized || normalized === ".") {
|
|
34843
35734
|
return resolvePluginSourceBase();
|
|
34844
35735
|
}
|
|
@@ -34974,7 +35865,7 @@ function createConfigService(ctx) {
|
|
|
34974
35865
|
return options.mpDistRoot;
|
|
34975
35866
|
},
|
|
34976
35867
|
get outDir() {
|
|
34977
|
-
return
|
|
35868
|
+
return path72.resolve(options.cwd, options.mpDistRoot ?? "");
|
|
34978
35869
|
},
|
|
34979
35870
|
get currentSubPackageRoot() {
|
|
34980
35871
|
return options.currentSubPackageRoot;
|
|
@@ -35010,7 +35901,7 @@ function createConfigService(ctx) {
|
|
|
35010
35901
|
return resolveAbsolutePluginOutputRoot();
|
|
35011
35902
|
},
|
|
35012
35903
|
get absoluteSrcRoot() {
|
|
35013
|
-
return
|
|
35904
|
+
return path72.resolve(options.cwd, options.srcRoot);
|
|
35014
35905
|
},
|
|
35015
35906
|
get mode() {
|
|
35016
35907
|
return options.mode;
|
|
@@ -35034,27 +35925,27 @@ function createConfigService(ctx) {
|
|
|
35034
35925
|
return options.weappLibOutputMap;
|
|
35035
35926
|
},
|
|
35036
35927
|
relativeCwd(p) {
|
|
35037
|
-
return normalizeRelativePath(
|
|
35928
|
+
return normalizeRelativePath(path72.relative(options.cwd, p));
|
|
35038
35929
|
},
|
|
35039
35930
|
relativeSrcRoot(p) {
|
|
35040
35931
|
return options.relativeSrcRoot(p);
|
|
35041
35932
|
},
|
|
35042
35933
|
relativeAbsoluteSrcRoot(p) {
|
|
35043
|
-
const absoluteSrcRoot =
|
|
35934
|
+
const absoluteSrcRoot = path72.resolve(options.cwd, options.srcRoot);
|
|
35044
35935
|
const absolutePluginRoot = resolveAbsolutePluginRoot();
|
|
35045
35936
|
if (absolutePluginRoot) {
|
|
35046
|
-
const relativeToPlugin = normalizeRelativePath(
|
|
35937
|
+
const relativeToPlugin = normalizeRelativePath(path72.relative(absolutePluginRoot, p));
|
|
35047
35938
|
if (!relativeToPlugin.startsWith("..")) {
|
|
35048
|
-
const pluginBase =
|
|
35939
|
+
const pluginBase = path72.basename(absolutePluginRoot);
|
|
35049
35940
|
const posixBase = toPosixPath(pluginBase);
|
|
35050
35941
|
return relativeToPlugin ? `${posixBase}/${relativeToPlugin}` : posixBase;
|
|
35051
35942
|
}
|
|
35052
35943
|
}
|
|
35053
|
-
const relativeFromSrc = normalizeRelativePath(
|
|
35944
|
+
const relativeFromSrc = normalizeRelativePath(path72.relative(absoluteSrcRoot, p));
|
|
35054
35945
|
if (!relativeFromSrc.startsWith("..")) {
|
|
35055
35946
|
return relativeFromSrc;
|
|
35056
35947
|
}
|
|
35057
|
-
const relativeFromCwd = normalizeRelativePath(
|
|
35948
|
+
const relativeFromCwd = normalizeRelativePath(path72.relative(options.cwd, p));
|
|
35058
35949
|
return relativeFromCwd;
|
|
35059
35950
|
},
|
|
35060
35951
|
relativeOutputPath(p) {
|
|
@@ -35067,7 +35958,7 @@ function createConfigService(ctx) {
|
|
|
35067
35958
|
const base = normalizeRelativePath(removeExtensionDeep13(relative3));
|
|
35068
35959
|
const mapped = libOutputMap.get(base);
|
|
35069
35960
|
if (mapped) {
|
|
35070
|
-
const ext =
|
|
35961
|
+
const ext = path72.extname(relative3);
|
|
35071
35962
|
const fileName = ext ? `${mapped}${ext}` : mapped;
|
|
35072
35963
|
return remapPluginRelativePath(fileName);
|
|
35073
35964
|
}
|
|
@@ -35193,7 +36084,7 @@ init_esm_shims();
|
|
|
35193
36084
|
// src/runtime/npmPlugin/service.ts
|
|
35194
36085
|
init_esm_shims();
|
|
35195
36086
|
import fs39 from "fs-extra";
|
|
35196
|
-
import
|
|
36087
|
+
import path76 from "pathe";
|
|
35197
36088
|
|
|
35198
36089
|
// src/runtime/npmPlugin/builder.ts
|
|
35199
36090
|
init_esm_shims();
|
|
@@ -35202,13 +36093,27 @@ import process11 from "process";
|
|
|
35202
36093
|
import * as t2 from "@babel/types";
|
|
35203
36094
|
import { defu as defu9, isObject as isObject10 } from "@weapp-core/shared";
|
|
35204
36095
|
import fs37 from "fs-extra";
|
|
35205
|
-
import
|
|
36096
|
+
import path73 from "pathe";
|
|
35206
36097
|
import { build as viteBuild } from "vite";
|
|
35207
36098
|
var ALIPAY_EXTENSION_MAP = {
|
|
35208
36099
|
".wxml": ".axml",
|
|
35209
36100
|
".wxss": ".acss",
|
|
35210
36101
|
".wxs": ".sjs"
|
|
35211
36102
|
};
|
|
36103
|
+
var WX_TEMPLATE_REFERENCE_RE = /\.wxml\b|\.wxss\b|\.wxs\b/;
|
|
36104
|
+
var ESM_SYNTAX_RE = /\bimport\s|\bexport\s/;
|
|
36105
|
+
var NULLISH_COALESCING_RE = /\?\?/;
|
|
36106
|
+
var WX_DIRECTIVE_RE = /\bwx:(?:if|elif|else|for|for-item|for-index|key)\b/;
|
|
36107
|
+
var WX_DIRECTIVE_CAPTURE_RE = /\bwx:(if|elif|else|for|for-item|for-index|key)\b/g;
|
|
36108
|
+
var WXS_TAG_RE = /<\s*(?:\/\s*)?wxs\b/;
|
|
36109
|
+
var WXS_CLOSING_TAG_RE = /<\s*\/\s*wxs\b/g;
|
|
36110
|
+
var ELSE_ATTRIBUTE_RE = /\selse(?=[\s/>])/;
|
|
36111
|
+
var IMPORT_SJS_TAG_RE = /<import-sjs([\s\S]*?)>/g;
|
|
36112
|
+
var SRC_ATTRIBUTE_RE = /\bsrc\s*=\s*/g;
|
|
36113
|
+
var MODULE_ATTRIBUTE_RE = /\bmodule\s*=\s*/g;
|
|
36114
|
+
var WXML_EXTENSION_RE = /\.wxml\b/g;
|
|
36115
|
+
var WXSS_EXTENSION_RE = /\.wxss\b/g;
|
|
36116
|
+
var WXS_EXTENSION_RE = /\.wxs\b/g;
|
|
35212
36117
|
var ALIPAY_TEXT_FILE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
35213
36118
|
".js",
|
|
35214
36119
|
".json",
|
|
@@ -35229,7 +36134,7 @@ async function collectFiles(root) {
|
|
|
35229
36134
|
}
|
|
35230
36135
|
const entries = await fs37.readdir(current2, { withFileTypes: true });
|
|
35231
36136
|
for (const entry of entries) {
|
|
35232
|
-
const filePath =
|
|
36137
|
+
const filePath = path73.resolve(current2, entry.name);
|
|
35233
36138
|
if (entry.isDirectory()) {
|
|
35234
36139
|
stack.push(filePath);
|
|
35235
36140
|
} else if (entry.isFile()) {
|
|
@@ -35244,15 +36149,15 @@ async function shouldRebuildCachedAlipayMiniprogramPackage(pkgRoot, outDir, sour
|
|
|
35244
36149
|
return true;
|
|
35245
36150
|
}
|
|
35246
36151
|
if (sourceRoot && alipayNpmDistDirName === "node_modules") {
|
|
35247
|
-
const sourceEsRoot =
|
|
35248
|
-
const targetEsRoot =
|
|
36152
|
+
const sourceEsRoot = path73.resolve(sourceRoot, "es");
|
|
36153
|
+
const targetEsRoot = path73.resolve(pkgRoot, "es");
|
|
35249
36154
|
if (await fs37.pathExists(sourceEsRoot) && !await fs37.pathExists(targetEsRoot)) {
|
|
35250
36155
|
return true;
|
|
35251
36156
|
}
|
|
35252
36157
|
}
|
|
35253
36158
|
const files = await collectFiles(pkgRoot);
|
|
35254
36159
|
for (const filePath of files) {
|
|
35255
|
-
const ext =
|
|
36160
|
+
const ext = path73.extname(filePath);
|
|
35256
36161
|
if (ext === ".wxml" || ext === ".wxss" || ext === ".wxs") {
|
|
35257
36162
|
return true;
|
|
35258
36163
|
}
|
|
@@ -35265,23 +36170,23 @@ async function shouldRebuildCachedAlipayMiniprogramPackage(pkgRoot, outDir, sour
|
|
|
35265
36170
|
} catch {
|
|
35266
36171
|
continue;
|
|
35267
36172
|
}
|
|
35268
|
-
if (
|
|
36173
|
+
if (WX_TEMPLATE_REFERENCE_RE.test(source)) {
|
|
35269
36174
|
return true;
|
|
35270
36175
|
}
|
|
35271
|
-
if (ext === ".js" && (
|
|
36176
|
+
if (ext === ".js" && (ESM_SYNTAX_RE.test(source) || NULLISH_COALESCING_RE.test(source))) {
|
|
35272
36177
|
return true;
|
|
35273
36178
|
}
|
|
35274
|
-
if ((ext === ".axml" || ext === ".wxml") && (
|
|
36179
|
+
if ((ext === ".axml" || ext === ".wxml") && (WX_DIRECTIVE_RE.test(source) || WXS_TAG_RE.test(source) || ELSE_ATTRIBUTE_RE.test(source))) {
|
|
35275
36180
|
return true;
|
|
35276
36181
|
}
|
|
35277
36182
|
}
|
|
35278
|
-
const nestedRoot =
|
|
36183
|
+
const nestedRoot = path73.resolve(pkgRoot, "miniprogram_npm");
|
|
35279
36184
|
if (!await fs37.pathExists(nestedRoot)) {
|
|
35280
36185
|
return false;
|
|
35281
36186
|
}
|
|
35282
36187
|
const entries = await fs37.readdir(nestedRoot);
|
|
35283
36188
|
for (const name of entries) {
|
|
35284
|
-
const target =
|
|
36189
|
+
const target = path73.resolve(outDir, name);
|
|
35285
36190
|
if (!await fs37.pathExists(target)) {
|
|
35286
36191
|
return true;
|
|
35287
36192
|
}
|
|
@@ -35289,15 +36194,15 @@ async function shouldRebuildCachedAlipayMiniprogramPackage(pkgRoot, outDir, sour
|
|
|
35289
36194
|
return false;
|
|
35290
36195
|
}
|
|
35291
36196
|
function hasEsmSyntax(source) {
|
|
35292
|
-
return
|
|
36197
|
+
return ESM_SYNTAX_RE.test(source);
|
|
35293
36198
|
}
|
|
35294
36199
|
function rewriteAlipayWxmlSyntax(source) {
|
|
35295
|
-
return source.replace(
|
|
35296
|
-
return tag.replace(
|
|
35297
|
-
}).replace(
|
|
36200
|
+
return source.replace(WX_DIRECTIVE_CAPTURE_RE, (_2, directive) => `a:${directive}`).replace(WXS_CLOSING_TAG_RE, "</import-sjs").replace(WXS_TAG_RE, "<import-sjs").replace(IMPORT_SJS_TAG_RE, (tag) => {
|
|
36201
|
+
return tag.replace(SRC_ATTRIBUTE_RE, "from=").replace(MODULE_ATTRIBUTE_RE, "name=");
|
|
36202
|
+
}).replace(ELSE_ATTRIBUTE_RE, " a:else");
|
|
35298
36203
|
}
|
|
35299
36204
|
function rewriteAlipayExtensionReferences(source) {
|
|
35300
|
-
return source.replace(
|
|
36205
|
+
return source.replace(WXML_EXTENSION_RE, ".axml").replace(WXSS_EXTENSION_RE, ".acss").replace(WXS_EXTENSION_RE, ".sjs");
|
|
35301
36206
|
}
|
|
35302
36207
|
function transformWxmlToAxmlForAlipay(source) {
|
|
35303
36208
|
return rewriteAlipayWxmlSyntax(source);
|
|
@@ -35337,11 +36242,11 @@ async function transformJsModuleToCjsForAlipay(source) {
|
|
|
35337
36242
|
let transformed = false;
|
|
35338
36243
|
const exportAssignments = [];
|
|
35339
36244
|
traverse(ast, {
|
|
35340
|
-
ImportDeclaration(
|
|
35341
|
-
const sourceLiteral = t2.stringLiteral(
|
|
35342
|
-
const specifiers =
|
|
36245
|
+
ImportDeclaration(path82) {
|
|
36246
|
+
const sourceLiteral = t2.stringLiteral(path82.node.source.value);
|
|
36247
|
+
const specifiers = path82.node.specifiers ?? [];
|
|
35343
36248
|
if (specifiers.length === 0) {
|
|
35344
|
-
|
|
36249
|
+
path82.replaceWith(
|
|
35345
36250
|
t2.expressionStatement(
|
|
35346
36251
|
t2.callExpression(t2.identifier("require"), [sourceLiteral])
|
|
35347
36252
|
)
|
|
@@ -35349,7 +36254,7 @@ async function transformJsModuleToCjsForAlipay(source) {
|
|
|
35349
36254
|
transformed = true;
|
|
35350
36255
|
return;
|
|
35351
36256
|
}
|
|
35352
|
-
const requireId =
|
|
36257
|
+
const requireId = path82.scope.generateUidIdentifier("imported");
|
|
35353
36258
|
const statements = [
|
|
35354
36259
|
t2.variableDeclaration("const", [
|
|
35355
36260
|
t2.variableDeclarator(
|
|
@@ -35396,23 +36301,23 @@ async function transformJsModuleToCjsForAlipay(source) {
|
|
|
35396
36301
|
])
|
|
35397
36302
|
);
|
|
35398
36303
|
}
|
|
35399
|
-
|
|
36304
|
+
path82.replaceWithMultiple(statements);
|
|
35400
36305
|
transformed = true;
|
|
35401
36306
|
},
|
|
35402
|
-
ExportDefaultDeclaration(
|
|
35403
|
-
const declaration =
|
|
36307
|
+
ExportDefaultDeclaration(path82) {
|
|
36308
|
+
const declaration = path82.node.declaration;
|
|
35404
36309
|
if (t2.isFunctionDeclaration(declaration) || t2.isClassDeclaration(declaration)) {
|
|
35405
|
-
const exportId = declaration.id ??
|
|
36310
|
+
const exportId = declaration.id ?? path82.scope.generateUidIdentifier("defaultExport");
|
|
35406
36311
|
if (!declaration.id) {
|
|
35407
36312
|
declaration.id = exportId;
|
|
35408
36313
|
}
|
|
35409
|
-
|
|
36314
|
+
path82.replaceWith(declaration);
|
|
35410
36315
|
exportAssignments.push(createExportsAssignment("default", exportId));
|
|
35411
36316
|
transformed = true;
|
|
35412
36317
|
return;
|
|
35413
36318
|
}
|
|
35414
|
-
const targetId =
|
|
35415
|
-
|
|
36319
|
+
const targetId = path82.scope.generateUidIdentifier("defaultExport");
|
|
36320
|
+
path82.replaceWith(
|
|
35416
36321
|
t2.variableDeclaration("const", [
|
|
35417
36322
|
t2.variableDeclarator(targetId, declaration)
|
|
35418
36323
|
])
|
|
@@ -35420,10 +36325,10 @@ async function transformJsModuleToCjsForAlipay(source) {
|
|
|
35420
36325
|
exportAssignments.push(createExportsAssignment("default", targetId));
|
|
35421
36326
|
transformed = true;
|
|
35422
36327
|
},
|
|
35423
|
-
ExportNamedDeclaration(
|
|
35424
|
-
const declaration =
|
|
36328
|
+
ExportNamedDeclaration(path82) {
|
|
36329
|
+
const declaration = path82.node.declaration;
|
|
35425
36330
|
if (declaration) {
|
|
35426
|
-
|
|
36331
|
+
path82.replaceWith(declaration);
|
|
35427
36332
|
const names = Object.keys(t2.getBindingIdentifiers(declaration));
|
|
35428
36333
|
for (const name of names) {
|
|
35429
36334
|
exportAssignments.push(createExportsAssignment(name, t2.identifier(name)));
|
|
@@ -35431,19 +36336,19 @@ async function transformJsModuleToCjsForAlipay(source) {
|
|
|
35431
36336
|
transformed = true;
|
|
35432
36337
|
return;
|
|
35433
36338
|
}
|
|
35434
|
-
const specifiers =
|
|
36339
|
+
const specifiers = path82.node.specifiers ?? [];
|
|
35435
36340
|
if (specifiers.length === 0) {
|
|
35436
|
-
|
|
36341
|
+
path82.remove();
|
|
35437
36342
|
transformed = true;
|
|
35438
36343
|
return;
|
|
35439
36344
|
}
|
|
35440
|
-
if (
|
|
35441
|
-
const requireId =
|
|
36345
|
+
if (path82.node.source) {
|
|
36346
|
+
const requireId = path82.scope.generateUidIdentifier("reExported");
|
|
35442
36347
|
const statements2 = [
|
|
35443
36348
|
t2.variableDeclaration("const", [
|
|
35444
36349
|
t2.variableDeclarator(
|
|
35445
36350
|
requireId,
|
|
35446
|
-
t2.callExpression(t2.identifier("require"), [t2.stringLiteral(
|
|
36351
|
+
t2.callExpression(t2.identifier("require"), [t2.stringLiteral(path82.node.source.value)])
|
|
35447
36352
|
)
|
|
35448
36353
|
])
|
|
35449
36354
|
];
|
|
@@ -35455,7 +36360,7 @@ async function transformJsModuleToCjsForAlipay(source) {
|
|
|
35455
36360
|
const exportedName = getModuleExportName(specifier.exported);
|
|
35456
36361
|
statements2.push(createExportsAssignment(exportedName, createRequireMemberExpression(requireId, localName)));
|
|
35457
36362
|
}
|
|
35458
|
-
|
|
36363
|
+
path82.replaceWithMultiple(statements2);
|
|
35459
36364
|
transformed = true;
|
|
35460
36365
|
return;
|
|
35461
36366
|
}
|
|
@@ -35468,7 +36373,7 @@ async function transformJsModuleToCjsForAlipay(source) {
|
|
|
35468
36373
|
const exportedName = getModuleExportName(specifier.exported);
|
|
35469
36374
|
statements.push(createExportsAssignment(exportedName, t2.identifier(localName)));
|
|
35470
36375
|
}
|
|
35471
|
-
|
|
36376
|
+
path82.replaceWithMultiple(statements);
|
|
35472
36377
|
transformed = true;
|
|
35473
36378
|
}
|
|
35474
36379
|
});
|
|
@@ -35490,7 +36395,7 @@ async function normalizeMiniprogramPackageForAlipay(pkgRoot) {
|
|
|
35490
36395
|
}
|
|
35491
36396
|
const initialFiles = await collectFiles(pkgRoot);
|
|
35492
36397
|
const renameTasks = initialFiles.map((filePath) => {
|
|
35493
|
-
const ext =
|
|
36398
|
+
const ext = path73.extname(filePath);
|
|
35494
36399
|
const nextExt = ALIPAY_EXTENSION_MAP[ext];
|
|
35495
36400
|
if (!nextExt) {
|
|
35496
36401
|
return null;
|
|
@@ -35508,7 +36413,7 @@ async function normalizeMiniprogramPackageForAlipay(pkgRoot) {
|
|
|
35508
36413
|
}
|
|
35509
36414
|
const normalizedFiles = await collectFiles(pkgRoot);
|
|
35510
36415
|
for (const filePath of normalizedFiles) {
|
|
35511
|
-
const ext =
|
|
36416
|
+
const ext = path73.extname(filePath);
|
|
35512
36417
|
if (!ALIPAY_TEXT_FILE_EXTENSIONS.has(ext)) {
|
|
35513
36418
|
continue;
|
|
35514
36419
|
}
|
|
@@ -35527,14 +36432,14 @@ async function normalizeMiniprogramPackageForAlipay(pkgRoot) {
|
|
|
35527
36432
|
}
|
|
35528
36433
|
}
|
|
35529
36434
|
async function hoistNestedMiniprogramDependenciesForAlipay(pkgRoot, outDir) {
|
|
35530
|
-
const nestedRoot =
|
|
36435
|
+
const nestedRoot = path73.resolve(pkgRoot, "miniprogram_npm");
|
|
35531
36436
|
if (!await fs37.pathExists(nestedRoot)) {
|
|
35532
36437
|
return;
|
|
35533
36438
|
}
|
|
35534
36439
|
const entries = await fs37.readdir(nestedRoot);
|
|
35535
36440
|
for (const name of entries) {
|
|
35536
|
-
const source =
|
|
35537
|
-
const target =
|
|
36441
|
+
const source = path73.resolve(nestedRoot, name);
|
|
36442
|
+
const target = path73.resolve(outDir, name);
|
|
35538
36443
|
if (await fs37.pathExists(target)) {
|
|
35539
36444
|
continue;
|
|
35540
36445
|
}
|
|
@@ -35546,11 +36451,11 @@ async function hoistNestedMiniprogramDependenciesForAlipay(pkgRoot, outDir) {
|
|
|
35546
36451
|
}
|
|
35547
36452
|
}
|
|
35548
36453
|
async function copyEsModuleDirectoryForAlipay(sourceRoot, targetRoot) {
|
|
35549
|
-
const sourceDir =
|
|
36454
|
+
const sourceDir = path73.resolve(sourceRoot, "es");
|
|
35550
36455
|
if (!await fs37.pathExists(sourceDir)) {
|
|
35551
36456
|
return false;
|
|
35552
36457
|
}
|
|
35553
|
-
await fs37.copy(sourceDir,
|
|
36458
|
+
await fs37.copy(sourceDir, path73.resolve(targetRoot, "es"), {
|
|
35554
36459
|
overwrite: true
|
|
35555
36460
|
});
|
|
35556
36461
|
return true;
|
|
@@ -35564,7 +36469,18 @@ function createPackageBuilder(ctx, oxcVitePlugin) {
|
|
|
35564
36469
|
async function shouldSkipBuild(outDir, isOutdated) {
|
|
35565
36470
|
return !isOutdated && await fs37.pathExists(outDir);
|
|
35566
36471
|
}
|
|
35567
|
-
|
|
36472
|
+
function resolveBuildOutDir(options, fallbackOutDir) {
|
|
36473
|
+
const rawOutDir = options?.build?.outDir;
|
|
36474
|
+
if (typeof rawOutDir !== "string" || !rawOutDir.trim()) {
|
|
36475
|
+
return fallbackOutDir;
|
|
36476
|
+
}
|
|
36477
|
+
if (path73.isAbsolute(rawOutDir)) {
|
|
36478
|
+
return rawOutDir;
|
|
36479
|
+
}
|
|
36480
|
+
const root = typeof options.root === "string" && options.root ? options.root : ctx.configService?.cwd ?? process11.cwd();
|
|
36481
|
+
return path73.resolve(root, rawOutDir);
|
|
36482
|
+
}
|
|
36483
|
+
function resolvePackageBuildTarget({ entry, name, options, outDir }) {
|
|
35568
36484
|
const defineImportMetaEnv = ctx.configService?.defineImportMetaEnv ?? {};
|
|
35569
36485
|
const mergedOptions = defu9(options, {
|
|
35570
36486
|
configFile: false,
|
|
@@ -35605,34 +36521,50 @@ function createPackageBuilder(ctx, oxcVitePlugin) {
|
|
|
35605
36521
|
} else if (isObject10(resolvedOptions)) {
|
|
35606
36522
|
finalOptions = resolvedOptions;
|
|
35607
36523
|
}
|
|
35608
|
-
|
|
35609
|
-
|
|
35610
|
-
|
|
35611
|
-
|
|
35612
|
-
|
|
35613
|
-
|
|
35614
|
-
|
|
36524
|
+
return {
|
|
36525
|
+
outDir: resolveBuildOutDir(finalOptions ?? mergedOptions, outDir),
|
|
36526
|
+
options: finalOptions
|
|
36527
|
+
};
|
|
36528
|
+
}
|
|
36529
|
+
async function runResolvedBundleBuild(finalOptions) {
|
|
36530
|
+
if (!finalOptions) {
|
|
36531
|
+
return;
|
|
36532
|
+
}
|
|
36533
|
+
if (oxcVitePlugin) {
|
|
36534
|
+
const toPluginArray = (plugins) => {
|
|
36535
|
+
const queue = [];
|
|
36536
|
+
const result = [];
|
|
36537
|
+
if (plugins) {
|
|
36538
|
+
queue.push(plugins);
|
|
36539
|
+
}
|
|
36540
|
+
while (queue.length > 0) {
|
|
36541
|
+
const current2 = queue.shift();
|
|
36542
|
+
if (!current2) {
|
|
36543
|
+
continue;
|
|
35615
36544
|
}
|
|
35616
|
-
|
|
35617
|
-
|
|
35618
|
-
|
|
35619
|
-
continue;
|
|
35620
|
-
}
|
|
35621
|
-
if (Array.isArray(current2)) {
|
|
35622
|
-
queue.unshift(...current2);
|
|
35623
|
-
continue;
|
|
35624
|
-
}
|
|
35625
|
-
result.push(current2);
|
|
36545
|
+
if (Array.isArray(current2)) {
|
|
36546
|
+
queue.unshift(...current2);
|
|
36547
|
+
continue;
|
|
35626
36548
|
}
|
|
35627
|
-
|
|
35628
|
-
}
|
|
35629
|
-
|
|
35630
|
-
|
|
35631
|
-
|
|
35632
|
-
|
|
35633
|
-
|
|
35634
|
-
|
|
36549
|
+
result.push(current2);
|
|
36550
|
+
}
|
|
36551
|
+
return result;
|
|
36552
|
+
};
|
|
36553
|
+
const existing = toPluginArray(finalOptions.plugins);
|
|
36554
|
+
const hasPlugin = existing.includes(oxcVitePlugin);
|
|
36555
|
+
const nextPlugins = hasPlugin ? existing : [oxcVitePlugin, ...existing];
|
|
36556
|
+
finalOptions.plugins = nextPlugins;
|
|
35635
36557
|
}
|
|
36558
|
+
await viteBuild(finalOptions);
|
|
36559
|
+
}
|
|
36560
|
+
async function bundleBuild({ entry, name, options, outDir }) {
|
|
36561
|
+
const resolvedTarget = resolvePackageBuildTarget({
|
|
36562
|
+
entry,
|
|
36563
|
+
name,
|
|
36564
|
+
options,
|
|
36565
|
+
outDir
|
|
36566
|
+
});
|
|
36567
|
+
await runResolvedBundleBuild(resolvedTarget.options);
|
|
35636
36568
|
}
|
|
35637
36569
|
async function copyBuild({ from, to }) {
|
|
35638
36570
|
await fs37.copy(
|
|
@@ -35649,8 +36581,24 @@ function createPackageBuilder(ctx, oxcVitePlugin) {
|
|
|
35649
36581
|
const { packageJson: targetJson, rootPath } = packageInfo;
|
|
35650
36582
|
const dependencies = targetJson.dependencies ?? {};
|
|
35651
36583
|
const keys = Object.keys(dependencies);
|
|
35652
|
-
const destOutDir = path72.resolve(outDir, dep);
|
|
35653
36584
|
if (isMiniprogramPackage(targetJson)) {
|
|
36585
|
+
const sourceDir = path73.resolve(
|
|
36586
|
+
rootPath,
|
|
36587
|
+
targetJson.miniprogram
|
|
36588
|
+
);
|
|
36589
|
+
const resolvedTarget = resolvePackageBuildTarget({
|
|
36590
|
+
entry: {
|
|
36591
|
+
index: sourceDir
|
|
36592
|
+
},
|
|
36593
|
+
name: dep,
|
|
36594
|
+
options,
|
|
36595
|
+
outDir: path73.resolve(outDir, dep)
|
|
36596
|
+
});
|
|
36597
|
+
const destOutDir = resolvedTarget.outDir;
|
|
36598
|
+
if (!resolvedTarget.options) {
|
|
36599
|
+
npmLogger.info(`[npm] \u4F9D\u8D56 \`${dep}\` \u88AB npm.buildOptions \u8DF3\u8FC7\u5904\u7406!`);
|
|
36600
|
+
return;
|
|
36601
|
+
}
|
|
35654
36602
|
if (await shouldSkipBuild(destOutDir, isDependenciesCacheOutdate)) {
|
|
35655
36603
|
const alipayNpmDistDirName = getAlipayNpmDistDirName(ctx.configService.weappViteConfig?.npm?.alipayNpmMode);
|
|
35656
36604
|
const shouldRebuildAlipayPackage = ctx.configService.platform === "alipay" ? await shouldRebuildCachedAlipayMiniprogramPackage(destOutDir, outDir, rootPath, alipayNpmDistDirName) : false;
|
|
@@ -35660,10 +36608,7 @@ function createPackageBuilder(ctx, oxcVitePlugin) {
|
|
|
35660
36608
|
}
|
|
35661
36609
|
}
|
|
35662
36610
|
await copyBuild({
|
|
35663
|
-
from:
|
|
35664
|
-
rootPath,
|
|
35665
|
-
targetJson.miniprogram
|
|
35666
|
-
),
|
|
36611
|
+
from: sourceDir,
|
|
35667
36612
|
to: destOutDir,
|
|
35668
36613
|
name: dep
|
|
35669
36614
|
});
|
|
@@ -35693,8 +36638,21 @@ function createPackageBuilder(ctx, oxcVitePlugin) {
|
|
|
35693
36638
|
npmLogger.warn(`[npm] \u65E0\u6CD5\u89E3\u6790\u6A21\u5757 \`${dep}\`\uFF0C\u8DF3\u8FC7\u5904\u7406!`);
|
|
35694
36639
|
return;
|
|
35695
36640
|
}
|
|
36641
|
+
const resolvedTarget = resolvePackageBuildTarget({
|
|
36642
|
+
entry: {
|
|
36643
|
+
index
|
|
36644
|
+
},
|
|
36645
|
+
name: dep,
|
|
36646
|
+
options,
|
|
36647
|
+
outDir: path73.resolve(outDir, dep)
|
|
36648
|
+
});
|
|
36649
|
+
const destOutDir = resolvedTarget.outDir;
|
|
36650
|
+
if (!resolvedTarget.options) {
|
|
36651
|
+
npmLogger.info(`[npm] \u4F9D\u8D56 \`${dep}\` \u88AB npm.buildOptions \u8DF3\u8FC7\u5904\u7406!`);
|
|
36652
|
+
return;
|
|
36653
|
+
}
|
|
35696
36654
|
if (!isDependenciesCacheOutdate && await fs37.pathExists(destOutDir)) {
|
|
35697
|
-
const destEntry =
|
|
36655
|
+
const destEntry = path73.resolve(destOutDir, "index.js");
|
|
35698
36656
|
if (await fs37.pathExists(destEntry)) {
|
|
35699
36657
|
const [srcStat, destStat] = await Promise.all([fs37.stat(index), fs37.stat(destEntry)]);
|
|
35700
36658
|
if (srcStat.mtimeMs <= destStat.mtimeMs) {
|
|
@@ -35703,14 +36661,7 @@ function createPackageBuilder(ctx, oxcVitePlugin) {
|
|
|
35703
36661
|
}
|
|
35704
36662
|
}
|
|
35705
36663
|
}
|
|
35706
|
-
await
|
|
35707
|
-
entry: {
|
|
35708
|
-
index
|
|
35709
|
-
},
|
|
35710
|
-
name: dep,
|
|
35711
|
-
options,
|
|
35712
|
-
outDir: destOutDir
|
|
35713
|
-
});
|
|
36664
|
+
await runResolvedBundleBuild(resolvedTarget.options);
|
|
35714
36665
|
if (keys.length > 0) {
|
|
35715
36666
|
await Promise.all(
|
|
35716
36667
|
keys.filter((x3) => isBuiltin(x3)).map((x3) => {
|
|
@@ -35727,7 +36678,7 @@ function createPackageBuilder(ctx, oxcVitePlugin) {
|
|
|
35727
36678
|
npmLogger.success(`[npm] \`${dep}\` \u4F9D\u8D56\u5904\u7406\u5B8C\u6210!`);
|
|
35728
36679
|
}
|
|
35729
36680
|
buildPackage = async ({ dep, outDir, options, isDependenciesCacheOutdate }) => {
|
|
35730
|
-
const taskKey = `${
|
|
36681
|
+
const taskKey = `${path73.resolve(outDir)}::${dep}`;
|
|
35731
36682
|
const pending = packageBuildInFlight.get(taskKey);
|
|
35732
36683
|
if (pending) {
|
|
35733
36684
|
return pending;
|
|
@@ -35758,21 +36709,49 @@ function createPackageBuilder(ctx, oxcVitePlugin) {
|
|
|
35758
36709
|
init_esm_shims();
|
|
35759
36710
|
import { isObject as isObject11, objectHash } from "@weapp-core/shared";
|
|
35760
36711
|
import fs38 from "fs-extra";
|
|
35761
|
-
import
|
|
36712
|
+
import path74 from "pathe";
|
|
36713
|
+
var CACHE_KEY_RE = /[\\/]/;
|
|
36714
|
+
function serializeDependencyScope(scope) {
|
|
36715
|
+
if (scope === false) {
|
|
36716
|
+
return false;
|
|
36717
|
+
}
|
|
36718
|
+
if (!Array.isArray(scope)) {
|
|
36719
|
+
return void 0;
|
|
36720
|
+
}
|
|
36721
|
+
return scope.map((item) => {
|
|
36722
|
+
return typeof item === "string" ? item : item.toString();
|
|
36723
|
+
});
|
|
36724
|
+
}
|
|
36725
|
+
function resolveMainPackageDependencyScope(ctx) {
|
|
36726
|
+
const configService = requireConfigService(ctx, "\u8BFB\u53D6\u4E3B\u5305 npm \u4F9D\u8D56\u8303\u56F4\u524D\u5FC5\u987B\u521D\u59CB\u5316 configService\u3002");
|
|
36727
|
+
return configService.weappViteConfig?.npm?.mainPackage?.dependencies;
|
|
36728
|
+
}
|
|
35762
36729
|
function createDependenciesCache(ctx) {
|
|
35763
36730
|
function getDependenciesCacheFilePath(key = "/") {
|
|
35764
36731
|
const configService = requireConfigService(ctx, "\u751F\u6210 npm \u7F13\u5B58\u8DEF\u5F84\u524D\u5FC5\u987B\u521D\u59CB\u5316 configService\u3002");
|
|
35765
|
-
return
|
|
36732
|
+
return path74.resolve(configService.cwd, `node_modules/weapp-vite/.cache/${key.replace(CACHE_KEY_RE, "-")}.json`);
|
|
36733
|
+
}
|
|
36734
|
+
function resolveDependencyScope(root) {
|
|
36735
|
+
if (root === "__all__") {
|
|
36736
|
+
return void 0;
|
|
36737
|
+
}
|
|
36738
|
+
if (root && root !== "/") {
|
|
36739
|
+
return ctx.scanService?.subPackageMap.get(root)?.subPackage.dependencies;
|
|
36740
|
+
}
|
|
36741
|
+
return resolveMainPackageDependencyScope(ctx);
|
|
35766
36742
|
}
|
|
35767
|
-
function dependenciesCacheHash() {
|
|
36743
|
+
function dependenciesCacheHash(root) {
|
|
35768
36744
|
const configService = requireConfigService(ctx, "\u8BFB\u53D6\u4F9D\u8D56\u7F13\u5B58\u54C8\u5E0C\u524D\u5FC5\u987B\u521D\u59CB\u5316 configService\u3002");
|
|
35769
|
-
return objectHash(
|
|
36745
|
+
return objectHash({
|
|
36746
|
+
dependencies: configService.packageJson.dependencies ?? {},
|
|
36747
|
+
scope: serializeDependencyScope(resolveDependencyScope(root))
|
|
36748
|
+
});
|
|
35770
36749
|
}
|
|
35771
36750
|
async function writeDependenciesCache(root) {
|
|
35772
36751
|
const configService = requireConfigService(ctx, "\u5199\u5165 npm \u7F13\u5B58\u524D\u5FC5\u987B\u521D\u59CB\u5316 configService\u3002");
|
|
35773
36752
|
if (configService.weappViteConfig?.npm?.cache) {
|
|
35774
36753
|
await fs38.outputJSON(getDependenciesCacheFilePath(root), {
|
|
35775
|
-
hash: dependenciesCacheHash()
|
|
36754
|
+
hash: dependenciesCacheHash(root)
|
|
35776
36755
|
});
|
|
35777
36756
|
}
|
|
35778
36757
|
}
|
|
@@ -35786,7 +36765,7 @@ function createDependenciesCache(ctx) {
|
|
|
35786
36765
|
if (ctx.configService?.weappViteConfig?.npm?.cache) {
|
|
35787
36766
|
const json = await readDependenciesCache(root);
|
|
35788
36767
|
if (isObject11(json)) {
|
|
35789
|
-
return dependenciesCacheHash() !== json.hash;
|
|
36768
|
+
return dependenciesCacheHash(root) !== json.hash;
|
|
35790
36769
|
}
|
|
35791
36770
|
return true;
|
|
35792
36771
|
}
|
|
@@ -35794,7 +36773,7 @@ function createDependenciesCache(ctx) {
|
|
|
35794
36773
|
}
|
|
35795
36774
|
return {
|
|
35796
36775
|
getDependenciesCacheFilePath,
|
|
35797
|
-
dependenciesCacheHash,
|
|
36776
|
+
dependenciesCacheHash: () => dependenciesCacheHash(),
|
|
35798
36777
|
writeDependenciesCache,
|
|
35799
36778
|
readDependenciesCache,
|
|
35800
36779
|
checkDependenciesCacheOutdate
|
|
@@ -35803,7 +36782,7 @@ function createDependenciesCache(ctx) {
|
|
|
35803
36782
|
|
|
35804
36783
|
// src/runtime/npmPlugin/relations.ts
|
|
35805
36784
|
init_esm_shims();
|
|
35806
|
-
import
|
|
36785
|
+
import path75 from "pathe";
|
|
35807
36786
|
function normalizeRelativeDir(value) {
|
|
35808
36787
|
const normalized = toPosixPath(value).replace(/\/+$/, "");
|
|
35809
36788
|
const trimmed = normalized.startsWith("./") ? normalized.slice(2) : normalized;
|
|
@@ -35852,13 +36831,13 @@ function getPackNpmRelationList(ctx) {
|
|
|
35852
36831
|
return [
|
|
35853
36832
|
{
|
|
35854
36833
|
...packNpmRelationList[0],
|
|
35855
|
-
miniprogramNpmDistDir:
|
|
36834
|
+
miniprogramNpmDistDir: path75.join("dist", configService.platform, resolvePlatformProjectRoot(configService))
|
|
35856
36835
|
}
|
|
35857
36836
|
];
|
|
35858
36837
|
}
|
|
35859
36838
|
return packNpmRelationList.map((entry) => {
|
|
35860
36839
|
const rawDir = entry.miniprogramNpmDistDir;
|
|
35861
|
-
if (!rawDir ||
|
|
36840
|
+
if (!rawDir || path75.isAbsolute(rawDir)) {
|
|
35862
36841
|
return entry;
|
|
35863
36842
|
}
|
|
35864
36843
|
const trimmed = normalizeRelativeDir(rawDir);
|
|
@@ -35869,12 +36848,83 @@ function getPackNpmRelationList(ctx) {
|
|
|
35869
36848
|
}
|
|
35870
36849
|
return {
|
|
35871
36850
|
...entry,
|
|
35872
|
-
miniprogramNpmDistDir:
|
|
36851
|
+
miniprogramNpmDistDir: path75.join("dist", configService.platform, trimmed)
|
|
35873
36852
|
};
|
|
35874
36853
|
});
|
|
35875
36854
|
}
|
|
35876
36855
|
|
|
35877
36856
|
// src/runtime/npmPlugin/service.ts
|
|
36857
|
+
var LEADING_SLASHES_RE = /^\/+/;
|
|
36858
|
+
function matchDependencyName(patterns, dep) {
|
|
36859
|
+
return patterns.some((pattern) => {
|
|
36860
|
+
if (typeof pattern === "string") {
|
|
36861
|
+
return pattern === dep;
|
|
36862
|
+
}
|
|
36863
|
+
pattern.lastIndex = 0;
|
|
36864
|
+
return pattern.test(dep);
|
|
36865
|
+
});
|
|
36866
|
+
}
|
|
36867
|
+
function resolveDependencyId2(value) {
|
|
36868
|
+
const normalized = toPosixPath(value).replace(LEADING_SLASHES_RE, "");
|
|
36869
|
+
const segments = normalized.split("/").filter(Boolean);
|
|
36870
|
+
if (segments.length === 0) {
|
|
36871
|
+
return "";
|
|
36872
|
+
}
|
|
36873
|
+
if (normalized.startsWith("@") && segments.length > 1) {
|
|
36874
|
+
return `${segments[0]}/${segments[1]}`;
|
|
36875
|
+
}
|
|
36876
|
+
return segments[0];
|
|
36877
|
+
}
|
|
36878
|
+
function matchDependencyPath(patterns, value) {
|
|
36879
|
+
const dependencyId = resolveDependencyId2(value);
|
|
36880
|
+
return patterns.some((pattern) => {
|
|
36881
|
+
if (typeof pattern === "string") {
|
|
36882
|
+
return dependencyId === pattern || value === pattern || value.startsWith(`${pattern}/`);
|
|
36883
|
+
}
|
|
36884
|
+
pattern.lastIndex = 0;
|
|
36885
|
+
if (pattern.test(dependencyId)) {
|
|
36886
|
+
return true;
|
|
36887
|
+
}
|
|
36888
|
+
pattern.lastIndex = 0;
|
|
36889
|
+
return pattern.test(value);
|
|
36890
|
+
});
|
|
36891
|
+
}
|
|
36892
|
+
function resolveTargetDependencies(allDependencies, patterns) {
|
|
36893
|
+
if (patterns === false) {
|
|
36894
|
+
return [];
|
|
36895
|
+
}
|
|
36896
|
+
if (!Array.isArray(patterns)) {
|
|
36897
|
+
return allDependencies;
|
|
36898
|
+
}
|
|
36899
|
+
const selected = /* @__PURE__ */ new Set();
|
|
36900
|
+
for (const dep of allDependencies) {
|
|
36901
|
+
if (matchDependencyName(patterns, dep)) {
|
|
36902
|
+
selected.add(dep);
|
|
36903
|
+
}
|
|
36904
|
+
}
|
|
36905
|
+
for (const pattern of patterns) {
|
|
36906
|
+
if (typeof pattern === "string") {
|
|
36907
|
+
selected.add(pattern);
|
|
36908
|
+
}
|
|
36909
|
+
}
|
|
36910
|
+
return [...selected];
|
|
36911
|
+
}
|
|
36912
|
+
function hasSameDependencySet(source, target) {
|
|
36913
|
+
if (source.length !== target.length) {
|
|
36914
|
+
return false;
|
|
36915
|
+
}
|
|
36916
|
+
return source.every((dep) => target.includes(dep));
|
|
36917
|
+
}
|
|
36918
|
+
function resolveMainPackageDependencyPatterns(ctx) {
|
|
36919
|
+
return ctx.configService?.weappViteConfig?.npm?.mainPackage?.dependencies;
|
|
36920
|
+
}
|
|
36921
|
+
function hasLocalSubPackageNpmConfig(ctx) {
|
|
36922
|
+
const npmSubPackages = ctx.configService?.weappViteConfig?.npm?.subPackages;
|
|
36923
|
+
if (npmSubPackages && Object.values(npmSubPackages).some((config) => Array.isArray(config?.dependencies) && config.dependencies.length > 0)) {
|
|
36924
|
+
return true;
|
|
36925
|
+
}
|
|
36926
|
+
return false;
|
|
36927
|
+
}
|
|
35878
36928
|
function createNpmService(ctx) {
|
|
35879
36929
|
const oxcRuntimeSupport = createOxcRuntimeSupport();
|
|
35880
36930
|
const oxcVitePlugin = oxcRuntimeSupport.vitePlugin;
|
|
@@ -35891,84 +36941,95 @@ function createNpmService(ctx) {
|
|
|
35891
36941
|
return;
|
|
35892
36942
|
}
|
|
35893
36943
|
debug?.("buildNpm start");
|
|
36944
|
+
if (ctx.scanService && hasLocalSubPackageNpmConfig(ctx) && typeof ctx.scanService.loadAppEntry === "function") {
|
|
36945
|
+
await ctx.scanService.loadAppEntry();
|
|
36946
|
+
if (typeof ctx.scanService.loadSubPackages === "function") {
|
|
36947
|
+
ctx.scanService.loadSubPackages();
|
|
36948
|
+
}
|
|
36949
|
+
}
|
|
35894
36950
|
const packNpmRelationList = getPackNpmRelationList(ctx);
|
|
35895
36951
|
const [mainRelation, ...subRelations] = packNpmRelationList;
|
|
35896
|
-
const packageJsonPath =
|
|
36952
|
+
const packageJsonPath = path76.resolve(ctx.configService.cwd, mainRelation.packageJsonPath);
|
|
35897
36953
|
if (await fs39.pathExists(packageJsonPath)) {
|
|
35898
36954
|
const pkgJson = await fs39.readJson(packageJsonPath);
|
|
35899
36955
|
const npmDistDirName = getNpmDistDirName();
|
|
35900
|
-
const outDir =
|
|
36956
|
+
const outDir = path76.resolve(ctx.configService.cwd, mainRelation.miniprogramNpmDistDir, npmDistDirName);
|
|
36957
|
+
const cachedSourceOutDir = path76.resolve(ctx.configService.cwd, "node_modules/weapp-vite/.cache/npm-source", npmDistDirName);
|
|
36958
|
+
const localSubPackageOutRoot = ctx.configService.outDir || path76.resolve(ctx.configService.cwd, mainRelation.miniprogramNpmDistDir);
|
|
35901
36959
|
if (pkgJson.dependencies) {
|
|
35902
|
-
const
|
|
35903
|
-
|
|
35904
|
-
|
|
36960
|
+
const allDependencies = Object.keys(pkgJson.dependencies);
|
|
36961
|
+
const mainDependencyPatterns = resolveMainPackageDependencyPatterns(ctx);
|
|
36962
|
+
const mainDependencies = resolveTargetDependencies(allDependencies, mainDependencyPatterns);
|
|
36963
|
+
const sourceOutDir = hasSameDependencySet(allDependencies, mainDependencies) ? outDir : cachedSourceOutDir;
|
|
36964
|
+
const localSubPackageMetas = [...ctx.scanService?.subPackageMap.values() ?? []].filter((meta) => Array.isArray(meta.subPackage.dependencies) && meta.subPackage.dependencies.length > 0);
|
|
36965
|
+
const buildTargetDependencies = async (args) => {
|
|
36966
|
+
const isNpmDistMissing = !await fs39.pathExists(args.npmDistDir);
|
|
36967
|
+
const isDependenciesCacheOutdate = isNpmDistMissing || await cache2.checkDependenciesCacheOutdate(args.cacheKey);
|
|
36968
|
+
if (isDependenciesCacheOutdate) {
|
|
36969
|
+
await fs39.remove(args.npmDistDir);
|
|
36970
|
+
}
|
|
36971
|
+
if (args.dependencies.length === 0) {
|
|
36972
|
+
await fs39.remove(args.npmDistDir);
|
|
36973
|
+
await cache2.writeDependenciesCache(args.cacheKey);
|
|
36974
|
+
return;
|
|
36975
|
+
}
|
|
35905
36976
|
await Promise.all(
|
|
35906
|
-
dependencies.map((dep) => {
|
|
36977
|
+
args.dependencies.map((dep) => {
|
|
35907
36978
|
return builder.buildPackage({
|
|
35908
36979
|
dep,
|
|
35909
|
-
outDir,
|
|
36980
|
+
outDir: args.npmDistDir,
|
|
35910
36981
|
options,
|
|
35911
36982
|
isDependenciesCacheOutdate
|
|
35912
36983
|
});
|
|
35913
36984
|
})
|
|
35914
36985
|
);
|
|
35915
|
-
await cache2.writeDependenciesCache();
|
|
35916
|
-
|
|
35917
|
-
|
|
35918
|
-
|
|
35919
|
-
|
|
35920
|
-
|
|
35921
|
-
|
|
35922
|
-
|
|
35923
|
-
|
|
35924
|
-
|
|
35925
|
-
|
|
35926
|
-
|
|
35927
|
-
|
|
35928
|
-
|
|
35929
|
-
|
|
35930
|
-
|
|
35931
|
-
|
|
35932
|
-
|
|
35933
|
-
|
|
35934
|
-
|
|
35935
|
-
|
|
35936
|
-
|
|
35937
|
-
|
|
35938
|
-
|
|
35939
|
-
|
|
35940
|
-
|
|
35941
|
-
|
|
35942
|
-
|
|
35943
|
-
|
|
35944
|
-
|
|
35945
|
-
|
|
35946
|
-
|
|
35947
|
-
|
|
35948
|
-
|
|
35949
|
-
|
|
36986
|
+
await cache2.writeDependenciesCache(args.cacheKey);
|
|
36987
|
+
};
|
|
36988
|
+
if (sourceOutDir !== outDir) {
|
|
36989
|
+
await buildTargetDependencies({
|
|
36990
|
+
cacheKey: "__all__",
|
|
36991
|
+
dependencies: allDependencies,
|
|
36992
|
+
npmDistDir: sourceOutDir
|
|
36993
|
+
});
|
|
36994
|
+
}
|
|
36995
|
+
await buildTargetDependencies({
|
|
36996
|
+
dependencies: mainDependencies,
|
|
36997
|
+
npmDistDir: outDir
|
|
36998
|
+
});
|
|
36999
|
+
if (mainDependencies.length === 0) {
|
|
37000
|
+
await Promise.all(subRelations.map((relation) => {
|
|
37001
|
+
return fs39.remove(path76.resolve(ctx.configService.cwd, relation.miniprogramNpmDistDir, npmDistDirName));
|
|
37002
|
+
}));
|
|
37003
|
+
} else {
|
|
37004
|
+
await Promise.all(subRelations.map(async (relation) => {
|
|
37005
|
+
const targetDir = path76.resolve(ctx.configService.cwd, relation.miniprogramNpmDistDir, npmDistDirName);
|
|
37006
|
+
await fs39.remove(targetDir);
|
|
37007
|
+
await fs39.copy(outDir, targetDir, {
|
|
37008
|
+
overwrite: true
|
|
37009
|
+
});
|
|
37010
|
+
}));
|
|
37011
|
+
}
|
|
37012
|
+
await Promise.all(Array.from(localSubPackageMetas, async (meta) => {
|
|
37013
|
+
const targetDir = path76.resolve(localSubPackageOutRoot, meta.subPackage.root, npmDistDirName);
|
|
37014
|
+
const isDependenciesCacheOutdate = await cache2.checkDependenciesCacheOutdate(meta.subPackage.root);
|
|
37015
|
+
if (isDependenciesCacheOutdate || !await fs39.pathExists(targetDir)) {
|
|
37016
|
+
await fs39.remove(targetDir);
|
|
37017
|
+
await fs39.copy(sourceOutDir, targetDir, {
|
|
37018
|
+
overwrite: true,
|
|
37019
|
+
filter: (src) => {
|
|
37020
|
+
if (Array.isArray(meta.subPackage.dependencies)) {
|
|
37021
|
+
const relPath = toPosixPath(path76.relative(sourceOutDir, src));
|
|
37022
|
+
if (relPath === "") {
|
|
35950
37023
|
return true;
|
|
35951
37024
|
}
|
|
35952
|
-
|
|
35953
|
-
}
|
|
35954
|
-
await cache2.writeDependenciesCache(x3.root);
|
|
35955
|
-
} else {
|
|
35956
|
-
await fs39.copy(outDir, x3.npmDistDir, {
|
|
35957
|
-
overwrite: true,
|
|
35958
|
-
filter: (src) => {
|
|
35959
|
-
if (Array.isArray(x3.dependencies)) {
|
|
35960
|
-
const relPath = toPosixPath(path75.relative(outDir, src));
|
|
35961
|
-
if (relPath === "") {
|
|
35962
|
-
return true;
|
|
35963
|
-
}
|
|
35964
|
-
return regExpTest(x3.dependencies, relPath);
|
|
35965
|
-
}
|
|
35966
|
-
return true;
|
|
37025
|
+
return matchDependencyPath(meta.subPackage.dependencies, relPath);
|
|
35967
37026
|
}
|
|
35968
|
-
|
|
35969
|
-
|
|
35970
|
-
|
|
35971
|
-
|
|
37027
|
+
return true;
|
|
37028
|
+
}
|
|
37029
|
+
});
|
|
37030
|
+
}
|
|
37031
|
+
await cache2.writeDependenciesCache(meta.subPackage.root);
|
|
37032
|
+
}));
|
|
35972
37033
|
}
|
|
35973
37034
|
}
|
|
35974
37035
|
debug?.("buildNpm end");
|
|
@@ -36994,7 +38055,26 @@ function createRuntimeState() {
|
|
|
36994
38055
|
"const pages = routes.pages;",
|
|
36995
38056
|
"const entries = routes.entries;",
|
|
36996
38057
|
"const subPackages = routes.subPackages;",
|
|
36997
|
-
"
|
|
38058
|
+
"const resolveMiniProgramGlobal = () => (globalThis.wx ?? globalThis.tt ?? globalThis.my);",
|
|
38059
|
+
"const callRouteMethod = (methodName, option) => {",
|
|
38060
|
+
" const miniProgramGlobal = resolveMiniProgramGlobal();",
|
|
38061
|
+
" const routeMethod = miniProgramGlobal?.[methodName];",
|
|
38062
|
+
' if (typeof routeMethod !== "function") {',
|
|
38063
|
+
' throw new Error("[weapp-vite] \u5F53\u524D\u8FD0\u884C\u73AF\u5883\u4E0D\u652F\u6301\u8DEF\u7531\u65B9\u6CD5: " + methodName);',
|
|
38064
|
+
" }",
|
|
38065
|
+
" if (option === undefined) {",
|
|
38066
|
+
" return routeMethod.call(miniProgramGlobal);",
|
|
38067
|
+
" }",
|
|
38068
|
+
" return routeMethod.call(miniProgramGlobal, option);",
|
|
38069
|
+
"};",
|
|
38070
|
+
"const wxRouter = {",
|
|
38071
|
+
' switchTab(option) { return callRouteMethod("switchTab", option); },',
|
|
38072
|
+
' reLaunch(option) { return callRouteMethod("reLaunch", option); },',
|
|
38073
|
+
' redirectTo(option) { return callRouteMethod("redirectTo", option); },',
|
|
38074
|
+
' navigateTo(option) { return callRouteMethod("navigateTo", option); },',
|
|
38075
|
+
' navigateBack(option) { return callRouteMethod("navigateBack", option); },',
|
|
38076
|
+
"};",
|
|
38077
|
+
"export { routes, pages, entries, subPackages, wxRouter };",
|
|
36998
38078
|
"export default routes;"
|
|
36999
38079
|
].join("\n"),
|
|
37000
38080
|
typedDefinition: "",
|
|
@@ -37060,12 +38140,12 @@ init_esm_shims();
|
|
|
37060
38140
|
// src/runtime/scanPlugin/service.ts
|
|
37061
38141
|
init_esm_shims();
|
|
37062
38142
|
import { isObject as isObject12 } from "@weapp-core/shared";
|
|
37063
|
-
import
|
|
38143
|
+
import path80 from "pathe";
|
|
37064
38144
|
|
|
37065
38145
|
// src/runtime/scanPlugin/styleEntries/index.ts
|
|
37066
38146
|
init_esm_shims();
|
|
37067
38147
|
import fs42 from "fs-extra";
|
|
37068
|
-
import
|
|
38148
|
+
import path79 from "pathe";
|
|
37069
38149
|
|
|
37070
38150
|
// src/runtime/scanPlugin/styleEntries/config.ts
|
|
37071
38151
|
init_esm_shims();
|
|
@@ -37136,7 +38216,7 @@ function coerceStyleConfig(entry) {
|
|
|
37136
38216
|
// src/runtime/scanPlugin/styleEntries/entries.ts
|
|
37137
38217
|
init_esm_shims();
|
|
37138
38218
|
import fs41 from "fs-extra";
|
|
37139
|
-
import
|
|
38219
|
+
import path77 from "pathe";
|
|
37140
38220
|
|
|
37141
38221
|
// src/runtime/scanPlugin/styleEntries/patterns.ts
|
|
37142
38222
|
init_esm_shims();
|
|
@@ -37220,18 +38300,18 @@ function addStyleEntry(descriptor, absolutePath, posixOutput, root, normalizedRo
|
|
|
37220
38300
|
source: descriptor.source,
|
|
37221
38301
|
absolutePath,
|
|
37222
38302
|
outputRelativePath: posixOutput,
|
|
37223
|
-
inputExtension:
|
|
38303
|
+
inputExtension: path77.extname(absolutePath).toLowerCase(),
|
|
37224
38304
|
scope: descriptor.scope,
|
|
37225
38305
|
include,
|
|
37226
38306
|
exclude
|
|
37227
38307
|
});
|
|
37228
38308
|
}
|
|
37229
38309
|
function appendDefaultScopedStyleEntries(root, normalizedRoot, service, dedupe, normalized) {
|
|
37230
|
-
const absoluteSubRoot =
|
|
38310
|
+
const absoluteSubRoot = path77.resolve(service.absoluteSrcRoot, root);
|
|
37231
38311
|
for (const { base, scope } of DEFAULT_SCOPED_FILES) {
|
|
37232
38312
|
for (const ext of DEFAULT_SCOPED_EXTENSIONS) {
|
|
37233
38313
|
const filename = `${base}${ext}`;
|
|
37234
|
-
const absolutePath =
|
|
38314
|
+
const absolutePath = path77.resolve(absoluteSubRoot, filename);
|
|
37235
38315
|
if (!fs41.existsSync(absolutePath)) {
|
|
37236
38316
|
continue;
|
|
37237
38317
|
}
|
|
@@ -37256,7 +38336,7 @@ function appendDefaultScopedStyleEntries(root, normalizedRoot, service, dedupe,
|
|
|
37256
38336
|
|
|
37257
38337
|
// src/runtime/scanPlugin/styleEntries/resolve.ts
|
|
37258
38338
|
init_esm_shims();
|
|
37259
|
-
import
|
|
38339
|
+
import path78 from "pathe";
|
|
37260
38340
|
function resolveStyleEntryAbsolutePath(source, subPackageRoot, configService) {
|
|
37261
38341
|
const service = configService;
|
|
37262
38342
|
if (!service) {
|
|
@@ -37267,17 +38347,17 @@ function resolveStyleEntryAbsolutePath(source, subPackageRoot, configService) {
|
|
|
37267
38347
|
return void 0;
|
|
37268
38348
|
}
|
|
37269
38349
|
const srcRoot = service.absoluteSrcRoot;
|
|
37270
|
-
const absoluteSubRoot =
|
|
38350
|
+
const absoluteSubRoot = path78.resolve(srcRoot, subPackageRoot);
|
|
37271
38351
|
const normalizedEntry = toPosixPath(trimmed);
|
|
37272
38352
|
const normalizedRoot = toPosixPath(subPackageRoot);
|
|
37273
38353
|
const candidates = [];
|
|
37274
|
-
if (
|
|
38354
|
+
if (path78.isAbsolute(trimmed)) {
|
|
37275
38355
|
candidates.push(trimmed);
|
|
37276
38356
|
} else if (normalizedEntry === normalizedRoot || normalizedEntry.startsWith(`${normalizedRoot}/`)) {
|
|
37277
|
-
candidates.push(
|
|
38357
|
+
candidates.push(path78.resolve(srcRoot, trimmed));
|
|
37278
38358
|
} else {
|
|
37279
|
-
candidates.push(
|
|
37280
|
-
candidates.push(
|
|
38359
|
+
candidates.push(path78.resolve(absoluteSubRoot, trimmed));
|
|
38360
|
+
candidates.push(path78.resolve(srcRoot, trimmed));
|
|
37281
38361
|
}
|
|
37282
38362
|
for (const candidate of candidates) {
|
|
37283
38363
|
if (isPathInside(srcRoot, candidate)) {
|
|
@@ -37305,7 +38385,7 @@ function inferScopeFromRelativePath(relativePath) {
|
|
|
37305
38385
|
if (cleaned.includes("/")) {
|
|
37306
38386
|
return void 0;
|
|
37307
38387
|
}
|
|
37308
|
-
const base =
|
|
38388
|
+
const base = path78.posix.basename(cleaned, path78.posix.extname(cleaned));
|
|
37309
38389
|
if (base === "pages") {
|
|
37310
38390
|
return "pages";
|
|
37311
38391
|
}
|
|
@@ -37347,7 +38427,7 @@ function normalizeSubPackageStyleEntries(styles, subPackage, configService) {
|
|
|
37347
38427
|
default2.warn(`[\u5206\u5305] \u5206\u5305 ${root} \u6837\u5F0F\u5165\u53E3 \`${descriptor.source}\` \u5BF9\u5E94\u6587\u4EF6\u4E0D\u5B58\u5728\uFF0C\u5DF2\u5FFD\u7565\u3002`);
|
|
37348
38428
|
continue;
|
|
37349
38429
|
}
|
|
37350
|
-
const ext =
|
|
38430
|
+
const ext = path79.extname(absolutePath).toLowerCase();
|
|
37351
38431
|
if (!SUPPORTED_SHARED_STYLE_EXTS.has(ext)) {
|
|
37352
38432
|
default2.warn(`[\u5206\u5305] \u5206\u5305 ${root} \u6837\u5F0F\u5165\u53E3 \`${descriptor.source}\` \u5F53\u524D\u4EC5\u652F\u6301\u4EE5\u4E0B\u683C\u5F0F\uFF1A${SUPPORTED_SHARED_STYLE_EXTENSIONS.join(", ")}\uFF0C\u5DF2\u5FFD\u7565\u3002`);
|
|
37353
38433
|
continue;
|
|
@@ -37399,7 +38479,7 @@ function createScanService(ctx) {
|
|
|
37399
38479
|
return scanState.appEntry;
|
|
37400
38480
|
}
|
|
37401
38481
|
const appDirname = ctx.configService.absoluteSrcRoot;
|
|
37402
|
-
const appBasename =
|
|
38482
|
+
const appBasename = path80.resolve(appDirname, "app");
|
|
37403
38483
|
let { path: appConfigFile } = await findJsonEntry(appBasename);
|
|
37404
38484
|
const { path: appEntryPath } = await findJsEntry(appBasename);
|
|
37405
38485
|
let configFromVue;
|
|
@@ -37408,14 +38488,14 @@ function createScanService(ctx) {
|
|
|
37408
38488
|
vueAppPath = await findVueEntry(appBasename);
|
|
37409
38489
|
}
|
|
37410
38490
|
if (!appConfigFile && vueAppPath) {
|
|
37411
|
-
const { extractConfigFromVue: extractConfigFromVue2 } = await import("./file-
|
|
38491
|
+
const { extractConfigFromVue: extractConfigFromVue2 } = await import("./file-VKNW65BI.mjs");
|
|
37412
38492
|
configFromVue = await extractConfigFromVue2(vueAppPath);
|
|
37413
38493
|
if (configFromVue) {
|
|
37414
38494
|
appConfigFile = vueAppPath;
|
|
37415
38495
|
}
|
|
37416
38496
|
}
|
|
37417
38497
|
if (ctx.configService.absolutePluginRoot) {
|
|
37418
|
-
const pluginBasename =
|
|
38498
|
+
const pluginBasename = path80.resolve(ctx.configService.absolutePluginRoot, "plugin");
|
|
37419
38499
|
const { path: pluginConfigFile } = await findJsonEntry(pluginBasename);
|
|
37420
38500
|
if (pluginConfigFile) {
|
|
37421
38501
|
const pluginConfig = await ctx.jsonService.read(pluginConfigFile);
|
|
@@ -37444,14 +38524,14 @@ function createScanService(ctx) {
|
|
|
37444
38524
|
scanState.appEntry = resolvedAppEntry;
|
|
37445
38525
|
const { sitemapLocation = "sitemap.json", themeLocation = "theme.json" } = config;
|
|
37446
38526
|
if (sitemapLocation) {
|
|
37447
|
-
const { path: sitemapJsonPath } = await findJsonEntry(
|
|
38527
|
+
const { path: sitemapJsonPath } = await findJsonEntry(path80.resolve(appDirname, sitemapLocation));
|
|
37448
38528
|
if (sitemapJsonPath) {
|
|
37449
38529
|
resolvedAppEntry.sitemapJsonPath = sitemapJsonPath;
|
|
37450
38530
|
resolvedAppEntry.sitemapJson = await ctx.jsonService.read(sitemapJsonPath);
|
|
37451
38531
|
}
|
|
37452
38532
|
}
|
|
37453
38533
|
if (themeLocation) {
|
|
37454
|
-
const { path: themeJsonPath } = await findJsonEntry(
|
|
38534
|
+
const { path: themeJsonPath } = await findJsonEntry(path80.resolve(appDirname, themeLocation));
|
|
37455
38535
|
if (themeJsonPath) {
|
|
37456
38536
|
resolvedAppEntry.themeJsonPath = themeJsonPath;
|
|
37457
38537
|
resolvedAppEntry.themeJson = await ctx.jsonService.read(themeJsonPath);
|
|
@@ -37485,7 +38565,8 @@ function createScanService(ctx) {
|
|
|
37485
38565
|
entries: resolveSubPackageEntries(subPackage)
|
|
37486
38566
|
};
|
|
37487
38567
|
const subPackageConfig = configService.weappViteConfig?.subPackages?.[subPackage.root];
|
|
37488
|
-
|
|
38568
|
+
const npmSubPackageConfig = configService.weappViteConfig?.npm?.subPackages?.[subPackage.root];
|
|
38569
|
+
meta.subPackage.dependencies = npmSubPackageConfig?.dependencies;
|
|
37489
38570
|
meta.subPackage.inlineConfig = subPackageConfig?.inlineConfig;
|
|
37490
38571
|
meta.autoImportComponents = subPackageConfig?.autoImportComponents;
|
|
37491
38572
|
meta.styleEntries = normalizeSubPackageStyleEntries(
|
|
@@ -37513,12 +38594,12 @@ function createScanService(ctx) {
|
|
|
37513
38594
|
}
|
|
37514
38595
|
}
|
|
37515
38596
|
if (scanState.appEntry) {
|
|
37516
|
-
return
|
|
38597
|
+
return [...subPackageMap.values()];
|
|
37517
38598
|
}
|
|
37518
38599
|
throw new Error(`\u5728 ${configService.absoluteSrcRoot} \u76EE\u5F55\u4E0B\u6CA1\u6709\u627E\u5230 \`app.json\`, \u8BF7\u786E\u4FDD\u4F60\u521D\u59CB\u5316\u4E86\u5C0F\u7A0B\u5E8F\u9879\u76EE\uFF0C\u6216\u8005\u5728 \`vite.config.ts\` \u4E2D\u8BBE\u7F6E\u7684\u6B63\u786E\u7684 \`weapp.srcRoot\` \u914D\u7F6E\u8DEF\u5F84 `);
|
|
37519
38600
|
}
|
|
37520
38601
|
function isMainPackageFileName(fileName) {
|
|
37521
|
-
return
|
|
38602
|
+
return [...independentSubPackageMap.keys()].every((root) => {
|
|
37522
38603
|
return !fileName.startsWith(root);
|
|
37523
38604
|
});
|
|
37524
38605
|
}
|
|
@@ -37570,7 +38651,7 @@ function createScanService(ctx) {
|
|
|
37570
38651
|
}
|
|
37571
38652
|
},
|
|
37572
38653
|
drainIndependentDirtyRoots() {
|
|
37573
|
-
const roots =
|
|
38654
|
+
const roots = [...independentDirtyRoots];
|
|
37574
38655
|
independentDirtyRoots.clear();
|
|
37575
38656
|
return roots;
|
|
37576
38657
|
}
|
|
@@ -37729,7 +38810,7 @@ function createWebServicePlugin(ctx) {
|
|
|
37729
38810
|
init_esm_shims();
|
|
37730
38811
|
import { removeExtensionDeep as removeExtensionDeep15 } from "@weapp-core/shared";
|
|
37731
38812
|
import fs43 from "fs-extra";
|
|
37732
|
-
import
|
|
38813
|
+
import path81 from "pathe";
|
|
37733
38814
|
function createWxmlService(ctx) {
|
|
37734
38815
|
const { depsMap, tokenMap, componentsMap, cache: cache2, emittedCode } = ctx.runtimeState.wxml;
|
|
37735
38816
|
async function addDeps(filepath, deps = []) {
|
|
@@ -37845,7 +38926,7 @@ function createWxmlService(ctx) {
|
|
|
37845
38926
|
return cached;
|
|
37846
38927
|
}
|
|
37847
38928
|
}
|
|
37848
|
-
const dirname5 =
|
|
38929
|
+
const dirname5 = path81.dirname(filepath);
|
|
37849
38930
|
const wxml = await fs43.readFile(filepath, "utf8");
|
|
37850
38931
|
const res = analyze(wxml);
|
|
37851
38932
|
tokenMap.set(filepath, res);
|
|
@@ -37854,9 +38935,9 @@ function createWxmlService(ctx) {
|
|
|
37854
38935
|
filepath,
|
|
37855
38936
|
res.deps.filter((x3) => isImportTag(x3.tagName) && isTemplate(x3.value)).map((x3) => {
|
|
37856
38937
|
if (x3.value.startsWith("/")) {
|
|
37857
|
-
return
|
|
38938
|
+
return path81.resolve(configService.absoluteSrcRoot, x3.value.slice(1));
|
|
37858
38939
|
} else {
|
|
37859
|
-
return
|
|
38940
|
+
return path81.resolve(dirname5, x3.value);
|
|
37860
38941
|
}
|
|
37861
38942
|
})
|
|
37862
38943
|
);
|