weapp-vite 4.0.0 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-PVNQ5M6Y.cjs → chunk-4RA3EKOJ.cjs} +309 -42
- package/dist/{chunk-GENEJE4Z.mjs → chunk-X6MUD4OM.mjs} +310 -43
- package/dist/cli.cjs +14 -14
- package/dist/cli.mjs +2 -2
- package/dist/index.cjs +3 -3
- package/dist/index.mjs +1 -1
- package/package.json +5 -5
|
@@ -1539,8 +1539,8 @@ var configExtensions = [
|
|
|
1539
1539
|
"json"
|
|
1540
1540
|
];
|
|
1541
1541
|
var supportedCssLangs = [
|
|
1542
|
-
"css",
|
|
1543
1542
|
"wxss",
|
|
1543
|
+
"css",
|
|
1544
1544
|
"scss",
|
|
1545
1545
|
"less",
|
|
1546
1546
|
"sass",
|
|
@@ -3617,30 +3617,54 @@ function changeFileExtension(filePath, extension) {
|
|
|
3617
3617
|
}
|
|
3618
3618
|
_chunkWAO6ZIROcjs.__name.call(void 0, changeFileExtension, "changeFileExtension");
|
|
3619
3619
|
async function findJsEntry(filepath) {
|
|
3620
|
-
|
|
3621
|
-
|
|
3620
|
+
const predictions = jsExtensions.map((ext2) => {
|
|
3621
|
+
return changeFileExtension(filepath, ext2);
|
|
3622
|
+
});
|
|
3623
|
+
for (const p2 of predictions) {
|
|
3622
3624
|
if (await _fsextra2.default.exists(p2)) {
|
|
3623
|
-
return
|
|
3625
|
+
return {
|
|
3626
|
+
path: p2,
|
|
3627
|
+
predictions
|
|
3628
|
+
};
|
|
3624
3629
|
}
|
|
3625
3630
|
}
|
|
3631
|
+
return {
|
|
3632
|
+
predictions
|
|
3633
|
+
};
|
|
3626
3634
|
}
|
|
3627
3635
|
_chunkWAO6ZIROcjs.__name.call(void 0, findJsEntry, "findJsEntry");
|
|
3628
3636
|
async function findJsonEntry(filepath) {
|
|
3629
|
-
|
|
3630
|
-
|
|
3637
|
+
const predictions = configExtensions.map((ext2) => {
|
|
3638
|
+
return changeFileExtension(filepath, ext2);
|
|
3639
|
+
});
|
|
3640
|
+
for (const p2 of predictions) {
|
|
3631
3641
|
if (await _fsextra2.default.exists(p2)) {
|
|
3632
|
-
return
|
|
3642
|
+
return {
|
|
3643
|
+
predictions,
|
|
3644
|
+
path: p2
|
|
3645
|
+
};
|
|
3633
3646
|
}
|
|
3634
3647
|
}
|
|
3648
|
+
return {
|
|
3649
|
+
predictions
|
|
3650
|
+
};
|
|
3635
3651
|
}
|
|
3636
3652
|
_chunkWAO6ZIROcjs.__name.call(void 0, findJsonEntry, "findJsonEntry");
|
|
3637
3653
|
async function findTemplateEntry(filepath) {
|
|
3638
|
-
|
|
3639
|
-
|
|
3654
|
+
const predictions = templateExtensions.map((ext2) => {
|
|
3655
|
+
return changeFileExtension(filepath, ext2);
|
|
3656
|
+
});
|
|
3657
|
+
for (const p2 of predictions) {
|
|
3640
3658
|
if (await _fsextra2.default.exists(p2)) {
|
|
3641
|
-
return
|
|
3659
|
+
return {
|
|
3660
|
+
predictions,
|
|
3661
|
+
path: p2
|
|
3662
|
+
};
|
|
3642
3663
|
}
|
|
3643
3664
|
}
|
|
3665
|
+
return {
|
|
3666
|
+
predictions
|
|
3667
|
+
};
|
|
3644
3668
|
}
|
|
3645
3669
|
_chunkWAO6ZIROcjs.__name.call(void 0, findTemplateEntry, "findTemplateEntry");
|
|
3646
3670
|
function isTemplate(filepath) {
|
|
@@ -5309,12 +5333,12 @@ var AutoImportService2 = class {
|
|
|
5309
5333
|
// for auto import
|
|
5310
5334
|
async scanPotentialComponentEntries(filePath) {
|
|
5311
5335
|
const baseName = _shared.removeExtension.call(void 0, filePath);
|
|
5312
|
-
const jsEntry = await findJsEntry(baseName);
|
|
5336
|
+
const { path: jsEntry } = await findJsEntry(baseName);
|
|
5313
5337
|
if (!jsEntry) {
|
|
5314
5338
|
return;
|
|
5315
5339
|
}
|
|
5316
5340
|
if (jsEntry) {
|
|
5317
|
-
const jsonPath = await findJsonEntry(baseName);
|
|
5341
|
+
const { path: jsonPath } = await findJsonEntry(baseName);
|
|
5318
5342
|
if (jsonPath) {
|
|
5319
5343
|
const json = await this.jsonService.read(jsonPath);
|
|
5320
5344
|
if (_optionalChain([json, 'optionalAccess', _118 => _118.component])) {
|
|
@@ -9607,7 +9631,7 @@ var PathScurryBase = class {
|
|
|
9607
9631
|
results.push(withFileTypes ? entry : entry.fullpath());
|
|
9608
9632
|
}
|
|
9609
9633
|
const dirs = /* @__PURE__ */ new Set();
|
|
9610
|
-
const
|
|
9634
|
+
const walk2 = /* @__PURE__ */ _chunkWAO6ZIROcjs.__name.call(void 0, (dir, cb) => {
|
|
9611
9635
|
dirs.add(dir);
|
|
9612
9636
|
dir.readdirCB((er, entries) => {
|
|
9613
9637
|
if (er) {
|
|
@@ -9625,10 +9649,10 @@ var PathScurryBase = class {
|
|
|
9625
9649
|
results.push(withFileTypes ? e2 : e2.fullpath());
|
|
9626
9650
|
}
|
|
9627
9651
|
if (follow && e2.isSymbolicLink()) {
|
|
9628
|
-
e2.realpath().then((r4) => _optionalChain([r4, 'optionalAccess', _170 => _170.isUnknown, 'call', _171 => _171()]) ? r4.lstat() : r4).then((r4) => _optionalChain([r4, 'optionalAccess', _172 => _172.shouldWalk, 'call', _173 => _173(dirs, walkFilter)]) ?
|
|
9652
|
+
e2.realpath().then((r4) => _optionalChain([r4, 'optionalAccess', _170 => _170.isUnknown, 'call', _171 => _171()]) ? r4.lstat() : r4).then((r4) => _optionalChain([r4, 'optionalAccess', _172 => _172.shouldWalk, 'call', _173 => _173(dirs, walkFilter)]) ? walk2(r4, next) : next());
|
|
9629
9653
|
} else {
|
|
9630
9654
|
if (e2.shouldWalk(dirs, walkFilter)) {
|
|
9631
|
-
|
|
9655
|
+
walk2(e2, next);
|
|
9632
9656
|
} else {
|
|
9633
9657
|
next();
|
|
9634
9658
|
}
|
|
@@ -9638,7 +9662,7 @@ var PathScurryBase = class {
|
|
|
9638
9662
|
}, "walk");
|
|
9639
9663
|
const start = entry;
|
|
9640
9664
|
return new Promise((res, rej) => {
|
|
9641
|
-
|
|
9665
|
+
walk2(start, (er) => {
|
|
9642
9666
|
if (er) return rej(er);
|
|
9643
9667
|
res(results);
|
|
9644
9668
|
});
|
|
@@ -13486,7 +13510,7 @@ _chunkWAO6ZIROcjs.init_cjs_shims.call(void 0, );
|
|
|
13486
13510
|
function analyzeAppJson(json) {
|
|
13487
13511
|
const entries = [];
|
|
13488
13512
|
const pages = _nullishCoalesce(json.pages, () => ( []));
|
|
13489
|
-
const components2 = Object.values(_nullishCoalesce(json
|
|
13513
|
+
const components2 = Object.values(_nullishCoalesce(_shared.get.call(void 0, json, "usingComponents"), () => ( {})));
|
|
13490
13514
|
const subPackages = _nullishCoalesce([
|
|
13491
13515
|
..._nullishCoalesce(json.subPackages, () => ( [])),
|
|
13492
13516
|
..._nullishCoalesce(json.subpackages, () => ( []))
|
|
@@ -13509,12 +13533,212 @@ function analyzeAppJson(json) {
|
|
|
13509
13533
|
_chunkWAO6ZIROcjs.__name.call(void 0, analyzeAppJson, "analyzeAppJson");
|
|
13510
13534
|
function analyzeCommonJson(json) {
|
|
13511
13535
|
const entries = [];
|
|
13512
|
-
const components2 = Object.values(_nullishCoalesce(json
|
|
13536
|
+
const components2 = Object.values(_nullishCoalesce(_shared.get.call(void 0, json, "usingComponents"), () => ( {})));
|
|
13513
13537
|
entries.push(...components2);
|
|
13514
13538
|
return entries;
|
|
13515
13539
|
}
|
|
13516
13540
|
_chunkWAO6ZIROcjs.__name.call(void 0, analyzeCommonJson, "analyzeCommonJson");
|
|
13517
13541
|
|
|
13542
|
+
// src/plugins/utils/ast.ts
|
|
13543
|
+
_chunkWAO6ZIROcjs.init_cjs_shims.call(void 0, );
|
|
13544
|
+
|
|
13545
|
+
// ../../node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/index.js
|
|
13546
|
+
_chunkWAO6ZIROcjs.init_cjs_shims.call(void 0, );
|
|
13547
|
+
|
|
13548
|
+
// ../../node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/sync.js
|
|
13549
|
+
_chunkWAO6ZIROcjs.init_cjs_shims.call(void 0, );
|
|
13550
|
+
|
|
13551
|
+
// ../../node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/walker.js
|
|
13552
|
+
_chunkWAO6ZIROcjs.init_cjs_shims.call(void 0, );
|
|
13553
|
+
var WalkerBase = class {
|
|
13554
|
+
static {
|
|
13555
|
+
_chunkWAO6ZIROcjs.__name.call(void 0, this, "WalkerBase");
|
|
13556
|
+
}
|
|
13557
|
+
constructor() {
|
|
13558
|
+
this.should_skip = false;
|
|
13559
|
+
this.should_remove = false;
|
|
13560
|
+
this.replacement = null;
|
|
13561
|
+
this.context = {
|
|
13562
|
+
skip: /* @__PURE__ */ _chunkWAO6ZIROcjs.__name.call(void 0, () => this.should_skip = true, "skip"),
|
|
13563
|
+
remove: /* @__PURE__ */ _chunkWAO6ZIROcjs.__name.call(void 0, () => this.should_remove = true, "remove"),
|
|
13564
|
+
replace: /* @__PURE__ */ _chunkWAO6ZIROcjs.__name.call(void 0, (node) => this.replacement = node, "replace")
|
|
13565
|
+
};
|
|
13566
|
+
}
|
|
13567
|
+
/**
|
|
13568
|
+
* @template {Node} Parent
|
|
13569
|
+
* @param {Parent | null | undefined} parent
|
|
13570
|
+
* @param {keyof Parent | null | undefined} prop
|
|
13571
|
+
* @param {number | null | undefined} index
|
|
13572
|
+
* @param {Node} node
|
|
13573
|
+
*/
|
|
13574
|
+
replace(parent, prop, index, node) {
|
|
13575
|
+
if (parent && prop) {
|
|
13576
|
+
if (index != null) {
|
|
13577
|
+
parent[prop][index] = node;
|
|
13578
|
+
} else {
|
|
13579
|
+
parent[prop] = node;
|
|
13580
|
+
}
|
|
13581
|
+
}
|
|
13582
|
+
}
|
|
13583
|
+
/**
|
|
13584
|
+
* @template {Node} Parent
|
|
13585
|
+
* @param {Parent | null | undefined} parent
|
|
13586
|
+
* @param {keyof Parent | null | undefined} prop
|
|
13587
|
+
* @param {number | null | undefined} index
|
|
13588
|
+
*/
|
|
13589
|
+
remove(parent, prop, index) {
|
|
13590
|
+
if (parent && prop) {
|
|
13591
|
+
if (index !== null && index !== void 0) {
|
|
13592
|
+
parent[prop].splice(index, 1);
|
|
13593
|
+
} else {
|
|
13594
|
+
delete parent[prop];
|
|
13595
|
+
}
|
|
13596
|
+
}
|
|
13597
|
+
}
|
|
13598
|
+
};
|
|
13599
|
+
|
|
13600
|
+
// ../../node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/sync.js
|
|
13601
|
+
var SyncWalker = class extends WalkerBase {
|
|
13602
|
+
static {
|
|
13603
|
+
_chunkWAO6ZIROcjs.__name.call(void 0, this, "SyncWalker");
|
|
13604
|
+
}
|
|
13605
|
+
/**
|
|
13606
|
+
*
|
|
13607
|
+
* @param {SyncHandler} [enter]
|
|
13608
|
+
* @param {SyncHandler} [leave]
|
|
13609
|
+
*/
|
|
13610
|
+
constructor(enter, leave) {
|
|
13611
|
+
super();
|
|
13612
|
+
this.should_skip = false;
|
|
13613
|
+
this.should_remove = false;
|
|
13614
|
+
this.replacement = null;
|
|
13615
|
+
this.context = {
|
|
13616
|
+
skip: /* @__PURE__ */ _chunkWAO6ZIROcjs.__name.call(void 0, () => this.should_skip = true, "skip"),
|
|
13617
|
+
remove: /* @__PURE__ */ _chunkWAO6ZIROcjs.__name.call(void 0, () => this.should_remove = true, "remove"),
|
|
13618
|
+
replace: /* @__PURE__ */ _chunkWAO6ZIROcjs.__name.call(void 0, (node) => this.replacement = node, "replace")
|
|
13619
|
+
};
|
|
13620
|
+
this.enter = enter;
|
|
13621
|
+
this.leave = leave;
|
|
13622
|
+
}
|
|
13623
|
+
/**
|
|
13624
|
+
* @template {Node} Parent
|
|
13625
|
+
* @param {Node} node
|
|
13626
|
+
* @param {Parent | null} parent
|
|
13627
|
+
* @param {keyof Parent} [prop]
|
|
13628
|
+
* @param {number | null} [index]
|
|
13629
|
+
* @returns {Node | null}
|
|
13630
|
+
*/
|
|
13631
|
+
visit(node, parent, prop, index) {
|
|
13632
|
+
if (node) {
|
|
13633
|
+
if (this.enter) {
|
|
13634
|
+
const _should_skip = this.should_skip;
|
|
13635
|
+
const _should_remove = this.should_remove;
|
|
13636
|
+
const _replacement = this.replacement;
|
|
13637
|
+
this.should_skip = false;
|
|
13638
|
+
this.should_remove = false;
|
|
13639
|
+
this.replacement = null;
|
|
13640
|
+
this.enter.call(this.context, node, parent, prop, index);
|
|
13641
|
+
if (this.replacement) {
|
|
13642
|
+
node = this.replacement;
|
|
13643
|
+
this.replace(parent, prop, index, node);
|
|
13644
|
+
}
|
|
13645
|
+
if (this.should_remove) {
|
|
13646
|
+
this.remove(parent, prop, index);
|
|
13647
|
+
}
|
|
13648
|
+
const skipped = this.should_skip;
|
|
13649
|
+
const removed = this.should_remove;
|
|
13650
|
+
this.should_skip = _should_skip;
|
|
13651
|
+
this.should_remove = _should_remove;
|
|
13652
|
+
this.replacement = _replacement;
|
|
13653
|
+
if (skipped) return node;
|
|
13654
|
+
if (removed) return null;
|
|
13655
|
+
}
|
|
13656
|
+
let key;
|
|
13657
|
+
for (key in node) {
|
|
13658
|
+
const value = node[key];
|
|
13659
|
+
if (value && typeof value === "object") {
|
|
13660
|
+
if (Array.isArray(value)) {
|
|
13661
|
+
const nodes = (
|
|
13662
|
+
/** @type {Array<unknown>} */
|
|
13663
|
+
value
|
|
13664
|
+
);
|
|
13665
|
+
for (let i = 0; i < nodes.length; i += 1) {
|
|
13666
|
+
const item = nodes[i];
|
|
13667
|
+
if (isNode(item)) {
|
|
13668
|
+
if (!this.visit(item, node, key, i)) {
|
|
13669
|
+
i--;
|
|
13670
|
+
}
|
|
13671
|
+
}
|
|
13672
|
+
}
|
|
13673
|
+
} else if (isNode(value)) {
|
|
13674
|
+
this.visit(value, node, key, null);
|
|
13675
|
+
}
|
|
13676
|
+
}
|
|
13677
|
+
}
|
|
13678
|
+
if (this.leave) {
|
|
13679
|
+
const _replacement = this.replacement;
|
|
13680
|
+
const _should_remove = this.should_remove;
|
|
13681
|
+
this.replacement = null;
|
|
13682
|
+
this.should_remove = false;
|
|
13683
|
+
this.leave.call(this.context, node, parent, prop, index);
|
|
13684
|
+
if (this.replacement) {
|
|
13685
|
+
node = this.replacement;
|
|
13686
|
+
this.replace(parent, prop, index, node);
|
|
13687
|
+
}
|
|
13688
|
+
if (this.should_remove) {
|
|
13689
|
+
this.remove(parent, prop, index);
|
|
13690
|
+
}
|
|
13691
|
+
const removed = this.should_remove;
|
|
13692
|
+
this.replacement = _replacement;
|
|
13693
|
+
this.should_remove = _should_remove;
|
|
13694
|
+
if (removed) return null;
|
|
13695
|
+
}
|
|
13696
|
+
}
|
|
13697
|
+
return node;
|
|
13698
|
+
}
|
|
13699
|
+
};
|
|
13700
|
+
function isNode(value) {
|
|
13701
|
+
return value !== null && typeof value === "object" && "type" in value && typeof value.type === "string";
|
|
13702
|
+
}
|
|
13703
|
+
_chunkWAO6ZIROcjs.__name.call(void 0, isNode, "isNode");
|
|
13704
|
+
|
|
13705
|
+
// ../../node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/async.js
|
|
13706
|
+
_chunkWAO6ZIROcjs.init_cjs_shims.call(void 0, );
|
|
13707
|
+
|
|
13708
|
+
// ../../node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/index.js
|
|
13709
|
+
function walk(ast, { enter, leave }) {
|
|
13710
|
+
const instance = new SyncWalker(enter, leave);
|
|
13711
|
+
return instance.visit(ast, null);
|
|
13712
|
+
}
|
|
13713
|
+
_chunkWAO6ZIROcjs.__name.call(void 0, walk, "walk");
|
|
13714
|
+
|
|
13715
|
+
// src/plugins/utils/ast.ts
|
|
13716
|
+
function collectRequireTokens(ast) {
|
|
13717
|
+
const requireModules = [];
|
|
13718
|
+
walk(ast, {
|
|
13719
|
+
enter(node) {
|
|
13720
|
+
if (node.type === "CallExpression") {
|
|
13721
|
+
if (node.callee.type === "MemberExpression" && node.callee.object.type === "Identifier" && node.callee.object.name === "require" && node.callee.property.type === "Identifier" && node.callee.property.name === "async") {
|
|
13722
|
+
if (node.arguments[0] && node.arguments[0].type === "Literal" && typeof node.arguments[0].value === "string") {
|
|
13723
|
+
requireModules.push({
|
|
13724
|
+
// @ts-ignore
|
|
13725
|
+
start: node.arguments[0].start,
|
|
13726
|
+
// @ts-ignore
|
|
13727
|
+
end: node.arguments[0].end,
|
|
13728
|
+
value: node.arguments[0].value,
|
|
13729
|
+
async: true
|
|
13730
|
+
});
|
|
13731
|
+
}
|
|
13732
|
+
}
|
|
13733
|
+
}
|
|
13734
|
+
}
|
|
13735
|
+
});
|
|
13736
|
+
return {
|
|
13737
|
+
requireModules
|
|
13738
|
+
};
|
|
13739
|
+
}
|
|
13740
|
+
_chunkWAO6ZIROcjs.__name.call(void 0, collectRequireTokens, "collectRequireTokens");
|
|
13741
|
+
|
|
13518
13742
|
// src/plugins/core.ts
|
|
13519
13743
|
function weappVite(ctx, subPackageMeta) {
|
|
13520
13744
|
const { scanService, configService, jsonService, wxmlService, autoImportService, buildService, watcherService } = ctx;
|
|
@@ -13596,23 +13820,27 @@ function weappVite(ctx, subPackageMeta) {
|
|
|
13596
13820
|
async function loadEntry(id, type) {
|
|
13597
13821
|
this.addWatchFile(id);
|
|
13598
13822
|
const baseName = _shared.removeExtensionDeep.call(void 0, id);
|
|
13599
|
-
let jsonPath = await findJsonEntry(id);
|
|
13823
|
+
let { path: jsonPath, predictions } = await findJsonEntry(id);
|
|
13824
|
+
for (const prediction of predictions) {
|
|
13825
|
+
this.addWatchFile(prediction);
|
|
13826
|
+
}
|
|
13600
13827
|
let json = {};
|
|
13601
13828
|
if (jsonPath) {
|
|
13602
13829
|
json = await jsonService.read(jsonPath);
|
|
13603
13830
|
} else {
|
|
13604
13831
|
jsonPath = changeFileExtension(id, ".json");
|
|
13605
13832
|
}
|
|
13606
|
-
this.addWatchFile(jsonPath);
|
|
13607
13833
|
const entries = [];
|
|
13608
13834
|
let templatePath = "";
|
|
13609
13835
|
if (type === "app") {
|
|
13610
13836
|
entries.push(...analyzeAppJson(json));
|
|
13611
13837
|
const { sitemapLocation = "sitemap.json", themeLocation = "theme.json" } = json;
|
|
13612
13838
|
if (sitemapLocation) {
|
|
13613
|
-
const sitemapJsonPath = await findJsonEntry(_pathe2.default.resolve(_pathe2.default.dirname(id), sitemapLocation));
|
|
13839
|
+
const { path: sitemapJsonPath, predictions: predictions2 } = await findJsonEntry(_pathe2.default.resolve(_pathe2.default.dirname(id), sitemapLocation));
|
|
13840
|
+
for (const prediction of predictions2) {
|
|
13841
|
+
this.addWatchFile(prediction);
|
|
13842
|
+
}
|
|
13614
13843
|
if (sitemapJsonPath) {
|
|
13615
|
-
this.addWatchFile(sitemapJsonPath);
|
|
13616
13844
|
const sitemapJson = await jsonService.read(sitemapJsonPath);
|
|
13617
13845
|
setJsonEmitFilesMap({
|
|
13618
13846
|
json: sitemapJson,
|
|
@@ -13622,9 +13850,11 @@ function weappVite(ctx, subPackageMeta) {
|
|
|
13622
13850
|
}
|
|
13623
13851
|
}
|
|
13624
13852
|
if (themeLocation) {
|
|
13625
|
-
const themeJsonPath = await findJsonEntry(_pathe2.default.resolve(_pathe2.default.dirname(id), themeLocation));
|
|
13853
|
+
const { path: themeJsonPath, predictions: predictions2 } = await findJsonEntry(_pathe2.default.resolve(_pathe2.default.dirname(id), themeLocation));
|
|
13854
|
+
for (const prediction of predictions2) {
|
|
13855
|
+
this.addWatchFile(prediction);
|
|
13856
|
+
}
|
|
13626
13857
|
if (themeJsonPath) {
|
|
13627
|
-
this.addWatchFile(themeJsonPath);
|
|
13628
13858
|
const themeJson = await jsonService.read(themeJsonPath);
|
|
13629
13859
|
setJsonEmitFilesMap({
|
|
13630
13860
|
json: themeJson,
|
|
@@ -13634,10 +13864,12 @@ function weappVite(ctx, subPackageMeta) {
|
|
|
13634
13864
|
}
|
|
13635
13865
|
}
|
|
13636
13866
|
} else {
|
|
13637
|
-
const templateEntry = await findTemplateEntry(id);
|
|
13867
|
+
const { path: templateEntry, predictions: predictions2 } = await findTemplateEntry(id);
|
|
13868
|
+
for (const prediction of predictions2) {
|
|
13869
|
+
this.addWatchFile(prediction);
|
|
13870
|
+
}
|
|
13638
13871
|
if (templateEntry) {
|
|
13639
13872
|
templatePath = templateEntry;
|
|
13640
|
-
this.addWatchFile(templateEntry);
|
|
13641
13873
|
await scanTemplateEntry(templateEntry);
|
|
13642
13874
|
}
|
|
13643
13875
|
const hit = wxmlService.wxmlComponentsMap.get(baseName);
|
|
@@ -13648,7 +13880,8 @@ function weappVite(ctx, subPackageMeta) {
|
|
|
13648
13880
|
if (res) {
|
|
13649
13881
|
const { entry: componentEntry, value } = res;
|
|
13650
13882
|
if (_optionalChain([componentEntry, 'optionalAccess', _296 => _296.jsonPath])) {
|
|
13651
|
-
|
|
13883
|
+
const usingComponents = _shared.get.call(void 0, json, "usingComponents");
|
|
13884
|
+
if (_shared.isObject.call(void 0, usingComponents) && Reflect.has(usingComponents, value.name)) {
|
|
13652
13885
|
continue;
|
|
13653
13886
|
}
|
|
13654
13887
|
_shared.set.call(void 0, json, `usingComponents.${value.name}`, value.from);
|
|
@@ -13657,7 +13890,8 @@ function weappVite(ctx, subPackageMeta) {
|
|
|
13657
13890
|
for (const resolver of configService.weappViteConfig.enhance.autoImportComponents.resolvers) {
|
|
13658
13891
|
const value = resolver(depComponentName, baseName);
|
|
13659
13892
|
if (value) {
|
|
13660
|
-
|
|
13893
|
+
const usingComponents = _shared.get.call(void 0, json, "usingComponents");
|
|
13894
|
+
if (!(_shared.isObject.call(void 0, usingComponents) && Reflect.has(usingComponents, value.name))) {
|
|
13661
13895
|
_shared.set.call(void 0, json, `usingComponents.${value.name}`, value.from);
|
|
13662
13896
|
}
|
|
13663
13897
|
}
|
|
@@ -13710,8 +13944,9 @@ function weappVite(ctx, subPackageMeta) {
|
|
|
13710
13944
|
const ms = new MagicString(code);
|
|
13711
13945
|
for (const ext2 of supportedCssLangs) {
|
|
13712
13946
|
const mayBeCssPath = changeFileExtension(id, ext2);
|
|
13947
|
+
this.addWatchFile(mayBeCssPath);
|
|
13713
13948
|
if (await _fsextra2.default.exists(mayBeCssPath)) {
|
|
13714
|
-
ms.prepend(`import '${mayBeCssPath}'
|
|
13949
|
+
ms.prepend(`import '${mayBeCssPath}';
|
|
13715
13950
|
`);
|
|
13716
13951
|
}
|
|
13717
13952
|
}
|
|
@@ -13785,8 +14020,8 @@ function weappVite(ctx, subPackageMeta) {
|
|
|
13785
14020
|
if (isCSSRequest(id)) {
|
|
13786
14021
|
const parsed = parseRequest(id);
|
|
13787
14022
|
const realPath = getCssRealPath(parsed);
|
|
14023
|
+
this.addWatchFile(realPath);
|
|
13788
14024
|
if (await _fsextra2.default.exists(realPath)) {
|
|
13789
|
-
this.addWatchFile(realPath);
|
|
13790
14025
|
const css2 = await _fsextra2.default.readFile(realPath, "utf8");
|
|
13791
14026
|
return {
|
|
13792
14027
|
code: css2
|
|
@@ -13800,14 +14035,41 @@ function weappVite(ctx, subPackageMeta) {
|
|
|
13800
14035
|
return await loadEntry.call(this, id, "app");
|
|
13801
14036
|
}
|
|
13802
14037
|
},
|
|
14038
|
+
transform: {
|
|
14039
|
+
order: "post",
|
|
14040
|
+
async handler(code, id) {
|
|
14041
|
+
if (isJsOrTs(id)) {
|
|
14042
|
+
try {
|
|
14043
|
+
const ast = this.parse(code);
|
|
14044
|
+
const { requireModules } = collectRequireTokens(ast);
|
|
14045
|
+
for (const requireModule of requireModules) {
|
|
14046
|
+
const absPath = _pathe2.default.resolve(_pathe2.default.dirname(id), requireModule.value);
|
|
14047
|
+
const resolveId = await this.resolve(absPath, id);
|
|
14048
|
+
if (resolveId) {
|
|
14049
|
+
await this.load(resolveId);
|
|
14050
|
+
this.emitFile({
|
|
14051
|
+
type: "chunk",
|
|
14052
|
+
id: resolveId.id,
|
|
14053
|
+
fileName: configService.relativeAbsoluteSrcRoot(changeFileExtension(resolveId.id, ".js")),
|
|
14054
|
+
preserveSignature: "exports-only"
|
|
14055
|
+
});
|
|
14056
|
+
}
|
|
14057
|
+
}
|
|
14058
|
+
return {
|
|
14059
|
+
code,
|
|
14060
|
+
ast,
|
|
14061
|
+
map: null
|
|
14062
|
+
};
|
|
14063
|
+
} catch (error) {
|
|
14064
|
+
logger_default.error(error);
|
|
14065
|
+
}
|
|
14066
|
+
}
|
|
14067
|
+
}
|
|
14068
|
+
},
|
|
13803
14069
|
// shouldTransformCachedModule() {
|
|
13804
14070
|
// return true
|
|
13805
14071
|
// },
|
|
13806
14072
|
renderStart() {
|
|
13807
|
-
if (_optionalChain([configService, 'access', _312 => _312.weappViteConfig, 'optionalAccess', _313 => _313.debug, 'optionalAccess', _314 => _314.watchFiles])) {
|
|
13808
|
-
const watchFiles = this.getWatchFiles();
|
|
13809
|
-
configService.weappViteConfig.debug.watchFiles(watchFiles, subPackageMeta);
|
|
13810
|
-
}
|
|
13811
14073
|
for (const jsonEmitFile of jsonEmitFilesMap.values()) {
|
|
13812
14074
|
if (jsonEmitFile.entry.json && _shared.isObject.call(void 0, jsonEmitFile.entry.json) && !_shared.isEmptyObject.call(void 0, jsonEmitFile.entry.json)) {
|
|
13813
14075
|
this.emitFile({
|
|
@@ -13858,6 +14120,10 @@ function weappVite(ctx, subPackageMeta) {
|
|
|
13858
14120
|
}
|
|
13859
14121
|
}
|
|
13860
14122
|
}
|
|
14123
|
+
if (_optionalChain([configService, 'access', _312 => _312.weappViteConfig, 'optionalAccess', _313 => _313.debug, 'optionalAccess', _314 => _314.watchFiles])) {
|
|
14124
|
+
const watchFiles = this.getWatchFiles();
|
|
14125
|
+
configService.weappViteConfig.debug.watchFiles(watchFiles, subPackageMeta);
|
|
14126
|
+
}
|
|
13861
14127
|
}
|
|
13862
14128
|
}
|
|
13863
14129
|
];
|
|
@@ -14087,8 +14353,8 @@ var wxsCodeCache = new LRUCache({
|
|
|
14087
14353
|
function wxs({ configService, wxmlService }) {
|
|
14088
14354
|
const wxsMap = /* @__PURE__ */ new Map();
|
|
14089
14355
|
async function transformWxs({ wxsPath }) {
|
|
14356
|
+
this.addWatchFile(wxsPath);
|
|
14090
14357
|
if (await _fsextra2.default.exists(wxsPath)) {
|
|
14091
|
-
this.addWatchFile(wxsPath);
|
|
14092
14358
|
const arr = wxsPath.match(/\.wxs(\.[jt]s)?$/);
|
|
14093
14359
|
let isRaw = true;
|
|
14094
14360
|
if (arr) {
|
|
@@ -14176,13 +14442,13 @@ _chunkWAO6ZIROcjs.__name.call(void 0, vitePluginWeapp, "vitePluginWeapp");
|
|
|
14176
14442
|
|
|
14177
14443
|
|
|
14178
14444
|
|
|
14179
|
-
// ../../node_modules/.pnpm/package-manager-detector@1.
|
|
14445
|
+
// ../../node_modules/.pnpm/package-manager-detector@1.2.0/node_modules/package-manager-detector/dist/detect.mjs
|
|
14180
14446
|
_chunkWAO6ZIROcjs.init_cjs_shims.call(void 0, );
|
|
14181
14447
|
|
|
14182
14448
|
|
|
14183
14449
|
|
|
14184
14450
|
|
|
14185
|
-
// ../../node_modules/.pnpm/package-manager-detector@1.
|
|
14451
|
+
// ../../node_modules/.pnpm/package-manager-detector@1.2.0/node_modules/package-manager-detector/dist/constants.mjs
|
|
14186
14452
|
_chunkWAO6ZIROcjs.init_cjs_shims.call(void 0, );
|
|
14187
14453
|
var AGENTS = [
|
|
14188
14454
|
"npm",
|
|
@@ -14198,6 +14464,7 @@ var LOCKS = {
|
|
|
14198
14464
|
"bun.lockb": "bun",
|
|
14199
14465
|
"deno.lock": "deno",
|
|
14200
14466
|
"pnpm-lock.yaml": "pnpm",
|
|
14467
|
+
"pnpm-workspace.yaml": "pnpm",
|
|
14201
14468
|
"yarn.lock": "yarn",
|
|
14202
14469
|
"package-lock.json": "npm",
|
|
14203
14470
|
"npm-shrinkwrap.json": "npm"
|
|
@@ -14218,7 +14485,7 @@ var INSTALL_METADATA = {
|
|
|
14218
14485
|
"bun.lockb": "bun"
|
|
14219
14486
|
};
|
|
14220
14487
|
|
|
14221
|
-
// ../../node_modules/.pnpm/package-manager-detector@1.
|
|
14488
|
+
// ../../node_modules/.pnpm/package-manager-detector@1.2.0/node_modules/package-manager-detector/dist/detect.mjs
|
|
14222
14489
|
async function pathExists(path23, type) {
|
|
14223
14490
|
try {
|
|
14224
14491
|
const stat3 = await _promises2.default.stat(path23);
|
|
@@ -22718,8 +22985,8 @@ var ScanService2 = class {
|
|
|
22718
22985
|
async loadAppEntry() {
|
|
22719
22986
|
const appDirname = this.configService.absoluteSrcRoot;
|
|
22720
22987
|
const appBasename = _pathe2.default.resolve(appDirname, "app");
|
|
22721
|
-
const appConfigFile = await findJsonEntry(appBasename);
|
|
22722
|
-
const appEntryPath = await findJsEntry(appBasename);
|
|
22988
|
+
const { path: appConfigFile } = await findJsonEntry(appBasename);
|
|
22989
|
+
const { path: appEntryPath } = await findJsEntry(appBasename);
|
|
22723
22990
|
if (appEntryPath && appConfigFile) {
|
|
22724
22991
|
const config = await this.jsonService.read(appConfigFile);
|
|
22725
22992
|
if (_shared.isObject.call(void 0, config)) {
|
|
@@ -22732,14 +22999,14 @@ var ScanService2 = class {
|
|
|
22732
22999
|
this.appEntry = appEntry;
|
|
22733
23000
|
const { sitemapLocation = "sitemap.json", themeLocation = "theme.json" } = config;
|
|
22734
23001
|
if (sitemapLocation) {
|
|
22735
|
-
const sitemapJsonPath = await findJsonEntry(_pathe2.default.resolve(appDirname, sitemapLocation));
|
|
23002
|
+
const { path: sitemapJsonPath } = await findJsonEntry(_pathe2.default.resolve(appDirname, sitemapLocation));
|
|
22736
23003
|
if (sitemapJsonPath) {
|
|
22737
23004
|
appEntry.sitemapJsonPath = sitemapJsonPath;
|
|
22738
23005
|
appEntry.sitemapJson = await this.jsonService.read(sitemapJsonPath);
|
|
22739
23006
|
}
|
|
22740
23007
|
}
|
|
22741
23008
|
if (themeLocation) {
|
|
22742
|
-
const themeJsonPath = await findJsonEntry(_pathe2.default.resolve(appDirname, themeLocation));
|
|
23009
|
+
const { path: themeJsonPath } = await findJsonEntry(_pathe2.default.resolve(appDirname, themeLocation));
|
|
22743
23010
|
if (themeJsonPath) {
|
|
22744
23011
|
appEntry.themeJsonPath = themeJsonPath;
|
|
22745
23012
|
appEntry.themeJson = await this.jsonService.read(themeJsonPath);
|
|
@@ -1538,8 +1538,8 @@ var configExtensions = [
|
|
|
1538
1538
|
"json"
|
|
1539
1539
|
];
|
|
1540
1540
|
var supportedCssLangs = [
|
|
1541
|
-
"css",
|
|
1542
1541
|
"wxss",
|
|
1542
|
+
"css",
|
|
1543
1543
|
"scss",
|
|
1544
1544
|
"less",
|
|
1545
1545
|
"sass",
|
|
@@ -3616,30 +3616,54 @@ function changeFileExtension(filePath, extension) {
|
|
|
3616
3616
|
}
|
|
3617
3617
|
__name(changeFileExtension, "changeFileExtension");
|
|
3618
3618
|
async function findJsEntry(filepath) {
|
|
3619
|
-
|
|
3620
|
-
|
|
3619
|
+
const predictions = jsExtensions.map((ext2) => {
|
|
3620
|
+
return changeFileExtension(filepath, ext2);
|
|
3621
|
+
});
|
|
3622
|
+
for (const p2 of predictions) {
|
|
3621
3623
|
if (await fs.exists(p2)) {
|
|
3622
|
-
return
|
|
3624
|
+
return {
|
|
3625
|
+
path: p2,
|
|
3626
|
+
predictions
|
|
3627
|
+
};
|
|
3623
3628
|
}
|
|
3624
3629
|
}
|
|
3630
|
+
return {
|
|
3631
|
+
predictions
|
|
3632
|
+
};
|
|
3625
3633
|
}
|
|
3626
3634
|
__name(findJsEntry, "findJsEntry");
|
|
3627
3635
|
async function findJsonEntry(filepath) {
|
|
3628
|
-
|
|
3629
|
-
|
|
3636
|
+
const predictions = configExtensions.map((ext2) => {
|
|
3637
|
+
return changeFileExtension(filepath, ext2);
|
|
3638
|
+
});
|
|
3639
|
+
for (const p2 of predictions) {
|
|
3630
3640
|
if (await fs.exists(p2)) {
|
|
3631
|
-
return
|
|
3641
|
+
return {
|
|
3642
|
+
predictions,
|
|
3643
|
+
path: p2
|
|
3644
|
+
};
|
|
3632
3645
|
}
|
|
3633
3646
|
}
|
|
3647
|
+
return {
|
|
3648
|
+
predictions
|
|
3649
|
+
};
|
|
3634
3650
|
}
|
|
3635
3651
|
__name(findJsonEntry, "findJsonEntry");
|
|
3636
3652
|
async function findTemplateEntry(filepath) {
|
|
3637
|
-
|
|
3638
|
-
|
|
3653
|
+
const predictions = templateExtensions.map((ext2) => {
|
|
3654
|
+
return changeFileExtension(filepath, ext2);
|
|
3655
|
+
});
|
|
3656
|
+
for (const p2 of predictions) {
|
|
3639
3657
|
if (await fs.exists(p2)) {
|
|
3640
|
-
return
|
|
3658
|
+
return {
|
|
3659
|
+
predictions,
|
|
3660
|
+
path: p2
|
|
3661
|
+
};
|
|
3641
3662
|
}
|
|
3642
3663
|
}
|
|
3664
|
+
return {
|
|
3665
|
+
predictions
|
|
3666
|
+
};
|
|
3643
3667
|
}
|
|
3644
3668
|
__name(findTemplateEntry, "findTemplateEntry");
|
|
3645
3669
|
function isTemplate(filepath) {
|
|
@@ -5308,12 +5332,12 @@ var AutoImportService2 = class {
|
|
|
5308
5332
|
// for auto import
|
|
5309
5333
|
async scanPotentialComponentEntries(filePath) {
|
|
5310
5334
|
const baseName = removeExtension(filePath);
|
|
5311
|
-
const jsEntry = await findJsEntry(baseName);
|
|
5335
|
+
const { path: jsEntry } = await findJsEntry(baseName);
|
|
5312
5336
|
if (!jsEntry) {
|
|
5313
5337
|
return;
|
|
5314
5338
|
}
|
|
5315
5339
|
if (jsEntry) {
|
|
5316
|
-
const jsonPath = await findJsonEntry(baseName);
|
|
5340
|
+
const { path: jsonPath } = await findJsonEntry(baseName);
|
|
5317
5341
|
if (jsonPath) {
|
|
5318
5342
|
const json = await this.jsonService.read(jsonPath);
|
|
5319
5343
|
if (json?.component) {
|
|
@@ -9606,7 +9630,7 @@ var PathScurryBase = class {
|
|
|
9606
9630
|
results.push(withFileTypes ? entry : entry.fullpath());
|
|
9607
9631
|
}
|
|
9608
9632
|
const dirs = /* @__PURE__ */ new Set();
|
|
9609
|
-
const
|
|
9633
|
+
const walk2 = /* @__PURE__ */ __name((dir, cb) => {
|
|
9610
9634
|
dirs.add(dir);
|
|
9611
9635
|
dir.readdirCB((er, entries) => {
|
|
9612
9636
|
if (er) {
|
|
@@ -9624,10 +9648,10 @@ var PathScurryBase = class {
|
|
|
9624
9648
|
results.push(withFileTypes ? e2 : e2.fullpath());
|
|
9625
9649
|
}
|
|
9626
9650
|
if (follow && e2.isSymbolicLink()) {
|
|
9627
|
-
e2.realpath().then((r4) => r4?.isUnknown() ? r4.lstat() : r4).then((r4) => r4?.shouldWalk(dirs, walkFilter) ?
|
|
9651
|
+
e2.realpath().then((r4) => r4?.isUnknown() ? r4.lstat() : r4).then((r4) => r4?.shouldWalk(dirs, walkFilter) ? walk2(r4, next) : next());
|
|
9628
9652
|
} else {
|
|
9629
9653
|
if (e2.shouldWalk(dirs, walkFilter)) {
|
|
9630
|
-
|
|
9654
|
+
walk2(e2, next);
|
|
9631
9655
|
} else {
|
|
9632
9656
|
next();
|
|
9633
9657
|
}
|
|
@@ -9637,7 +9661,7 @@ var PathScurryBase = class {
|
|
|
9637
9661
|
}, "walk");
|
|
9638
9662
|
const start = entry;
|
|
9639
9663
|
return new Promise((res, rej) => {
|
|
9640
|
-
|
|
9664
|
+
walk2(start, (er) => {
|
|
9641
9665
|
if (er) return rej(er);
|
|
9642
9666
|
res(results);
|
|
9643
9667
|
});
|
|
@@ -13474,7 +13498,7 @@ ${result.code}`);
|
|
|
13474
13498
|
__name(handleWxml, "handleWxml");
|
|
13475
13499
|
|
|
13476
13500
|
// src/plugins/core.ts
|
|
13477
|
-
import { isEmptyObject as isEmptyObject2, isObject as isObject3, removeExtensionDeep as removeExtensionDeep4, set as set2 } from "@weapp-core/shared";
|
|
13501
|
+
import { get as get3, isEmptyObject as isEmptyObject2, isObject as isObject3, removeExtensionDeep as removeExtensionDeep4, set as set2 } from "@weapp-core/shared";
|
|
13478
13502
|
import fs5 from "fs-extra";
|
|
13479
13503
|
import path8 from "pathe";
|
|
13480
13504
|
import { build as build2 } from "vite";
|
|
@@ -13485,7 +13509,7 @@ import { get as get2, removeExtensionDeep as removeExtensionDeep3 } from "@weapp
|
|
|
13485
13509
|
function analyzeAppJson(json) {
|
|
13486
13510
|
const entries = [];
|
|
13487
13511
|
const pages = json.pages ?? [];
|
|
13488
|
-
const components2 = Object.values(json
|
|
13512
|
+
const components2 = Object.values(get2(json, "usingComponents") ?? {});
|
|
13489
13513
|
const subPackages = [
|
|
13490
13514
|
...json.subPackages ?? [],
|
|
13491
13515
|
...json.subpackages ?? []
|
|
@@ -13508,12 +13532,212 @@ function analyzeAppJson(json) {
|
|
|
13508
13532
|
__name(analyzeAppJson, "analyzeAppJson");
|
|
13509
13533
|
function analyzeCommonJson(json) {
|
|
13510
13534
|
const entries = [];
|
|
13511
|
-
const components2 = Object.values(json
|
|
13535
|
+
const components2 = Object.values(get2(json, "usingComponents") ?? {});
|
|
13512
13536
|
entries.push(...components2);
|
|
13513
13537
|
return entries;
|
|
13514
13538
|
}
|
|
13515
13539
|
__name(analyzeCommonJson, "analyzeCommonJson");
|
|
13516
13540
|
|
|
13541
|
+
// src/plugins/utils/ast.ts
|
|
13542
|
+
init_esm_shims();
|
|
13543
|
+
|
|
13544
|
+
// ../../node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/index.js
|
|
13545
|
+
init_esm_shims();
|
|
13546
|
+
|
|
13547
|
+
// ../../node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/sync.js
|
|
13548
|
+
init_esm_shims();
|
|
13549
|
+
|
|
13550
|
+
// ../../node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/walker.js
|
|
13551
|
+
init_esm_shims();
|
|
13552
|
+
var WalkerBase = class {
|
|
13553
|
+
static {
|
|
13554
|
+
__name(this, "WalkerBase");
|
|
13555
|
+
}
|
|
13556
|
+
constructor() {
|
|
13557
|
+
this.should_skip = false;
|
|
13558
|
+
this.should_remove = false;
|
|
13559
|
+
this.replacement = null;
|
|
13560
|
+
this.context = {
|
|
13561
|
+
skip: /* @__PURE__ */ __name(() => this.should_skip = true, "skip"),
|
|
13562
|
+
remove: /* @__PURE__ */ __name(() => this.should_remove = true, "remove"),
|
|
13563
|
+
replace: /* @__PURE__ */ __name((node) => this.replacement = node, "replace")
|
|
13564
|
+
};
|
|
13565
|
+
}
|
|
13566
|
+
/**
|
|
13567
|
+
* @template {Node} Parent
|
|
13568
|
+
* @param {Parent | null | undefined} parent
|
|
13569
|
+
* @param {keyof Parent | null | undefined} prop
|
|
13570
|
+
* @param {number | null | undefined} index
|
|
13571
|
+
* @param {Node} node
|
|
13572
|
+
*/
|
|
13573
|
+
replace(parent, prop, index, node) {
|
|
13574
|
+
if (parent && prop) {
|
|
13575
|
+
if (index != null) {
|
|
13576
|
+
parent[prop][index] = node;
|
|
13577
|
+
} else {
|
|
13578
|
+
parent[prop] = node;
|
|
13579
|
+
}
|
|
13580
|
+
}
|
|
13581
|
+
}
|
|
13582
|
+
/**
|
|
13583
|
+
* @template {Node} Parent
|
|
13584
|
+
* @param {Parent | null | undefined} parent
|
|
13585
|
+
* @param {keyof Parent | null | undefined} prop
|
|
13586
|
+
* @param {number | null | undefined} index
|
|
13587
|
+
*/
|
|
13588
|
+
remove(parent, prop, index) {
|
|
13589
|
+
if (parent && prop) {
|
|
13590
|
+
if (index !== null && index !== void 0) {
|
|
13591
|
+
parent[prop].splice(index, 1);
|
|
13592
|
+
} else {
|
|
13593
|
+
delete parent[prop];
|
|
13594
|
+
}
|
|
13595
|
+
}
|
|
13596
|
+
}
|
|
13597
|
+
};
|
|
13598
|
+
|
|
13599
|
+
// ../../node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/sync.js
|
|
13600
|
+
var SyncWalker = class extends WalkerBase {
|
|
13601
|
+
static {
|
|
13602
|
+
__name(this, "SyncWalker");
|
|
13603
|
+
}
|
|
13604
|
+
/**
|
|
13605
|
+
*
|
|
13606
|
+
* @param {SyncHandler} [enter]
|
|
13607
|
+
* @param {SyncHandler} [leave]
|
|
13608
|
+
*/
|
|
13609
|
+
constructor(enter, leave) {
|
|
13610
|
+
super();
|
|
13611
|
+
this.should_skip = false;
|
|
13612
|
+
this.should_remove = false;
|
|
13613
|
+
this.replacement = null;
|
|
13614
|
+
this.context = {
|
|
13615
|
+
skip: /* @__PURE__ */ __name(() => this.should_skip = true, "skip"),
|
|
13616
|
+
remove: /* @__PURE__ */ __name(() => this.should_remove = true, "remove"),
|
|
13617
|
+
replace: /* @__PURE__ */ __name((node) => this.replacement = node, "replace")
|
|
13618
|
+
};
|
|
13619
|
+
this.enter = enter;
|
|
13620
|
+
this.leave = leave;
|
|
13621
|
+
}
|
|
13622
|
+
/**
|
|
13623
|
+
* @template {Node} Parent
|
|
13624
|
+
* @param {Node} node
|
|
13625
|
+
* @param {Parent | null} parent
|
|
13626
|
+
* @param {keyof Parent} [prop]
|
|
13627
|
+
* @param {number | null} [index]
|
|
13628
|
+
* @returns {Node | null}
|
|
13629
|
+
*/
|
|
13630
|
+
visit(node, parent, prop, index) {
|
|
13631
|
+
if (node) {
|
|
13632
|
+
if (this.enter) {
|
|
13633
|
+
const _should_skip = this.should_skip;
|
|
13634
|
+
const _should_remove = this.should_remove;
|
|
13635
|
+
const _replacement = this.replacement;
|
|
13636
|
+
this.should_skip = false;
|
|
13637
|
+
this.should_remove = false;
|
|
13638
|
+
this.replacement = null;
|
|
13639
|
+
this.enter.call(this.context, node, parent, prop, index);
|
|
13640
|
+
if (this.replacement) {
|
|
13641
|
+
node = this.replacement;
|
|
13642
|
+
this.replace(parent, prop, index, node);
|
|
13643
|
+
}
|
|
13644
|
+
if (this.should_remove) {
|
|
13645
|
+
this.remove(parent, prop, index);
|
|
13646
|
+
}
|
|
13647
|
+
const skipped = this.should_skip;
|
|
13648
|
+
const removed = this.should_remove;
|
|
13649
|
+
this.should_skip = _should_skip;
|
|
13650
|
+
this.should_remove = _should_remove;
|
|
13651
|
+
this.replacement = _replacement;
|
|
13652
|
+
if (skipped) return node;
|
|
13653
|
+
if (removed) return null;
|
|
13654
|
+
}
|
|
13655
|
+
let key;
|
|
13656
|
+
for (key in node) {
|
|
13657
|
+
const value = node[key];
|
|
13658
|
+
if (value && typeof value === "object") {
|
|
13659
|
+
if (Array.isArray(value)) {
|
|
13660
|
+
const nodes = (
|
|
13661
|
+
/** @type {Array<unknown>} */
|
|
13662
|
+
value
|
|
13663
|
+
);
|
|
13664
|
+
for (let i = 0; i < nodes.length; i += 1) {
|
|
13665
|
+
const item = nodes[i];
|
|
13666
|
+
if (isNode(item)) {
|
|
13667
|
+
if (!this.visit(item, node, key, i)) {
|
|
13668
|
+
i--;
|
|
13669
|
+
}
|
|
13670
|
+
}
|
|
13671
|
+
}
|
|
13672
|
+
} else if (isNode(value)) {
|
|
13673
|
+
this.visit(value, node, key, null);
|
|
13674
|
+
}
|
|
13675
|
+
}
|
|
13676
|
+
}
|
|
13677
|
+
if (this.leave) {
|
|
13678
|
+
const _replacement = this.replacement;
|
|
13679
|
+
const _should_remove = this.should_remove;
|
|
13680
|
+
this.replacement = null;
|
|
13681
|
+
this.should_remove = false;
|
|
13682
|
+
this.leave.call(this.context, node, parent, prop, index);
|
|
13683
|
+
if (this.replacement) {
|
|
13684
|
+
node = this.replacement;
|
|
13685
|
+
this.replace(parent, prop, index, node);
|
|
13686
|
+
}
|
|
13687
|
+
if (this.should_remove) {
|
|
13688
|
+
this.remove(parent, prop, index);
|
|
13689
|
+
}
|
|
13690
|
+
const removed = this.should_remove;
|
|
13691
|
+
this.replacement = _replacement;
|
|
13692
|
+
this.should_remove = _should_remove;
|
|
13693
|
+
if (removed) return null;
|
|
13694
|
+
}
|
|
13695
|
+
}
|
|
13696
|
+
return node;
|
|
13697
|
+
}
|
|
13698
|
+
};
|
|
13699
|
+
function isNode(value) {
|
|
13700
|
+
return value !== null && typeof value === "object" && "type" in value && typeof value.type === "string";
|
|
13701
|
+
}
|
|
13702
|
+
__name(isNode, "isNode");
|
|
13703
|
+
|
|
13704
|
+
// ../../node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/async.js
|
|
13705
|
+
init_esm_shims();
|
|
13706
|
+
|
|
13707
|
+
// ../../node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/index.js
|
|
13708
|
+
function walk(ast, { enter, leave }) {
|
|
13709
|
+
const instance = new SyncWalker(enter, leave);
|
|
13710
|
+
return instance.visit(ast, null);
|
|
13711
|
+
}
|
|
13712
|
+
__name(walk, "walk");
|
|
13713
|
+
|
|
13714
|
+
// src/plugins/utils/ast.ts
|
|
13715
|
+
function collectRequireTokens(ast) {
|
|
13716
|
+
const requireModules = [];
|
|
13717
|
+
walk(ast, {
|
|
13718
|
+
enter(node) {
|
|
13719
|
+
if (node.type === "CallExpression") {
|
|
13720
|
+
if (node.callee.type === "MemberExpression" && node.callee.object.type === "Identifier" && node.callee.object.name === "require" && node.callee.property.type === "Identifier" && node.callee.property.name === "async") {
|
|
13721
|
+
if (node.arguments[0] && node.arguments[0].type === "Literal" && typeof node.arguments[0].value === "string") {
|
|
13722
|
+
requireModules.push({
|
|
13723
|
+
// @ts-ignore
|
|
13724
|
+
start: node.arguments[0].start,
|
|
13725
|
+
// @ts-ignore
|
|
13726
|
+
end: node.arguments[0].end,
|
|
13727
|
+
value: node.arguments[0].value,
|
|
13728
|
+
async: true
|
|
13729
|
+
});
|
|
13730
|
+
}
|
|
13731
|
+
}
|
|
13732
|
+
}
|
|
13733
|
+
}
|
|
13734
|
+
});
|
|
13735
|
+
return {
|
|
13736
|
+
requireModules
|
|
13737
|
+
};
|
|
13738
|
+
}
|
|
13739
|
+
__name(collectRequireTokens, "collectRequireTokens");
|
|
13740
|
+
|
|
13517
13741
|
// src/plugins/core.ts
|
|
13518
13742
|
function weappVite(ctx, subPackageMeta) {
|
|
13519
13743
|
const { scanService, configService, jsonService, wxmlService, autoImportService, buildService, watcherService } = ctx;
|
|
@@ -13595,23 +13819,27 @@ function weappVite(ctx, subPackageMeta) {
|
|
|
13595
13819
|
async function loadEntry(id, type) {
|
|
13596
13820
|
this.addWatchFile(id);
|
|
13597
13821
|
const baseName = removeExtensionDeep4(id);
|
|
13598
|
-
let jsonPath = await findJsonEntry(id);
|
|
13822
|
+
let { path: jsonPath, predictions } = await findJsonEntry(id);
|
|
13823
|
+
for (const prediction of predictions) {
|
|
13824
|
+
this.addWatchFile(prediction);
|
|
13825
|
+
}
|
|
13599
13826
|
let json = {};
|
|
13600
13827
|
if (jsonPath) {
|
|
13601
13828
|
json = await jsonService.read(jsonPath);
|
|
13602
13829
|
} else {
|
|
13603
13830
|
jsonPath = changeFileExtension(id, ".json");
|
|
13604
13831
|
}
|
|
13605
|
-
this.addWatchFile(jsonPath);
|
|
13606
13832
|
const entries = [];
|
|
13607
13833
|
let templatePath = "";
|
|
13608
13834
|
if (type === "app") {
|
|
13609
13835
|
entries.push(...analyzeAppJson(json));
|
|
13610
13836
|
const { sitemapLocation = "sitemap.json", themeLocation = "theme.json" } = json;
|
|
13611
13837
|
if (sitemapLocation) {
|
|
13612
|
-
const sitemapJsonPath = await findJsonEntry(path8.resolve(path8.dirname(id), sitemapLocation));
|
|
13838
|
+
const { path: sitemapJsonPath, predictions: predictions2 } = await findJsonEntry(path8.resolve(path8.dirname(id), sitemapLocation));
|
|
13839
|
+
for (const prediction of predictions2) {
|
|
13840
|
+
this.addWatchFile(prediction);
|
|
13841
|
+
}
|
|
13613
13842
|
if (sitemapJsonPath) {
|
|
13614
|
-
this.addWatchFile(sitemapJsonPath);
|
|
13615
13843
|
const sitemapJson = await jsonService.read(sitemapJsonPath);
|
|
13616
13844
|
setJsonEmitFilesMap({
|
|
13617
13845
|
json: sitemapJson,
|
|
@@ -13621,9 +13849,11 @@ function weappVite(ctx, subPackageMeta) {
|
|
|
13621
13849
|
}
|
|
13622
13850
|
}
|
|
13623
13851
|
if (themeLocation) {
|
|
13624
|
-
const themeJsonPath = await findJsonEntry(path8.resolve(path8.dirname(id), themeLocation));
|
|
13852
|
+
const { path: themeJsonPath, predictions: predictions2 } = await findJsonEntry(path8.resolve(path8.dirname(id), themeLocation));
|
|
13853
|
+
for (const prediction of predictions2) {
|
|
13854
|
+
this.addWatchFile(prediction);
|
|
13855
|
+
}
|
|
13625
13856
|
if (themeJsonPath) {
|
|
13626
|
-
this.addWatchFile(themeJsonPath);
|
|
13627
13857
|
const themeJson = await jsonService.read(themeJsonPath);
|
|
13628
13858
|
setJsonEmitFilesMap({
|
|
13629
13859
|
json: themeJson,
|
|
@@ -13633,10 +13863,12 @@ function weappVite(ctx, subPackageMeta) {
|
|
|
13633
13863
|
}
|
|
13634
13864
|
}
|
|
13635
13865
|
} else {
|
|
13636
|
-
const templateEntry = await findTemplateEntry(id);
|
|
13866
|
+
const { path: templateEntry, predictions: predictions2 } = await findTemplateEntry(id);
|
|
13867
|
+
for (const prediction of predictions2) {
|
|
13868
|
+
this.addWatchFile(prediction);
|
|
13869
|
+
}
|
|
13637
13870
|
if (templateEntry) {
|
|
13638
13871
|
templatePath = templateEntry;
|
|
13639
|
-
this.addWatchFile(templateEntry);
|
|
13640
13872
|
await scanTemplateEntry(templateEntry);
|
|
13641
13873
|
}
|
|
13642
13874
|
const hit = wxmlService.wxmlComponentsMap.get(baseName);
|
|
@@ -13647,7 +13879,8 @@ function weappVite(ctx, subPackageMeta) {
|
|
|
13647
13879
|
if (res) {
|
|
13648
13880
|
const { entry: componentEntry, value } = res;
|
|
13649
13881
|
if (componentEntry?.jsonPath) {
|
|
13650
|
-
|
|
13882
|
+
const usingComponents = get3(json, "usingComponents");
|
|
13883
|
+
if (isObject3(usingComponents) && Reflect.has(usingComponents, value.name)) {
|
|
13651
13884
|
continue;
|
|
13652
13885
|
}
|
|
13653
13886
|
set2(json, `usingComponents.${value.name}`, value.from);
|
|
@@ -13656,7 +13889,8 @@ function weappVite(ctx, subPackageMeta) {
|
|
|
13656
13889
|
for (const resolver of configService.weappViteConfig.enhance.autoImportComponents.resolvers) {
|
|
13657
13890
|
const value = resolver(depComponentName, baseName);
|
|
13658
13891
|
if (value) {
|
|
13659
|
-
|
|
13892
|
+
const usingComponents = get3(json, "usingComponents");
|
|
13893
|
+
if (!(isObject3(usingComponents) && Reflect.has(usingComponents, value.name))) {
|
|
13660
13894
|
set2(json, `usingComponents.${value.name}`, value.from);
|
|
13661
13895
|
}
|
|
13662
13896
|
}
|
|
@@ -13709,8 +13943,9 @@ function weappVite(ctx, subPackageMeta) {
|
|
|
13709
13943
|
const ms = new MagicString(code);
|
|
13710
13944
|
for (const ext2 of supportedCssLangs) {
|
|
13711
13945
|
const mayBeCssPath = changeFileExtension(id, ext2);
|
|
13946
|
+
this.addWatchFile(mayBeCssPath);
|
|
13712
13947
|
if (await fs5.exists(mayBeCssPath)) {
|
|
13713
|
-
ms.prepend(`import '${mayBeCssPath}'
|
|
13948
|
+
ms.prepend(`import '${mayBeCssPath}';
|
|
13714
13949
|
`);
|
|
13715
13950
|
}
|
|
13716
13951
|
}
|
|
@@ -13784,8 +14019,8 @@ function weappVite(ctx, subPackageMeta) {
|
|
|
13784
14019
|
if (isCSSRequest(id)) {
|
|
13785
14020
|
const parsed = parseRequest(id);
|
|
13786
14021
|
const realPath = getCssRealPath(parsed);
|
|
14022
|
+
this.addWatchFile(realPath);
|
|
13787
14023
|
if (await fs5.exists(realPath)) {
|
|
13788
|
-
this.addWatchFile(realPath);
|
|
13789
14024
|
const css2 = await fs5.readFile(realPath, "utf8");
|
|
13790
14025
|
return {
|
|
13791
14026
|
code: css2
|
|
@@ -13799,14 +14034,41 @@ function weappVite(ctx, subPackageMeta) {
|
|
|
13799
14034
|
return await loadEntry.call(this, id, "app");
|
|
13800
14035
|
}
|
|
13801
14036
|
},
|
|
14037
|
+
transform: {
|
|
14038
|
+
order: "post",
|
|
14039
|
+
async handler(code, id) {
|
|
14040
|
+
if (isJsOrTs(id)) {
|
|
14041
|
+
try {
|
|
14042
|
+
const ast = this.parse(code);
|
|
14043
|
+
const { requireModules } = collectRequireTokens(ast);
|
|
14044
|
+
for (const requireModule of requireModules) {
|
|
14045
|
+
const absPath = path8.resolve(path8.dirname(id), requireModule.value);
|
|
14046
|
+
const resolveId = await this.resolve(absPath, id);
|
|
14047
|
+
if (resolveId) {
|
|
14048
|
+
await this.load(resolveId);
|
|
14049
|
+
this.emitFile({
|
|
14050
|
+
type: "chunk",
|
|
14051
|
+
id: resolveId.id,
|
|
14052
|
+
fileName: configService.relativeAbsoluteSrcRoot(changeFileExtension(resolveId.id, ".js")),
|
|
14053
|
+
preserveSignature: "exports-only"
|
|
14054
|
+
});
|
|
14055
|
+
}
|
|
14056
|
+
}
|
|
14057
|
+
return {
|
|
14058
|
+
code,
|
|
14059
|
+
ast,
|
|
14060
|
+
map: null
|
|
14061
|
+
};
|
|
14062
|
+
} catch (error) {
|
|
14063
|
+
logger_default.error(error);
|
|
14064
|
+
}
|
|
14065
|
+
}
|
|
14066
|
+
}
|
|
14067
|
+
},
|
|
13802
14068
|
// shouldTransformCachedModule() {
|
|
13803
14069
|
// return true
|
|
13804
14070
|
// },
|
|
13805
14071
|
renderStart() {
|
|
13806
|
-
if (configService.weappViteConfig?.debug?.watchFiles) {
|
|
13807
|
-
const watchFiles = this.getWatchFiles();
|
|
13808
|
-
configService.weappViteConfig.debug.watchFiles(watchFiles, subPackageMeta);
|
|
13809
|
-
}
|
|
13810
14072
|
for (const jsonEmitFile of jsonEmitFilesMap.values()) {
|
|
13811
14073
|
if (jsonEmitFile.entry.json && isObject3(jsonEmitFile.entry.json) && !isEmptyObject2(jsonEmitFile.entry.json)) {
|
|
13812
14074
|
this.emitFile({
|
|
@@ -13857,6 +14119,10 @@ function weappVite(ctx, subPackageMeta) {
|
|
|
13857
14119
|
}
|
|
13858
14120
|
}
|
|
13859
14121
|
}
|
|
14122
|
+
if (configService.weappViteConfig?.debug?.watchFiles) {
|
|
14123
|
+
const watchFiles = this.getWatchFiles();
|
|
14124
|
+
configService.weappViteConfig.debug.watchFiles(watchFiles, subPackageMeta);
|
|
14125
|
+
}
|
|
13860
14126
|
}
|
|
13861
14127
|
}
|
|
13862
14128
|
];
|
|
@@ -14086,8 +14352,8 @@ var wxsCodeCache = new LRUCache({
|
|
|
14086
14352
|
function wxs({ configService, wxmlService }) {
|
|
14087
14353
|
const wxsMap = /* @__PURE__ */ new Map();
|
|
14088
14354
|
async function transformWxs({ wxsPath }) {
|
|
14355
|
+
this.addWatchFile(wxsPath);
|
|
14089
14356
|
if (await fs6.exists(wxsPath)) {
|
|
14090
|
-
this.addWatchFile(wxsPath);
|
|
14091
14357
|
const arr = wxsPath.match(/\.wxs(\.[jt]s)?$/);
|
|
14092
14358
|
let isRaw = true;
|
|
14093
14359
|
if (arr) {
|
|
@@ -14175,13 +14441,13 @@ __name(vitePluginWeapp, "vitePluginWeapp");
|
|
|
14175
14441
|
import { defu as defu3 } from "@weapp-core/shared";
|
|
14176
14442
|
import fs8 from "fs-extra";
|
|
14177
14443
|
|
|
14178
|
-
// ../../node_modules/.pnpm/package-manager-detector@1.
|
|
14444
|
+
// ../../node_modules/.pnpm/package-manager-detector@1.2.0/node_modules/package-manager-detector/dist/detect.mjs
|
|
14179
14445
|
init_esm_shims();
|
|
14180
14446
|
import fs7 from "node:fs/promises";
|
|
14181
14447
|
import path11 from "node:path";
|
|
14182
14448
|
import process3 from "node:process";
|
|
14183
14449
|
|
|
14184
|
-
// ../../node_modules/.pnpm/package-manager-detector@1.
|
|
14450
|
+
// ../../node_modules/.pnpm/package-manager-detector@1.2.0/node_modules/package-manager-detector/dist/constants.mjs
|
|
14185
14451
|
init_esm_shims();
|
|
14186
14452
|
var AGENTS = [
|
|
14187
14453
|
"npm",
|
|
@@ -14197,6 +14463,7 @@ var LOCKS = {
|
|
|
14197
14463
|
"bun.lockb": "bun",
|
|
14198
14464
|
"deno.lock": "deno",
|
|
14199
14465
|
"pnpm-lock.yaml": "pnpm",
|
|
14466
|
+
"pnpm-workspace.yaml": "pnpm",
|
|
14200
14467
|
"yarn.lock": "yarn",
|
|
14201
14468
|
"package-lock.json": "npm",
|
|
14202
14469
|
"npm-shrinkwrap.json": "npm"
|
|
@@ -14217,7 +14484,7 @@ var INSTALL_METADATA = {
|
|
|
14217
14484
|
"bun.lockb": "bun"
|
|
14218
14485
|
};
|
|
14219
14486
|
|
|
14220
|
-
// ../../node_modules/.pnpm/package-manager-detector@1.
|
|
14487
|
+
// ../../node_modules/.pnpm/package-manager-detector@1.2.0/node_modules/package-manager-detector/dist/detect.mjs
|
|
14221
14488
|
async function pathExists(path23, type) {
|
|
14222
14489
|
try {
|
|
14223
14490
|
const stat3 = await fs7.stat(path23);
|
|
@@ -22717,8 +22984,8 @@ var ScanService2 = class {
|
|
|
22717
22984
|
async loadAppEntry() {
|
|
22718
22985
|
const appDirname = this.configService.absoluteSrcRoot;
|
|
22719
22986
|
const appBasename = path18.resolve(appDirname, "app");
|
|
22720
|
-
const appConfigFile = await findJsonEntry(appBasename);
|
|
22721
|
-
const appEntryPath = await findJsEntry(appBasename);
|
|
22987
|
+
const { path: appConfigFile } = await findJsonEntry(appBasename);
|
|
22988
|
+
const { path: appEntryPath } = await findJsEntry(appBasename);
|
|
22722
22989
|
if (appEntryPath && appConfigFile) {
|
|
22723
22990
|
const config = await this.jsonService.read(appConfigFile);
|
|
22724
22991
|
if (isObject6(config)) {
|
|
@@ -22731,14 +22998,14 @@ var ScanService2 = class {
|
|
|
22731
22998
|
this.appEntry = appEntry;
|
|
22732
22999
|
const { sitemapLocation = "sitemap.json", themeLocation = "theme.json" } = config;
|
|
22733
23000
|
if (sitemapLocation) {
|
|
22734
|
-
const sitemapJsonPath = await findJsonEntry(path18.resolve(appDirname, sitemapLocation));
|
|
23001
|
+
const { path: sitemapJsonPath } = await findJsonEntry(path18.resolve(appDirname, sitemapLocation));
|
|
22735
23002
|
if (sitemapJsonPath) {
|
|
22736
23003
|
appEntry.sitemapJsonPath = sitemapJsonPath;
|
|
22737
23004
|
appEntry.sitemapJson = await this.jsonService.read(sitemapJsonPath);
|
|
22738
23005
|
}
|
|
22739
23006
|
}
|
|
22740
23007
|
if (themeLocation) {
|
|
22741
|
-
const themeJsonPath = await findJsonEntry(path18.resolve(appDirname, themeLocation));
|
|
23008
|
+
const { path: themeJsonPath } = await findJsonEntry(path18.resolve(appDirname, themeLocation));
|
|
22742
23009
|
if (themeJsonPath) {
|
|
22743
23010
|
appEntry.themeJsonPath = themeJsonPath;
|
|
22744
23011
|
appEntry.themeJson = await this.jsonService.read(themeJsonPath);
|
package/dist/cli.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk4RA3EKOJcjs = require('./chunk-4RA3EKOJ.cjs');
|
|
7
7
|
require('./chunk-T5OM6XSR.cjs');
|
|
8
8
|
require('./chunk-7K7GXEBV.cjs');
|
|
9
9
|
|
|
@@ -621,7 +621,7 @@ var CAC = class extends _events.EventEmitter {
|
|
|
621
621
|
};
|
|
622
622
|
var cac = /* @__PURE__ */ _chunkWAO6ZIROcjs.__name.call(void 0, (name = "") => new CAC(name), "cac");
|
|
623
623
|
|
|
624
|
-
// ../../node_modules/.pnpm/package-manager-detector@1.
|
|
624
|
+
// ../../node_modules/.pnpm/package-manager-detector@1.2.0/node_modules/package-manager-detector/dist/commands.mjs
|
|
625
625
|
_chunkWAO6ZIROcjs.init_cjs_shims.call(void 0, );
|
|
626
626
|
function npmRun(agent) {
|
|
627
627
|
return (args) => {
|
|
@@ -823,14 +823,14 @@ async function generate(options) {
|
|
|
823
823
|
for (const { code, fileName: fileName2 } of files) {
|
|
824
824
|
if (code !== void 0) {
|
|
825
825
|
await _fsextra2.default.outputFile(_pathe2.default.resolve(basepath, fileName2), code, "utf8");
|
|
826
|
-
|
|
826
|
+
_chunk4RA3EKOJcjs.logger_default.success(`${composePath(outDir, fileName2)} \u521B\u5EFA\u6210\u529F\uFF01`);
|
|
827
827
|
}
|
|
828
828
|
}
|
|
829
829
|
}
|
|
830
830
|
_chunkWAO6ZIROcjs.__name.call(void 0, generate, "generate");
|
|
831
831
|
|
|
832
832
|
// src/cli.ts
|
|
833
|
-
var import_reflect_metadata = _chunkWAO6ZIROcjs.__toESM.call(void 0,
|
|
833
|
+
var import_reflect_metadata = _chunkWAO6ZIROcjs.__toESM.call(void 0, _chunk4RA3EKOJcjs.require_Reflect.call(void 0, ), 1);
|
|
834
834
|
var cli = cac("weapp-vite");
|
|
835
835
|
function loadConfig() {
|
|
836
836
|
return _vite.loadConfigFromFile.call(void 0, {
|
|
@@ -852,9 +852,9 @@ function logBuildAppFinish(configService) {
|
|
|
852
852
|
]
|
|
853
853
|
}));
|
|
854
854
|
const devCommand = `${command} ${args.join(" ")}`;
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
855
|
+
_chunk4RA3EKOJcjs.logger_default.success("\u5E94\u7528\u6784\u5EFA\u5B8C\u6210\uFF01\u9884\u89C8\u65B9\u5F0F ( `2` \u79CD\u9009\u5176\u4E00\u5373\u53EF)\uFF1A");
|
|
856
|
+
_chunk4RA3EKOJcjs.logger_default.info(`\u6267\u884C \`${devCommand}\` \u53EF\u4EE5\u76F4\u63A5\u5728 \`\u5FAE\u4FE1\u5F00\u53D1\u8005\u5DE5\u5177\` \u91CC\u6253\u5F00\u5F53\u524D\u5E94\u7528`);
|
|
857
|
+
_chunk4RA3EKOJcjs.logger_default.info("\u6216\u624B\u52A8\u6253\u5F00\u5FAE\u4FE1\u5F00\u53D1\u8005\u5DE5\u5177\uFF0C\u5BFC\u5165\u6839\u76EE\u5F55(`project.config.json` \u6587\u4EF6\u6240\u5728\u7684\u76EE\u5F55)\uFF0C\u5373\u53EF\u9884\u89C8\u6548\u679C");
|
|
858
858
|
logBuildAppFinishOnlyShowOnce = true;
|
|
859
859
|
}
|
|
860
860
|
}
|
|
@@ -881,7 +881,7 @@ async function openIde() {
|
|
|
881
881
|
"-p"
|
|
882
882
|
]);
|
|
883
883
|
} catch (error) {
|
|
884
|
-
|
|
884
|
+
_chunk4RA3EKOJcjs.logger_default.error(error);
|
|
885
885
|
}
|
|
886
886
|
}
|
|
887
887
|
_chunkWAO6ZIROcjs.__name.call(void 0, openIde, "openIde");
|
|
@@ -892,7 +892,7 @@ cli.option("-c, --config <file>", `[string] use specified config file`).option("
|
|
|
892
892
|
}).option("-l, --logLevel <level>", `[string] info | warn | error | silent`).option("--clearScreen", `[boolean] allow/disable clear screen when logging`).option("-d, --debug [feat]", `[string | boolean] show debug logs`).option("-f, --filter <filter>", `[string] filter debug logs`).option("-m, --mode <mode>", `[string] set env mode`);
|
|
893
893
|
cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--skipNpm", `[boolean] if skip npm build`).option("-o, --open", `[boolean] open ide`).action(async (root, options) => {
|
|
894
894
|
filterDuplicateOptions(options);
|
|
895
|
-
const { buildService, configService } = await
|
|
895
|
+
const { buildService, configService } = await _chunk4RA3EKOJcjs.createCompilerContext.call(void 0, {
|
|
896
896
|
cwd: root,
|
|
897
897
|
mode: options.mode,
|
|
898
898
|
isDev: true
|
|
@@ -905,7 +905,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
|
|
|
905
905
|
});
|
|
906
906
|
cli.command("build [root]", "build for production").option("--target <target>", `[string] transpile target (default: 'modules')`).option("--outDir <dir>", `[string] output directory (default: dist)`).option("--sourcemap [output]", `[boolean | "inline" | "hidden"] output source maps for build (default: false)`).option("--minify [minifier]", `[boolean | "terser" | "esbuild"] enable/disable minification, or specify minifier to use (default: esbuild)`).option("--emptyOutDir", `[boolean] force empty outDir when it's outside of root`).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--skipNpm", `[boolean] if skip npm build`).option("-o, --open", `[boolean] open ide`).action(async (root, options) => {
|
|
907
907
|
filterDuplicateOptions(options);
|
|
908
|
-
const { buildService, configService } = await
|
|
908
|
+
const { buildService, configService } = await _chunk4RA3EKOJcjs.createCompilerContext.call(void 0, {
|
|
909
909
|
cwd: root,
|
|
910
910
|
mode: options.mode
|
|
911
911
|
});
|
|
@@ -921,7 +921,7 @@ cli.command("init").action(async () => {
|
|
|
921
921
|
command: "weapp-vite"
|
|
922
922
|
});
|
|
923
923
|
} catch (error) {
|
|
924
|
-
|
|
924
|
+
_chunk4RA3EKOJcjs.logger_default.error(error);
|
|
925
925
|
}
|
|
926
926
|
});
|
|
927
927
|
cli.command("open").action(async () => {
|
|
@@ -934,7 +934,7 @@ cli.command("npm").alias("build:npm").alias("build-npm").action(async () => {
|
|
|
934
934
|
"-p"
|
|
935
935
|
]);
|
|
936
936
|
} catch (error) {
|
|
937
|
-
|
|
937
|
+
_chunk4RA3EKOJcjs.logger_default.error(error);
|
|
938
938
|
}
|
|
939
939
|
});
|
|
940
940
|
cli.command("gc [filepath]", "generate component").alias("g").alias("generate").option("-a, --app", "type app").option("-p, --page", "type app").option("-n, --name <name>", "filename").action(async (filepath, options) => {
|
|
@@ -949,7 +949,7 @@ cli.command("gc [filepath]", "generate component").alias("g").alias("generate").
|
|
|
949
949
|
fileName = "app";
|
|
950
950
|
}
|
|
951
951
|
if (filepath === void 0) {
|
|
952
|
-
|
|
952
|
+
_chunk4RA3EKOJcjs.logger_default.error("weapp-vite generate <outDir> \u547D\u4EE4\u5FC5\u987B\u4F20\u5165\u8DEF\u5F84\u53C2\u6570 outDir");
|
|
953
953
|
return;
|
|
954
954
|
}
|
|
955
955
|
if (options.page) {
|
|
@@ -968,5 +968,5 @@ cli.command("create [outDir]", "create project").option("-t, --template <type>",
|
|
|
968
968
|
await _init.createProject.call(void 0, outDir, options.template);
|
|
969
969
|
});
|
|
970
970
|
cli.help();
|
|
971
|
-
cli.version(
|
|
971
|
+
cli.version(_chunk4RA3EKOJcjs.VERSION);
|
|
972
972
|
cli.parse();
|
package/dist/cli.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
createCompilerContext,
|
|
4
4
|
logger_default,
|
|
5
5
|
require_Reflect
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-X6MUD4OM.mjs";
|
|
7
7
|
import "./chunk-OFNMPWNJ.mjs";
|
|
8
8
|
import "./chunk-QRBNPNZJ.mjs";
|
|
9
9
|
import {
|
|
@@ -621,7 +621,7 @@ var CAC = class extends EventEmitter {
|
|
|
621
621
|
};
|
|
622
622
|
var cac = /* @__PURE__ */ __name((name = "") => new CAC(name), "cac");
|
|
623
623
|
|
|
624
|
-
// ../../node_modules/.pnpm/package-manager-detector@1.
|
|
624
|
+
// ../../node_modules/.pnpm/package-manager-detector@1.2.0/node_modules/package-manager-detector/dist/commands.mjs
|
|
625
625
|
init_esm_shims();
|
|
626
626
|
function npmRun(agent) {
|
|
627
627
|
return (args) => {
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunk4RA3EKOJcjs = require('./chunk-4RA3EKOJ.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
var _chunkT5OM6XSRcjs = require('./chunk-T5OM6XSR.cjs');
|
|
@@ -19,7 +19,7 @@ var _chunkWAO6ZIROcjs = require('./chunk-WAO6ZIRO.cjs');
|
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
_chunkWAO6ZIROcjs.init_cjs_shims.call(void 0, );
|
|
22
|
-
var import_reflect_metadata = _chunkWAO6ZIROcjs.__toESM.call(void 0,
|
|
22
|
+
var import_reflect_metadata = _chunkWAO6ZIROcjs.__toESM.call(void 0, _chunk4RA3EKOJcjs.require_Reflect.call(void 0, ), 1);
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
@@ -28,4 +28,4 @@ var import_reflect_metadata = _chunkWAO6ZIROcjs.__toESM.call(void 0, _chunkPVNQ5
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
exports.createCompilerContext =
|
|
31
|
+
exports.createCompilerContext = _chunk4RA3EKOJcjs.createCompilerContext; exports.defineAppJson = _chunk7K7GXEBVcjs.defineAppJson; exports.defineComponentJson = _chunk7K7GXEBVcjs.defineComponentJson; exports.defineConfig = _chunkT5OM6XSRcjs.defineConfig; exports.definePageJson = _chunk7K7GXEBVcjs.definePageJson; exports.defineSitemapJson = _chunk7K7GXEBVcjs.defineSitemapJson; exports.defineThemeJson = _chunk7K7GXEBVcjs.defineThemeJson;
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-vite",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.2",
|
|
5
5
|
"description": "weapp-vite 一个现代化的小程序打包工具",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -92,14 +92,14 @@
|
|
|
92
92
|
"picomatch": "^4.0.2",
|
|
93
93
|
"postcss": "^8.5.3",
|
|
94
94
|
"tsup": "^8.4.0",
|
|
95
|
-
"vite": "^6.
|
|
95
|
+
"vite": "^6.3.0",
|
|
96
96
|
"vite-plugin-commonjs": "^0.10.4",
|
|
97
97
|
"vite-tsconfig-paths": "^5.1.4",
|
|
98
|
-
"@weapp-core/init": "^1.1.17",
|
|
99
98
|
"@weapp-core/logger": "^1.0.3",
|
|
99
|
+
"@weapp-core/init": "^1.1.17",
|
|
100
100
|
"@weapp-core/schematics": "^1.0.12",
|
|
101
|
-
"@weapp-core/shared": "^1.0.7",
|
|
102
101
|
"@weapp-vite/volar": "^0.0.0",
|
|
102
|
+
"@weapp-core/shared": "^1.0.7",
|
|
103
103
|
"weapp-ide-cli": "^2.0.10"
|
|
104
104
|
},
|
|
105
105
|
"publishConfig": {
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
"lru-cache": "^10.4.3",
|
|
120
120
|
"magic-string": "^0.30.17",
|
|
121
121
|
"p-queue": "^8.1.0",
|
|
122
|
-
"package-manager-detector": "^1.
|
|
122
|
+
"package-manager-detector": "^1.2.0",
|
|
123
123
|
"reflect-metadata": "^0.2.2",
|
|
124
124
|
"rimraf": "5.0.10",
|
|
125
125
|
"rollup": "^4.40.0",
|