weapp-vite 1.7.2 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-444MQSSG.mjs → chunk-25DMVYND.mjs} +5 -0
- package/dist/{chunk-26XKAYVS.mjs → chunk-GK2DYKAY.mjs} +135 -25
- package/dist/chunk-V57P47YG.mjs +41 -0
- package/dist/cli.cjs +148 -27
- package/dist/cli.mjs +7 -2
- package/dist/config.mjs +2 -1
- package/dist/index.cjs +146 -28
- package/dist/index.mjs +8 -2
- package/dist/json.mjs +5 -0
- package/package.json +3 -3
|
@@ -1,9 +1,101 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__commonJS,
|
|
3
|
+
__toESM,
|
|
4
|
+
init_esm_shims
|
|
5
|
+
} from "./chunk-V57P47YG.mjs";
|
|
6
|
+
|
|
7
|
+
// ../../node_modules/.pnpm/debounce@2.2.0/node_modules/debounce/index.js
|
|
8
|
+
var require_debounce = __commonJS({
|
|
9
|
+
"../../node_modules/.pnpm/debounce@2.2.0/node_modules/debounce/index.js"(exports, module) {
|
|
10
|
+
"use strict";
|
|
11
|
+
init_esm_shims();
|
|
12
|
+
function debounce2(function_, wait = 100, options = {}) {
|
|
13
|
+
if (typeof function_ !== "function") {
|
|
14
|
+
throw new TypeError(`Expected the first parameter to be a function, got \`${typeof function_}\`.`);
|
|
15
|
+
}
|
|
16
|
+
if (wait < 0) {
|
|
17
|
+
throw new RangeError("`wait` must not be negative.");
|
|
18
|
+
}
|
|
19
|
+
const { immediate } = typeof options === "boolean" ? { immediate: options } : options;
|
|
20
|
+
let storedContext;
|
|
21
|
+
let storedArguments;
|
|
22
|
+
let timeoutId;
|
|
23
|
+
let timestamp;
|
|
24
|
+
let result;
|
|
25
|
+
function run() {
|
|
26
|
+
const callContext = storedContext;
|
|
27
|
+
const callArguments = storedArguments;
|
|
28
|
+
storedContext = void 0;
|
|
29
|
+
storedArguments = void 0;
|
|
30
|
+
result = function_.apply(callContext, callArguments);
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
function later() {
|
|
34
|
+
const last = Date.now() - timestamp;
|
|
35
|
+
if (last < wait && last >= 0) {
|
|
36
|
+
timeoutId = setTimeout(later, wait - last);
|
|
37
|
+
} else {
|
|
38
|
+
timeoutId = void 0;
|
|
39
|
+
if (!immediate) {
|
|
40
|
+
result = run();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const debounced = function(...arguments_) {
|
|
45
|
+
if (storedContext && this !== storedContext && Object.getPrototypeOf(this) === Object.getPrototypeOf(storedContext)) {
|
|
46
|
+
throw new Error("Debounced method called with different contexts of the same prototype.");
|
|
47
|
+
}
|
|
48
|
+
storedContext = this;
|
|
49
|
+
storedArguments = arguments_;
|
|
50
|
+
timestamp = Date.now();
|
|
51
|
+
const callNow = immediate && !timeoutId;
|
|
52
|
+
if (!timeoutId) {
|
|
53
|
+
timeoutId = setTimeout(later, wait);
|
|
54
|
+
}
|
|
55
|
+
if (callNow) {
|
|
56
|
+
result = run();
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
60
|
+
Object.defineProperty(debounced, "isPending", {
|
|
61
|
+
get() {
|
|
62
|
+
return timeoutId !== void 0;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
debounced.clear = () => {
|
|
66
|
+
if (!timeoutId) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
clearTimeout(timeoutId);
|
|
70
|
+
timeoutId = void 0;
|
|
71
|
+
};
|
|
72
|
+
debounced.flush = () => {
|
|
73
|
+
if (!timeoutId) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
debounced.trigger();
|
|
77
|
+
};
|
|
78
|
+
debounced.trigger = () => {
|
|
79
|
+
result = run();
|
|
80
|
+
debounced.clear();
|
|
81
|
+
};
|
|
82
|
+
return debounced;
|
|
83
|
+
}
|
|
84
|
+
module.exports.debounce = debounce2;
|
|
85
|
+
module.exports = debounce2;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
1
89
|
// src/logger.ts
|
|
90
|
+
init_esm_shims();
|
|
2
91
|
import logger from "@weapp-core/logger";
|
|
3
92
|
var logger_default = logger;
|
|
4
93
|
|
|
94
|
+
// src/constants.ts
|
|
95
|
+
init_esm_shims();
|
|
96
|
+
|
|
5
97
|
// package.json
|
|
6
|
-
var version = "1.7.
|
|
98
|
+
var version = "1.7.3";
|
|
7
99
|
|
|
8
100
|
// src/constants.ts
|
|
9
101
|
var VERSION = version;
|
|
@@ -12,6 +104,7 @@ var configExtensions = [...jsExtensions.map((x) => `json.${x}`), "json"];
|
|
|
12
104
|
var supportedCssLangs = ["wxss", "scss", "less", "sass", "styl"];
|
|
13
105
|
|
|
14
106
|
// src/context.ts
|
|
107
|
+
init_esm_shims();
|
|
15
108
|
import { createRequire } from "node:module";
|
|
16
109
|
import process from "node:process";
|
|
17
110
|
import { addExtension as addExtension2, defu as defu2, get as get2, isObject as isObject3, objectHash, removeExtension as removeExtension2 } from "@weapp-core/shared";
|
|
@@ -21,6 +114,7 @@ import { build, loadConfigFromFile } from "vite";
|
|
|
21
114
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
22
115
|
|
|
23
116
|
// src/debugger.ts
|
|
117
|
+
init_esm_shims();
|
|
24
118
|
import createDebug from "debug";
|
|
25
119
|
function createDebugger(namespace) {
|
|
26
120
|
const debug3 = createDebug(namespace);
|
|
@@ -30,6 +124,7 @@ function createDebugger(namespace) {
|
|
|
30
124
|
}
|
|
31
125
|
|
|
32
126
|
// src/defaults.ts
|
|
127
|
+
init_esm_shims();
|
|
33
128
|
var defaultExcluded = ["**/node_modules/**", "**/miniprogram_npm/**"];
|
|
34
129
|
function getOutputExtensions(_platform) {
|
|
35
130
|
return {
|
|
@@ -50,6 +145,8 @@ function getWeappViteConfig() {
|
|
|
50
145
|
}
|
|
51
146
|
|
|
52
147
|
// src/plugins/index.ts
|
|
148
|
+
init_esm_shims();
|
|
149
|
+
var import_debounce = __toESM(require_debounce(), 1);
|
|
53
150
|
import { isObject as isObject2, removeExtension } from "@weapp-core/shared";
|
|
54
151
|
import { fdir as Fdir } from "fdir";
|
|
55
152
|
import fs4 from "fs-extra";
|
|
@@ -57,7 +154,11 @@ import MagicString2 from "magic-string";
|
|
|
57
154
|
import path4 from "pathe";
|
|
58
155
|
import { isCSSRequest } from "vite";
|
|
59
156
|
|
|
157
|
+
// src/utils/index.ts
|
|
158
|
+
init_esm_shims();
|
|
159
|
+
|
|
60
160
|
// src/utils/file.ts
|
|
161
|
+
init_esm_shims();
|
|
61
162
|
import fs from "fs-extra";
|
|
62
163
|
import path from "pathe";
|
|
63
164
|
function isJsOrTs(name) {
|
|
@@ -106,6 +207,7 @@ function resolveGlobs(globs, subPackageMeta) {
|
|
|
106
207
|
}
|
|
107
208
|
|
|
108
209
|
// src/utils/json.ts
|
|
210
|
+
init_esm_shims();
|
|
109
211
|
import { get, isObject, set } from "@weapp-core/shared";
|
|
110
212
|
import { bundleRequire } from "bundle-require";
|
|
111
213
|
import { parse as parseJson, stringify } from "comment-json";
|
|
@@ -217,6 +319,7 @@ function resolveJson(entry, aliasEntries) {
|
|
|
217
319
|
}
|
|
218
320
|
|
|
219
321
|
// src/utils/projectConfig.ts
|
|
322
|
+
init_esm_shims();
|
|
220
323
|
import fs3 from "fs-extra";
|
|
221
324
|
import path3 from "pathe";
|
|
222
325
|
async function getProjectConfig(root, options) {
|
|
@@ -246,6 +349,7 @@ async function getProjectConfig(root, options) {
|
|
|
246
349
|
}
|
|
247
350
|
|
|
248
351
|
// src/utils/regexp.ts
|
|
352
|
+
init_esm_shims();
|
|
249
353
|
function isRegexp(value) {
|
|
250
354
|
return Object.prototype.toString.call(value) === "[object RegExp]";
|
|
251
355
|
}
|
|
@@ -269,11 +373,13 @@ function regExpTest(arr = [], str) {
|
|
|
269
373
|
}
|
|
270
374
|
|
|
271
375
|
// src/wxml/index.ts
|
|
376
|
+
init_esm_shims();
|
|
272
377
|
import { addExtension, removeExtensionDeep } from "@weapp-core/shared";
|
|
273
378
|
import { Parser } from "htmlparser2";
|
|
274
379
|
import MagicString from "magic-string";
|
|
275
380
|
|
|
276
381
|
// src/wxs/index.ts
|
|
382
|
+
init_esm_shims();
|
|
277
383
|
import babel from "@babel/core";
|
|
278
384
|
import t from "@babel/types";
|
|
279
385
|
import { defu } from "@weapp-core/shared";
|
|
@@ -451,6 +557,7 @@ ${res.code}`);
|
|
|
451
557
|
}
|
|
452
558
|
|
|
453
559
|
// src/plugins/parse.ts
|
|
560
|
+
init_esm_shims();
|
|
454
561
|
function parseRequest(id) {
|
|
455
562
|
const [filename, rawQuery] = id.split(`?`, 2);
|
|
456
563
|
const query = Object.fromEntries(new URLSearchParams(rawQuery));
|
|
@@ -471,6 +578,9 @@ function getCssRealPath(res) {
|
|
|
471
578
|
|
|
472
579
|
// src/plugins/index.ts
|
|
473
580
|
var debug = createDebugger("weapp-vite:plugin");
|
|
581
|
+
var debouncedLoggerSuccess = (0, import_debounce.default)((message) => {
|
|
582
|
+
return logger_default.success(message);
|
|
583
|
+
}, 25);
|
|
474
584
|
function vitePluginWeapp(ctx, subPackageMeta) {
|
|
475
585
|
let configResolved;
|
|
476
586
|
function relative(p) {
|
|
@@ -695,31 +805,27 @@ function vitePluginWeapp(ctx, subPackageMeta) {
|
|
|
695
805
|
},
|
|
696
806
|
// for debug
|
|
697
807
|
watchChange(id, change) {
|
|
698
|
-
|
|
699
|
-
debug?.("watchChange watchFiles count: ", watchFiles.length);
|
|
700
|
-
logger_default.success(`[${change.event}] ${transformAbsoluteToRelative(id)}`);
|
|
701
|
-
},
|
|
702
|
-
renderStart() {
|
|
703
|
-
const watchFiles = this.getWatchFiles();
|
|
704
|
-
debug?.("renderStart watchFiles count: ", watchFiles.length);
|
|
808
|
+
debouncedLoggerSuccess(`[${change.event}] ${transformAbsoluteToRelative(id)}`);
|
|
705
809
|
},
|
|
810
|
+
// renderStart() {
|
|
811
|
+
// const watchFiles = this.getWatchFiles()
|
|
812
|
+
// debug?.('renderStart watchFiles count: ', watchFiles.length)
|
|
813
|
+
// },
|
|
706
814
|
// transform(code, id, options) {
|
|
707
815
|
// console.log(id)
|
|
708
816
|
// },
|
|
709
817
|
// 调试监听
|
|
710
818
|
// buildEnd() {
|
|
711
819
|
// },
|
|
712
|
-
renderChunk() {
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
},
|
|
716
|
-
augmentChunkHash() {
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
},
|
|
820
|
+
// renderChunk() {
|
|
821
|
+
// const watchFiles = this.getWatchFiles()
|
|
822
|
+
// debug?.('renderChunk watchFiles count: ', watchFiles.length)
|
|
823
|
+
// },
|
|
824
|
+
// augmentChunkHash() {
|
|
825
|
+
// const watchFiles = this.getWatchFiles()
|
|
826
|
+
// debug?.('augmentChunkHash watchFiles count: ', watchFiles.length)
|
|
827
|
+
// },
|
|
720
828
|
generateBundle(_options, bundle) {
|
|
721
|
-
const watchFiles = this.getWatchFiles();
|
|
722
|
-
debug?.("generateBundle watchFiles count: ", watchFiles.length);
|
|
723
829
|
debug?.("generateBundle start");
|
|
724
830
|
const bundleKeys = Object.keys(bundle);
|
|
725
831
|
for (const bundleKey of bundleKeys) {
|
|
@@ -741,11 +847,11 @@ function vitePluginWeapp(ctx, subPackageMeta) {
|
|
|
741
847
|
}
|
|
742
848
|
}
|
|
743
849
|
debug?.("generateBundle end");
|
|
744
|
-
},
|
|
745
|
-
writeBundle() {
|
|
746
|
-
const watchFiles = this.getWatchFiles();
|
|
747
|
-
debug?.("writeBundle watchFiles count: ", watchFiles.length);
|
|
748
850
|
}
|
|
851
|
+
// writeBundle() {
|
|
852
|
+
// const watchFiles = this.getWatchFiles()
|
|
853
|
+
// debug?.('writeBundle watchFiles count: ', watchFiles.length)
|
|
854
|
+
// },
|
|
749
855
|
},
|
|
750
856
|
{
|
|
751
857
|
// todo
|
|
@@ -762,8 +868,12 @@ function vitePluginWeapp(ctx, subPackageMeta) {
|
|
|
762
868
|
// src/context.ts
|
|
763
869
|
var debug2 = createDebugger("weapp-vite:context");
|
|
764
870
|
var require2 = createRequire(import.meta.url);
|
|
871
|
+
var once = false;
|
|
765
872
|
function logBuildIndependentSubPackageFinish(root) {
|
|
766
|
-
|
|
873
|
+
if (!once) {
|
|
874
|
+
logger_default.success(`\u72EC\u7ACB\u5206\u5305 ${root} \u6784\u5EFA\u5B8C\u6210\uFF01`);
|
|
875
|
+
once = true;
|
|
876
|
+
}
|
|
767
877
|
}
|
|
768
878
|
var CompilerContext = class {
|
|
769
879
|
/**
|
|
@@ -1065,7 +1175,7 @@ var CompilerContext = class {
|
|
|
1065
1175
|
const targetJsonPath = require2.resolve(id);
|
|
1066
1176
|
const dest = path5.join(outDir, dep);
|
|
1067
1177
|
if (!isDependenciesCacheOutdate && await fs5.exists(dest)) {
|
|
1068
|
-
|
|
1178
|
+
debug2?.(`${dep} \u4F9D\u8D56\u672A\u53D1\u751F\u53D8\u5316\uFF0C\u8DF3\u8FC7\u5904\u7406!`);
|
|
1069
1179
|
continue;
|
|
1070
1180
|
}
|
|
1071
1181
|
await fs5.copy(
|
|
@@ -1078,7 +1188,7 @@ var CompilerContext = class {
|
|
|
1078
1188
|
} else {
|
|
1079
1189
|
const destOutDir = path5.join(outDir, dep);
|
|
1080
1190
|
if (!isDependenciesCacheOutdate && await fs5.exists(destOutDir)) {
|
|
1081
|
-
|
|
1191
|
+
debug2?.(`${dep} \u4F9D\u8D56\u672A\u53D1\u751F\u53D8\u5316\uFF0C\u8DF3\u8FC7\u5904\u7406!`);
|
|
1082
1192
|
continue;
|
|
1083
1193
|
}
|
|
1084
1194
|
const mergedOptions = defu2(options, {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __esm = (fn, res) => function __init() {
|
|
8
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
9
|
+
};
|
|
10
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
11
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
|
|
30
|
+
// ../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.9.1_jiti@2.3.1_postcss@8.4.47_tsx@4.19.2_typescript@5.6.3_yaml@2.6.0/node_modules/tsup/assets/esm_shims.js
|
|
31
|
+
var init_esm_shims = __esm({
|
|
32
|
+
"../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.9.1_jiti@2.3.1_postcss@8.4.47_tsx@4.19.2_typescript@5.6.3_yaml@2.6.0/node_modules/tsup/assets/esm_shims.js"() {
|
|
33
|
+
"use strict";
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
__commonJS,
|
|
39
|
+
__toESM,
|
|
40
|
+
init_esm_shims
|
|
41
|
+
};
|
package/dist/cli.cjs
CHANGED
|
@@ -5,6 +5,12 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
11
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
12
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
13
|
+
};
|
|
8
14
|
var __copyProps = (to, from, except, desc) => {
|
|
9
15
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
16
|
for (let key of __getOwnPropNames(from))
|
|
@@ -23,18 +29,110 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
29
|
));
|
|
24
30
|
|
|
25
31
|
// ../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.9.1_jiti@2.3.1_postcss@8.4.47_tsx@4.19.2_typescript@5.6.3_yaml@2.6.0/node_modules/tsup/assets/cjs_shims.js
|
|
26
|
-
var getImportMetaUrl
|
|
27
|
-
var
|
|
32
|
+
var getImportMetaUrl, importMetaUrl;
|
|
33
|
+
var init_cjs_shims = __esm({
|
|
34
|
+
"../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.9.1_jiti@2.3.1_postcss@8.4.47_tsx@4.19.2_typescript@5.6.3_yaml@2.6.0/node_modules/tsup/assets/cjs_shims.js"() {
|
|
35
|
+
"use strict";
|
|
36
|
+
getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
37
|
+
importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// ../../node_modules/.pnpm/debounce@2.2.0/node_modules/debounce/index.js
|
|
42
|
+
var require_debounce = __commonJS({
|
|
43
|
+
"../../node_modules/.pnpm/debounce@2.2.0/node_modules/debounce/index.js"(exports2, module2) {
|
|
44
|
+
"use strict";
|
|
45
|
+
init_cjs_shims();
|
|
46
|
+
function debounce2(function_, wait = 100, options = {}) {
|
|
47
|
+
if (typeof function_ !== "function") {
|
|
48
|
+
throw new TypeError(`Expected the first parameter to be a function, got \`${typeof function_}\`.`);
|
|
49
|
+
}
|
|
50
|
+
if (wait < 0) {
|
|
51
|
+
throw new RangeError("`wait` must not be negative.");
|
|
52
|
+
}
|
|
53
|
+
const { immediate } = typeof options === "boolean" ? { immediate: options } : options;
|
|
54
|
+
let storedContext;
|
|
55
|
+
let storedArguments;
|
|
56
|
+
let timeoutId;
|
|
57
|
+
let timestamp;
|
|
58
|
+
let result;
|
|
59
|
+
function run() {
|
|
60
|
+
const callContext = storedContext;
|
|
61
|
+
const callArguments = storedArguments;
|
|
62
|
+
storedContext = void 0;
|
|
63
|
+
storedArguments = void 0;
|
|
64
|
+
result = function_.apply(callContext, callArguments);
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
function later() {
|
|
68
|
+
const last = Date.now() - timestamp;
|
|
69
|
+
if (last < wait && last >= 0) {
|
|
70
|
+
timeoutId = setTimeout(later, wait - last);
|
|
71
|
+
} else {
|
|
72
|
+
timeoutId = void 0;
|
|
73
|
+
if (!immediate) {
|
|
74
|
+
result = run();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const debounced = function(...arguments_) {
|
|
79
|
+
if (storedContext && this !== storedContext && Object.getPrototypeOf(this) === Object.getPrototypeOf(storedContext)) {
|
|
80
|
+
throw new Error("Debounced method called with different contexts of the same prototype.");
|
|
81
|
+
}
|
|
82
|
+
storedContext = this;
|
|
83
|
+
storedArguments = arguments_;
|
|
84
|
+
timestamp = Date.now();
|
|
85
|
+
const callNow = immediate && !timeoutId;
|
|
86
|
+
if (!timeoutId) {
|
|
87
|
+
timeoutId = setTimeout(later, wait);
|
|
88
|
+
}
|
|
89
|
+
if (callNow) {
|
|
90
|
+
result = run();
|
|
91
|
+
}
|
|
92
|
+
return result;
|
|
93
|
+
};
|
|
94
|
+
Object.defineProperty(debounced, "isPending", {
|
|
95
|
+
get() {
|
|
96
|
+
return timeoutId !== void 0;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
debounced.clear = () => {
|
|
100
|
+
if (!timeoutId) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
clearTimeout(timeoutId);
|
|
104
|
+
timeoutId = void 0;
|
|
105
|
+
};
|
|
106
|
+
debounced.flush = () => {
|
|
107
|
+
if (!timeoutId) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
debounced.trigger();
|
|
111
|
+
};
|
|
112
|
+
debounced.trigger = () => {
|
|
113
|
+
result = run();
|
|
114
|
+
debounced.clear();
|
|
115
|
+
};
|
|
116
|
+
return debounced;
|
|
117
|
+
}
|
|
118
|
+
module2.exports.debounce = debounce2;
|
|
119
|
+
module2.exports = debounce2;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
28
122
|
|
|
29
123
|
// src/cli.ts
|
|
124
|
+
init_cjs_shims();
|
|
30
125
|
var import_node_process3 = __toESM(require("process"), 1);
|
|
31
126
|
var import_init = require("@weapp-core/init");
|
|
32
127
|
var import_cac = require("cac");
|
|
33
128
|
var import_vite3 = require("vite");
|
|
34
129
|
var import_weapp_ide_cli = require("weapp-ide-cli");
|
|
35
130
|
|
|
131
|
+
// src/constants.ts
|
|
132
|
+
init_cjs_shims();
|
|
133
|
+
|
|
36
134
|
// package.json
|
|
37
|
-
var version = "1.7.
|
|
135
|
+
var version = "1.7.3";
|
|
38
136
|
|
|
39
137
|
// src/constants.ts
|
|
40
138
|
var VERSION = version;
|
|
@@ -43,6 +141,7 @@ var configExtensions = [...jsExtensions.map((x) => `json.${x}`), "json"];
|
|
|
43
141
|
var supportedCssLangs = ["wxss", "scss", "less", "sass", "styl"];
|
|
44
142
|
|
|
45
143
|
// src/context.ts
|
|
144
|
+
init_cjs_shims();
|
|
46
145
|
var import_node_module = require("module");
|
|
47
146
|
var import_node_process = __toESM(require("process"), 1);
|
|
48
147
|
var import_shared5 = require("@weapp-core/shared");
|
|
@@ -52,6 +151,7 @@ var import_vite2 = require("vite");
|
|
|
52
151
|
var import_vite_tsconfig_paths = __toESM(require("vite-tsconfig-paths"), 1);
|
|
53
152
|
|
|
54
153
|
// src/debugger.ts
|
|
154
|
+
init_cjs_shims();
|
|
55
155
|
var import_debug = __toESM(require("debug"), 1);
|
|
56
156
|
function createDebugger(namespace) {
|
|
57
157
|
const debug3 = (0, import_debug.default)(namespace);
|
|
@@ -61,6 +161,7 @@ function createDebugger(namespace) {
|
|
|
61
161
|
}
|
|
62
162
|
|
|
63
163
|
// src/defaults.ts
|
|
164
|
+
init_cjs_shims();
|
|
64
165
|
var defaultExcluded = ["**/node_modules/**", "**/miniprogram_npm/**"];
|
|
65
166
|
function getOutputExtensions(_platform) {
|
|
66
167
|
return {
|
|
@@ -81,18 +182,25 @@ function getWeappViteConfig() {
|
|
|
81
182
|
}
|
|
82
183
|
|
|
83
184
|
// src/logger.ts
|
|
185
|
+
init_cjs_shims();
|
|
84
186
|
var import_logger = __toESM(require("@weapp-core/logger"), 1);
|
|
85
187
|
var logger_default = import_logger.default;
|
|
86
188
|
|
|
87
189
|
// src/plugins/index.ts
|
|
190
|
+
init_cjs_shims();
|
|
88
191
|
var import_shared4 = require("@weapp-core/shared");
|
|
192
|
+
var import_debounce = __toESM(require_debounce(), 1);
|
|
89
193
|
var import_fdir = require("fdir");
|
|
90
194
|
var import_fs_extra4 = __toESM(require("fs-extra"), 1);
|
|
91
195
|
var import_magic_string2 = __toESM(require("magic-string"), 1);
|
|
92
196
|
var import_pathe4 = __toESM(require("pathe"), 1);
|
|
93
197
|
var import_vite = require("vite");
|
|
94
198
|
|
|
199
|
+
// src/utils/index.ts
|
|
200
|
+
init_cjs_shims();
|
|
201
|
+
|
|
95
202
|
// src/utils/file.ts
|
|
203
|
+
init_cjs_shims();
|
|
96
204
|
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
97
205
|
var import_pathe = __toESM(require("pathe"), 1);
|
|
98
206
|
function isJsOrTs(name) {
|
|
@@ -141,6 +249,7 @@ function resolveGlobs(globs, subPackageMeta) {
|
|
|
141
249
|
}
|
|
142
250
|
|
|
143
251
|
// src/utils/json.ts
|
|
252
|
+
init_cjs_shims();
|
|
144
253
|
var import_shared = require("@weapp-core/shared");
|
|
145
254
|
var import_bundle_require = require("bundle-require");
|
|
146
255
|
var import_comment_json = require("comment-json");
|
|
@@ -252,6 +361,7 @@ function resolveJson(entry, aliasEntries) {
|
|
|
252
361
|
}
|
|
253
362
|
|
|
254
363
|
// src/utils/projectConfig.ts
|
|
364
|
+
init_cjs_shims();
|
|
255
365
|
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
256
366
|
var import_pathe3 = __toESM(require("pathe"), 1);
|
|
257
367
|
async function getProjectConfig(root, options) {
|
|
@@ -281,6 +391,7 @@ async function getProjectConfig(root, options) {
|
|
|
281
391
|
}
|
|
282
392
|
|
|
283
393
|
// src/utils/regexp.ts
|
|
394
|
+
init_cjs_shims();
|
|
284
395
|
function isRegexp(value) {
|
|
285
396
|
return Object.prototype.toString.call(value) === "[object RegExp]";
|
|
286
397
|
}
|
|
@@ -304,11 +415,13 @@ function regExpTest(arr = [], str) {
|
|
|
304
415
|
}
|
|
305
416
|
|
|
306
417
|
// src/wxml/index.ts
|
|
418
|
+
init_cjs_shims();
|
|
307
419
|
var import_shared3 = require("@weapp-core/shared");
|
|
308
420
|
var import_htmlparser2 = require("htmlparser2");
|
|
309
421
|
var import_magic_string = __toESM(require("magic-string"), 1);
|
|
310
422
|
|
|
311
423
|
// src/wxs/index.ts
|
|
424
|
+
init_cjs_shims();
|
|
312
425
|
var import_core = __toESM(require("@babel/core"), 1);
|
|
313
426
|
var import_types = __toESM(require("@babel/types"), 1);
|
|
314
427
|
var import_shared2 = require("@weapp-core/shared");
|
|
@@ -486,6 +599,7 @@ ${res.code}`);
|
|
|
486
599
|
}
|
|
487
600
|
|
|
488
601
|
// src/plugins/parse.ts
|
|
602
|
+
init_cjs_shims();
|
|
489
603
|
function parseRequest(id) {
|
|
490
604
|
const [filename, rawQuery] = id.split(`?`, 2);
|
|
491
605
|
const query = Object.fromEntries(new URLSearchParams(rawQuery));
|
|
@@ -506,6 +620,9 @@ function getCssRealPath(res) {
|
|
|
506
620
|
|
|
507
621
|
// src/plugins/index.ts
|
|
508
622
|
var debug = createDebugger("weapp-vite:plugin");
|
|
623
|
+
var debouncedLoggerSuccess = (0, import_debounce.default)((message) => {
|
|
624
|
+
return logger_default.success(message);
|
|
625
|
+
}, 25);
|
|
509
626
|
function vitePluginWeapp(ctx, subPackageMeta) {
|
|
510
627
|
let configResolved;
|
|
511
628
|
function relative(p) {
|
|
@@ -730,31 +847,27 @@ function vitePluginWeapp(ctx, subPackageMeta) {
|
|
|
730
847
|
},
|
|
731
848
|
// for debug
|
|
732
849
|
watchChange(id, change) {
|
|
733
|
-
|
|
734
|
-
debug?.("watchChange watchFiles count: ", watchFiles.length);
|
|
735
|
-
logger_default.success(`[${change.event}] ${transformAbsoluteToRelative(id)}`);
|
|
736
|
-
},
|
|
737
|
-
renderStart() {
|
|
738
|
-
const watchFiles = this.getWatchFiles();
|
|
739
|
-
debug?.("renderStart watchFiles count: ", watchFiles.length);
|
|
850
|
+
debouncedLoggerSuccess(`[${change.event}] ${transformAbsoluteToRelative(id)}`);
|
|
740
851
|
},
|
|
852
|
+
// renderStart() {
|
|
853
|
+
// const watchFiles = this.getWatchFiles()
|
|
854
|
+
// debug?.('renderStart watchFiles count: ', watchFiles.length)
|
|
855
|
+
// },
|
|
741
856
|
// transform(code, id, options) {
|
|
742
857
|
// console.log(id)
|
|
743
858
|
// },
|
|
744
859
|
// 调试监听
|
|
745
860
|
// buildEnd() {
|
|
746
861
|
// },
|
|
747
|
-
renderChunk() {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
},
|
|
751
|
-
augmentChunkHash() {
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
},
|
|
862
|
+
// renderChunk() {
|
|
863
|
+
// const watchFiles = this.getWatchFiles()
|
|
864
|
+
// debug?.('renderChunk watchFiles count: ', watchFiles.length)
|
|
865
|
+
// },
|
|
866
|
+
// augmentChunkHash() {
|
|
867
|
+
// const watchFiles = this.getWatchFiles()
|
|
868
|
+
// debug?.('augmentChunkHash watchFiles count: ', watchFiles.length)
|
|
869
|
+
// },
|
|
755
870
|
generateBundle(_options, bundle) {
|
|
756
|
-
const watchFiles = this.getWatchFiles();
|
|
757
|
-
debug?.("generateBundle watchFiles count: ", watchFiles.length);
|
|
758
871
|
debug?.("generateBundle start");
|
|
759
872
|
const bundleKeys = Object.keys(bundle);
|
|
760
873
|
for (const bundleKey of bundleKeys) {
|
|
@@ -776,11 +889,11 @@ function vitePluginWeapp(ctx, subPackageMeta) {
|
|
|
776
889
|
}
|
|
777
890
|
}
|
|
778
891
|
debug?.("generateBundle end");
|
|
779
|
-
},
|
|
780
|
-
writeBundle() {
|
|
781
|
-
const watchFiles = this.getWatchFiles();
|
|
782
|
-
debug?.("writeBundle watchFiles count: ", watchFiles.length);
|
|
783
892
|
}
|
|
893
|
+
// writeBundle() {
|
|
894
|
+
// const watchFiles = this.getWatchFiles()
|
|
895
|
+
// debug?.('writeBundle watchFiles count: ', watchFiles.length)
|
|
896
|
+
// },
|
|
784
897
|
},
|
|
785
898
|
{
|
|
786
899
|
// todo
|
|
@@ -794,11 +907,18 @@ function vitePluginWeapp(ctx, subPackageMeta) {
|
|
|
794
907
|
];
|
|
795
908
|
}
|
|
796
909
|
|
|
910
|
+
// src/config.ts
|
|
911
|
+
init_cjs_shims();
|
|
912
|
+
|
|
797
913
|
// src/context.ts
|
|
798
914
|
var debug2 = createDebugger("weapp-vite:context");
|
|
799
915
|
var require2 = (0, import_node_module.createRequire)(importMetaUrl);
|
|
916
|
+
var once = false;
|
|
800
917
|
function logBuildIndependentSubPackageFinish(root) {
|
|
801
|
-
|
|
918
|
+
if (!once) {
|
|
919
|
+
logger_default.success(`\u72EC\u7ACB\u5206\u5305 ${root} \u6784\u5EFA\u5B8C\u6210\uFF01`);
|
|
920
|
+
once = true;
|
|
921
|
+
}
|
|
802
922
|
}
|
|
803
923
|
var CompilerContext = class {
|
|
804
924
|
/**
|
|
@@ -1100,7 +1220,7 @@ var CompilerContext = class {
|
|
|
1100
1220
|
const targetJsonPath = require2.resolve(id);
|
|
1101
1221
|
const dest = import_pathe5.default.join(outDir, dep);
|
|
1102
1222
|
if (!isDependenciesCacheOutdate && await import_fs_extra5.default.exists(dest)) {
|
|
1103
|
-
|
|
1223
|
+
debug2?.(`${dep} \u4F9D\u8D56\u672A\u53D1\u751F\u53D8\u5316\uFF0C\u8DF3\u8FC7\u5904\u7406!`);
|
|
1104
1224
|
continue;
|
|
1105
1225
|
}
|
|
1106
1226
|
await import_fs_extra5.default.copy(
|
|
@@ -1113,7 +1233,7 @@ var CompilerContext = class {
|
|
|
1113
1233
|
} else {
|
|
1114
1234
|
const destOutDir = import_pathe5.default.join(outDir, dep);
|
|
1115
1235
|
if (!isDependenciesCacheOutdate && await import_fs_extra5.default.exists(destOutDir)) {
|
|
1116
|
-
|
|
1236
|
+
debug2?.(`${dep} \u4F9D\u8D56\u672A\u53D1\u751F\u53D8\u5316\uFF0C\u8DF3\u8FC7\u5904\u7406!`);
|
|
1117
1237
|
continue;
|
|
1118
1238
|
}
|
|
1119
1239
|
const mergedOptions = (0, import_shared5.defu)(options, {
|
|
@@ -1357,6 +1477,7 @@ async function createCompilerContext(options) {
|
|
|
1357
1477
|
}
|
|
1358
1478
|
|
|
1359
1479
|
// src/schematics.ts
|
|
1480
|
+
init_cjs_shims();
|
|
1360
1481
|
var import_node_process2 = __toESM(require("process"), 1);
|
|
1361
1482
|
var import_schematics = require("@weapp-core/schematics");
|
|
1362
1483
|
var import_shared6 = require("@weapp-core/shared");
|
package/dist/cli.mjs
CHANGED
|
@@ -2,10 +2,14 @@ import {
|
|
|
2
2
|
VERSION,
|
|
3
3
|
createCompilerContext,
|
|
4
4
|
logger_default
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-GK2DYKAY.mjs";
|
|
6
|
+
import "./chunk-25DMVYND.mjs";
|
|
7
|
+
import {
|
|
8
|
+
init_esm_shims
|
|
9
|
+
} from "./chunk-V57P47YG.mjs";
|
|
7
10
|
|
|
8
11
|
// src/cli.ts
|
|
12
|
+
init_esm_shims();
|
|
9
13
|
import process2 from "node:process";
|
|
10
14
|
import { createProject, initConfig } from "@weapp-core/init";
|
|
11
15
|
import { cac } from "cac";
|
|
@@ -13,6 +17,7 @@ import { loadConfigFromFile } from "vite";
|
|
|
13
17
|
import { parse } from "weapp-ide-cli";
|
|
14
18
|
|
|
15
19
|
// src/schematics.ts
|
|
20
|
+
init_esm_shims();
|
|
16
21
|
import process from "node:process";
|
|
17
22
|
import { generateJs, generateJson, generateWxml, generateWxss } from "@weapp-core/schematics";
|
|
18
23
|
import { defu } from "@weapp-core/shared";
|
package/dist/config.mjs
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -5,6 +5,12 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
11
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
12
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
13
|
+
};
|
|
8
14
|
var __export = (target, all) => {
|
|
9
15
|
for (var name in all)
|
|
10
16
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -27,6 +33,98 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
33
|
));
|
|
28
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
35
|
|
|
36
|
+
// ../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.9.1_jiti@2.3.1_postcss@8.4.47_tsx@4.19.2_typescript@5.6.3_yaml@2.6.0/node_modules/tsup/assets/cjs_shims.js
|
|
37
|
+
var getImportMetaUrl, importMetaUrl;
|
|
38
|
+
var init_cjs_shims = __esm({
|
|
39
|
+
"../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.9.1_jiti@2.3.1_postcss@8.4.47_tsx@4.19.2_typescript@5.6.3_yaml@2.6.0/node_modules/tsup/assets/cjs_shims.js"() {
|
|
40
|
+
"use strict";
|
|
41
|
+
getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
42
|
+
importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// ../../node_modules/.pnpm/debounce@2.2.0/node_modules/debounce/index.js
|
|
47
|
+
var require_debounce = __commonJS({
|
|
48
|
+
"../../node_modules/.pnpm/debounce@2.2.0/node_modules/debounce/index.js"(exports2, module2) {
|
|
49
|
+
"use strict";
|
|
50
|
+
init_cjs_shims();
|
|
51
|
+
function debounce2(function_, wait = 100, options = {}) {
|
|
52
|
+
if (typeof function_ !== "function") {
|
|
53
|
+
throw new TypeError(`Expected the first parameter to be a function, got \`${typeof function_}\`.`);
|
|
54
|
+
}
|
|
55
|
+
if (wait < 0) {
|
|
56
|
+
throw new RangeError("`wait` must not be negative.");
|
|
57
|
+
}
|
|
58
|
+
const { immediate } = typeof options === "boolean" ? { immediate: options } : options;
|
|
59
|
+
let storedContext;
|
|
60
|
+
let storedArguments;
|
|
61
|
+
let timeoutId;
|
|
62
|
+
let timestamp;
|
|
63
|
+
let result;
|
|
64
|
+
function run() {
|
|
65
|
+
const callContext = storedContext;
|
|
66
|
+
const callArguments = storedArguments;
|
|
67
|
+
storedContext = void 0;
|
|
68
|
+
storedArguments = void 0;
|
|
69
|
+
result = function_.apply(callContext, callArguments);
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
function later() {
|
|
73
|
+
const last = Date.now() - timestamp;
|
|
74
|
+
if (last < wait && last >= 0) {
|
|
75
|
+
timeoutId = setTimeout(later, wait - last);
|
|
76
|
+
} else {
|
|
77
|
+
timeoutId = void 0;
|
|
78
|
+
if (!immediate) {
|
|
79
|
+
result = run();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const debounced = function(...arguments_) {
|
|
84
|
+
if (storedContext && this !== storedContext && Object.getPrototypeOf(this) === Object.getPrototypeOf(storedContext)) {
|
|
85
|
+
throw new Error("Debounced method called with different contexts of the same prototype.");
|
|
86
|
+
}
|
|
87
|
+
storedContext = this;
|
|
88
|
+
storedArguments = arguments_;
|
|
89
|
+
timestamp = Date.now();
|
|
90
|
+
const callNow = immediate && !timeoutId;
|
|
91
|
+
if (!timeoutId) {
|
|
92
|
+
timeoutId = setTimeout(later, wait);
|
|
93
|
+
}
|
|
94
|
+
if (callNow) {
|
|
95
|
+
result = run();
|
|
96
|
+
}
|
|
97
|
+
return result;
|
|
98
|
+
};
|
|
99
|
+
Object.defineProperty(debounced, "isPending", {
|
|
100
|
+
get() {
|
|
101
|
+
return timeoutId !== void 0;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
debounced.clear = () => {
|
|
105
|
+
if (!timeoutId) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
clearTimeout(timeoutId);
|
|
109
|
+
timeoutId = void 0;
|
|
110
|
+
};
|
|
111
|
+
debounced.flush = () => {
|
|
112
|
+
if (!timeoutId) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
debounced.trigger();
|
|
116
|
+
};
|
|
117
|
+
debounced.trigger = () => {
|
|
118
|
+
result = run();
|
|
119
|
+
debounced.clear();
|
|
120
|
+
};
|
|
121
|
+
return debounced;
|
|
122
|
+
}
|
|
123
|
+
module2.exports.debounce = debounce2;
|
|
124
|
+
module2.exports = debounce2;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
30
128
|
// src/index.ts
|
|
31
129
|
var src_exports = {};
|
|
32
130
|
__export(src_exports, {
|
|
@@ -34,12 +132,10 @@ __export(src_exports, {
|
|
|
34
132
|
createCompilerContext: () => createCompilerContext
|
|
35
133
|
});
|
|
36
134
|
module.exports = __toCommonJS(src_exports);
|
|
37
|
-
|
|
38
|
-
// ../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.9.1_jiti@2.3.1_postcss@8.4.47_tsx@4.19.2_typescript@5.6.3_yaml@2.6.0/node_modules/tsup/assets/cjs_shims.js
|
|
39
|
-
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
40
|
-
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
135
|
+
init_cjs_shims();
|
|
41
136
|
|
|
42
137
|
// src/context.ts
|
|
138
|
+
init_cjs_shims();
|
|
43
139
|
var import_node_module = require("module");
|
|
44
140
|
var import_node_process = __toESM(require("process"), 1);
|
|
45
141
|
var import_shared5 = require("@weapp-core/shared");
|
|
@@ -49,6 +145,7 @@ var import_vite2 = require("vite");
|
|
|
49
145
|
var import_vite_tsconfig_paths = __toESM(require("vite-tsconfig-paths"), 1);
|
|
50
146
|
|
|
51
147
|
// src/debugger.ts
|
|
148
|
+
init_cjs_shims();
|
|
52
149
|
var import_debug = __toESM(require("debug"), 1);
|
|
53
150
|
function createDebugger(namespace) {
|
|
54
151
|
const debug3 = (0, import_debug.default)(namespace);
|
|
@@ -58,6 +155,7 @@ function createDebugger(namespace) {
|
|
|
58
155
|
}
|
|
59
156
|
|
|
60
157
|
// src/defaults.ts
|
|
158
|
+
init_cjs_shims();
|
|
61
159
|
var defaultExcluded = ["**/node_modules/**", "**/miniprogram_npm/**"];
|
|
62
160
|
function getOutputExtensions(_platform) {
|
|
63
161
|
return {
|
|
@@ -78,11 +176,14 @@ function getWeappViteConfig() {
|
|
|
78
176
|
}
|
|
79
177
|
|
|
80
178
|
// src/logger.ts
|
|
179
|
+
init_cjs_shims();
|
|
81
180
|
var import_logger = __toESM(require("@weapp-core/logger"), 1);
|
|
82
181
|
var logger_default = import_logger.default;
|
|
83
182
|
|
|
84
183
|
// src/plugins/index.ts
|
|
184
|
+
init_cjs_shims();
|
|
85
185
|
var import_shared4 = require("@weapp-core/shared");
|
|
186
|
+
var import_debounce = __toESM(require_debounce(), 1);
|
|
86
187
|
var import_fdir = require("fdir");
|
|
87
188
|
var import_fs_extra4 = __toESM(require("fs-extra"), 1);
|
|
88
189
|
var import_magic_string2 = __toESM(require("magic-string"), 1);
|
|
@@ -90,11 +191,16 @@ var import_pathe4 = __toESM(require("pathe"), 1);
|
|
|
90
191
|
var import_vite = require("vite");
|
|
91
192
|
|
|
92
193
|
// src/constants.ts
|
|
194
|
+
init_cjs_shims();
|
|
93
195
|
var jsExtensions = ["ts", "js"];
|
|
94
196
|
var configExtensions = [...jsExtensions.map((x) => `json.${x}`), "json"];
|
|
95
197
|
var supportedCssLangs = ["wxss", "scss", "less", "sass", "styl"];
|
|
96
198
|
|
|
199
|
+
// src/utils/index.ts
|
|
200
|
+
init_cjs_shims();
|
|
201
|
+
|
|
97
202
|
// src/utils/file.ts
|
|
203
|
+
init_cjs_shims();
|
|
98
204
|
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
99
205
|
var import_pathe = __toESM(require("pathe"), 1);
|
|
100
206
|
function isJsOrTs(name) {
|
|
@@ -143,6 +249,7 @@ function resolveGlobs(globs, subPackageMeta) {
|
|
|
143
249
|
}
|
|
144
250
|
|
|
145
251
|
// src/utils/json.ts
|
|
252
|
+
init_cjs_shims();
|
|
146
253
|
var import_shared = require("@weapp-core/shared");
|
|
147
254
|
var import_bundle_require = require("bundle-require");
|
|
148
255
|
var import_comment_json = require("comment-json");
|
|
@@ -254,6 +361,7 @@ function resolveJson(entry, aliasEntries) {
|
|
|
254
361
|
}
|
|
255
362
|
|
|
256
363
|
// src/utils/projectConfig.ts
|
|
364
|
+
init_cjs_shims();
|
|
257
365
|
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
258
366
|
var import_pathe3 = __toESM(require("pathe"), 1);
|
|
259
367
|
async function getProjectConfig(root, options) {
|
|
@@ -283,6 +391,7 @@ async function getProjectConfig(root, options) {
|
|
|
283
391
|
}
|
|
284
392
|
|
|
285
393
|
// src/utils/regexp.ts
|
|
394
|
+
init_cjs_shims();
|
|
286
395
|
function isRegexp(value) {
|
|
287
396
|
return Object.prototype.toString.call(value) === "[object RegExp]";
|
|
288
397
|
}
|
|
@@ -306,11 +415,13 @@ function regExpTest(arr = [], str) {
|
|
|
306
415
|
}
|
|
307
416
|
|
|
308
417
|
// src/wxml/index.ts
|
|
418
|
+
init_cjs_shims();
|
|
309
419
|
var import_shared3 = require("@weapp-core/shared");
|
|
310
420
|
var import_htmlparser2 = require("htmlparser2");
|
|
311
421
|
var import_magic_string = __toESM(require("magic-string"), 1);
|
|
312
422
|
|
|
313
423
|
// src/wxs/index.ts
|
|
424
|
+
init_cjs_shims();
|
|
314
425
|
var import_core = __toESM(require("@babel/core"), 1);
|
|
315
426
|
var import_types = __toESM(require("@babel/types"), 1);
|
|
316
427
|
var import_shared2 = require("@weapp-core/shared");
|
|
@@ -488,6 +599,7 @@ ${res.code}`);
|
|
|
488
599
|
}
|
|
489
600
|
|
|
490
601
|
// src/plugins/parse.ts
|
|
602
|
+
init_cjs_shims();
|
|
491
603
|
function parseRequest(id) {
|
|
492
604
|
const [filename, rawQuery] = id.split(`?`, 2);
|
|
493
605
|
const query = Object.fromEntries(new URLSearchParams(rawQuery));
|
|
@@ -508,6 +620,9 @@ function getCssRealPath(res) {
|
|
|
508
620
|
|
|
509
621
|
// src/plugins/index.ts
|
|
510
622
|
var debug = createDebugger("weapp-vite:plugin");
|
|
623
|
+
var debouncedLoggerSuccess = (0, import_debounce.default)((message) => {
|
|
624
|
+
return logger_default.success(message);
|
|
625
|
+
}, 25);
|
|
511
626
|
function vitePluginWeapp(ctx, subPackageMeta) {
|
|
512
627
|
let configResolved;
|
|
513
628
|
function relative(p) {
|
|
@@ -732,31 +847,27 @@ function vitePluginWeapp(ctx, subPackageMeta) {
|
|
|
732
847
|
},
|
|
733
848
|
// for debug
|
|
734
849
|
watchChange(id, change) {
|
|
735
|
-
|
|
736
|
-
debug?.("watchChange watchFiles count: ", watchFiles.length);
|
|
737
|
-
logger_default.success(`[${change.event}] ${transformAbsoluteToRelative(id)}`);
|
|
738
|
-
},
|
|
739
|
-
renderStart() {
|
|
740
|
-
const watchFiles = this.getWatchFiles();
|
|
741
|
-
debug?.("renderStart watchFiles count: ", watchFiles.length);
|
|
850
|
+
debouncedLoggerSuccess(`[${change.event}] ${transformAbsoluteToRelative(id)}`);
|
|
742
851
|
},
|
|
852
|
+
// renderStart() {
|
|
853
|
+
// const watchFiles = this.getWatchFiles()
|
|
854
|
+
// debug?.('renderStart watchFiles count: ', watchFiles.length)
|
|
855
|
+
// },
|
|
743
856
|
// transform(code, id, options) {
|
|
744
857
|
// console.log(id)
|
|
745
858
|
// },
|
|
746
859
|
// 调试监听
|
|
747
860
|
// buildEnd() {
|
|
748
861
|
// },
|
|
749
|
-
renderChunk() {
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
},
|
|
753
|
-
augmentChunkHash() {
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
},
|
|
862
|
+
// renderChunk() {
|
|
863
|
+
// const watchFiles = this.getWatchFiles()
|
|
864
|
+
// debug?.('renderChunk watchFiles count: ', watchFiles.length)
|
|
865
|
+
// },
|
|
866
|
+
// augmentChunkHash() {
|
|
867
|
+
// const watchFiles = this.getWatchFiles()
|
|
868
|
+
// debug?.('augmentChunkHash watchFiles count: ', watchFiles.length)
|
|
869
|
+
// },
|
|
757
870
|
generateBundle(_options, bundle) {
|
|
758
|
-
const watchFiles = this.getWatchFiles();
|
|
759
|
-
debug?.("generateBundle watchFiles count: ", watchFiles.length);
|
|
760
871
|
debug?.("generateBundle start");
|
|
761
872
|
const bundleKeys = Object.keys(bundle);
|
|
762
873
|
for (const bundleKey of bundleKeys) {
|
|
@@ -778,11 +889,11 @@ function vitePluginWeapp(ctx, subPackageMeta) {
|
|
|
778
889
|
}
|
|
779
890
|
}
|
|
780
891
|
debug?.("generateBundle end");
|
|
781
|
-
},
|
|
782
|
-
writeBundle() {
|
|
783
|
-
const watchFiles = this.getWatchFiles();
|
|
784
|
-
debug?.("writeBundle watchFiles count: ", watchFiles.length);
|
|
785
892
|
}
|
|
893
|
+
// writeBundle() {
|
|
894
|
+
// const watchFiles = this.getWatchFiles()
|
|
895
|
+
// debug?.('writeBundle watchFiles count: ', watchFiles.length)
|
|
896
|
+
// },
|
|
786
897
|
},
|
|
787
898
|
{
|
|
788
899
|
// todo
|
|
@@ -796,11 +907,18 @@ function vitePluginWeapp(ctx, subPackageMeta) {
|
|
|
796
907
|
];
|
|
797
908
|
}
|
|
798
909
|
|
|
910
|
+
// src/config.ts
|
|
911
|
+
init_cjs_shims();
|
|
912
|
+
|
|
799
913
|
// src/context.ts
|
|
800
914
|
var debug2 = createDebugger("weapp-vite:context");
|
|
801
915
|
var require2 = (0, import_node_module.createRequire)(importMetaUrl);
|
|
916
|
+
var once = false;
|
|
802
917
|
function logBuildIndependentSubPackageFinish(root) {
|
|
803
|
-
|
|
918
|
+
if (!once) {
|
|
919
|
+
logger_default.success(`\u72EC\u7ACB\u5206\u5305 ${root} \u6784\u5EFA\u5B8C\u6210\uFF01`);
|
|
920
|
+
once = true;
|
|
921
|
+
}
|
|
804
922
|
}
|
|
805
923
|
var CompilerContext = class {
|
|
806
924
|
/**
|
|
@@ -1102,7 +1220,7 @@ var CompilerContext = class {
|
|
|
1102
1220
|
const targetJsonPath = require2.resolve(id);
|
|
1103
1221
|
const dest = import_pathe5.default.join(outDir, dep);
|
|
1104
1222
|
if (!isDependenciesCacheOutdate && await import_fs_extra5.default.exists(dest)) {
|
|
1105
|
-
|
|
1223
|
+
debug2?.(`${dep} \u4F9D\u8D56\u672A\u53D1\u751F\u53D8\u5316\uFF0C\u8DF3\u8FC7\u5904\u7406!`);
|
|
1106
1224
|
continue;
|
|
1107
1225
|
}
|
|
1108
1226
|
await import_fs_extra5.default.copy(
|
|
@@ -1115,7 +1233,7 @@ var CompilerContext = class {
|
|
|
1115
1233
|
} else {
|
|
1116
1234
|
const destOutDir = import_pathe5.default.join(outDir, dep);
|
|
1117
1235
|
if (!isDependenciesCacheOutdate && await import_fs_extra5.default.exists(destOutDir)) {
|
|
1118
|
-
|
|
1236
|
+
debug2?.(`${dep} \u4F9D\u8D56\u672A\u53D1\u751F\u53D8\u5316\uFF0C\u8DF3\u8FC7\u5904\u7406!`);
|
|
1119
1237
|
continue;
|
|
1120
1238
|
}
|
|
1121
1239
|
const mergedOptions = (0, import_shared5.defu)(options, {
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CompilerContext,
|
|
3
3
|
createCompilerContext
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-GK2DYKAY.mjs";
|
|
5
|
+
import "./chunk-25DMVYND.mjs";
|
|
6
|
+
import {
|
|
7
|
+
init_esm_shims
|
|
8
|
+
} from "./chunk-V57P47YG.mjs";
|
|
9
|
+
|
|
10
|
+
// src/index.ts
|
|
11
|
+
init_esm_shims();
|
|
6
12
|
export {
|
|
7
13
|
CompilerContext,
|
|
8
14
|
createCompilerContext
|
package/dist/json.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-vite",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.7.
|
|
4
|
+
"version": "1.7.3",
|
|
5
5
|
"description": "weapp-vite 一个现代化的小程序打包工具",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -82,9 +82,9 @@
|
|
|
82
82
|
"vite-tsconfig-paths": "^5.1.0",
|
|
83
83
|
"@weapp-core/init": "^1.1.8",
|
|
84
84
|
"@weapp-core/logger": "^1.0.1",
|
|
85
|
+
"weapp-ide-cli": "^2.0.6",
|
|
85
86
|
"@weapp-core/shared": "^1.0.4",
|
|
86
|
-
"@weapp-core/schematics": "^1.0.5"
|
|
87
|
-
"weapp-ide-cli": "^2.0.6"
|
|
87
|
+
"@weapp-core/schematics": "^1.0.5"
|
|
88
88
|
},
|
|
89
89
|
"publishConfig": {
|
|
90
90
|
"access": "public",
|