weapp-vite 6.7.4 → 6.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,16 +14,19 @@ import {
14
14
  templateExtensions,
15
15
  touch,
16
16
  vueExtensions
17
- } from "./chunk-3ULSPLMB.mjs";
17
+ } from "./chunk-Z53O6PMZ.mjs";
18
+ import {
19
+ applyWeappViteHostMeta
20
+ } from "./chunk-BGBLJUWD.mjs";
18
21
  import {
19
22
  configureLogger,
20
23
  default as default2
21
- } from "./chunk-VZEM2LX3.mjs";
24
+ } from "./chunk-XIEFUUA5.mjs";
22
25
  import {
23
26
  __commonJS,
24
27
  __toESM,
25
28
  init_esm_shims
26
- } from "./chunk-BQM4WPKJ.mjs";
29
+ } from "./chunk-QD76G22N.mjs";
27
30
 
28
31
  // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/debug.js
29
32
  var require_debug = __commonJS({
@@ -2547,7 +2550,7 @@ function extractPropertiesObject(node) {
2547
2550
  }
2548
2551
  return propMap;
2549
2552
  }
2550
- function resolveOptionsObjectExpression(path81, node) {
2553
+ function resolveOptionsObjectExpression(path82, node) {
2551
2554
  if (!node) {
2552
2555
  return void 0;
2553
2556
  }
@@ -2555,7 +2558,7 @@ function resolveOptionsObjectExpression(path81, node) {
2555
2558
  return node;
2556
2559
  }
2557
2560
  if (node.type === "Identifier") {
2558
- const binding = path81.scope.getBinding(node.name);
2561
+ const binding = path82.scope.getBinding(node.name);
2559
2562
  const bindingPath = binding?.path;
2560
2563
  if (bindingPath?.isVariableDeclarator()) {
2561
2564
  const init = bindingPath.node.init;
@@ -2566,7 +2569,7 @@ function resolveOptionsObjectExpression(path81, node) {
2566
2569
  return void 0;
2567
2570
  }
2568
2571
  if (node.type === "TSAsExpression" || node.type === "TSSatisfiesExpression" || node.type === "TSNonNullExpression") {
2569
- return resolveOptionsObjectExpression(path81, node.expression);
2572
+ return resolveOptionsObjectExpression(path82, node.expression);
2570
2573
  }
2571
2574
  return void 0;
2572
2575
  }
@@ -2590,12 +2593,12 @@ function extractComponentProps(code) {
2590
2593
  const ast = parse(code, BABEL_TS_MODULE_PARSER_OPTIONS);
2591
2594
  let props = /* @__PURE__ */ new Map();
2592
2595
  traverse(ast, {
2593
- CallExpression(path81) {
2596
+ CallExpression(path82) {
2594
2597
  if (props.size > 0) {
2595
2598
  return;
2596
2599
  }
2597
- const [options] = path81.node.arguments;
2598
- const optionsObject = resolveOptionsObjectExpression(path81, options);
2600
+ const [options] = path82.node.arguments;
2601
+ const optionsObject = resolveOptionsObjectExpression(path82, options);
2599
2602
  if (!optionsObject) {
2600
2603
  return;
2601
2604
  }
@@ -2766,12 +2769,12 @@ function extractComponentPropsFromDts(code) {
2766
2769
  errorRecovery: true
2767
2770
  });
2768
2771
  traverse(ast, {
2769
- TSInterfaceDeclaration(path81) {
2772
+ TSInterfaceDeclaration(path82) {
2770
2773
  if (props.size > 0) {
2771
- path81.stop();
2774
+ path82.stop();
2772
2775
  return;
2773
2776
  }
2774
- for (const member of path81.node.body.body) {
2777
+ for (const member of path82.node.body.body) {
2775
2778
  if (member.type !== "TSPropertySignature") {
2776
2779
  continue;
2777
2780
  }
@@ -2782,22 +2785,22 @@ function extractComponentPropsFromDts(code) {
2782
2785
  const typeNode = unwrapTypeAnnotation(member.typeAnnotation);
2783
2786
  if (typeNode?.type === "TSTypeLiteral") {
2784
2787
  props = extractFromPropertiesTypeLiteral(typeNode);
2785
- path81.stop();
2788
+ path82.stop();
2786
2789
  return;
2787
2790
  }
2788
2791
  }
2789
- const extracted = extractFromPropsInterfaceMembers(path81.node);
2792
+ const extracted = extractFromPropsInterfaceMembers(path82.node);
2790
2793
  if (extracted.size > 0) {
2791
2794
  props = extracted;
2792
- path81.stop();
2795
+ path82.stop();
2793
2796
  }
2794
2797
  },
2795
- ClassDeclaration(path81) {
2798
+ ClassDeclaration(path82) {
2796
2799
  if (props.size > 0) {
2797
- path81.stop();
2800
+ path82.stop();
2798
2801
  return;
2799
2802
  }
2800
- for (const member of path81.node.body.body) {
2803
+ for (const member of path82.node.body.body) {
2801
2804
  if (member.type !== "ClassProperty" && member.type !== "ClassAccessorProperty") {
2802
2805
  continue;
2803
2806
  }
@@ -2808,7 +2811,7 @@ function extractComponentPropsFromDts(code) {
2808
2811
  const typeNode = unwrapTypeAnnotation(member.typeAnnotation);
2809
2812
  if (typeNode?.type === "TSTypeLiteral") {
2810
2813
  props = extractFromPropertiesTypeLiteral(typeNode);
2811
- path81.stop();
2814
+ path82.stop();
2812
2815
  return;
2813
2816
  }
2814
2817
  }
@@ -7160,28 +7163,6 @@ function isCSSRequest(request) {
7160
7163
  function isRegexp(value) {
7161
7164
  return Object.prototype.toString.call(value) === "[object RegExp]";
7162
7165
  }
7163
- function regExpTest(arr, str, options) {
7164
- if (!Array.isArray(arr)) {
7165
- throw new TypeError("paramater 'arr' should be an Array of Regexp | String");
7166
- }
7167
- for (const item of arr) {
7168
- if (typeof item === "string") {
7169
- if (options?.exact) {
7170
- if (str === item) {
7171
- return true;
7172
- }
7173
- } else if (str.includes(item)) {
7174
- return true;
7175
- }
7176
- } else if (isRegexp(item)) {
7177
- item.lastIndex = 0;
7178
- if (item.test(str)) {
7179
- return true;
7180
- }
7181
- }
7182
- }
7183
- return false;
7184
- }
7185
7166
 
7186
7167
  // src/utils/resolvedId.ts
7187
7168
  init_esm_shims();
@@ -8464,7 +8445,7 @@ async function updateCandidateFromFile(ctx, stateCandidates, filePath, event, ma
8464
8445
  if (!ctx.configService) {
8465
8446
  return false;
8466
8447
  }
8467
- if (event === "rename") {
8448
+ if (event === "rename" || event === "create" || event === "delete") {
8468
8449
  markNeedsFullRescan?.();
8469
8450
  return true;
8470
8451
  }
@@ -14404,17 +14385,17 @@ function withTrailingSlash(input = "", respectQueryAndFragment) {
14404
14385
  if (hasTrailingSlash(input, true)) {
14405
14386
  return input || "/";
14406
14387
  }
14407
- let path81 = input;
14388
+ let path82 = input;
14408
14389
  let fragment = "";
14409
14390
  const fragmentIndex = input.indexOf("#");
14410
14391
  if (fragmentIndex !== -1) {
14411
- path81 = input.slice(0, fragmentIndex);
14392
+ path82 = input.slice(0, fragmentIndex);
14412
14393
  fragment = input.slice(fragmentIndex);
14413
- if (!path81) {
14394
+ if (!path82) {
14414
14395
  return fragment;
14415
14396
  }
14416
14397
  }
14417
- const [s0, ...s] = path81.split("?");
14398
+ const [s0, ...s] = path82.split("?");
14418
14399
  return s0 + "/" + (s.length > 0 ? `?${s.join("?")}` : "") + fragment;
14419
14400
  }
14420
14401
  function isNonEmptyURL(url) {
@@ -14442,8 +14423,8 @@ import path22, { dirname } from "path";
14442
14423
  import v8 from "v8";
14443
14424
  import { format, inspect } from "util";
14444
14425
  var BUILTIN_MODULES = new Set(builtinModules);
14445
- function normalizeSlash(path81) {
14446
- return path81.replace(/\\/g, "/");
14426
+ function normalizeSlash(path82) {
14427
+ return path82.replace(/\\/g, "/");
14447
14428
  }
14448
14429
  var own$1 = {}.hasOwnProperty;
14449
14430
  var classRegExp = /^([A-Z][a-z\d]*)+$/;
@@ -14556,8 +14537,8 @@ codes.ERR_INVALID_PACKAGE_CONFIG = createError(
14556
14537
  * @param {string} [base]
14557
14538
  * @param {string} [message]
14558
14539
  */
14559
- (path81, base, message) => {
14560
- return `Invalid package config ${path81}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
14540
+ (path82, base, message) => {
14541
+ return `Invalid package config ${path82}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
14561
14542
  },
14562
14543
  Error
14563
14544
  );
@@ -14589,8 +14570,8 @@ codes.ERR_MODULE_NOT_FOUND = createError(
14589
14570
  * @param {string} base
14590
14571
  * @param {boolean} [exactUrl]
14591
14572
  */
14592
- (path81, base, exactUrl = false) => {
14593
- return `Cannot find ${exactUrl ? "module" : "package"} '${path81}' imported from ${base}`;
14573
+ (path82, base, exactUrl = false) => {
14574
+ return `Cannot find ${exactUrl ? "module" : "package"} '${path82}' imported from ${base}`;
14594
14575
  },
14595
14576
  Error
14596
14577
  );
@@ -14641,8 +14622,8 @@ codes.ERR_UNKNOWN_FILE_EXTENSION = createError(
14641
14622
  * @param {string} extension
14642
14623
  * @param {string} path
14643
14624
  */
14644
- (extension, path81) => {
14645
- return `Unknown file extension "${extension}" for ${path81}`;
14625
+ (extension, path82) => {
14626
+ return `Unknown file extension "${extension}" for ${path82}`;
14646
14627
  },
14647
14628
  TypeError
14648
14629
  );
@@ -15013,9 +14994,9 @@ Default "index" lookups for the main are deprecated for ES modules.`,
15013
14994
  );
15014
14995
  }
15015
14996
  }
15016
- function tryStatSync(path81) {
14997
+ function tryStatSync(path82) {
15017
14998
  try {
15018
- return statSync(path81);
14999
+ return statSync(path82);
15019
15000
  } catch {
15020
15001
  }
15021
15002
  }
@@ -15934,7 +15915,7 @@ function findUpSync(name, {
15934
15915
  directory = path23.dirname(directory);
15935
15916
  }
15936
15917
  }
15937
- function _resolve2(path81, options = {}) {
15918
+ function _resolve2(path82, options = {}) {
15938
15919
  if (options.platform === "auto" || !options.platform)
15939
15920
  options.platform = process3.platform === "win32" ? "win32" : "posix";
15940
15921
  if (process3.versions.pnp) {
@@ -15943,11 +15924,11 @@ function _resolve2(path81, options = {}) {
15943
15924
  paths.push(process3.cwd());
15944
15925
  const targetRequire = createRequire5(import.meta.url);
15945
15926
  try {
15946
- return targetRequire.resolve(path81, { paths });
15927
+ return targetRequire.resolve(path82, { paths });
15947
15928
  } catch {
15948
15929
  }
15949
15930
  }
15950
- const modulePath = resolvePathSync(path81, {
15931
+ const modulePath = resolvePathSync(path82, {
15951
15932
  url: options.paths
15952
15933
  });
15953
15934
  if (options.platform === "win32")
@@ -16018,10 +15999,10 @@ var findUp = quansync2({
16018
15999
  async: findUp$1
16019
16000
  });
16020
16001
  var loadPackageJSON = quansync2(function* (cwd = process3.cwd()) {
16021
- const path81 = yield findUp("package.json", { cwd });
16022
- if (!path81 || !fs13.existsSync(path81))
16002
+ const path82 = yield findUp("package.json", { cwd });
16003
+ if (!path82 || !fs13.existsSync(path82))
16023
16004
  return null;
16024
- return JSON.parse(yield readFile(path81));
16005
+ return JSON.parse(yield readFile(path82));
16025
16006
  });
16026
16007
  var loadPackageJSONSync = loadPackageJSON.sync;
16027
16008
  var isPackageListed = quansync2(function* (name, cwd) {
@@ -21380,44 +21361,44 @@ var optArgSync = (opt = {}) => optArgT(opt);
21380
21361
  init_esm_shims();
21381
21362
  import { parse as parse4, resolve } from "path";
21382
21363
  import { inspect as inspect2 } from "util";
21383
- var pathArg = (path81, opt = {}) => {
21384
- const type = typeof path81;
21364
+ var pathArg = (path82, opt = {}) => {
21365
+ const type = typeof path82;
21385
21366
  if (type !== "string") {
21386
- const ctor = path81 && type === "object" && path81.constructor;
21387
- const received = ctor && ctor.name ? `an instance of ${ctor.name}` : type === "object" ? inspect2(path81) : `type ${type} ${path81}`;
21367
+ const ctor = path82 && type === "object" && path82.constructor;
21368
+ const received = ctor && ctor.name ? `an instance of ${ctor.name}` : type === "object" ? inspect2(path82) : `type ${type} ${path82}`;
21388
21369
  const msg = `The "path" argument must be of type string. Received ${received}`;
21389
21370
  throw Object.assign(new TypeError(msg), {
21390
- path: path81,
21371
+ path: path82,
21391
21372
  code: "ERR_INVALID_ARG_TYPE"
21392
21373
  });
21393
21374
  }
21394
- if (/\0/.test(path81)) {
21375
+ if (/\0/.test(path82)) {
21395
21376
  const msg = "path must be a string without null bytes";
21396
21377
  throw Object.assign(new TypeError(msg), {
21397
- path: path81,
21378
+ path: path82,
21398
21379
  code: "ERR_INVALID_ARG_VALUE"
21399
21380
  });
21400
21381
  }
21401
- path81 = resolve(path81);
21402
- const { root } = parse4(path81);
21403
- if (path81 === root && opt.preserveRoot !== false) {
21382
+ path82 = resolve(path82);
21383
+ const { root } = parse4(path82);
21384
+ if (path82 === root && opt.preserveRoot !== false) {
21404
21385
  const msg = "refusing to remove root directory without preserveRoot:false";
21405
21386
  throw Object.assign(new Error(msg), {
21406
- path: path81,
21387
+ path: path82,
21407
21388
  code: "ERR_PRESERVE_ROOT"
21408
21389
  });
21409
21390
  }
21410
21391
  if (process.platform === "win32") {
21411
21392
  const badWinChars = /[*|"<>?:]/;
21412
- const { root: root2 } = parse4(path81);
21413
- if (badWinChars.test(path81.substring(root2.length))) {
21393
+ const { root: root2 } = parse4(path82);
21394
+ if (badWinChars.test(path82.substring(root2.length))) {
21414
21395
  throw Object.assign(new Error("Illegal characters in path."), {
21415
- path: path81,
21396
+ path: path82,
21416
21397
  code: "EINVAL"
21417
21398
  });
21418
21399
  }
21419
21400
  }
21420
- return path81;
21401
+ return path82;
21421
21402
  };
21422
21403
  var path_arg_default = pathArg;
21423
21404
 
@@ -21432,11 +21413,11 @@ init_esm_shims();
21432
21413
  import { readdirSync as rdSync } from "fs";
21433
21414
  import fsPromises2 from "fs/promises";
21434
21415
  import { chmodSync, mkdirSync, renameSync, rmdirSync, rmSync, statSync as statSync2, lstatSync, unlinkSync } from "fs";
21435
- var readdirSync = (path81) => rdSync(path81, { withFileTypes: true });
21416
+ var readdirSync = (path82) => rdSync(path82, { withFileTypes: true });
21436
21417
  var promises2 = {
21437
21418
  chmod: fsPromises2.chmod,
21438
21419
  mkdir: fsPromises2.mkdir,
21439
- readdir: (path81) => fsPromises2.readdir(path81, { withFileTypes: true }),
21420
+ readdir: (path82) => fsPromises2.readdir(path82, { withFileTypes: true }),
21440
21421
  rename: fsPromises2.rename,
21441
21422
  rm: fsPromises2.rm,
21442
21423
  rmdir: fsPromises2.rmdir,
@@ -21451,10 +21432,10 @@ import { parse as parse5, resolve as resolve2 } from "path";
21451
21432
  // ../../node_modules/.pnpm/rimraf@6.1.3/node_modules/rimraf/dist/esm/readdir-or-error.js
21452
21433
  init_esm_shims();
21453
21434
  var { readdir } = promises2;
21454
- var readdirOrError = (path81) => readdir(path81).catch((er) => er);
21455
- var readdirOrErrorSync = (path81) => {
21435
+ var readdirOrError = (path82) => readdir(path82).catch((er) => er);
21436
+ var readdirOrErrorSync = (path82) => {
21456
21437
  try {
21457
- return readdirSync(path81);
21438
+ return readdirSync(path82);
21458
21439
  } catch (er) {
21459
21440
  return er;
21460
21441
  }
@@ -21490,17 +21471,17 @@ var ignoreENOENTSync = (fn, rethrow) => {
21490
21471
 
21491
21472
  // ../../node_modules/.pnpm/rimraf@6.1.3/node_modules/rimraf/dist/esm/rimraf-posix.js
21492
21473
  var { lstat, rmdir, unlink } = promises2;
21493
- var rimrafPosix = async (path81, opt) => {
21474
+ var rimrafPosix = async (path82, opt) => {
21494
21475
  opt?.signal?.throwIfAborted();
21495
- return await ignoreENOENT(lstat(path81).then((stat5) => rimrafPosixDir(path81, opt, stat5))) ?? true;
21476
+ return await ignoreENOENT(lstat(path82).then((stat5) => rimrafPosixDir(path82, opt, stat5))) ?? true;
21496
21477
  };
21497
- var rimrafPosixSync = (path81, opt) => {
21478
+ var rimrafPosixSync = (path82, opt) => {
21498
21479
  opt?.signal?.throwIfAborted();
21499
- return ignoreENOENTSync(() => rimrafPosixDirSync(path81, opt, lstatSync(path81))) ?? true;
21480
+ return ignoreENOENTSync(() => rimrafPosixDirSync(path82, opt, lstatSync(path82))) ?? true;
21500
21481
  };
21501
- var rimrafPosixDir = async (path81, opt, ent) => {
21482
+ var rimrafPosixDir = async (path82, opt, ent) => {
21502
21483
  opt?.signal?.throwIfAborted();
21503
- const entries = ent.isDirectory() ? await readdirOrError(path81) : null;
21484
+ const entries = ent.isDirectory() ? await readdirOrError(path82) : null;
21504
21485
  if (!Array.isArray(entries)) {
21505
21486
  if (entries) {
21506
21487
  if (errorCode(entries) === "ENOENT") {
@@ -21510,28 +21491,28 @@ var rimrafPosixDir = async (path81, opt, ent) => {
21510
21491
  throw entries;
21511
21492
  }
21512
21493
  }
21513
- if (opt.filter && !await opt.filter(path81, ent)) {
21494
+ if (opt.filter && !await opt.filter(path82, ent)) {
21514
21495
  return false;
21515
21496
  }
21516
- await ignoreENOENT(unlink(path81));
21497
+ await ignoreENOENT(unlink(path82));
21517
21498
  return true;
21518
21499
  }
21519
- const removedAll = (await Promise.all(entries.map((ent2) => rimrafPosixDir(resolve2(path81, ent2.name), opt, ent2)))).every((v2) => v2 === true);
21500
+ const removedAll = (await Promise.all(entries.map((ent2) => rimrafPosixDir(resolve2(path82, ent2.name), opt, ent2)))).every((v2) => v2 === true);
21520
21501
  if (!removedAll) {
21521
21502
  return false;
21522
21503
  }
21523
- if (opt.preserveRoot === false && path81 === parse5(path81).root) {
21504
+ if (opt.preserveRoot === false && path82 === parse5(path82).root) {
21524
21505
  return false;
21525
21506
  }
21526
- if (opt.filter && !await opt.filter(path81, ent)) {
21507
+ if (opt.filter && !await opt.filter(path82, ent)) {
21527
21508
  return false;
21528
21509
  }
21529
- await ignoreENOENT(rmdir(path81));
21510
+ await ignoreENOENT(rmdir(path82));
21530
21511
  return true;
21531
21512
  };
21532
- var rimrafPosixDirSync = (path81, opt, ent) => {
21513
+ var rimrafPosixDirSync = (path82, opt, ent) => {
21533
21514
  opt?.signal?.throwIfAborted();
21534
- const entries = ent.isDirectory() ? readdirOrErrorSync(path81) : null;
21515
+ const entries = ent.isDirectory() ? readdirOrErrorSync(path82) : null;
21535
21516
  if (!Array.isArray(entries)) {
21536
21517
  if (entries) {
21537
21518
  if (errorCode(entries) === "ENOENT") {
@@ -21541,27 +21522,27 @@ var rimrafPosixDirSync = (path81, opt, ent) => {
21541
21522
  throw entries;
21542
21523
  }
21543
21524
  }
21544
- if (opt.filter && !opt.filter(path81, ent)) {
21525
+ if (opt.filter && !opt.filter(path82, ent)) {
21545
21526
  return false;
21546
21527
  }
21547
- ignoreENOENTSync(() => unlinkSync(path81));
21528
+ ignoreENOENTSync(() => unlinkSync(path82));
21548
21529
  return true;
21549
21530
  }
21550
21531
  let removedAll = true;
21551
21532
  for (const ent2 of entries) {
21552
- const p = resolve2(path81, ent2.name);
21533
+ const p = resolve2(path82, ent2.name);
21553
21534
  removedAll = rimrafPosixDirSync(p, opt, ent2) && removedAll;
21554
21535
  }
21555
- if (opt.preserveRoot === false && path81 === parse5(path81).root) {
21536
+ if (opt.preserveRoot === false && path82 === parse5(path82).root) {
21556
21537
  return false;
21557
21538
  }
21558
21539
  if (!removedAll) {
21559
21540
  return false;
21560
21541
  }
21561
- if (opt.filter && !opt.filter(path81, ent)) {
21542
+ if (opt.filter && !opt.filter(path82, ent)) {
21562
21543
  return false;
21563
21544
  }
21564
- ignoreENOENTSync(() => rmdirSync(path81));
21545
+ ignoreENOENTSync(() => rmdirSync(path82));
21565
21546
  return true;
21566
21547
  };
21567
21548
 
@@ -21572,28 +21553,28 @@ import { parse as parse8, resolve as resolve5 } from "path";
21572
21553
  // ../../node_modules/.pnpm/rimraf@6.1.3/node_modules/rimraf/dist/esm/fix-eperm.js
21573
21554
  init_esm_shims();
21574
21555
  var { chmod } = promises2;
21575
- var fixEPERM = (fn) => async (path81) => {
21556
+ var fixEPERM = (fn) => async (path82) => {
21576
21557
  try {
21577
- return void await ignoreENOENT(fn(path81));
21558
+ return void await ignoreENOENT(fn(path82));
21578
21559
  } catch (er) {
21579
21560
  if (errorCode(er) === "EPERM") {
21580
- if (!await ignoreENOENT(chmod(path81, 438).then(() => true), er)) {
21561
+ if (!await ignoreENOENT(chmod(path82, 438).then(() => true), er)) {
21581
21562
  return;
21582
21563
  }
21583
- return void await fn(path81);
21564
+ return void await fn(path82);
21584
21565
  }
21585
21566
  throw er;
21586
21567
  }
21587
21568
  };
21588
- var fixEPERMSync = (fn) => (path81) => {
21569
+ var fixEPERMSync = (fn) => (path82) => {
21589
21570
  try {
21590
- return void ignoreENOENTSync(() => fn(path81));
21571
+ return void ignoreENOENTSync(() => fn(path82));
21591
21572
  } catch (er) {
21592
21573
  if (errorCode(er) === "EPERM") {
21593
- if (!ignoreENOENTSync(() => (chmodSync(path81, 438), true), er)) {
21574
+ if (!ignoreENOENTSync(() => (chmodSync(path82, 438), true), er)) {
21594
21575
  return;
21595
21576
  }
21596
- return void fn(path81);
21577
+ return void fn(path82);
21597
21578
  }
21598
21579
  throw er;
21599
21580
  }
@@ -21607,21 +21588,21 @@ var RATE = 1.2;
21607
21588
  var MAXRETRIES = 10;
21608
21589
  var codes2 = /* @__PURE__ */ new Set(["EMFILE", "ENFILE", "EBUSY"]);
21609
21590
  var retryBusy = (fn) => {
21610
- const method = async (path81, opt, backoff = 1, total = 0) => {
21591
+ const method = async (path82, opt, backoff = 1, total = 0) => {
21611
21592
  const mbo = opt.maxBackoff || MAXBACKOFF;
21612
21593
  const rate = opt.backoff || RATE;
21613
21594
  const max = opt.maxRetries || MAXRETRIES;
21614
21595
  let retries = 0;
21615
21596
  while (true) {
21616
21597
  try {
21617
- return await fn(path81);
21598
+ return await fn(path82);
21618
21599
  } catch (er) {
21619
- if (isFsError(er) && er.path === path81 && codes2.has(er.code)) {
21600
+ if (isFsError(er) && er.path === path82 && codes2.has(er.code)) {
21620
21601
  backoff = Math.ceil(backoff * rate);
21621
21602
  total = backoff + total;
21622
21603
  if (total < mbo) {
21623
21604
  await setTimeout2(backoff);
21624
- return method(path81, opt, backoff, total);
21605
+ return method(path82, opt, backoff, total);
21625
21606
  }
21626
21607
  if (retries < max) {
21627
21608
  retries++;
@@ -21635,14 +21616,14 @@ var retryBusy = (fn) => {
21635
21616
  return method;
21636
21617
  };
21637
21618
  var retryBusySync = (fn) => {
21638
- const method = (path81, opt) => {
21619
+ const method = (path82, opt) => {
21639
21620
  const max = opt.maxRetries || MAXRETRIES;
21640
21621
  let retries = 0;
21641
21622
  while (true) {
21642
21623
  try {
21643
- return fn(path81);
21624
+ return fn(path82);
21644
21625
  } catch (er) {
21645
- if (isFsError(er) && er.path === path81 && codes2.has(er.code) && retries < max) {
21626
+ if (isFsError(er) && er.path === path82 && codes2.has(er.code) && retries < max) {
21646
21627
  retries++;
21647
21628
  continue;
21648
21629
  }
@@ -21662,16 +21643,16 @@ init_esm_shims();
21662
21643
  import { tmpdir } from "os";
21663
21644
  import { parse as parse6, resolve as resolve3 } from "path";
21664
21645
  var { stat } = promises2;
21665
- var isDirSync = (path81) => {
21646
+ var isDirSync = (path82) => {
21666
21647
  try {
21667
- return statSync2(path81).isDirectory();
21648
+ return statSync2(path82).isDirectory();
21668
21649
  } catch {
21669
21650
  return false;
21670
21651
  }
21671
21652
  };
21672
- var isDir = (path81) => stat(path81).then((st2) => st2.isDirectory(), () => false);
21673
- var win32DefaultTmp = async (path81) => {
21674
- const { root } = parse6(path81);
21653
+ var isDir = (path82) => stat(path82).then((st2) => st2.isDirectory(), () => false);
21654
+ var win32DefaultTmp = async (path82) => {
21655
+ const { root } = parse6(path82);
21675
21656
  const tmp = tmpdir();
21676
21657
  const { root: tmpRoot } = parse6(tmp);
21677
21658
  if (root.toLowerCase() === tmpRoot.toLowerCase()) {
@@ -21683,8 +21664,8 @@ var win32DefaultTmp = async (path81) => {
21683
21664
  }
21684
21665
  return root;
21685
21666
  };
21686
- var win32DefaultTmpSync = (path81) => {
21687
- const { root } = parse6(path81);
21667
+ var win32DefaultTmpSync = (path82) => {
21668
+ const { root } = parse6(path82);
21688
21669
  const tmp = tmpdir();
21689
21670
  const { root: tmpRoot } = parse6(tmp);
21690
21671
  if (root.toLowerCase() === tmpRoot.toLowerCase()) {
@@ -21703,22 +21684,22 @@ var defaultTmpSync = process.platform === "win32" ? win32DefaultTmpSync : posixD
21703
21684
 
21704
21685
  // ../../node_modules/.pnpm/rimraf@6.1.3/node_modules/rimraf/dist/esm/rimraf-move-remove.js
21705
21686
  var { lstat: lstat2, rename, unlink: unlink2, rmdir: rmdir2 } = promises2;
21706
- var uniqueFilename = (path81) => `.${basename(path81)}.${Math.random()}`;
21687
+ var uniqueFilename = (path82) => `.${basename(path82)}.${Math.random()}`;
21707
21688
  var unlinkFixEPERM = fixEPERM(unlink2);
21708
21689
  var unlinkFixEPERMSync = fixEPERMSync(unlinkSync);
21709
- var rimrafMoveRemove = async (path81, opt) => {
21690
+ var rimrafMoveRemove = async (path82, opt) => {
21710
21691
  opt?.signal?.throwIfAborted();
21711
- return await ignoreENOENT(lstat2(path81).then((stat5) => rimrafMoveRemoveDir(path81, opt, stat5))) ?? true;
21692
+ return await ignoreENOENT(lstat2(path82).then((stat5) => rimrafMoveRemoveDir(path82, opt, stat5))) ?? true;
21712
21693
  };
21713
- var rimrafMoveRemoveDir = async (path81, opt, ent) => {
21694
+ var rimrafMoveRemoveDir = async (path82, opt, ent) => {
21714
21695
  opt?.signal?.throwIfAborted();
21715
21696
  if (!opt.tmp) {
21716
- return rimrafMoveRemoveDir(path81, { ...opt, tmp: await defaultTmp(path81) }, ent);
21697
+ return rimrafMoveRemoveDir(path82, { ...opt, tmp: await defaultTmp(path82) }, ent);
21717
21698
  }
21718
- if (path81 === opt.tmp && parse7(path81).root !== path81) {
21699
+ if (path82 === opt.tmp && parse7(path82).root !== path82) {
21719
21700
  throw new Error("cannot delete temp directory used for deletion");
21720
21701
  }
21721
- const entries = ent.isDirectory() ? await readdirOrError(path81) : null;
21702
+ const entries = ent.isDirectory() ? await readdirOrError(path82) : null;
21722
21703
  if (!Array.isArray(entries)) {
21723
21704
  if (entries) {
21724
21705
  if (errorCode(entries) === "ENOENT") {
@@ -21728,44 +21709,44 @@ var rimrafMoveRemoveDir = async (path81, opt, ent) => {
21728
21709
  throw entries;
21729
21710
  }
21730
21711
  }
21731
- if (opt.filter && !await opt.filter(path81, ent)) {
21712
+ if (opt.filter && !await opt.filter(path82, ent)) {
21732
21713
  return false;
21733
21714
  }
21734
- await ignoreENOENT(tmpUnlink(path81, opt.tmp, unlinkFixEPERM));
21715
+ await ignoreENOENT(tmpUnlink(path82, opt.tmp, unlinkFixEPERM));
21735
21716
  return true;
21736
21717
  }
21737
- const removedAll = (await Promise.all(entries.map((ent2) => rimrafMoveRemoveDir(resolve4(path81, ent2.name), opt, ent2)))).every((v2) => v2 === true);
21718
+ const removedAll = (await Promise.all(entries.map((ent2) => rimrafMoveRemoveDir(resolve4(path82, ent2.name), opt, ent2)))).every((v2) => v2 === true);
21738
21719
  if (!removedAll) {
21739
21720
  return false;
21740
21721
  }
21741
- if (opt.preserveRoot === false && path81 === parse7(path81).root) {
21722
+ if (opt.preserveRoot === false && path82 === parse7(path82).root) {
21742
21723
  return false;
21743
21724
  }
21744
- if (opt.filter && !await opt.filter(path81, ent)) {
21725
+ if (opt.filter && !await opt.filter(path82, ent)) {
21745
21726
  return false;
21746
21727
  }
21747
- await ignoreENOENT(tmpUnlink(path81, opt.tmp, rmdir2));
21728
+ await ignoreENOENT(tmpUnlink(path82, opt.tmp, rmdir2));
21748
21729
  return true;
21749
21730
  };
21750
- var tmpUnlink = async (path81, tmp, rm2) => {
21751
- const tmpFile = resolve4(tmp, uniqueFilename(path81));
21752
- await rename(path81, tmpFile);
21731
+ var tmpUnlink = async (path82, tmp, rm2) => {
21732
+ const tmpFile = resolve4(tmp, uniqueFilename(path82));
21733
+ await rename(path82, tmpFile);
21753
21734
  return await rm2(tmpFile);
21754
21735
  };
21755
- var rimrafMoveRemoveSync = (path81, opt) => {
21736
+ var rimrafMoveRemoveSync = (path82, opt) => {
21756
21737
  opt?.signal?.throwIfAborted();
21757
- return ignoreENOENTSync(() => rimrafMoveRemoveDirSync(path81, opt, lstatSync(path81))) ?? true;
21738
+ return ignoreENOENTSync(() => rimrafMoveRemoveDirSync(path82, opt, lstatSync(path82))) ?? true;
21758
21739
  };
21759
- var rimrafMoveRemoveDirSync = (path81, opt, ent) => {
21740
+ var rimrafMoveRemoveDirSync = (path82, opt, ent) => {
21760
21741
  opt?.signal?.throwIfAborted();
21761
21742
  if (!opt.tmp) {
21762
- return rimrafMoveRemoveDirSync(path81, { ...opt, tmp: defaultTmpSync(path81) }, ent);
21743
+ return rimrafMoveRemoveDirSync(path82, { ...opt, tmp: defaultTmpSync(path82) }, ent);
21763
21744
  }
21764
21745
  const tmp = opt.tmp;
21765
- if (path81 === opt.tmp && parse7(path81).root !== path81) {
21746
+ if (path82 === opt.tmp && parse7(path82).root !== path82) {
21766
21747
  throw new Error("cannot delete temp directory used for deletion");
21767
21748
  }
21768
- const entries = ent.isDirectory() ? readdirOrErrorSync(path81) : null;
21749
+ const entries = ent.isDirectory() ? readdirOrErrorSync(path82) : null;
21769
21750
  if (!Array.isArray(entries)) {
21770
21751
  if (entries) {
21771
21752
  if (errorCode(entries) === "ENOENT") {
@@ -21775,32 +21756,32 @@ var rimrafMoveRemoveDirSync = (path81, opt, ent) => {
21775
21756
  throw entries;
21776
21757
  }
21777
21758
  }
21778
- if (opt.filter && !opt.filter(path81, ent)) {
21759
+ if (opt.filter && !opt.filter(path82, ent)) {
21779
21760
  return false;
21780
21761
  }
21781
- ignoreENOENTSync(() => tmpUnlinkSync(path81, tmp, unlinkFixEPERMSync));
21762
+ ignoreENOENTSync(() => tmpUnlinkSync(path82, tmp, unlinkFixEPERMSync));
21782
21763
  return true;
21783
21764
  }
21784
21765
  let removedAll = true;
21785
21766
  for (const ent2 of entries) {
21786
- const p = resolve4(path81, ent2.name);
21767
+ const p = resolve4(path82, ent2.name);
21787
21768
  removedAll = rimrafMoveRemoveDirSync(p, opt, ent2) && removedAll;
21788
21769
  }
21789
21770
  if (!removedAll) {
21790
21771
  return false;
21791
21772
  }
21792
- if (opt.preserveRoot === false && path81 === parse7(path81).root) {
21773
+ if (opt.preserveRoot === false && path82 === parse7(path82).root) {
21793
21774
  return false;
21794
21775
  }
21795
- if (opt.filter && !opt.filter(path81, ent)) {
21776
+ if (opt.filter && !opt.filter(path82, ent)) {
21796
21777
  return false;
21797
21778
  }
21798
- ignoreENOENTSync(() => tmpUnlinkSync(path81, tmp, rmdirSync));
21779
+ ignoreENOENTSync(() => tmpUnlinkSync(path82, tmp, rmdirSync));
21799
21780
  return true;
21800
21781
  };
21801
- var tmpUnlinkSync = (path81, tmp, rmSync2) => {
21802
- const tmpFile = resolve4(tmp, uniqueFilename(path81));
21803
- renameSync(path81, tmpFile);
21782
+ var tmpUnlinkSync = (path82, tmp, rmSync2) => {
21783
+ const tmpFile = resolve4(tmp, uniqueFilename(path82));
21784
+ renameSync(path82, tmpFile);
21804
21785
  return rmSync2(tmpFile);
21805
21786
  };
21806
21787
 
@@ -21810,26 +21791,26 @@ var rimrafWindowsFile = retryBusy(fixEPERM(unlink3));
21810
21791
  var rimrafWindowsFileSync = retryBusySync(fixEPERMSync(unlinkSync));
21811
21792
  var rimrafWindowsDirRetry = retryBusy(fixEPERM(rmdir3));
21812
21793
  var rimrafWindowsDirRetrySync = retryBusySync(fixEPERMSync(rmdirSync));
21813
- var rimrafWindowsDirMoveRemoveFallback = async (path81, { filter: filter2, ...opt }) => {
21794
+ var rimrafWindowsDirMoveRemoveFallback = async (path82, { filter: filter2, ...opt }) => {
21814
21795
  opt?.signal?.throwIfAborted();
21815
21796
  try {
21816
- await rimrafWindowsDirRetry(path81, opt);
21797
+ await rimrafWindowsDirRetry(path82, opt);
21817
21798
  return true;
21818
21799
  } catch (er) {
21819
21800
  if (errorCode(er) === "ENOTEMPTY") {
21820
- return rimrafMoveRemove(path81, opt);
21801
+ return rimrafMoveRemove(path82, opt);
21821
21802
  }
21822
21803
  throw er;
21823
21804
  }
21824
21805
  };
21825
- var rimrafWindowsDirMoveRemoveFallbackSync = (path81, { filter: filter2, ...opt }) => {
21806
+ var rimrafWindowsDirMoveRemoveFallbackSync = (path82, { filter: filter2, ...opt }) => {
21826
21807
  opt?.signal?.throwIfAborted();
21827
21808
  try {
21828
- rimrafWindowsDirRetrySync(path81, opt);
21809
+ rimrafWindowsDirRetrySync(path82, opt);
21829
21810
  return true;
21830
21811
  } catch (er) {
21831
21812
  if (errorCode(er) === "ENOTEMPTY") {
21832
- return rimrafMoveRemoveSync(path81, opt);
21813
+ return rimrafMoveRemoveSync(path82, opt);
21833
21814
  }
21834
21815
  throw er;
21835
21816
  }
@@ -21837,17 +21818,17 @@ var rimrafWindowsDirMoveRemoveFallbackSync = (path81, { filter: filter2, ...opt
21837
21818
  var START = /* @__PURE__ */ Symbol("start");
21838
21819
  var CHILD = /* @__PURE__ */ Symbol("child");
21839
21820
  var FINISH = /* @__PURE__ */ Symbol("finish");
21840
- var rimrafWindows = async (path81, opt) => {
21821
+ var rimrafWindows = async (path82, opt) => {
21841
21822
  opt?.signal?.throwIfAborted();
21842
- return await ignoreENOENT(lstat3(path81).then((stat5) => rimrafWindowsDir(path81, opt, stat5, START))) ?? true;
21823
+ return await ignoreENOENT(lstat3(path82).then((stat5) => rimrafWindowsDir(path82, opt, stat5, START))) ?? true;
21843
21824
  };
21844
- var rimrafWindowsSync = (path81, opt) => {
21825
+ var rimrafWindowsSync = (path82, opt) => {
21845
21826
  opt?.signal?.throwIfAborted();
21846
- return ignoreENOENTSync(() => rimrafWindowsDirSync(path81, opt, lstatSync(path81), START)) ?? true;
21827
+ return ignoreENOENTSync(() => rimrafWindowsDirSync(path82, opt, lstatSync(path82), START)) ?? true;
21847
21828
  };
21848
- var rimrafWindowsDir = async (path81, opt, ent, state = START) => {
21829
+ var rimrafWindowsDir = async (path82, opt, ent, state = START) => {
21849
21830
  opt?.signal?.throwIfAborted();
21850
- const entries = ent.isDirectory() ? await readdirOrError(path81) : null;
21831
+ const entries = ent.isDirectory() ? await readdirOrError(path82) : null;
21851
21832
  if (!Array.isArray(entries)) {
21852
21833
  if (entries) {
21853
21834
  if (errorCode(entries) === "ENOENT") {
@@ -21857,32 +21838,32 @@ var rimrafWindowsDir = async (path81, opt, ent, state = START) => {
21857
21838
  throw entries;
21858
21839
  }
21859
21840
  }
21860
- if (opt.filter && !await opt.filter(path81, ent)) {
21841
+ if (opt.filter && !await opt.filter(path82, ent)) {
21861
21842
  return false;
21862
21843
  }
21863
- await ignoreENOENT(rimrafWindowsFile(path81, opt));
21844
+ await ignoreENOENT(rimrafWindowsFile(path82, opt));
21864
21845
  return true;
21865
21846
  }
21866
21847
  const s = state === START ? CHILD : state;
21867
- const removedAll = (await Promise.all(entries.map((ent2) => rimrafWindowsDir(resolve5(path81, ent2.name), opt, ent2, s)))).every((v2) => v2 === true);
21848
+ const removedAll = (await Promise.all(entries.map((ent2) => rimrafWindowsDir(resolve5(path82, ent2.name), opt, ent2, s)))).every((v2) => v2 === true);
21868
21849
  if (state === START) {
21869
- return rimrafWindowsDir(path81, opt, ent, FINISH);
21850
+ return rimrafWindowsDir(path82, opt, ent, FINISH);
21870
21851
  } else if (state === FINISH) {
21871
- if (opt.preserveRoot === false && path81 === parse8(path81).root) {
21852
+ if (opt.preserveRoot === false && path82 === parse8(path82).root) {
21872
21853
  return false;
21873
21854
  }
21874
21855
  if (!removedAll) {
21875
21856
  return false;
21876
21857
  }
21877
- if (opt.filter && !await opt.filter(path81, ent)) {
21858
+ if (opt.filter && !await opt.filter(path82, ent)) {
21878
21859
  return false;
21879
21860
  }
21880
- await ignoreENOENT(rimrafWindowsDirMoveRemoveFallback(path81, opt));
21861
+ await ignoreENOENT(rimrafWindowsDirMoveRemoveFallback(path82, opt));
21881
21862
  }
21882
21863
  return true;
21883
21864
  };
21884
- var rimrafWindowsDirSync = (path81, opt, ent, state = START) => {
21885
- const entries = ent.isDirectory() ? readdirOrErrorSync(path81) : null;
21865
+ var rimrafWindowsDirSync = (path82, opt, ent, state = START) => {
21866
+ const entries = ent.isDirectory() ? readdirOrErrorSync(path82) : null;
21886
21867
  if (!Array.isArray(entries)) {
21887
21868
  if (entries) {
21888
21869
  if (errorCode(entries) === "ENOENT") {
@@ -21892,31 +21873,31 @@ var rimrafWindowsDirSync = (path81, opt, ent, state = START) => {
21892
21873
  throw entries;
21893
21874
  }
21894
21875
  }
21895
- if (opt.filter && !opt.filter(path81, ent)) {
21876
+ if (opt.filter && !opt.filter(path82, ent)) {
21896
21877
  return false;
21897
21878
  }
21898
- ignoreENOENTSync(() => rimrafWindowsFileSync(path81, opt));
21879
+ ignoreENOENTSync(() => rimrafWindowsFileSync(path82, opt));
21899
21880
  return true;
21900
21881
  }
21901
21882
  let removedAll = true;
21902
21883
  for (const ent2 of entries) {
21903
21884
  const s = state === START ? CHILD : state;
21904
- const p = resolve5(path81, ent2.name);
21885
+ const p = resolve5(path82, ent2.name);
21905
21886
  removedAll = rimrafWindowsDirSync(p, opt, ent2, s) && removedAll;
21906
21887
  }
21907
21888
  if (state === START) {
21908
- return rimrafWindowsDirSync(path81, opt, ent, FINISH);
21889
+ return rimrafWindowsDirSync(path82, opt, ent, FINISH);
21909
21890
  } else if (state === FINISH) {
21910
- if (opt.preserveRoot === false && path81 === parse8(path81).root) {
21891
+ if (opt.preserveRoot === false && path82 === parse8(path82).root) {
21911
21892
  return false;
21912
21893
  }
21913
21894
  if (!removedAll) {
21914
21895
  return false;
21915
21896
  }
21916
- if (opt.filter && !opt.filter(path81, ent)) {
21897
+ if (opt.filter && !opt.filter(path82, ent)) {
21917
21898
  return false;
21918
21899
  }
21919
- ignoreENOENTSync(() => rimrafWindowsDirMoveRemoveFallbackSync(path81, opt));
21900
+ ignoreENOENTSync(() => rimrafWindowsDirMoveRemoveFallbackSync(path82, opt));
21920
21901
  }
21921
21902
  return true;
21922
21903
  };
@@ -21928,16 +21909,16 @@ var rimrafManualSync = process.platform === "win32" ? rimrafWindowsSync : rimraf
21928
21909
  // ../../node_modules/.pnpm/rimraf@6.1.3/node_modules/rimraf/dist/esm/rimraf-native.js
21929
21910
  init_esm_shims();
21930
21911
  var { rm } = promises2;
21931
- var rimrafNative = async (path81, opt) => {
21932
- await rm(path81, {
21912
+ var rimrafNative = async (path82, opt) => {
21913
+ await rm(path82, {
21933
21914
  ...opt,
21934
21915
  force: true,
21935
21916
  recursive: true
21936
21917
  });
21937
21918
  return true;
21938
21919
  };
21939
- var rimrafNativeSync = (path81, opt) => {
21940
- rmSync(path81, {
21920
+ var rimrafNativeSync = (path82, opt) => {
21921
+ rmSync(path82, {
21941
21922
  ...opt,
21942
21923
  force: true,
21943
21924
  recursive: true
@@ -21953,26 +21934,26 @@ var useNative = !hasNative || process.platform === "win32" ? () => false : (opt)
21953
21934
  var useNativeSync = !hasNative || process.platform === "win32" ? () => false : (opt) => !opt?.signal && !opt?.filter;
21954
21935
 
21955
21936
  // ../../node_modules/.pnpm/rimraf@6.1.3/node_modules/rimraf/dist/esm/index.js
21956
- var wrap = (fn) => async (path81, opt) => {
21937
+ var wrap = (fn) => async (path82, opt) => {
21957
21938
  const options = optArg(opt);
21958
21939
  if (options.glob) {
21959
- path81 = await Ze(path81, options.glob);
21940
+ path82 = await Ze(path82, options.glob);
21960
21941
  }
21961
- if (Array.isArray(path81)) {
21962
- return !!(await Promise.all(path81.map((p) => fn(path_arg_default(p, options), options)))).reduce((a3, b) => a3 && b, true);
21942
+ if (Array.isArray(path82)) {
21943
+ return !!(await Promise.all(path82.map((p) => fn(path_arg_default(p, options), options)))).reduce((a3, b) => a3 && b, true);
21963
21944
  } else {
21964
- return !!await fn(path_arg_default(path81, options), options);
21945
+ return !!await fn(path_arg_default(path82, options), options);
21965
21946
  }
21966
21947
  };
21967
- var wrapSync = (fn) => (path81, opt) => {
21948
+ var wrapSync = (fn) => (path82, opt) => {
21968
21949
  const options = optArgSync(opt);
21969
21950
  if (options.glob) {
21970
- path81 = ts(path81, options.glob);
21951
+ path82 = ts(path82, options.glob);
21971
21952
  }
21972
- if (Array.isArray(path81)) {
21973
- return !!path81.map((p) => fn(path_arg_default(p, options), options)).reduce((a3, b) => a3 && b, true);
21953
+ if (Array.isArray(path82)) {
21954
+ return !!path82.map((p) => fn(path_arg_default(p, options), options)).reduce((a3, b) => a3 && b, true);
21974
21955
  } else {
21975
- return !!fn(path_arg_default(path81, options), options);
21956
+ return !!fn(path_arg_default(path82, options), options);
21976
21957
  }
21977
21958
  };
21978
21959
  var nativeSync = wrapSync(rimrafNativeSync);
@@ -21993,8 +21974,8 @@ var moveRemoveSync = wrapSync(rimrafMoveRemoveSync);
21993
21974
  var moveRemove = Object.assign(wrap(rimrafMoveRemove), {
21994
21975
  sync: moveRemoveSync
21995
21976
  });
21996
- var rimrafSync = wrapSync((path81, opt) => useNativeSync(opt) ? rimrafNativeSync(path81, opt) : rimrafManualSync(path81, opt));
21997
- var rimraf_ = wrap((path81, opt) => useNative(opt) ? rimrafNative(path81, opt) : rimrafManual(path81, opt));
21977
+ var rimrafSync = wrapSync((path82, opt) => useNativeSync(opt) ? rimrafNativeSync(path82, opt) : rimrafManualSync(path82, opt));
21978
+ var rimraf_ = wrap((path82, opt) => useNative(opt) ? rimrafNative(path82, opt) : rimrafManual(path82, opt));
21998
21979
  var rimraf = Object.assign(rimraf_, {
21999
21980
  rimraf: rimraf_,
22000
21981
  sync: rimrafSync,
@@ -22188,7 +22169,7 @@ var ReaddirpStream = class extends Readable {
22188
22169
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
22189
22170
  const statMethod = opts.lstat ? lstat4 : stat2;
22190
22171
  if (wantBigintFsStats) {
22191
- this._stat = (path81) => statMethod(path81, { bigint: true });
22172
+ this._stat = (path82) => statMethod(path82, { bigint: true });
22192
22173
  } else {
22193
22174
  this._stat = statMethod;
22194
22175
  }
@@ -22213,8 +22194,8 @@ var ReaddirpStream = class extends Readable {
22213
22194
  const par = this.parent;
22214
22195
  const fil = par && par.files;
22215
22196
  if (fil && fil.length > 0) {
22216
- const { path: path81, depth } = par;
22217
- const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path81));
22197
+ const { path: path82, depth } = par;
22198
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path82));
22218
22199
  const awaited = await Promise.all(slice);
22219
22200
  for (const entry of awaited) {
22220
22201
  if (!entry)
@@ -22254,20 +22235,20 @@ var ReaddirpStream = class extends Readable {
22254
22235
  this.reading = false;
22255
22236
  }
22256
22237
  }
22257
- async _exploreDir(path81, depth) {
22238
+ async _exploreDir(path82, depth) {
22258
22239
  let files;
22259
22240
  try {
22260
- files = await readdir2(path81, this._rdOptions);
22241
+ files = await readdir2(path82, this._rdOptions);
22261
22242
  } catch (error) {
22262
22243
  this._onError(error);
22263
22244
  }
22264
- return { files, depth, path: path81 };
22245
+ return { files, depth, path: path82 };
22265
22246
  }
22266
- async _formatEntry(dirent, path81) {
22247
+ async _formatEntry(dirent, path82) {
22267
22248
  let entry;
22268
22249
  const basename4 = this._isDirent ? dirent.name : dirent;
22269
22250
  try {
22270
- const fullPath = presolve(pjoin(path81, basename4));
22251
+ const fullPath = presolve(pjoin(path82, basename4));
22271
22252
  entry = { path: prelative(this._root, fullPath), fullPath, basename: basename4 };
22272
22253
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
22273
22254
  } catch (err) {
@@ -22668,16 +22649,16 @@ var delFromSet = (main, prop, item) => {
22668
22649
  };
22669
22650
  var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
22670
22651
  var FsWatchInstances = /* @__PURE__ */ new Map();
22671
- function createFsWatchInstance(path81, options, listener, errHandler, emitRaw) {
22652
+ function createFsWatchInstance(path82, options, listener, errHandler, emitRaw) {
22672
22653
  const handleEvent = (rawEvent, evPath) => {
22673
- listener(path81);
22674
- emitRaw(rawEvent, evPath, { watchedPath: path81 });
22675
- if (evPath && path81 !== evPath) {
22676
- fsWatchBroadcast(sp.resolve(path81, evPath), KEY_LISTENERS, sp.join(path81, evPath));
22654
+ listener(path82);
22655
+ emitRaw(rawEvent, evPath, { watchedPath: path82 });
22656
+ if (evPath && path82 !== evPath) {
22657
+ fsWatchBroadcast(sp.resolve(path82, evPath), KEY_LISTENERS, sp.join(path82, evPath));
22677
22658
  }
22678
22659
  };
22679
22660
  try {
22680
- return fs_watch(path81, {
22661
+ return fs_watch(path82, {
22681
22662
  persistent: options.persistent
22682
22663
  }, handleEvent);
22683
22664
  } catch (error) {
@@ -22693,12 +22674,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
22693
22674
  listener(val1, val2, val3);
22694
22675
  });
22695
22676
  };
22696
- var setFsWatchListener = (path81, fullPath, options, handlers) => {
22677
+ var setFsWatchListener = (path82, fullPath, options, handlers) => {
22697
22678
  const { listener, errHandler, rawEmitter } = handlers;
22698
22679
  let cont = FsWatchInstances.get(fullPath);
22699
22680
  let watcher;
22700
22681
  if (!options.persistent) {
22701
- watcher = createFsWatchInstance(path81, options, listener, errHandler, rawEmitter);
22682
+ watcher = createFsWatchInstance(path82, options, listener, errHandler, rawEmitter);
22702
22683
  if (!watcher)
22703
22684
  return;
22704
22685
  return watcher.close.bind(watcher);
@@ -22709,7 +22690,7 @@ var setFsWatchListener = (path81, fullPath, options, handlers) => {
22709
22690
  addAndConvert(cont, KEY_RAW, rawEmitter);
22710
22691
  } else {
22711
22692
  watcher = createFsWatchInstance(
22712
- path81,
22693
+ path82,
22713
22694
  options,
22714
22695
  fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
22715
22696
  errHandler,
@@ -22724,7 +22705,7 @@ var setFsWatchListener = (path81, fullPath, options, handlers) => {
22724
22705
  cont.watcherUnusable = true;
22725
22706
  if (isWindows && error.code === "EPERM") {
22726
22707
  try {
22727
- const fd = await open(path81, "r");
22708
+ const fd = await open(path82, "r");
22728
22709
  await fd.close();
22729
22710
  broadcastErr(error);
22730
22711
  } catch (err) {
@@ -22755,7 +22736,7 @@ var setFsWatchListener = (path81, fullPath, options, handlers) => {
22755
22736
  };
22756
22737
  };
22757
22738
  var FsWatchFileInstances = /* @__PURE__ */ new Map();
22758
- var setFsWatchFileListener = (path81, fullPath, options, handlers) => {
22739
+ var setFsWatchFileListener = (path82, fullPath, options, handlers) => {
22759
22740
  const { listener, rawEmitter } = handlers;
22760
22741
  let cont = FsWatchFileInstances.get(fullPath);
22761
22742
  const copts = cont && cont.options;
@@ -22777,7 +22758,7 @@ var setFsWatchFileListener = (path81, fullPath, options, handlers) => {
22777
22758
  });
22778
22759
  const currmtime = curr.mtimeMs;
22779
22760
  if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
22780
- foreach(cont.listeners, (listener2) => listener2(path81, curr));
22761
+ foreach(cont.listeners, (listener2) => listener2(path82, curr));
22781
22762
  }
22782
22763
  })
22783
22764
  };
@@ -22807,13 +22788,13 @@ var NodeFsHandler = class {
22807
22788
  * @param listener on fs change
22808
22789
  * @returns closer for the watcher instance
22809
22790
  */
22810
- _watchWithNodeFs(path81, listener) {
22791
+ _watchWithNodeFs(path82, listener) {
22811
22792
  const opts = this.fsw.options;
22812
- const directory = sp.dirname(path81);
22813
- const basename4 = sp.basename(path81);
22793
+ const directory = sp.dirname(path82);
22794
+ const basename4 = sp.basename(path82);
22814
22795
  const parent = this.fsw._getWatchedDir(directory);
22815
22796
  parent.add(basename4);
22816
- const absolutePath = sp.resolve(path81);
22797
+ const absolutePath = sp.resolve(path82);
22817
22798
  const options = {
22818
22799
  persistent: opts.persistent
22819
22800
  };
@@ -22823,12 +22804,12 @@ var NodeFsHandler = class {
22823
22804
  if (opts.usePolling) {
22824
22805
  const enableBin = opts.interval !== opts.binaryInterval;
22825
22806
  options.interval = enableBin && isBinaryPath(basename4) ? opts.binaryInterval : opts.interval;
22826
- closer = setFsWatchFileListener(path81, absolutePath, options, {
22807
+ closer = setFsWatchFileListener(path82, absolutePath, options, {
22827
22808
  listener,
22828
22809
  rawEmitter: this.fsw._emitRaw
22829
22810
  });
22830
22811
  } else {
22831
- closer = setFsWatchListener(path81, absolutePath, options, {
22812
+ closer = setFsWatchListener(path82, absolutePath, options, {
22832
22813
  listener,
22833
22814
  errHandler: this._boundHandleError,
22834
22815
  rawEmitter: this.fsw._emitRaw
@@ -22850,7 +22831,7 @@ var NodeFsHandler = class {
22850
22831
  let prevStats = stats;
22851
22832
  if (parent.has(basename4))
22852
22833
  return;
22853
- const listener = async (path81, newStats) => {
22834
+ const listener = async (path82, newStats) => {
22854
22835
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
22855
22836
  return;
22856
22837
  if (!newStats || newStats.mtimeMs === 0) {
@@ -22864,11 +22845,11 @@ var NodeFsHandler = class {
22864
22845
  this.fsw._emit(EV.CHANGE, file, newStats2);
22865
22846
  }
22866
22847
  if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
22867
- this.fsw._closeFile(path81);
22848
+ this.fsw._closeFile(path82);
22868
22849
  prevStats = newStats2;
22869
22850
  const closer2 = this._watchWithNodeFs(file, listener);
22870
22851
  if (closer2)
22871
- this.fsw._addPathCloser(path81, closer2);
22852
+ this.fsw._addPathCloser(path82, closer2);
22872
22853
  } else {
22873
22854
  prevStats = newStats2;
22874
22855
  }
@@ -22900,7 +22881,7 @@ var NodeFsHandler = class {
22900
22881
  * @param item basename of this item
22901
22882
  * @returns true if no more processing is needed for this entry.
22902
22883
  */
22903
- async _handleSymlink(entry, directory, path81, item) {
22884
+ async _handleSymlink(entry, directory, path82, item) {
22904
22885
  if (this.fsw.closed) {
22905
22886
  return;
22906
22887
  }
@@ -22910,7 +22891,7 @@ var NodeFsHandler = class {
22910
22891
  this.fsw._incrReadyCount();
22911
22892
  let linkPath;
22912
22893
  try {
22913
- linkPath = await fsrealpath(path81);
22894
+ linkPath = await fsrealpath(path82);
22914
22895
  } catch (e) {
22915
22896
  this.fsw._emitReady();
22916
22897
  return true;
@@ -22920,12 +22901,12 @@ var NodeFsHandler = class {
22920
22901
  if (dir.has(item)) {
22921
22902
  if (this.fsw._symlinkPaths.get(full) !== linkPath) {
22922
22903
  this.fsw._symlinkPaths.set(full, linkPath);
22923
- this.fsw._emit(EV.CHANGE, path81, entry.stats);
22904
+ this.fsw._emit(EV.CHANGE, path82, entry.stats);
22924
22905
  }
22925
22906
  } else {
22926
22907
  dir.add(item);
22927
22908
  this.fsw._symlinkPaths.set(full, linkPath);
22928
- this.fsw._emit(EV.ADD, path81, entry.stats);
22909
+ this.fsw._emit(EV.ADD, path82, entry.stats);
22929
22910
  }
22930
22911
  this.fsw._emitReady();
22931
22912
  return true;
@@ -22955,9 +22936,9 @@ var NodeFsHandler = class {
22955
22936
  return;
22956
22937
  }
22957
22938
  const item = entry.path;
22958
- let path81 = sp.join(directory, item);
22939
+ let path82 = sp.join(directory, item);
22959
22940
  current2.add(item);
22960
- if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path81, item)) {
22941
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path82, item)) {
22961
22942
  return;
22962
22943
  }
22963
22944
  if (this.fsw.closed) {
@@ -22966,8 +22947,8 @@ var NodeFsHandler = class {
22966
22947
  }
22967
22948
  if (item === target || !target && !previous.has(item)) {
22968
22949
  this.fsw._incrReadyCount();
22969
- path81 = sp.join(dir, sp.relative(dir, path81));
22970
- this._addToNodeFs(path81, initialAdd, wh, depth + 1);
22950
+ path82 = sp.join(dir, sp.relative(dir, path82));
22951
+ this._addToNodeFs(path82, initialAdd, wh, depth + 1);
22971
22952
  }
22972
22953
  }).on(EV.ERROR, this._boundHandleError);
22973
22954
  return new Promise((resolve8, reject) => {
@@ -23036,13 +23017,13 @@ var NodeFsHandler = class {
23036
23017
  * @param depth Child path actually targeted for watch
23037
23018
  * @param target Child path actually targeted for watch
23038
23019
  */
23039
- async _addToNodeFs(path81, initialAdd, priorWh, depth, target) {
23020
+ async _addToNodeFs(path82, initialAdd, priorWh, depth, target) {
23040
23021
  const ready = this.fsw._emitReady;
23041
- if (this.fsw._isIgnored(path81) || this.fsw.closed) {
23022
+ if (this.fsw._isIgnored(path82) || this.fsw.closed) {
23042
23023
  ready();
23043
23024
  return false;
23044
23025
  }
23045
- const wh = this.fsw._getWatchHelpers(path81);
23026
+ const wh = this.fsw._getWatchHelpers(path82);
23046
23027
  if (priorWh) {
23047
23028
  wh.filterPath = (entry) => priorWh.filterPath(entry);
23048
23029
  wh.filterDir = (entry) => priorWh.filterDir(entry);
@@ -23058,8 +23039,8 @@ var NodeFsHandler = class {
23058
23039
  const follow = this.fsw.options.followSymlinks;
23059
23040
  let closer;
23060
23041
  if (stats.isDirectory()) {
23061
- const absPath = sp.resolve(path81);
23062
- const targetPath = follow ? await fsrealpath(path81) : path81;
23042
+ const absPath = sp.resolve(path82);
23043
+ const targetPath = follow ? await fsrealpath(path82) : path82;
23063
23044
  if (this.fsw.closed)
23064
23045
  return;
23065
23046
  closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
@@ -23069,29 +23050,29 @@ var NodeFsHandler = class {
23069
23050
  this.fsw._symlinkPaths.set(absPath, targetPath);
23070
23051
  }
23071
23052
  } else if (stats.isSymbolicLink()) {
23072
- const targetPath = follow ? await fsrealpath(path81) : path81;
23053
+ const targetPath = follow ? await fsrealpath(path82) : path82;
23073
23054
  if (this.fsw.closed)
23074
23055
  return;
23075
23056
  const parent = sp.dirname(wh.watchPath);
23076
23057
  this.fsw._getWatchedDir(parent).add(wh.watchPath);
23077
23058
  this.fsw._emit(EV.ADD, wh.watchPath, stats);
23078
- closer = await this._handleDir(parent, stats, initialAdd, depth, path81, wh, targetPath);
23059
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path82, wh, targetPath);
23079
23060
  if (this.fsw.closed)
23080
23061
  return;
23081
23062
  if (targetPath !== void 0) {
23082
- this.fsw._symlinkPaths.set(sp.resolve(path81), targetPath);
23063
+ this.fsw._symlinkPaths.set(sp.resolve(path82), targetPath);
23083
23064
  }
23084
23065
  } else {
23085
23066
  closer = this._handleFile(wh.watchPath, stats, initialAdd);
23086
23067
  }
23087
23068
  ready();
23088
23069
  if (closer)
23089
- this.fsw._addPathCloser(path81, closer);
23070
+ this.fsw._addPathCloser(path82, closer);
23090
23071
  return false;
23091
23072
  } catch (error) {
23092
23073
  if (this.fsw._handleError(error)) {
23093
23074
  ready();
23094
- return path81;
23075
+ return path82;
23095
23076
  }
23096
23077
  }
23097
23078
  }
@@ -23134,24 +23115,24 @@ function createPattern(matcher) {
23134
23115
  }
23135
23116
  return () => false;
23136
23117
  }
23137
- function normalizePath3(path81) {
23138
- if (typeof path81 !== "string")
23118
+ function normalizePath3(path82) {
23119
+ if (typeof path82 !== "string")
23139
23120
  throw new Error("string expected");
23140
- path81 = sp2.normalize(path81);
23141
- path81 = path81.replace(/\\/g, "/");
23121
+ path82 = sp2.normalize(path82);
23122
+ path82 = path82.replace(/\\/g, "/");
23142
23123
  let prepend = false;
23143
- if (path81.startsWith("//"))
23124
+ if (path82.startsWith("//"))
23144
23125
  prepend = true;
23145
- path81 = path81.replace(DOUBLE_SLASH_RE, "/");
23126
+ path82 = path82.replace(DOUBLE_SLASH_RE, "/");
23146
23127
  if (prepend)
23147
- path81 = "/" + path81;
23148
- return path81;
23128
+ path82 = "/" + path82;
23129
+ return path82;
23149
23130
  }
23150
23131
  function matchPatterns(patterns, testString, stats) {
23151
- const path81 = normalizePath3(testString);
23132
+ const path82 = normalizePath3(testString);
23152
23133
  for (let index = 0; index < patterns.length; index++) {
23153
23134
  const pattern = patterns[index];
23154
- if (pattern(path81, stats)) {
23135
+ if (pattern(path82, stats)) {
23155
23136
  return true;
23156
23137
  }
23157
23138
  }
@@ -23189,19 +23170,19 @@ var toUnix = (string) => {
23189
23170
  }
23190
23171
  return str;
23191
23172
  };
23192
- var normalizePathToUnix = (path81) => toUnix(sp2.normalize(toUnix(path81)));
23193
- var normalizeIgnored = (cwd = "") => (path81) => {
23194
- if (typeof path81 === "string") {
23195
- return normalizePathToUnix(sp2.isAbsolute(path81) ? path81 : sp2.join(cwd, path81));
23173
+ var normalizePathToUnix = (path82) => toUnix(sp2.normalize(toUnix(path82)));
23174
+ var normalizeIgnored = (cwd = "") => (path82) => {
23175
+ if (typeof path82 === "string") {
23176
+ return normalizePathToUnix(sp2.isAbsolute(path82) ? path82 : sp2.join(cwd, path82));
23196
23177
  } else {
23197
- return path81;
23178
+ return path82;
23198
23179
  }
23199
23180
  };
23200
- var getAbsolutePath = (path81, cwd) => {
23201
- if (sp2.isAbsolute(path81)) {
23202
- return path81;
23181
+ var getAbsolutePath = (path82, cwd) => {
23182
+ if (sp2.isAbsolute(path82)) {
23183
+ return path82;
23203
23184
  }
23204
- return sp2.join(cwd, path81);
23185
+ return sp2.join(cwd, path82);
23205
23186
  };
23206
23187
  var EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
23207
23188
  var DirEntry = class {
@@ -23266,10 +23247,10 @@ var WatchHelper = class {
23266
23247
  dirParts;
23267
23248
  followSymlinks;
23268
23249
  statMethod;
23269
- constructor(path81, follow, fsw) {
23250
+ constructor(path82, follow, fsw) {
23270
23251
  this.fsw = fsw;
23271
- const watchPath = path81;
23272
- this.path = path81 = path81.replace(REPLACER_RE, "");
23252
+ const watchPath = path82;
23253
+ this.path = path82 = path82.replace(REPLACER_RE, "");
23273
23254
  this.watchPath = watchPath;
23274
23255
  this.fullWatchPath = sp2.resolve(watchPath);
23275
23256
  this.dirParts = [];
@@ -23409,20 +23390,20 @@ var FSWatcher = class extends EventEmitter {
23409
23390
  this._closePromise = void 0;
23410
23391
  let paths = unifyPaths(paths_);
23411
23392
  if (cwd) {
23412
- paths = paths.map((path81) => {
23413
- const absPath = getAbsolutePath(path81, cwd);
23393
+ paths = paths.map((path82) => {
23394
+ const absPath = getAbsolutePath(path82, cwd);
23414
23395
  return absPath;
23415
23396
  });
23416
23397
  }
23417
- paths.forEach((path81) => {
23418
- this._removeIgnoredPath(path81);
23398
+ paths.forEach((path82) => {
23399
+ this._removeIgnoredPath(path82);
23419
23400
  });
23420
23401
  this._userIgnored = void 0;
23421
23402
  if (!this._readyCount)
23422
23403
  this._readyCount = 0;
23423
23404
  this._readyCount += paths.length;
23424
- Promise.all(paths.map(async (path81) => {
23425
- const res = await this._nodeFsHandler._addToNodeFs(path81, !_internal, void 0, 0, _origAdd);
23405
+ Promise.all(paths.map(async (path82) => {
23406
+ const res = await this._nodeFsHandler._addToNodeFs(path82, !_internal, void 0, 0, _origAdd);
23426
23407
  if (res)
23427
23408
  this._emitReady();
23428
23409
  return res;
@@ -23444,17 +23425,17 @@ var FSWatcher = class extends EventEmitter {
23444
23425
  return this;
23445
23426
  const paths = unifyPaths(paths_);
23446
23427
  const { cwd } = this.options;
23447
- paths.forEach((path81) => {
23448
- if (!sp2.isAbsolute(path81) && !this._closers.has(path81)) {
23428
+ paths.forEach((path82) => {
23429
+ if (!sp2.isAbsolute(path82) && !this._closers.has(path82)) {
23449
23430
  if (cwd)
23450
- path81 = sp2.join(cwd, path81);
23451
- path81 = sp2.resolve(path81);
23431
+ path82 = sp2.join(cwd, path82);
23432
+ path82 = sp2.resolve(path82);
23452
23433
  }
23453
- this._closePath(path81);
23454
- this._addIgnoredPath(path81);
23455
- if (this._watched.has(path81)) {
23434
+ this._closePath(path82);
23435
+ this._addIgnoredPath(path82);
23436
+ if (this._watched.has(path82)) {
23456
23437
  this._addIgnoredPath({
23457
- path: path81,
23438
+ path: path82,
23458
23439
  recursive: true
23459
23440
  });
23460
23441
  }
@@ -23518,38 +23499,38 @@ var FSWatcher = class extends EventEmitter {
23518
23499
  * @param stats arguments to be passed with event
23519
23500
  * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
23520
23501
  */
23521
- async _emit(event, path81, stats) {
23502
+ async _emit(event, path82, stats) {
23522
23503
  if (this.closed)
23523
23504
  return;
23524
23505
  const opts = this.options;
23525
23506
  if (isWindows)
23526
- path81 = sp2.normalize(path81);
23507
+ path82 = sp2.normalize(path82);
23527
23508
  if (opts.cwd)
23528
- path81 = sp2.relative(opts.cwd, path81);
23529
- const args = [path81];
23509
+ path82 = sp2.relative(opts.cwd, path82);
23510
+ const args = [path82];
23530
23511
  if (stats != null)
23531
23512
  args.push(stats);
23532
23513
  const awf = opts.awaitWriteFinish;
23533
23514
  let pw;
23534
- if (awf && (pw = this._pendingWrites.get(path81))) {
23515
+ if (awf && (pw = this._pendingWrites.get(path82))) {
23535
23516
  pw.lastChange = /* @__PURE__ */ new Date();
23536
23517
  return this;
23537
23518
  }
23538
23519
  if (opts.atomic) {
23539
23520
  if (event === EVENTS.UNLINK) {
23540
- this._pendingUnlinks.set(path81, [event, ...args]);
23521
+ this._pendingUnlinks.set(path82, [event, ...args]);
23541
23522
  setTimeout(() => {
23542
- this._pendingUnlinks.forEach((entry, path82) => {
23523
+ this._pendingUnlinks.forEach((entry, path83) => {
23543
23524
  this.emit(...entry);
23544
23525
  this.emit(EVENTS.ALL, ...entry);
23545
- this._pendingUnlinks.delete(path82);
23526
+ this._pendingUnlinks.delete(path83);
23546
23527
  });
23547
23528
  }, typeof opts.atomic === "number" ? opts.atomic : 100);
23548
23529
  return this;
23549
23530
  }
23550
- if (event === EVENTS.ADD && this._pendingUnlinks.has(path81)) {
23531
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path82)) {
23551
23532
  event = EVENTS.CHANGE;
23552
- this._pendingUnlinks.delete(path81);
23533
+ this._pendingUnlinks.delete(path82);
23553
23534
  }
23554
23535
  }
23555
23536
  if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
@@ -23567,16 +23548,16 @@ var FSWatcher = class extends EventEmitter {
23567
23548
  this.emitWithAll(event, args);
23568
23549
  }
23569
23550
  };
23570
- this._awaitWriteFinish(path81, awf.stabilityThreshold, event, awfEmit);
23551
+ this._awaitWriteFinish(path82, awf.stabilityThreshold, event, awfEmit);
23571
23552
  return this;
23572
23553
  }
23573
23554
  if (event === EVENTS.CHANGE) {
23574
- const isThrottled = !this._throttle(EVENTS.CHANGE, path81, 50);
23555
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path82, 50);
23575
23556
  if (isThrottled)
23576
23557
  return this;
23577
23558
  }
23578
23559
  if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
23579
- const fullPath = opts.cwd ? sp2.join(opts.cwd, path81) : path81;
23560
+ const fullPath = opts.cwd ? sp2.join(opts.cwd, path82) : path82;
23580
23561
  let stats2;
23581
23562
  try {
23582
23563
  stats2 = await stat4(fullPath);
@@ -23607,23 +23588,23 @@ var FSWatcher = class extends EventEmitter {
23607
23588
  * @param timeout duration of time to suppress duplicate actions
23608
23589
  * @returns tracking object or false if action should be suppressed
23609
23590
  */
23610
- _throttle(actionType, path81, timeout) {
23591
+ _throttle(actionType, path82, timeout) {
23611
23592
  if (!this._throttled.has(actionType)) {
23612
23593
  this._throttled.set(actionType, /* @__PURE__ */ new Map());
23613
23594
  }
23614
23595
  const action = this._throttled.get(actionType);
23615
23596
  if (!action)
23616
23597
  throw new Error("invalid throttle");
23617
- const actionPath = action.get(path81);
23598
+ const actionPath = action.get(path82);
23618
23599
  if (actionPath) {
23619
23600
  actionPath.count++;
23620
23601
  return false;
23621
23602
  }
23622
23603
  let timeoutObject;
23623
23604
  const clear = () => {
23624
- const item = action.get(path81);
23605
+ const item = action.get(path82);
23625
23606
  const count = item ? item.count : 0;
23626
- action.delete(path81);
23607
+ action.delete(path82);
23627
23608
  clearTimeout(timeoutObject);
23628
23609
  if (item)
23629
23610
  clearTimeout(item.timeoutObject);
@@ -23631,7 +23612,7 @@ var FSWatcher = class extends EventEmitter {
23631
23612
  };
23632
23613
  timeoutObject = setTimeout(clear, timeout);
23633
23614
  const thr = { timeoutObject, clear, count: 0 };
23634
- action.set(path81, thr);
23615
+ action.set(path82, thr);
23635
23616
  return thr;
23636
23617
  }
23637
23618
  _incrReadyCount() {
@@ -23645,44 +23626,44 @@ var FSWatcher = class extends EventEmitter {
23645
23626
  * @param event
23646
23627
  * @param awfEmit Callback to be called when ready for event to be emitted.
23647
23628
  */
23648
- _awaitWriteFinish(path81, threshold, event, awfEmit) {
23629
+ _awaitWriteFinish(path82, threshold, event, awfEmit) {
23649
23630
  const awf = this.options.awaitWriteFinish;
23650
23631
  if (typeof awf !== "object")
23651
23632
  return;
23652
23633
  const pollInterval = awf.pollInterval;
23653
23634
  let timeoutHandler;
23654
- let fullPath = path81;
23655
- if (this.options.cwd && !sp2.isAbsolute(path81)) {
23656
- fullPath = sp2.join(this.options.cwd, path81);
23635
+ let fullPath = path82;
23636
+ if (this.options.cwd && !sp2.isAbsolute(path82)) {
23637
+ fullPath = sp2.join(this.options.cwd, path82);
23657
23638
  }
23658
23639
  const now = /* @__PURE__ */ new Date();
23659
23640
  const writes = this._pendingWrites;
23660
23641
  function awaitWriteFinishFn(prevStat) {
23661
23642
  statcb(fullPath, (err, curStat) => {
23662
- if (err || !writes.has(path81)) {
23643
+ if (err || !writes.has(path82)) {
23663
23644
  if (err && err.code !== "ENOENT")
23664
23645
  awfEmit(err);
23665
23646
  return;
23666
23647
  }
23667
23648
  const now2 = Number(/* @__PURE__ */ new Date());
23668
23649
  if (prevStat && curStat.size !== prevStat.size) {
23669
- writes.get(path81).lastChange = now2;
23650
+ writes.get(path82).lastChange = now2;
23670
23651
  }
23671
- const pw = writes.get(path81);
23652
+ const pw = writes.get(path82);
23672
23653
  const df = now2 - pw.lastChange;
23673
23654
  if (df >= threshold) {
23674
- writes.delete(path81);
23655
+ writes.delete(path82);
23675
23656
  awfEmit(void 0, curStat);
23676
23657
  } else {
23677
23658
  timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
23678
23659
  }
23679
23660
  });
23680
23661
  }
23681
- if (!writes.has(path81)) {
23682
- writes.set(path81, {
23662
+ if (!writes.has(path82)) {
23663
+ writes.set(path82, {
23683
23664
  lastChange: now,
23684
23665
  cancelWait: () => {
23685
- writes.delete(path81);
23666
+ writes.delete(path82);
23686
23667
  clearTimeout(timeoutHandler);
23687
23668
  return event;
23688
23669
  }
@@ -23693,8 +23674,8 @@ var FSWatcher = class extends EventEmitter {
23693
23674
  /**
23694
23675
  * Determines whether user has asked to ignore this path.
23695
23676
  */
23696
- _isIgnored(path81, stats) {
23697
- if (this.options.atomic && DOT_RE.test(path81))
23677
+ _isIgnored(path82, stats) {
23678
+ if (this.options.atomic && DOT_RE.test(path82))
23698
23679
  return true;
23699
23680
  if (!this._userIgnored) {
23700
23681
  const { cwd } = this.options;
@@ -23704,17 +23685,17 @@ var FSWatcher = class extends EventEmitter {
23704
23685
  const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
23705
23686
  this._userIgnored = anymatch(list, void 0);
23706
23687
  }
23707
- return this._userIgnored(path81, stats);
23688
+ return this._userIgnored(path82, stats);
23708
23689
  }
23709
- _isntIgnored(path81, stat5) {
23710
- return !this._isIgnored(path81, stat5);
23690
+ _isntIgnored(path82, stat5) {
23691
+ return !this._isIgnored(path82, stat5);
23711
23692
  }
23712
23693
  /**
23713
23694
  * Provides a set of common helpers and properties relating to symlink handling.
23714
23695
  * @param path file or directory pattern being watched
23715
23696
  */
23716
- _getWatchHelpers(path81) {
23717
- return new WatchHelper(path81, this.options.followSymlinks, this);
23697
+ _getWatchHelpers(path82) {
23698
+ return new WatchHelper(path82, this.options.followSymlinks, this);
23718
23699
  }
23719
23700
  // Directory helpers
23720
23701
  // -----------------
@@ -23746,63 +23727,63 @@ var FSWatcher = class extends EventEmitter {
23746
23727
  * @param item base path of item/directory
23747
23728
  */
23748
23729
  _remove(directory, item, isDirectory) {
23749
- const path81 = sp2.join(directory, item);
23750
- const fullPath = sp2.resolve(path81);
23751
- isDirectory = isDirectory != null ? isDirectory : this._watched.has(path81) || this._watched.has(fullPath);
23752
- if (!this._throttle("remove", path81, 100))
23730
+ const path82 = sp2.join(directory, item);
23731
+ const fullPath = sp2.resolve(path82);
23732
+ isDirectory = isDirectory != null ? isDirectory : this._watched.has(path82) || this._watched.has(fullPath);
23733
+ if (!this._throttle("remove", path82, 100))
23753
23734
  return;
23754
23735
  if (!isDirectory && this._watched.size === 1) {
23755
23736
  this.add(directory, item, true);
23756
23737
  }
23757
- const wp = this._getWatchedDir(path81);
23738
+ const wp = this._getWatchedDir(path82);
23758
23739
  const nestedDirectoryChildren = wp.getChildren();
23759
- nestedDirectoryChildren.forEach((nested) => this._remove(path81, nested));
23740
+ nestedDirectoryChildren.forEach((nested) => this._remove(path82, nested));
23760
23741
  const parent = this._getWatchedDir(directory);
23761
23742
  const wasTracked = parent.has(item);
23762
23743
  parent.remove(item);
23763
23744
  if (this._symlinkPaths.has(fullPath)) {
23764
23745
  this._symlinkPaths.delete(fullPath);
23765
23746
  }
23766
- let relPath = path81;
23747
+ let relPath = path82;
23767
23748
  if (this.options.cwd)
23768
- relPath = sp2.relative(this.options.cwd, path81);
23749
+ relPath = sp2.relative(this.options.cwd, path82);
23769
23750
  if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
23770
23751
  const event = this._pendingWrites.get(relPath).cancelWait();
23771
23752
  if (event === EVENTS.ADD)
23772
23753
  return;
23773
23754
  }
23774
- this._watched.delete(path81);
23755
+ this._watched.delete(path82);
23775
23756
  this._watched.delete(fullPath);
23776
23757
  const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
23777
- if (wasTracked && !this._isIgnored(path81))
23778
- this._emit(eventName, path81);
23779
- this._closePath(path81);
23758
+ if (wasTracked && !this._isIgnored(path82))
23759
+ this._emit(eventName, path82);
23760
+ this._closePath(path82);
23780
23761
  }
23781
23762
  /**
23782
23763
  * Closes all watchers for a path
23783
23764
  */
23784
- _closePath(path81) {
23785
- this._closeFile(path81);
23786
- const dir = sp2.dirname(path81);
23787
- this._getWatchedDir(dir).remove(sp2.basename(path81));
23765
+ _closePath(path82) {
23766
+ this._closeFile(path82);
23767
+ const dir = sp2.dirname(path82);
23768
+ this._getWatchedDir(dir).remove(sp2.basename(path82));
23788
23769
  }
23789
23770
  /**
23790
23771
  * Closes only file-specific watchers
23791
23772
  */
23792
- _closeFile(path81) {
23793
- const closers = this._closers.get(path81);
23773
+ _closeFile(path82) {
23774
+ const closers = this._closers.get(path82);
23794
23775
  if (!closers)
23795
23776
  return;
23796
23777
  closers.forEach((closer) => closer());
23797
- this._closers.delete(path81);
23778
+ this._closers.delete(path82);
23798
23779
  }
23799
- _addPathCloser(path81, closer) {
23780
+ _addPathCloser(path82, closer) {
23800
23781
  if (!closer)
23801
23782
  return;
23802
- let list = this._closers.get(path81);
23783
+ let list = this._closers.get(path82);
23803
23784
  if (!list) {
23804
23785
  list = [];
23805
- this._closers.set(path81, list);
23786
+ this._closers.set(path82, list);
23806
23787
  }
23807
23788
  list.push(closer);
23808
23789
  }
@@ -24270,7 +24251,7 @@ function isMetadataYarnClassic(metadataPath) {
24270
24251
  }
24271
24252
 
24272
24253
  // src/runtime/config/createConfigService.ts
24273
- import path71 from "pathe";
24254
+ import path72 from "pathe";
24274
24255
 
24275
24256
  // src/platform.ts
24276
24257
  init_esm_shims();
@@ -25450,7 +25431,7 @@ function mergeInlineConfig(config, injectBuiltinAliases, ...configs) {
25450
25431
  // src/runtime/config/internal/merge/miniprogram.ts
25451
25432
  init_esm_shims();
25452
25433
  import { defu as defu5 } from "@weapp-core/shared";
25453
- import path70 from "pathe";
25434
+ import path71 from "pathe";
25454
25435
 
25455
25436
  // src/runtime/config/internal/merge/plugins.ts
25456
25437
  init_esm_shims();
@@ -25751,10 +25732,12 @@ import path43 from "pathe";
25751
25732
  var AUTO_ROUTES_ID = "weapp-vite/auto-routes";
25752
25733
  var VIRTUAL_MODULE_ID = "virtual:weapp-vite-auto-routes";
25753
25734
  var RESOLVED_VIRTUAL_ID = "\0weapp-vite:auto-routes";
25735
+ var ROUTE_WATCHER_KEY = "__auto-routes-vue-watcher__";
25754
25736
  function createAutoRoutesPlugin(ctx) {
25755
25737
  const service = ctx.autoRoutesService;
25756
25738
  let resolvedConfig;
25757
25739
  const autoRoutesAliasTargets = /* @__PURE__ */ new Set();
25740
+ let routeWatcherStarted = false;
25758
25741
  const normalizeTargetId = (id) => {
25759
25742
  return path43.normalize(normalizeFsResolvedId(id));
25760
25743
  };
@@ -25810,6 +25793,62 @@ function createAutoRoutesPlugin(ctx) {
25810
25793
  }
25811
25794
  return relative3 === "pages" || relative3.startsWith("pages/") || relative3.includes("/pages/");
25812
25795
  }
25796
+ function startRouteFileWatcher() {
25797
+ if (routeWatcherStarted) {
25798
+ return;
25799
+ }
25800
+ const configService = ctx.configService;
25801
+ if (!configService?.isDev) {
25802
+ return;
25803
+ }
25804
+ if (!service.isEnabled()) {
25805
+ return;
25806
+ }
25807
+ const srcRoot = configService.absoluteSrcRoot;
25808
+ const allowedExtensions = new Set(vueExtensions.map((ext) => `.${ext}`));
25809
+ const watchDirs = [];
25810
+ for (const dir of service.getWatchDirectories()) {
25811
+ watchDirs.push(dir);
25812
+ }
25813
+ const defaultPagesDir = path43.join(srcRoot, "pages");
25814
+ if (!watchDirs.some((d) => normalizePath(d) === normalizePath(defaultPagesDir))) {
25815
+ watchDirs.push(defaultPagesDir);
25816
+ }
25817
+ if (!watchDirs.length) {
25818
+ return;
25819
+ }
25820
+ const isRouteVueFile = (filePath) => {
25821
+ const ext = path43.extname(filePath);
25822
+ return allowedExtensions.has(ext) && isPagesRelatedPath(filePath);
25823
+ };
25824
+ const watcher = chokidar_default.watch(watchDirs, {
25825
+ ignoreInitial: true,
25826
+ persistent: true,
25827
+ awaitWriteFinish: {
25828
+ stabilityThreshold: 80,
25829
+ pollInterval: 20
25830
+ }
25831
+ });
25832
+ watcher.on("add", (filePath) => {
25833
+ if (!isRouteVueFile(filePath)) {
25834
+ return;
25835
+ }
25836
+ default2.info(`[auto-routes:watch] \u65B0\u589E\u8DEF\u7531\u6587\u4EF6 ${configService.relativeCwd(filePath)}`);
25837
+ void service.handleFileChange(filePath, "create");
25838
+ });
25839
+ watcher.on("unlink", (filePath) => {
25840
+ if (!isRouteVueFile(filePath)) {
25841
+ return;
25842
+ }
25843
+ default2.info(`[auto-routes:watch] \u5220\u9664\u8DEF\u7531\u6587\u4EF6 ${configService.relativeCwd(filePath)}`);
25844
+ void service.handleFileChange(filePath, "delete");
25845
+ });
25846
+ const { sidecarWatcherMap } = ctx.runtimeState.watcher;
25847
+ sidecarWatcherMap.set(ROUTE_WATCHER_KEY, {
25848
+ close: () => void watcher.close()
25849
+ });
25850
+ routeWatcherStarted = true;
25851
+ }
25813
25852
  return {
25814
25853
  name: "weapp-vite:auto-routes",
25815
25854
  enforce: "pre",
@@ -25821,6 +25860,7 @@ function createAutoRoutesPlugin(ctx) {
25821
25860
  await service.ensureFresh();
25822
25861
  refreshAutoRoutesAliasTargets();
25823
25862
  addWatchTargets(this);
25863
+ startRouteFileWatcher();
25824
25864
  },
25825
25865
  resolveId(id) {
25826
25866
  if (id === AUTO_ROUTES_ID || id === VIRTUAL_MODULE_ID) {
@@ -27080,8 +27120,8 @@ function transformWxsCode(code, options) {
27080
27120
  }
27081
27121
  importees.push({ source: value });
27082
27122
  };
27083
- const tryCollectArgument = (path81) => {
27084
- const node = path81.node;
27123
+ const tryCollectArgument = (path82) => {
27124
+ const node = path82.node;
27085
27125
  if (t.isStringLiteral(node)) {
27086
27126
  maybePushImportee(node.value);
27087
27127
  return;
@@ -27092,7 +27132,7 @@ function transformWxsCode(code, options) {
27092
27132
  return;
27093
27133
  }
27094
27134
  try {
27095
- const evaluated = path81.evaluate();
27135
+ const evaluated = path82.evaluate();
27096
27136
  if (evaluated.confident) {
27097
27137
  maybePushImportee(evaluated.value);
27098
27138
  }
@@ -27745,6 +27785,7 @@ init_esm_shims();
27745
27785
 
27746
27786
  // src/plugins/core/lifecycle/emit.ts
27747
27787
  init_esm_shims();
27788
+ import path53 from "pathe";
27748
27789
 
27749
27790
  // src/utils/weapi.ts
27750
27791
  init_esm_shims();
@@ -27786,6 +27827,11 @@ function createWeapiAccessExpression(globalName) {
27786
27827
 
27787
27828
  // src/plugins/core/lifecycle/emit.ts
27788
27829
  var platformApiIdentifiers = /* @__PURE__ */ new Set(["wx", "my", "tt", "swan", "jd", "xhs"]);
27830
+ var WINDOWS_SEPARATOR_RE = /\\/g;
27831
+ var NPM_PROTOCOL_RE = /^npm:/;
27832
+ var PLUGIN_PROTOCOL_RE = /^plugin:\/\//;
27833
+ var ABSOLUTE_NPM_PREFIX_RE = /^\/(?:miniprogram_npm|node_modules)\//;
27834
+ var PRETTY_NODE_MODULES_RE = /node_modules\/(?:\.pnpm\/[^/]+\/node_modules\/)?(.+)/;
27789
27835
  function resolveInjectWeapiGlobalName(state) {
27790
27836
  const injectWeapi = state.ctx.configService.weappViteConfig?.injectWeapi;
27791
27837
  if (!injectWeapi) {
@@ -27802,8 +27848,8 @@ function replacePlatformApiAccess(code, globalName) {
27802
27848
  try {
27803
27849
  const ast = parseJsLike(code);
27804
27850
  let mutated = false;
27805
- const rewritePath = (path81) => {
27806
- const object = path81.node?.object;
27851
+ const rewritePath = (path82) => {
27852
+ const object = path82.node?.object;
27807
27853
  if (!object || object.type !== "Identifier") {
27808
27854
  return;
27809
27855
  }
@@ -27811,10 +27857,10 @@ function replacePlatformApiAccess(code, globalName) {
27811
27857
  if (!platformApiIdentifiers.has(identifierName)) {
27812
27858
  return;
27813
27859
  }
27814
- if (path81.scope?.hasBinding?.(identifierName)) {
27860
+ if (path82.scope?.hasBinding?.(identifierName)) {
27815
27861
  return;
27816
27862
  }
27817
- path81.node.object = {
27863
+ path82.node.object = {
27818
27864
  type: "Identifier",
27819
27865
  name: injectedApiIdentifier2
27820
27866
  };
@@ -27839,13 +27885,13 @@ function hasDependencyPrefix3(dependencies, importee) {
27839
27885
  if (!dependencies) {
27840
27886
  return false;
27841
27887
  }
27842
- const normalizedImportee = importee.replace(/\\/g, "/").replace(/^npm:/, "");
27888
+ const normalizedImportee = importee.replace(WINDOWS_SEPARATOR_RE, "/").replace(NPM_PROTOCOL_RE, "");
27843
27889
  const importeeTokens = normalizedImportee.split("/").filter(Boolean);
27844
27890
  if (importeeTokens.length === 0) {
27845
27891
  return false;
27846
27892
  }
27847
27893
  return Object.keys(dependencies).some((dep) => {
27848
- const depTokens = dep.replace(/\\/g, "/").split("/").filter(Boolean);
27894
+ const depTokens = dep.replace(WINDOWS_SEPARATOR_RE, "/").split("/").filter(Boolean);
27849
27895
  if (depTokens.length === 0 || depTokens.length > importeeTokens.length) {
27850
27896
  return false;
27851
27897
  }
@@ -27857,12 +27903,23 @@ function hasDependencyPrefix3(dependencies, importee) {
27857
27903
  return true;
27858
27904
  });
27859
27905
  }
27906
+ function resolveDependencyId(importee) {
27907
+ const normalizedImportee = importee.replace(WINDOWS_SEPARATOR_RE, "/").replace(NPM_PROTOCOL_RE, "").replace(ABSOLUTE_NPM_PREFIX_RE, "");
27908
+ const importeeTokens = normalizedImportee.split("/").filter(Boolean);
27909
+ if (importeeTokens.length === 0) {
27910
+ return "";
27911
+ }
27912
+ if (normalizedImportee.startsWith("@") && importeeTokens.length > 1) {
27913
+ return `${importeeTokens[0]}/${importeeTokens[1]}`;
27914
+ }
27915
+ return importeeTokens[0];
27916
+ }
27860
27917
  function normalizeNpmImportForAlipay(importee, dependencies, mode) {
27861
27918
  const trimmed = importee.trim();
27862
- if (!trimmed || /^plugin:\/\//.test(trimmed)) {
27919
+ if (!trimmed || PLUGIN_PROTOCOL_RE.test(trimmed)) {
27863
27920
  return importee;
27864
27921
  }
27865
- const normalized = trimmed.replace(/^npm:/, "");
27922
+ const normalized = trimmed.replace(NPM_PROTOCOL_RE, "");
27866
27923
  if (normalized.startsWith("/miniprogram_npm/") || normalized.startsWith("/node_modules/")) {
27867
27924
  return normalizeAlipayNpmImportPath(normalized, mode);
27868
27925
  }
@@ -27876,15 +27933,15 @@ function rewriteChunkNpmImportsForAlipay(code, dependencies, mode) {
27876
27933
  const ast = parseJsLike(code);
27877
27934
  let mutated = false;
27878
27935
  traverse(ast, {
27879
- CallExpression(path81) {
27880
- const callee = path81.node?.callee;
27936
+ CallExpression(path82) {
27937
+ const callee = path82.node?.callee;
27881
27938
  if (!callee || callee.type !== "Identifier" || callee.name !== "require") {
27882
27939
  return;
27883
27940
  }
27884
- if (path81.scope?.hasBinding?.("require")) {
27941
+ if (path82.scope?.hasBinding?.("require")) {
27885
27942
  return;
27886
27943
  }
27887
- const args = path81.node.arguments;
27944
+ const args = path82.node.arguments;
27888
27945
  if (!Array.isArray(args) || args.length === 0) {
27889
27946
  return;
27890
27947
  }
@@ -27948,6 +28005,131 @@ function rewriteBundlePlatformApi(bundle, globalName) {
27948
28005
  chunk.code = nextCode;
27949
28006
  }
27950
28007
  }
28008
+ function matchesSubPackageDependency(dependencies, importee, fallbackDependencies) {
28009
+ const normalized = importee.replace(NPM_PROTOCOL_RE, "").replace(ABSOLUTE_NPM_PREFIX_RE, "");
28010
+ if (Array.isArray(dependencies) && dependencies.length > 0) {
28011
+ const dependencyId = resolveDependencyId(normalized);
28012
+ return dependencies.some((pattern) => {
28013
+ if (typeof pattern === "string") {
28014
+ return dependencyId === pattern || normalized === pattern || normalized.startsWith(`${pattern}/`);
28015
+ }
28016
+ pattern.lastIndex = 0;
28017
+ if (pattern.test(dependencyId)) {
28018
+ return true;
28019
+ }
28020
+ pattern.lastIndex = 0;
28021
+ return pattern.test(normalized);
28022
+ });
28023
+ }
28024
+ return hasDependencyPrefix3(fallbackDependencies, normalized);
28025
+ }
28026
+ function normalizeWeappLocalNpmImport(importee) {
28027
+ const normalized = importee.replace(NPM_PROTOCOL_RE, "").replace(ABSOLUTE_NPM_PREFIX_RE, "");
28028
+ const segments = normalized.split("/").filter(Boolean);
28029
+ if (segments.length === 1 || segments.length === 2 && normalized.startsWith("@")) {
28030
+ return `${normalized}/index`;
28031
+ }
28032
+ return normalized;
28033
+ }
28034
+ function getRequireImportLiteral(node) {
28035
+ if (!node) {
28036
+ return null;
28037
+ }
28038
+ if (node.type === "StringLiteral" || node.type === "Literal") {
28039
+ return typeof node.value === "string" ? node.value : null;
28040
+ }
28041
+ if (node.type === "TemplateLiteral" && node.expressions?.length === 0 && node.quasis?.length === 1) {
28042
+ return node.quasis[0]?.value?.cooked ?? null;
28043
+ }
28044
+ return null;
28045
+ }
28046
+ function setRequireImportLiteral(node, nextValue) {
28047
+ if (!node) {
28048
+ return;
28049
+ }
28050
+ if (node.type === "StringLiteral" || node.type === "Literal") {
28051
+ node.value = nextValue;
28052
+ return;
28053
+ }
28054
+ if (node.type === "TemplateLiteral" && node.expressions?.length === 0 && node.quasis?.length === 1) {
28055
+ node.quasis[0].value.raw = nextValue;
28056
+ node.quasis[0].value.cooked = nextValue;
28057
+ }
28058
+ }
28059
+ function toRelativeRuntimeNpmImport(fileName, root, importee) {
28060
+ const normalized = normalizeWeappLocalNpmImport(importee);
28061
+ const relative3 = toPosixPath(path53.relative(path53.dirname(fileName), `${root}/miniprogram_npm/${normalized}`));
28062
+ return relative3.startsWith(".") ? relative3 : `./${relative3}`;
28063
+ }
28064
+ function rewriteChunkNpmImportsToLocalSubPackage(chunk, meta, dependencies) {
28065
+ try {
28066
+ const ast = parseJsLike(chunk.code);
28067
+ let mutated = false;
28068
+ traverse(ast, {
28069
+ CallExpression(path82) {
28070
+ const callee = path82.node?.callee;
28071
+ if (!callee || callee.type !== "Identifier" || callee.name !== "require") {
28072
+ return;
28073
+ }
28074
+ if (path82.scope?.hasBinding?.("require")) {
28075
+ return;
28076
+ }
28077
+ const args = path82.node.arguments;
28078
+ if (!Array.isArray(args) || args.length === 0) {
28079
+ return;
28080
+ }
28081
+ const firstArg = args[0];
28082
+ const currentValue = getRequireImportLiteral(firstArg);
28083
+ if (typeof currentValue !== "string" || !matchesSubPackageDependency(meta.subPackage.dependencies, currentValue, dependencies)) {
28084
+ return;
28085
+ }
28086
+ const nextValue = toRelativeRuntimeNpmImport(chunk.fileName, meta.subPackage.root, currentValue);
28087
+ if (nextValue === currentValue) {
28088
+ return;
28089
+ }
28090
+ setRequireImportLiteral(firstArg, nextValue);
28091
+ mutated = true;
28092
+ }
28093
+ });
28094
+ if (mutated) {
28095
+ chunk.code = generate(ast).code;
28096
+ }
28097
+ } catch {
28098
+ }
28099
+ }
28100
+ function rewriteJsonNpmImportsToLocalSubPackage(bundle, meta, dependencies) {
28101
+ for (const output of Object.values(bundle)) {
28102
+ if (output?.type !== "asset" || typeof output.fileName !== "string" || !output.fileName.endsWith(".json")) {
28103
+ continue;
28104
+ }
28105
+ if (output.fileName === `${meta.subPackage.root}.json` || !output.fileName.startsWith(`${meta.subPackage.root}/`)) {
28106
+ continue;
28107
+ }
28108
+ const source = typeof output.source === "string" ? output.source : output.source?.toString();
28109
+ if (!source) {
28110
+ continue;
28111
+ }
28112
+ try {
28113
+ const parsed = JSON.parse(source);
28114
+ if (!parsed || typeof parsed !== "object" || !parsed.usingComponents || typeof parsed.usingComponents !== "object" || Array.isArray(parsed.usingComponents)) {
28115
+ continue;
28116
+ }
28117
+ let mutated = false;
28118
+ for (const [componentName, importee] of Object.entries(parsed.usingComponents)) {
28119
+ if (typeof importee !== "string" || !matchesSubPackageDependency(meta.subPackage.dependencies, importee, dependencies)) {
28120
+ continue;
28121
+ }
28122
+ parsed.usingComponents[componentName] = toRelativeRuntimeNpmImport(output.fileName, meta.subPackage.root, importee);
28123
+ mutated = true;
28124
+ }
28125
+ if (mutated) {
28126
+ output.source = `${JSON.stringify(parsed, null, 2)}
28127
+ `;
28128
+ }
28129
+ } catch {
28130
+ }
28131
+ }
28132
+ }
27951
28133
  function createRenderStartHook(state) {
27952
28134
  const { ctx, subPackageMeta, buildTarget } = state;
27953
28135
  return function renderStart() {
@@ -27986,7 +28168,7 @@ function createGenerateBundleHook(state, isPluginBuild) {
27986
28168
  var matchSubPackage = matchSubPackage2;
27987
28169
  const sharedStrategy = configService.weappViteConfig?.chunks?.sharedStrategy ?? DEFAULT_SHARED_CHUNK_STRATEGY;
27988
28170
  const shouldLogChunks = configService.weappViteConfig?.chunks?.logOptimization ?? true;
27989
- const subPackageRoots = Array.from(scanService.subPackageMap.keys()).filter(Boolean);
28171
+ const subPackageRoots = [...scanService.subPackageMap.keys()].filter(Boolean);
27990
28172
  const duplicateWarningBytes = Number(configService.weappViteConfig?.chunks?.duplicateWarningBytes ?? 0);
27991
28173
  const shouldWarnOnDuplicate = Number.isFinite(duplicateWarningBytes) && duplicateWarningBytes > 0;
27992
28174
  let redundantBytesTotal = 0;
@@ -27999,7 +28181,7 @@ function createGenerateBundleHook(state, isPluginBuild) {
27999
28181
  const resolveSharedChunkLabel = (sharedFileName, finalFileName) => {
28000
28182
  const prettifyModuleLabel = (label) => {
28001
28183
  const normalized = toPosixPath(label);
28002
- const match = normalized.match(/node_modules\/(?:\.pnpm\/[^/]+\/node_modules\/)?(.+)/);
28184
+ const match = normalized.match(PRETTY_NODE_MODULES_RE);
28003
28185
  return match?.[1] || label;
28004
28186
  };
28005
28187
  const candidates = [];
@@ -28024,11 +28206,9 @@ function createGenerateBundleHook(state, isPluginBuild) {
28024
28206
  if (!chunk) {
28025
28207
  return finalFileName;
28026
28208
  }
28027
- const moduleLabels = Array.from(
28028
- new Set(
28029
- Object.keys(chunk.modules ?? {}).filter((id) => id && !id.startsWith("\0")).map((id) => configService.relativeAbsoluteSrcRoot(id)).filter(Boolean)
28030
- )
28031
- );
28209
+ const moduleLabels = [...new Set(
28210
+ Object.keys(chunk.modules ?? {}).filter((id) => id && !id.startsWith("\0")).map((id) => configService.relativeAbsoluteSrcRoot(id)).filter(Boolean)
28211
+ )];
28032
28212
  if (!moduleLabels.length) {
28033
28213
  return chunk.fileName || finalFileName;
28034
28214
  }
@@ -28072,7 +28252,7 @@ function createGenerateBundleHook(state, isPluginBuild) {
28072
28252
  subPackageSet.add(match);
28073
28253
  }
28074
28254
  }
28075
- const subPackageList = Array.from(subPackageSet).join("\u3001") || "\u76F8\u5173\u5206\u5305";
28255
+ const subPackageList = [...subPackageSet].join("\u3001") || "\u76F8\u5173\u5206\u5305";
28076
28256
  const ignoredHint = ignoredMainImporters?.length ? `\uFF0C\u5FFD\u7565\u4E3B\u5305\u5F15\u7528\uFF1A${ignoredMainImporters.join("\u3001")}` : "";
28077
28257
  default2.info(`[\u5206\u5305] \u5206\u5305 ${subPackageList} \u5171\u4EAB\u6A21\u5757\u5DF2\u590D\u5236\u5230\u5404\u81EA weapp-shared/common.js\uFF08${totalReferences} \u5904\u5F15\u7528${ignoredHint}\uFF09`);
28078
28258
  if (retainedInMain) {
@@ -28096,7 +28276,7 @@ function createGenerateBundleHook(state, isPluginBuild) {
28096
28276
  }
28097
28277
  const segments = [];
28098
28278
  if (involvedSubs.size) {
28099
- segments.push(`\u5206\u5305 ${Array.from(involvedSubs).join("\u3001")}`);
28279
+ segments.push(`\u5206\u5305 ${[...involvedSubs].join("\u3001")}`);
28100
28280
  }
28101
28281
  if (hasMainReference) {
28102
28282
  segments.push("\u4E3B\u5305");
@@ -28121,7 +28301,7 @@ function createGenerateBundleHook(state, isPluginBuild) {
28121
28301
  subPackageSet.add(match);
28122
28302
  }
28123
28303
  }
28124
- const subPackageList = Array.from(subPackageSet).join("\u3001") || "\u76F8\u5173\u5206\u5305";
28304
+ const subPackageList = [...subPackageSet].join("\u3001") || "\u76F8\u5173\u5206\u5305";
28125
28305
  default2.info(`[\u5206\u5305] \u5206\u5305 ${subPackageList} \u5DF2\u672C\u5730\u5316 ${runtimeFileName} \u4F9D\u8D56\uFF0C\u907F\u514D\u8DE8\u5305 runtime \u5F15\u7528\u3002`);
28126
28306
  } : void 0
28127
28307
  });
@@ -28135,6 +28315,22 @@ function createGenerateBundleHook(state, isPluginBuild) {
28135
28315
  });
28136
28316
  if (configService.platform === "alipay") {
28137
28317
  rewriteBundleNpmImportsForAlipay(rolldownBundle, configService.packageJson.dependencies, configService.weappViteConfig?.npm?.alipayNpmMode);
28318
+ } else {
28319
+ const subPackageMap = scanService.subPackageMap ?? /* @__PURE__ */ new Map();
28320
+ const localSubPackageMetas = [...subPackageMap.values()].filter((meta) => Array.isArray(meta?.subPackage?.dependencies) && meta.subPackage.dependencies.length > 0);
28321
+ for (const meta of localSubPackageMetas) {
28322
+ for (const output of Object.values(rolldownBundle)) {
28323
+ if (output?.type !== "chunk") {
28324
+ continue;
28325
+ }
28326
+ const chunk = output;
28327
+ if (chunk.fileName === meta.subPackage.root || !chunk.fileName.startsWith(`${meta.subPackage.root}/`)) {
28328
+ continue;
28329
+ }
28330
+ rewriteChunkNpmImportsToLocalSubPackage(chunk, meta, configService.packageJson.dependencies);
28331
+ }
28332
+ rewriteJsonNpmImportsToLocalSubPackage(rolldownBundle, meta, configService.packageJson.dependencies);
28333
+ }
28138
28334
  }
28139
28335
  const injectWeapiGlobalName = resolveInjectWeapiGlobalName(state);
28140
28336
  if (injectWeapiGlobalName) {
@@ -28172,7 +28368,7 @@ function createBuildEndHook(state) {
28172
28368
  // src/plugins/core/lifecycle/load.ts
28173
28369
  init_esm_shims();
28174
28370
  import { removeExtensionDeep as removeExtensionDeep11 } from "@weapp-core/shared";
28175
- import path53 from "pathe";
28371
+ import path54 from "pathe";
28176
28372
 
28177
28373
  // src/plugins/utils/parse.ts
28178
28374
  init_esm_shims();
@@ -28209,7 +28405,7 @@ function createOptionsHook(state) {
28209
28405
  let scannedInput;
28210
28406
  if (subPackageMeta) {
28211
28407
  scannedInput = subPackageMeta.entries.reduce((acc, entry) => {
28212
- acc[entry] = path53.resolve(configService.absoluteSrcRoot, entry);
28408
+ acc[entry] = path54.resolve(configService.absoluteSrcRoot, entry);
28213
28409
  return acc;
28214
28410
  }, {});
28215
28411
  } else if (configService.weappLibConfig?.enabled) {
@@ -28352,8 +28548,8 @@ function createLoadHook(state) {
28352
28548
  try {
28353
28549
  const ast = parseJsLike(code);
28354
28550
  let mutated = false;
28355
- const rewritePath = (path81) => {
28356
- const object = path81.node?.object;
28551
+ const rewritePath = (path82) => {
28552
+ const object = path82.node?.object;
28357
28553
  if (!object || object.type !== "Identifier") {
28358
28554
  return;
28359
28555
  }
@@ -28361,10 +28557,10 @@ function createLoadHook(state) {
28361
28557
  if (!platformApiIdentifiers3.has(identifierName)) {
28362
28558
  return;
28363
28559
  }
28364
- if (path81.scope?.hasBinding?.(identifierName)) {
28560
+ if (path82.scope?.hasBinding?.(identifierName)) {
28365
28561
  return;
28366
28562
  }
28367
- path81.node.object = {
28563
+ path82.node.object = {
28368
28564
  type: "Identifier",
28369
28565
  name: injectedApiIdentifier2
28370
28566
  };
@@ -28509,8 +28705,8 @@ function replacePlatformApiAccess2(code, globalName) {
28509
28705
  try {
28510
28706
  const ast = parseJsLike(code);
28511
28707
  let mutated = false;
28512
- const rewritePath = (path81) => {
28513
- const object = path81.node?.object;
28708
+ const rewritePath = (path82) => {
28709
+ const object = path82.node?.object;
28514
28710
  if (!object || object.type !== "Identifier") {
28515
28711
  return;
28516
28712
  }
@@ -28518,10 +28714,10 @@ function replacePlatformApiAccess2(code, globalName) {
28518
28714
  if (!platformApiIdentifiers2.has(identifierName)) {
28519
28715
  return;
28520
28716
  }
28521
- if (path81.scope?.hasBinding?.(identifierName)) {
28717
+ if (path82.scope?.hasBinding?.(identifierName)) {
28522
28718
  return;
28523
28719
  }
28524
- path81.node.object = {
28720
+ path82.node.object = {
28525
28721
  type: "Identifier",
28526
28722
  name: injectedApiIdentifier
28527
28723
  };
@@ -28565,14 +28761,14 @@ function createTransformHook(state) {
28565
28761
 
28566
28762
  // src/plugins/core/lifecycle/watch.ts
28567
28763
  init_esm_shims();
28568
- import path58 from "pathe";
28764
+ import path59 from "pathe";
28569
28765
 
28570
28766
  // src/plugins/css/shared/preprocessor.ts
28571
28767
  init_esm_shims();
28572
28768
  import { createHash as createHash2 } from "crypto";
28573
28769
  import { createRequire as createRequire7 } from "module";
28574
28770
  import fs25 from "fs-extra";
28575
- import path54 from "pathe";
28771
+ import path55 from "pathe";
28576
28772
  import { preprocessCSS } from "vite";
28577
28773
 
28578
28774
  // src/postcss/index.ts
@@ -28733,12 +28929,12 @@ async function processCssWithCache(code, configService) {
28733
28929
  }
28734
28930
  function dedupeAndNormalizeDependencies(base, dependencies) {
28735
28931
  const seen = /* @__PURE__ */ new Set();
28736
- const baseDir = path54.dirname(base);
28932
+ const baseDir = path55.dirname(base);
28737
28933
  for (const dep of dependencies) {
28738
28934
  if (!dep) {
28739
28935
  continue;
28740
28936
  }
28741
- const normalized = path54.isAbsolute(dep) ? dep : path54.resolve(baseDir, dep);
28937
+ const normalized = path55.isAbsolute(dep) ? dep : path55.resolve(baseDir, dep);
28742
28938
  seen.add(normalized);
28743
28939
  }
28744
28940
  return Array.from(seen);
@@ -28836,7 +29032,7 @@ init_esm_shims();
28836
29032
  // src/plugins/utils/invalidateEntry/cssGraph.ts
28837
29033
  init_esm_shims();
28838
29034
  import fs26 from "fs";
28839
- import path55 from "pathe";
29035
+ import path56 from "pathe";
28840
29036
 
28841
29037
  // src/plugins/utils/invalidateEntry/shared.ts
28842
29038
  init_esm_shims();
@@ -28941,7 +29137,7 @@ async function extractCssImportDependencies(ctx, importer) {
28941
29137
  }
28942
29138
  cssImportRE.lastIndex = 0;
28943
29139
  const dependencies = /* @__PURE__ */ new Set();
28944
- const dir = path55.dirname(importer);
29140
+ const dir = path56.dirname(importer);
28945
29141
  while (true) {
28946
29142
  const match = cssImportRE.exec(cssContent);
28947
29143
  if (!match) {
@@ -28953,9 +29149,9 @@ async function extractCssImportDependencies(ctx, importer) {
28953
29149
  }
28954
29150
  if (importProtocols.test(rawSpecifier)) {
28955
29151
  if (rawSpecifier.startsWith("/")) {
28956
- const absolute = path55.resolve(ctx.configService.absoluteSrcRoot, rawSpecifier.slice(1));
29152
+ const absolute = path56.resolve(ctx.configService.absoluteSrcRoot, rawSpecifier.slice(1));
28957
29153
  dependencies.add(absolute);
28958
- const ext2 = path55.extname(absolute);
29154
+ const ext2 = path56.extname(absolute);
28959
29155
  if (ext2) {
28960
29156
  dependencies.add(absolute.slice(0, -ext2.length));
28961
29157
  }
@@ -28964,7 +29160,7 @@ async function extractCssImportDependencies(ctx, importer) {
28964
29160
  }
28965
29161
  let specifier = rawSpecifier;
28966
29162
  if (specifier.startsWith("@/")) {
28967
- specifier = path55.join(ctx.configService.absoluteSrcRoot, specifier.slice(2));
29163
+ specifier = path56.join(ctx.configService.absoluteSrcRoot, specifier.slice(2));
28968
29164
  } else if (specifier === "@") {
28969
29165
  specifier = ctx.configService.absoluteSrcRoot;
28970
29166
  }
@@ -28972,9 +29168,9 @@ async function extractCssImportDependencies(ctx, importer) {
28972
29168
  specifier = specifier.slice(1);
28973
29169
  }
28974
29170
  const cleaned = specifier.replace(/[?#].*$/, "");
28975
- const resolved = path55.resolve(dir, cleaned);
29171
+ const resolved = path56.resolve(dir, cleaned);
28976
29172
  dependencies.add(resolved);
28977
- const ext = path55.extname(resolved);
29173
+ const ext = path56.extname(resolved);
28978
29174
  if (!ext) {
28979
29175
  dependencies.add(resolved);
28980
29176
  } else {
@@ -28993,7 +29189,7 @@ function collectCssImporters(ctx, dependency) {
28993
29189
  matches2.add(importer);
28994
29190
  }
28995
29191
  }
28996
- const ext = path55.extname(normalizedDependency);
29192
+ const ext = path56.extname(normalizedDependency);
28997
29193
  if (ext) {
28998
29194
  const base = normalizedDependency.slice(0, -ext.length);
28999
29195
  const baseMatches = graph.dependencyToImporters.get(base);
@@ -29027,7 +29223,7 @@ async function collectAffectedScriptsAndImporters(ctx, startCssFile) {
29027
29223
  continue;
29028
29224
  }
29029
29225
  visitedCss.add(current2);
29030
- const ext = path55.extname(current2);
29226
+ const ext = path56.extname(current2);
29031
29227
  if (ext) {
29032
29228
  const base = current2.slice(0, -ext.length);
29033
29229
  const script = await resolveScriptForCss(scriptCache, base);
@@ -29054,10 +29250,10 @@ function cleanupCssImporterGraph(ctx, importer) {
29054
29250
 
29055
29251
  // src/plugins/utils/invalidateEntry/sidecar.ts
29056
29252
  init_esm_shims();
29057
- import path56 from "pathe";
29253
+ import path57 from "pathe";
29058
29254
  async function invalidateEntryForSidecar(ctx, filePath, event = "update") {
29059
29255
  const configSuffix = configSuffixes.find((suffix) => filePath.endsWith(suffix));
29060
- const ext = path56.extname(filePath);
29256
+ const ext = path57.extname(filePath);
29061
29257
  const normalizedPath = normalizePath(filePath);
29062
29258
  let scriptBasePath;
29063
29259
  if (configSuffix) {
@@ -29122,13 +29318,13 @@ async function invalidateEntryForSidecar(ctx, filePath, event = "update") {
29122
29318
  init_esm_shims();
29123
29319
  import fs27 from "fs";
29124
29320
  import process7 from "process";
29125
- import path57 from "pathe";
29321
+ import path58 from "pathe";
29126
29322
  function ensureSidecarWatcher(ctx, rootDir) {
29127
29323
  if (!ctx.configService.isDev || !rootDir || process7.env.VITEST === "true" || process7.env.NODE_ENV === "test" || process7.env.WEAPP_VITE_DISABLE_SIDECAR_WATCH === "1") {
29128
29324
  return;
29129
29325
  }
29130
29326
  const { sidecarWatcherMap } = ctx.runtimeState.watcher;
29131
- const absRoot = path57.normalize(rootDir);
29327
+ const absRoot = path58.normalize(rootDir);
29132
29328
  if (!fs27.existsSync(absRoot)) {
29133
29329
  return;
29134
29330
  }
@@ -29140,7 +29336,7 @@ function ensureSidecarWatcher(ctx, rootDir) {
29140
29336
  if (!isSidecarFile(filePath)) {
29141
29337
  return;
29142
29338
  }
29143
- const ext = path57.extname(filePath);
29339
+ const ext = path58.extname(filePath);
29144
29340
  const isCssFile = Boolean(ext && watchedCssExts.has(ext));
29145
29341
  if (isCssFile && (event === "create" || event === "update")) {
29146
29342
  void extractCssImportDependencies(ctx, filePath);
@@ -29161,9 +29357,9 @@ function ensureSidecarWatcher(ctx, rootDir) {
29161
29357
  }
29162
29358
  };
29163
29359
  const patterns = [
29164
- ...configExtensions.map((ext) => path57.join(absRoot, `**/*.${ext}`)),
29165
- ...supportedCssLangs.map((ext) => path57.join(absRoot, `**/*.${ext}`)),
29166
- ...templateExtensions.map((ext) => path57.join(absRoot, `**/*.${ext}`))
29360
+ ...configExtensions.map((ext) => path58.join(absRoot, `**/*.${ext}`)),
29361
+ ...supportedCssLangs.map((ext) => path58.join(absRoot, `**/*.${ext}`)),
29362
+ ...templateExtensions.map((ext) => path58.join(absRoot, `**/*.${ext}`))
29167
29363
  ];
29168
29364
  const ignoredMatcher = createSidecarIgnoredMatcher(ctx, absRoot);
29169
29365
  const watcher = chokidar_default.watch(patterns, {
@@ -29179,15 +29375,15 @@ function ensureSidecarWatcher(ctx, rootDir) {
29179
29375
  if (!input) {
29180
29376
  return;
29181
29377
  }
29182
- const normalizedPath = path57.normalize(input);
29378
+ const normalizedPath = path58.normalize(input);
29183
29379
  if (!options?.silent) {
29184
29380
  default2.info(`[watch:${event}] ${ctx.configService.relativeCwd(normalizedPath)}`);
29185
29381
  }
29186
29382
  handleSidecarChange(event, normalizedPath, isReady);
29187
29383
  };
29188
- watcher.on("add", (path81) => forwardChange("create", path81));
29189
- watcher.on("change", (path81) => forwardChange("update", path81));
29190
- watcher.on("unlink", (path81) => forwardChange("delete", path81));
29384
+ watcher.on("add", (path82) => forwardChange("create", path82));
29385
+ watcher.on("change", (path82) => forwardChange("update", path82));
29386
+ watcher.on("unlink", (path82) => forwardChange("delete", path82));
29191
29387
  watcher.on("raw", (eventName, rawPath, details) => {
29192
29388
  if (eventName !== "rename") {
29193
29389
  return;
@@ -29197,7 +29393,7 @@ function ensureSidecarWatcher(ctx, rootDir) {
29197
29393
  return;
29198
29394
  }
29199
29395
  const baseDir = typeof details === "object" && details && "watchedPath" in details ? details.watchedPath ?? absRoot : absRoot;
29200
- const resolved = path57.isAbsolute(candidate) ? candidate : path57.resolve(baseDir, candidate);
29396
+ const resolved = path58.isAbsolute(candidate) ? candidate : path58.resolve(baseDir, candidate);
29201
29397
  if (ignoredMatcher(resolved)) {
29202
29398
  return;
29203
29399
  }
@@ -29225,22 +29421,22 @@ function ensureSidecarWatcher(ctx, rootDir) {
29225
29421
  function createSidecarIgnoredMatcher(ctx, rootDir) {
29226
29422
  const configService = ctx.configService;
29227
29423
  const ignoredRoots = /* @__PURE__ */ new Set();
29228
- const normalizedRoot = path57.normalize(rootDir);
29424
+ const normalizedRoot = path58.normalize(rootDir);
29229
29425
  for (const dirName of defaultIgnoredDirNames) {
29230
- ignoredRoots.add(path57.join(normalizedRoot, dirName));
29426
+ ignoredRoots.add(path58.join(normalizedRoot, dirName));
29231
29427
  }
29232
29428
  if (configService?.mpDistRoot) {
29233
- ignoredRoots.add(path57.resolve(configService.cwd, configService.mpDistRoot));
29429
+ ignoredRoots.add(path58.resolve(configService.cwd, configService.mpDistRoot));
29234
29430
  } else {
29235
- ignoredRoots.add(path57.join(normalizedRoot, "dist"));
29431
+ ignoredRoots.add(path58.join(normalizedRoot, "dist"));
29236
29432
  }
29237
29433
  if (configService?.outDir) {
29238
- ignoredRoots.add(path57.resolve(configService.cwd, configService.outDir));
29434
+ ignoredRoots.add(path58.resolve(configService.cwd, configService.outDir));
29239
29435
  }
29240
29436
  return (candidate) => {
29241
- const normalized = path57.normalize(candidate);
29437
+ const normalized = path58.normalize(candidate);
29242
29438
  for (const ignored of ignoredRoots) {
29243
- if (normalized === ignored || normalized.startsWith(`${ignored}${path57.sep}`)) {
29439
+ if (normalized === ignored || normalized.startsWith(`${ignored}${path58.sep}`)) {
29244
29440
  return true;
29245
29441
  }
29246
29442
  }
@@ -29263,7 +29459,7 @@ function createBuildStartHook(state) {
29263
29459
  ensureSidecarWatcher(ctx, configService.absolutePluginRoot);
29264
29460
  }
29265
29461
  } else {
29266
- const rootDir = subPackageMeta ? path58.resolve(configService.absoluteSrcRoot, subPackageMeta.subPackage.root) : configService.absoluteSrcRoot;
29462
+ const rootDir = subPackageMeta ? path59.resolve(configService.absoluteSrcRoot, subPackageMeta.subPackage.root) : configService.absoluteSrcRoot;
29267
29463
  ensureSidecarWatcher(ctx, rootDir);
29268
29464
  if (!subPackageMeta && configService.absolutePluginRoot) {
29269
29465
  ensureSidecarWatcher(ctx, configService.absolutePluginRoot);
@@ -29294,7 +29490,7 @@ function createWatchChangeHook(state) {
29294
29490
  }
29295
29491
  if (isTemplateFile2 || configSuffix || isStyleFile2) {
29296
29492
  const basePath = configSuffix ? normalizedId.slice(0, -configSuffix.length) : (() => {
29297
- const ext = path58.extname(normalizedId);
29493
+ const ext = path59.extname(normalizedId);
29298
29494
  return ext ? normalizedId.slice(0, -ext.length) : normalizedId;
29299
29495
  })();
29300
29496
  const primaryScript = await findJsEntry(basePath);
@@ -29333,7 +29529,7 @@ function createWatchChangeHook(state) {
29333
29529
  let shouldMarkProjectConfigDirty = relativeCwd === projectConfigFileName || relativeCwd === projectPrivateConfigFileName;
29334
29530
  if (isMultiPlatformEnabled) {
29335
29531
  const projectConfigRoot = typeof multiPlatformConfig === "object" && multiPlatformConfig.projectConfigRoot?.trim() ? multiPlatformConfig.projectConfigRoot.trim() : "config";
29336
- const platformConfigDir = path58.join(projectConfigRoot, platform);
29532
+ const platformConfigDir = path59.join(projectConfigRoot, platform);
29337
29533
  const platformConfigPrefix = `${platformConfigDir}/`;
29338
29534
  shouldMarkProjectConfigDirty = relativeCwd.startsWith(platformConfigPrefix);
29339
29535
  }
@@ -29383,7 +29579,7 @@ function createCoreLifecyclePlugin(state) {
29383
29579
 
29384
29580
  // src/plugins/core/requireAnalysis.ts
29385
29581
  init_esm_shims();
29386
- import path59 from "pathe";
29582
+ import path60 from "pathe";
29387
29583
 
29388
29584
  // src/plugins/utils/ast.ts
29389
29585
  init_esm_shims();
@@ -29444,7 +29640,7 @@ function createRequireAnalysisPlugin(state) {
29444
29640
  return;
29445
29641
  }
29446
29642
  for (const requireModule of requireTokens) {
29447
- const absPath = path59.resolve(path59.dirname(moduleInfo.id), requireModule.value);
29643
+ const absPath = path60.resolve(path60.dirname(moduleInfo.id), requireModule.value);
29448
29644
  const resolved = await this.resolve(absPath, moduleInfo.id);
29449
29645
  if (!resolved) {
29450
29646
  continue;
@@ -29538,11 +29734,11 @@ function weappVite(ctx, subPackageMeta) {
29538
29734
  // src/plugins/css.ts
29539
29735
  init_esm_shims();
29540
29736
  import fs28 from "fs-extra";
29541
- import path61 from "pathe";
29737
+ import path62 from "pathe";
29542
29738
 
29543
29739
  // src/plugins/css/shared/sharedStyles.ts
29544
29740
  init_esm_shims();
29545
- import path60 from "pathe";
29741
+ import path61 from "pathe";
29546
29742
  import picomatch2 from "picomatch";
29547
29743
  var styleMatcherCache = /* @__PURE__ */ new WeakMap();
29548
29744
  function collectSharedStyleEntries(ctx, configService) {
@@ -29651,7 +29847,7 @@ function findSharedStylesForModule(modulePath, fileName, sharedStyles) {
29651
29847
  }
29652
29848
  function resolveImportSpecifiers(fileName, entries) {
29653
29849
  const posixFileName = toPosixPath(fileName);
29654
- const dir = path60.posix.dirname(posixFileName);
29850
+ const dir = path61.posix.dirname(posixFileName);
29655
29851
  const seen = /* @__PURE__ */ new Set();
29656
29852
  const specifiers = [];
29657
29853
  for (const entry of entries) {
@@ -29659,8 +29855,8 @@ function resolveImportSpecifiers(fileName, entries) {
29659
29855
  if (target === posixFileName) {
29660
29856
  continue;
29661
29857
  }
29662
- const relative3 = path60.posix.relative(dir, target);
29663
- let specifier = relative3 || path60.posix.basename(target);
29858
+ const relative3 = path61.posix.relative(dir, target);
29859
+ let specifier = relative3 || path61.posix.basename(target);
29664
29860
  if (!specifier || specifier === ".") {
29665
29861
  continue;
29666
29862
  }
@@ -29764,7 +29960,7 @@ async function handleBundleEntry(bundle, bundleKey, asset2, configService, share
29764
29960
  };
29765
29961
  if (bundleKey.endsWith(".wxss")) {
29766
29962
  const [rawOriginal] = asset2.originalFileNames ?? [];
29767
- const absOriginal = rawOriginal ? toAbsolute(rawOriginal) : path61.resolve(configService.absoluteSrcRoot, bundleKey);
29963
+ const absOriginal = rawOriginal ? toAbsolute(rawOriginal) : path62.resolve(configService.absoluteSrcRoot, bundleKey);
29768
29964
  const fileName = configService.relativeOutputPath(absOriginal);
29769
29965
  if (fileName) {
29770
29966
  emitted.add(toPosixPath(fileName));
@@ -29983,7 +30179,7 @@ init_esm_shims();
29983
30179
  init_esm_shims();
29984
30180
  import { createRequire as createRequire8 } from "module";
29985
30181
  import process8 from "process";
29986
- import path62 from "pathe";
30182
+ import path63 from "pathe";
29987
30183
 
29988
30184
  // src/plugins/vue/transform/styleRequest.ts
29989
30185
  init_esm_shims();
@@ -30073,7 +30269,7 @@ function ensureWevuInstalled(ctx) {
30073
30269
  }
30074
30270
  const configService = ctx.configService;
30075
30271
  const cwd = configService?.cwd ?? process8.cwd();
30076
- const require3 = createRequire8(path62.join(cwd, "package.json"));
30272
+ const require3 = createRequire8(path63.join(cwd, "package.json"));
30077
30273
  try {
30078
30274
  require3.resolve("wevu");
30079
30275
  wevuInstallState = "present";
@@ -30162,7 +30358,7 @@ init_esm_shims();
30162
30358
  // src/plugins/vue/transform/plugin.ts
30163
30359
  init_esm_shims();
30164
30360
  import fs33 from "fs-extra";
30165
- import path67 from "pathe";
30361
+ import path68 from "pathe";
30166
30362
  import { compileJsxFile as compileJsxFile2, compileVueFile as compileVueFile2 } from "wevu/compiler";
30167
30363
 
30168
30364
  // src/plugins/performance/onPageScrollDiagnostics.ts
@@ -30300,52 +30496,52 @@ function collectOnPageScrollPerformanceWarnings(code, filename) {
30300
30496
  }
30301
30497
  };
30302
30498
  traverse(ast, {
30303
- ObjectMethod(path81) {
30304
- const keyName = isStaticPropertyName(path81.node.key);
30499
+ ObjectMethod(path82) {
30500
+ const keyName = isStaticPropertyName(path82.node.key);
30305
30501
  if (keyName !== "onPageScroll") {
30306
30502
  return;
30307
30503
  }
30308
- reportInspection(path81, path81.node, "onPageScroll");
30504
+ reportInspection(path82, path82.node, "onPageScroll");
30309
30505
  },
30310
- ObjectProperty(path81) {
30311
- if (path81.node.computed) {
30506
+ ObjectProperty(path82) {
30507
+ if (path82.node.computed) {
30312
30508
  return;
30313
30509
  }
30314
- const keyName = isStaticPropertyName(path81.node.key);
30510
+ const keyName = isStaticPropertyName(path82.node.key);
30315
30511
  if (keyName !== "onPageScroll") {
30316
30512
  return;
30317
30513
  }
30318
- const value = path81.node.value;
30514
+ const value = path82.node.value;
30319
30515
  if (value.type !== "FunctionExpression" && value.type !== "ArrowFunctionExpression") {
30320
30516
  return;
30321
30517
  }
30322
- reportInspection(path81.get("value"), value, "onPageScroll");
30518
+ reportInspection(path82.get("value"), value, "onPageScroll");
30323
30519
  },
30324
- CallExpression(path81) {
30325
- if (!isOnPageScrollCallee(path81.node.callee, onPageScrollHookNames, namespaceImports)) {
30520
+ CallExpression(path82) {
30521
+ if (!isOnPageScrollCallee(path82.node.callee, onPageScrollHookNames, namespaceImports)) {
30326
30522
  return;
30327
30523
  }
30328
- const arg0 = path81.node.arguments[0];
30524
+ const arg0 = path82.node.arguments[0];
30329
30525
  if (!arg0 || arg0.type === "SpreadElement") {
30330
30526
  return;
30331
30527
  }
30332
30528
  if (arg0.type !== "FunctionExpression" && arg0.type !== "ArrowFunctionExpression") {
30333
30529
  return;
30334
30530
  }
30335
- reportInspection(path81.get("arguments.0"), arg0, "onPageScroll(...)");
30531
+ reportInspection(path82.get("arguments.0"), arg0, "onPageScroll(...)");
30336
30532
  },
30337
- OptionalCallExpression(path81) {
30338
- if (!isOnPageScrollCallee(path81.node.callee, onPageScrollHookNames, namespaceImports)) {
30533
+ OptionalCallExpression(path82) {
30534
+ if (!isOnPageScrollCallee(path82.node.callee, onPageScrollHookNames, namespaceImports)) {
30339
30535
  return;
30340
30536
  }
30341
- const arg0 = path81.node.arguments[0];
30537
+ const arg0 = path82.node.arguments[0];
30342
30538
  if (!arg0 || arg0.type === "SpreadElement") {
30343
30539
  return;
30344
30540
  }
30345
30541
  if (arg0.type !== "FunctionExpression" && arg0.type !== "ArrowFunctionExpression") {
30346
30542
  return;
30347
30543
  }
30348
- reportInspection(path81.get("arguments.0"), arg0, "onPageScroll(...)");
30544
+ reportInspection(path82.get("arguments.0"), arg0, "onPageScroll(...)");
30349
30545
  }
30350
30546
  });
30351
30547
  return warnings;
@@ -30353,7 +30549,7 @@ function collectOnPageScrollPerformanceWarnings(code, filename) {
30353
30549
 
30354
30550
  // src/plugins/wevu.ts
30355
30551
  init_esm_shims();
30356
- import path63 from "pathe";
30552
+ import path64 from "pathe";
30357
30553
  import {
30358
30554
  createPageEntryMatcher,
30359
30555
  injectWevuPageFeaturesInJsWithResolver
@@ -30433,7 +30629,7 @@ function createWevuAutoPageFeaturesPlugin(ctx) {
30433
30629
  return null;
30434
30630
  }
30435
30631
  const filename = toAbsoluteId(sourceId, configService, void 0, { base: "cwd" });
30436
- if (!filename || !path63.isAbsolute(filename)) {
30632
+ if (!filename || !path64.isAbsolute(filename)) {
30437
30633
  return null;
30438
30634
  }
30439
30635
  if (!await pageMatcher.isPageFile(filename)) {
@@ -33213,7 +33409,7 @@ function scanWxml(wxml, options) {
33213
33409
 
33214
33410
  // src/plugins/vue/transform/classStyle.ts
33215
33411
  init_esm_shims();
33216
- import path64 from "pathe";
33412
+ import path65 from "pathe";
33217
33413
  import { resolveClassStyleWxsLocation } from "wevu/compiler";
33218
33414
  function resolveClassStylePackageRoot(ctx, relativeBase, configService) {
33219
33415
  const currentRoot = normalizeRoot(configService.currentSubPackageRoot ?? "");
@@ -33239,7 +33435,7 @@ function resolveClassStylePackageRoot(ctx, relativeBase, configService) {
33239
33435
  function resolveClassStyleWxsLocationForBase(ctx, relativeBase, extension, configService) {
33240
33436
  const classStyleWxsShared = configService.weappViteConfig?.vue?.template?.classStyleWxsShared ?? true;
33241
33437
  const packageRoot = classStyleWxsShared ? resolveClassStylePackageRoot(ctx, relativeBase, configService) : (() => {
33242
- const dir = path64.posix.dirname(toPosixPath(relativeBase));
33438
+ const dir = path65.posix.dirname(toPosixPath(relativeBase));
33243
33439
  return dir === "." ? "" : dir;
33244
33440
  })();
33245
33441
  return resolveClassStyleWxsLocation({ relativeBase, extension, packageRoot });
@@ -33566,12 +33762,12 @@ function emitClassStyleWxsAssetIfMissing(ctx, bundle, fileName, source) {
33566
33762
  // src/plugins/vue/transform/fallbackEntries.ts
33567
33763
  init_esm_shims();
33568
33764
  import fs31 from "fs-extra";
33569
- import path66 from "pathe";
33765
+ import path67 from "pathe";
33570
33766
 
33571
33767
  // src/plugins/vue/transform/collectVuePages.ts
33572
33768
  init_esm_shims();
33573
33769
  import fs30 from "fs-extra";
33574
- import path65 from "pathe";
33770
+ import path66 from "pathe";
33575
33771
  var VUE_LIKE_EXTENSIONS2 = [".vue", ".tsx", ".jsx"];
33576
33772
  function isVueLikeFile2(file) {
33577
33773
  return VUE_LIKE_EXTENSIONS2.some((ext) => file.endsWith(ext));
@@ -33589,7 +33785,7 @@ async function collectVuePages(root) {
33589
33785
  try {
33590
33786
  const entries = await fs30.readdir(root);
33591
33787
  for (const entry of entries) {
33592
- const full = path65.join(root, entry);
33788
+ const full = path66.join(root, entry);
33593
33789
  const stat5 = await fs30.stat(full);
33594
33790
  if (stat5.isDirectory()) {
33595
33791
  const nested = await collectVuePages(full);
@@ -33609,7 +33805,7 @@ async function collectFallbackPageEntryIds(configService, scanService) {
33609
33805
  if (scanService?.appEntry?.json?.pages?.length) {
33610
33806
  pageList = scanService.appEntry.json.pages;
33611
33807
  } else {
33612
- const appJsonPath = path66.join(configService.cwd, "dist", "app.json");
33808
+ const appJsonPath = path67.join(configService.cwd, "dist", "app.json");
33613
33809
  try {
33614
33810
  const appJsonContent = await fs31.readFile(appJsonPath, "utf-8");
33615
33811
  const appJson = JSON.parse(appJsonContent);
@@ -33618,8 +33814,8 @@ async function collectFallbackPageEntryIds(configService, scanService) {
33618
33814
  }
33619
33815
  }
33620
33816
  const collectedEntries = /* @__PURE__ */ new Set();
33621
- pageList.forEach((p) => collectedEntries.add(path66.join(configService.absoluteSrcRoot, p)));
33622
- const extraVueFiles = await collectVuePages(path66.join(configService.absoluteSrcRoot, "pages"));
33817
+ pageList.forEach((p) => collectedEntries.add(path67.join(configService.absoluteSrcRoot, p)));
33818
+ const extraVueFiles = await collectVuePages(path67.join(configService.absoluteSrcRoot, "pages"));
33623
33819
  extraVueFiles.forEach((f) => collectedEntries.add(f.slice(0, -4)));
33624
33820
  return collectedEntries;
33625
33821
  }
@@ -33879,15 +34075,15 @@ function collectIdentifiersFromExpression(expression) {
33879
34075
  return collected;
33880
34076
  }
33881
34077
  traverse(ast, {
33882
- Identifier(path81) {
33883
- if (!path81.isReferencedIdentifier()) {
34078
+ Identifier(path82) {
34079
+ if (!path82.isReferencedIdentifier()) {
33884
34080
  return;
33885
34081
  }
33886
- const name = path81.node.name;
34082
+ const name = path82.node.name;
33887
34083
  if (name === "__weappViteExpr") {
33888
34084
  return;
33889
34085
  }
33890
- if (path81.scope.hasBinding(name, true)) {
34086
+ if (path82.scope.hasBinding(name, true)) {
33891
34087
  return;
33892
34088
  }
33893
34089
  if (JS_GLOBAL_IDENTIFIERS.has(name)) {
@@ -33895,15 +34091,15 @@ function collectIdentifiersFromExpression(expression) {
33895
34091
  }
33896
34092
  collected.add(name);
33897
34093
  },
33898
- MemberExpression(path81) {
33899
- const member = path81.node;
34094
+ MemberExpression(path82) {
34095
+ const member = path82.node;
33900
34096
  if (member.computed || member.object.type !== "ThisExpression" || member.property.type !== "Identifier") {
33901
34097
  return;
33902
34098
  }
33903
34099
  collected.add(member.property.name);
33904
34100
  },
33905
- OptionalMemberExpression(path81) {
33906
- const member = path81.node;
34101
+ OptionalMemberExpression(path82) {
34102
+ const member = path82.node;
33907
34103
  if (member.computed || member.object.type !== "ThisExpression" || member.property.type !== "Identifier") {
33908
34104
  return;
33909
34105
  }
@@ -33936,15 +34132,15 @@ function injectSetDataPickInJs(source, pickKeys) {
33936
34132
  const ast = parseJsLike(source);
33937
34133
  const candidateOptions = /* @__PURE__ */ new Set();
33938
34134
  traverse(ast, {
33939
- CallExpression(path81) {
33940
- if (!isTargetWevuComponentCall(path81.node.callee)) {
34135
+ CallExpression(path82) {
34136
+ if (!isTargetWevuComponentCall(path82.node.callee)) {
33941
34137
  return;
33942
34138
  }
33943
- const firstArg = path81.node.arguments[0];
34139
+ const firstArg = path82.node.arguments[0];
33944
34140
  if (!firstArg || firstArg.type === "SpreadElement") {
33945
34141
  return;
33946
34142
  }
33947
- const resolvedOptions = resolveOptionsObjectExpression2(firstArg, path81.scope);
34143
+ const resolvedOptions = resolveOptionsObjectExpression2(firstArg, path82.scope);
33948
34144
  if (resolvedOptions) {
33949
34145
  candidateOptions.add(resolvedOptions);
33950
34146
  }
@@ -34634,7 +34830,7 @@ function createVueTransformPlugin(ctx) {
34634
34830
  }
34635
34831
  const sourceId = getSourceFromVirtualId(id);
34636
34832
  const filename = toAbsoluteId(sourceId, configService, void 0, { base: "cwd" });
34637
- if (!filename || !path67.isAbsolute(filename)) {
34833
+ if (!filename || !path68.isAbsolute(filename)) {
34638
34834
  return null;
34639
34835
  }
34640
34836
  if (typeof this.addWatchFile === "function") {
@@ -34877,12 +35073,12 @@ init_esm_shims();
34877
35073
  import { createHash as createHash3 } from "crypto";
34878
35074
  import { removeExtension as removeExtension2 } from "@weapp-core/shared";
34879
35075
  import fs34 from "fs-extra";
34880
- import path68 from "pathe";
35076
+ import path69 from "pathe";
34881
35077
  async function resolveWorkerEntry(ctx, entry) {
34882
35078
  const { configService, scanService } = ctx;
34883
- const relativeEntryPath = path68.join(scanService.workersDir, entry);
35079
+ const relativeEntryPath = path69.join(scanService.workersDir, entry);
34884
35080
  const key = removeExtension2(relativeEntryPath);
34885
- const absoluteEntry = path68.resolve(configService.absoluteSrcRoot, relativeEntryPath);
35081
+ const absoluteEntry = path69.resolve(configService.absoluteSrcRoot, relativeEntryPath);
34886
35082
  if (isJsOrTs(entry)) {
34887
35083
  const exists = await fs34.pathExists(absoluteEntry);
34888
35084
  if (!exists) {
@@ -34919,12 +35115,12 @@ function createWorkerBuildPlugin(ctx) {
34919
35115
  options.chunkFileNames = (chunkInfo) => {
34920
35116
  const workersDir = scanService.workersDir ?? "";
34921
35117
  if (chunkInfo.isDynamicEntry) {
34922
- return path68.join(workersDir, "[name].js");
35118
+ return path69.join(workersDir, "[name].js");
34923
35119
  }
34924
35120
  const sourceId = chunkInfo.facadeModuleId ?? chunkInfo.moduleIds[0];
34925
35121
  const hashBase = typeof sourceId === "string" ? configService.relativeCwd(sourceId) : chunkInfo.name;
34926
35122
  const stableHash = createHash3("sha256").update(hashBase).digest("base64url").slice(0, 8);
34927
- return path68.join(workersDir, `${chunkInfo.name}-${stableHash}.js`);
35123
+ return path69.join(workersDir, `${chunkInfo.name}-${stableHash}.js`);
34928
35124
  };
34929
35125
  }
34930
35126
  };
@@ -34940,7 +35136,7 @@ function workers(ctx) {
34940
35136
  init_esm_shims();
34941
35137
  import { removeExtension as removeExtension3 } from "@weapp-core/shared";
34942
35138
  import fs35 from "fs-extra";
34943
- import path69 from "pathe";
35139
+ import path70 from "pathe";
34944
35140
  var wxsCodeCache = new L({
34945
35141
  max: 512
34946
35142
  });
@@ -34967,13 +35163,13 @@ async function transformWxsFile(state, wxsPath) {
34967
35163
  if (typeof result?.code === "string") {
34968
35164
  code = result.code;
34969
35165
  }
34970
- const dirname5 = path69.dirname(wxsPath);
35166
+ const dirname5 = path70.dirname(wxsPath);
34971
35167
  await Promise.all(
34972
35168
  importees.map(({ source }) => {
34973
35169
  return transformWxsFile.call(
34974
35170
  this,
34975
35171
  state,
34976
- path69.resolve(dirname5, source)
35172
+ path70.resolve(dirname5, source)
34977
35173
  );
34978
35174
  })
34979
35175
  );
@@ -35001,7 +35197,7 @@ async function handleWxsDeps(state, deps, absPath) {
35001
35197
  if (!jsExtensions.includes(dep.attrs.lang) && !arr) {
35002
35198
  return;
35003
35199
  }
35004
- const wxsPath = path69.resolve(path69.dirname(absPath), dep.value);
35200
+ const wxsPath = path70.resolve(path70.dirname(absPath), dep.value);
35005
35201
  await transformWxsFile.call(this, state, wxsPath);
35006
35202
  })
35007
35203
  );
@@ -35023,7 +35219,7 @@ async function handleWxsDepsFromBundle(state, bundle) {
35023
35219
  } catch {
35024
35220
  return;
35025
35221
  }
35026
- const absPath = path69.resolve(state.ctx.configService.absoluteSrcRoot, fileName);
35222
+ const absPath = path70.resolve(state.ctx.configService.absoluteSrcRoot, fileName);
35027
35223
  await handleWxsDeps.call(this, state, deps, absPath);
35028
35224
  })
35029
35225
  );
@@ -35167,6 +35363,7 @@ function arrangePlugins(config, ctx, subPackageMeta) {
35167
35363
  }
35168
35364
 
35169
35365
  // src/runtime/config/internal/merge/miniprogram.ts
35366
+ var PACKAGE_NAME_REGEX = /[-/\\^$*+?.()|[\]{}]/g;
35170
35367
  function mergeMiniprogram(options, ...configs) {
35171
35368
  const {
35172
35369
  ctx,
@@ -35188,7 +35385,7 @@ function mergeMiniprogram(options, ...configs) {
35188
35385
  if (packageJson?.dependencies) {
35189
35386
  external.push(
35190
35387
  ...Object.keys(packageJson.dependencies).map((pkg) => {
35191
- return new RegExp(`^${pkg.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")}(\\/|$)`);
35388
+ return new RegExp(`^${pkg.replace(PACKAGE_NAME_REGEX, "\\$&")}(\\/|$)`);
35192
35389
  })
35193
35390
  );
35194
35391
  }
@@ -35203,17 +35400,17 @@ function mergeMiniprogram(options, ...configs) {
35203
35400
  };
35204
35401
  if (isDev) {
35205
35402
  const watchInclude = [
35206
- path70.join(cwd, srcRoot, "**")
35403
+ path71.join(cwd, srcRoot, "**")
35207
35404
  ];
35208
35405
  const pluginRootConfig = config.weapp?.pluginRoot;
35209
35406
  if (pluginRootConfig) {
35210
- const absolutePluginRoot = path70.resolve(cwd, pluginRootConfig);
35211
- const relativeToSrc = path70.relative(
35212
- path70.resolve(cwd, srcRoot),
35407
+ const absolutePluginRoot = path71.resolve(cwd, pluginRootConfig);
35408
+ const relativeToSrc = path71.relative(
35409
+ path71.resolve(cwd, srcRoot),
35213
35410
  absolutePluginRoot
35214
35411
  );
35215
- const pluginPatternBase = relativeToSrc.startsWith("..") ? absolutePluginRoot : path70.join(cwd, srcRoot, relativeToSrc);
35216
- watchInclude.push(path70.join(pluginPatternBase, "**"));
35412
+ const pluginPatternBase = relativeToSrc.startsWith("..") ? absolutePluginRoot : path71.join(cwd, srcRoot, relativeToSrc);
35413
+ watchInclude.push(path71.join(pluginPatternBase, "**"));
35217
35414
  }
35218
35415
  const inline = defu5(
35219
35416
  config,
@@ -35227,7 +35424,7 @@ function mergeMiniprogram(options, ...configs) {
35227
35424
  watch: {
35228
35425
  exclude: [
35229
35426
  ...defaultExcluded,
35230
- mpDistRoot ? path70.join(cwd, mpDistRoot, "**") : path70.join(cwd, "dist", "**")
35427
+ mpDistRoot ? path71.join(cwd, mpDistRoot, "**") : path71.join(cwd, "dist", "**")
35231
35428
  ],
35232
35429
  include: watchInclude
35233
35430
  },
@@ -35245,6 +35442,7 @@ function mergeMiniprogram(options, ...configs) {
35245
35442
  ...inline.define ?? {},
35246
35443
  __VITE_IS_MODERN__: "false"
35247
35444
  };
35445
+ applyWeappViteHostMeta(inline, "miniprogram");
35248
35446
  stripRollupOptions(inline);
35249
35447
  arrangePlugins(inline, ctx, subPackageMeta);
35250
35448
  injectBuiltinAliases(inline);
@@ -35271,6 +35469,7 @@ function mergeMiniprogram(options, ...configs) {
35271
35469
  ...inlineConfig.define ?? {},
35272
35470
  __VITE_IS_MODERN__: "false"
35273
35471
  };
35472
+ applyWeappViteHostMeta(inlineConfig, "miniprogram");
35274
35473
  stripRollupOptions(inlineConfig);
35275
35474
  arrangePlugins(inlineConfig, ctx, subPackageMeta);
35276
35475
  inlineConfig.logLevel = "info";
@@ -35344,9 +35543,8 @@ function mergeWeb(options, ...configs) {
35344
35543
  inline.plugins = mergedPlugins;
35345
35544
  inline.build ??= {};
35346
35545
  inline.build.outDir = web.outDir;
35347
- if (inline.build.emptyOutDir == null) {
35348
- inline.build.emptyOutDir = !isDev;
35349
- }
35546
+ inline.build.emptyOutDir ??= !isDev;
35547
+ applyWeappViteHostMeta(inline, "web");
35350
35548
  inline.define = defu6(inline.define ?? {}, getDefineImportMetaEnv());
35351
35549
  injectBuiltinAliases(inline);
35352
35550
  return inline;
@@ -35382,6 +35580,7 @@ function mergeWorkers(options, ...configs) {
35382
35580
  }
35383
35581
  }
35384
35582
  );
35583
+ applyWeappViteHostMeta(inline, "miniprogram");
35385
35584
  stripRollupOptions(inline);
35386
35585
  injectBuiltinAliases(inline);
35387
35586
  return inline;
@@ -35399,6 +35598,7 @@ function mergeWorkers(options, ...configs) {
35399
35598
  }
35400
35599
  }
35401
35600
  );
35601
+ applyWeappViteHostMeta(inlineConfig, "miniprogram");
35402
35602
  stripRollupOptions(inlineConfig);
35403
35603
  inlineConfig.logLevel = "info";
35404
35604
  injectBuiltinAliases(inlineConfig);
@@ -35501,14 +35701,14 @@ function createConfigService(ctx) {
35501
35701
  if (!pluginRootConfig) {
35502
35702
  return void 0;
35503
35703
  }
35504
- return path71.resolve(options.cwd, pluginRootConfig);
35704
+ return path72.resolve(options.cwd, pluginRootConfig);
35505
35705
  };
35506
35706
  const resolvePluginSourceBase = () => {
35507
35707
  const absolutePluginRoot = resolveAbsolutePluginRoot();
35508
35708
  if (!absolutePluginRoot) {
35509
35709
  return void 0;
35510
35710
  }
35511
- return toPosixPath(path71.basename(absolutePluginRoot));
35711
+ return toPosixPath(path72.basename(absolutePluginRoot));
35512
35712
  };
35513
35713
  const resolveAbsolutePluginOutputRoot = () => {
35514
35714
  const absolutePluginRoot = resolveAbsolutePluginRoot();
@@ -35517,19 +35717,19 @@ function createConfigService(ctx) {
35517
35717
  }
35518
35718
  const configured = options.projectConfig?.pluginRoot;
35519
35719
  if (configured) {
35520
- return path71.resolve(options.cwd, configured);
35720
+ return path72.resolve(options.cwd, configured);
35521
35721
  }
35522
- const outDir = path71.resolve(options.cwd, options.mpDistRoot ?? "");
35523
- const pluginBase = path71.basename(absolutePluginRoot);
35524
- return path71.resolve(outDir, pluginBase);
35722
+ const outDir = path72.resolve(options.cwd, options.mpDistRoot ?? "");
35723
+ const pluginBase = path72.basename(absolutePluginRoot);
35724
+ return path72.resolve(outDir, pluginBase);
35525
35725
  };
35526
35726
  const resolvePluginOutputBasePosix = () => {
35527
35727
  const absoluteOutputRoot = resolveAbsolutePluginOutputRoot();
35528
35728
  if (!absoluteOutputRoot) {
35529
35729
  return void 0;
35530
35730
  }
35531
- const outDir = path71.resolve(options.cwd, options.mpDistRoot ?? "");
35532
- const normalized = normalizeRelativePath(path71.relative(outDir, absoluteOutputRoot));
35731
+ const outDir = path72.resolve(options.cwd, options.mpDistRoot ?? "");
35732
+ const normalized = normalizeRelativePath(path72.relative(outDir, absoluteOutputRoot));
35533
35733
  if (!normalized || normalized === ".") {
35534
35734
  return resolvePluginSourceBase();
35535
35735
  }
@@ -35665,7 +35865,7 @@ function createConfigService(ctx) {
35665
35865
  return options.mpDistRoot;
35666
35866
  },
35667
35867
  get outDir() {
35668
- return path71.resolve(options.cwd, options.mpDistRoot ?? "");
35868
+ return path72.resolve(options.cwd, options.mpDistRoot ?? "");
35669
35869
  },
35670
35870
  get currentSubPackageRoot() {
35671
35871
  return options.currentSubPackageRoot;
@@ -35701,7 +35901,7 @@ function createConfigService(ctx) {
35701
35901
  return resolveAbsolutePluginOutputRoot();
35702
35902
  },
35703
35903
  get absoluteSrcRoot() {
35704
- return path71.resolve(options.cwd, options.srcRoot);
35904
+ return path72.resolve(options.cwd, options.srcRoot);
35705
35905
  },
35706
35906
  get mode() {
35707
35907
  return options.mode;
@@ -35725,27 +35925,27 @@ function createConfigService(ctx) {
35725
35925
  return options.weappLibOutputMap;
35726
35926
  },
35727
35927
  relativeCwd(p) {
35728
- return normalizeRelativePath(path71.relative(options.cwd, p));
35928
+ return normalizeRelativePath(path72.relative(options.cwd, p));
35729
35929
  },
35730
35930
  relativeSrcRoot(p) {
35731
35931
  return options.relativeSrcRoot(p);
35732
35932
  },
35733
35933
  relativeAbsoluteSrcRoot(p) {
35734
- const absoluteSrcRoot = path71.resolve(options.cwd, options.srcRoot);
35934
+ const absoluteSrcRoot = path72.resolve(options.cwd, options.srcRoot);
35735
35935
  const absolutePluginRoot = resolveAbsolutePluginRoot();
35736
35936
  if (absolutePluginRoot) {
35737
- const relativeToPlugin = normalizeRelativePath(path71.relative(absolutePluginRoot, p));
35937
+ const relativeToPlugin = normalizeRelativePath(path72.relative(absolutePluginRoot, p));
35738
35938
  if (!relativeToPlugin.startsWith("..")) {
35739
- const pluginBase = path71.basename(absolutePluginRoot);
35939
+ const pluginBase = path72.basename(absolutePluginRoot);
35740
35940
  const posixBase = toPosixPath(pluginBase);
35741
35941
  return relativeToPlugin ? `${posixBase}/${relativeToPlugin}` : posixBase;
35742
35942
  }
35743
35943
  }
35744
- const relativeFromSrc = normalizeRelativePath(path71.relative(absoluteSrcRoot, p));
35944
+ const relativeFromSrc = normalizeRelativePath(path72.relative(absoluteSrcRoot, p));
35745
35945
  if (!relativeFromSrc.startsWith("..")) {
35746
35946
  return relativeFromSrc;
35747
35947
  }
35748
- const relativeFromCwd = normalizeRelativePath(path71.relative(options.cwd, p));
35948
+ const relativeFromCwd = normalizeRelativePath(path72.relative(options.cwd, p));
35749
35949
  return relativeFromCwd;
35750
35950
  },
35751
35951
  relativeOutputPath(p) {
@@ -35758,7 +35958,7 @@ function createConfigService(ctx) {
35758
35958
  const base = normalizeRelativePath(removeExtensionDeep13(relative3));
35759
35959
  const mapped = libOutputMap.get(base);
35760
35960
  if (mapped) {
35761
- const ext = path71.extname(relative3);
35961
+ const ext = path72.extname(relative3);
35762
35962
  const fileName = ext ? `${mapped}${ext}` : mapped;
35763
35963
  return remapPluginRelativePath(fileName);
35764
35964
  }
@@ -35884,7 +36084,7 @@ init_esm_shims();
35884
36084
  // src/runtime/npmPlugin/service.ts
35885
36085
  init_esm_shims();
35886
36086
  import fs39 from "fs-extra";
35887
- import path75 from "pathe";
36087
+ import path76 from "pathe";
35888
36088
 
35889
36089
  // src/runtime/npmPlugin/builder.ts
35890
36090
  init_esm_shims();
@@ -35893,13 +36093,27 @@ import process11 from "process";
35893
36093
  import * as t2 from "@babel/types";
35894
36094
  import { defu as defu9, isObject as isObject10 } from "@weapp-core/shared";
35895
36095
  import fs37 from "fs-extra";
35896
- import path72 from "pathe";
36096
+ import path73 from "pathe";
35897
36097
  import { build as viteBuild } from "vite";
35898
36098
  var ALIPAY_EXTENSION_MAP = {
35899
36099
  ".wxml": ".axml",
35900
36100
  ".wxss": ".acss",
35901
36101
  ".wxs": ".sjs"
35902
36102
  };
36103
+ var WX_TEMPLATE_REFERENCE_RE = /\.wxml\b|\.wxss\b|\.wxs\b/;
36104
+ var ESM_SYNTAX_RE = /\bimport\s|\bexport\s/;
36105
+ var NULLISH_COALESCING_RE = /\?\?/;
36106
+ var WX_DIRECTIVE_RE = /\bwx:(?:if|elif|else|for|for-item|for-index|key)\b/;
36107
+ var WX_DIRECTIVE_CAPTURE_RE = /\bwx:(if|elif|else|for|for-item|for-index|key)\b/g;
36108
+ var WXS_TAG_RE = /<\s*(?:\/\s*)?wxs\b/;
36109
+ var WXS_CLOSING_TAG_RE = /<\s*\/\s*wxs\b/g;
36110
+ var ELSE_ATTRIBUTE_RE = /\selse(?=[\s/>])/;
36111
+ var IMPORT_SJS_TAG_RE = /<import-sjs([\s\S]*?)>/g;
36112
+ var SRC_ATTRIBUTE_RE = /\bsrc\s*=\s*/g;
36113
+ var MODULE_ATTRIBUTE_RE = /\bmodule\s*=\s*/g;
36114
+ var WXML_EXTENSION_RE = /\.wxml\b/g;
36115
+ var WXSS_EXTENSION_RE = /\.wxss\b/g;
36116
+ var WXS_EXTENSION_RE = /\.wxs\b/g;
35903
36117
  var ALIPAY_TEXT_FILE_EXTENSIONS = /* @__PURE__ */ new Set([
35904
36118
  ".js",
35905
36119
  ".json",
@@ -35920,7 +36134,7 @@ async function collectFiles(root) {
35920
36134
  }
35921
36135
  const entries = await fs37.readdir(current2, { withFileTypes: true });
35922
36136
  for (const entry of entries) {
35923
- const filePath = path72.resolve(current2, entry.name);
36137
+ const filePath = path73.resolve(current2, entry.name);
35924
36138
  if (entry.isDirectory()) {
35925
36139
  stack.push(filePath);
35926
36140
  } else if (entry.isFile()) {
@@ -35935,15 +36149,15 @@ async function shouldRebuildCachedAlipayMiniprogramPackage(pkgRoot, outDir, sour
35935
36149
  return true;
35936
36150
  }
35937
36151
  if (sourceRoot && alipayNpmDistDirName === "node_modules") {
35938
- const sourceEsRoot = path72.resolve(sourceRoot, "es");
35939
- const targetEsRoot = path72.resolve(pkgRoot, "es");
36152
+ const sourceEsRoot = path73.resolve(sourceRoot, "es");
36153
+ const targetEsRoot = path73.resolve(pkgRoot, "es");
35940
36154
  if (await fs37.pathExists(sourceEsRoot) && !await fs37.pathExists(targetEsRoot)) {
35941
36155
  return true;
35942
36156
  }
35943
36157
  }
35944
36158
  const files = await collectFiles(pkgRoot);
35945
36159
  for (const filePath of files) {
35946
- const ext = path72.extname(filePath);
36160
+ const ext = path73.extname(filePath);
35947
36161
  if (ext === ".wxml" || ext === ".wxss" || ext === ".wxs") {
35948
36162
  return true;
35949
36163
  }
@@ -35956,23 +36170,23 @@ async function shouldRebuildCachedAlipayMiniprogramPackage(pkgRoot, outDir, sour
35956
36170
  } catch {
35957
36171
  continue;
35958
36172
  }
35959
- if (/\.wxml\b|\.wxss\b|\.wxs\b/.test(source)) {
36173
+ if (WX_TEMPLATE_REFERENCE_RE.test(source)) {
35960
36174
  return true;
35961
36175
  }
35962
- if (ext === ".js" && (/\bimport\s|\bexport\s/.test(source) || /\?\?/.test(source))) {
36176
+ if (ext === ".js" && (ESM_SYNTAX_RE.test(source) || NULLISH_COALESCING_RE.test(source))) {
35963
36177
  return true;
35964
36178
  }
35965
- if ((ext === ".axml" || ext === ".wxml") && (/\bwx:(?:if|elif|else|for|for-item|for-index|key)\b/.test(source) || /<\s*(?:\/\s*)?wxs\b/.test(source) || /\selse(?=[\s/>])/.test(source))) {
36179
+ if ((ext === ".axml" || ext === ".wxml") && (WX_DIRECTIVE_RE.test(source) || WXS_TAG_RE.test(source) || ELSE_ATTRIBUTE_RE.test(source))) {
35966
36180
  return true;
35967
36181
  }
35968
36182
  }
35969
- const nestedRoot = path72.resolve(pkgRoot, "miniprogram_npm");
36183
+ const nestedRoot = path73.resolve(pkgRoot, "miniprogram_npm");
35970
36184
  if (!await fs37.pathExists(nestedRoot)) {
35971
36185
  return false;
35972
36186
  }
35973
36187
  const entries = await fs37.readdir(nestedRoot);
35974
36188
  for (const name of entries) {
35975
- const target = path72.resolve(outDir, name);
36189
+ const target = path73.resolve(outDir, name);
35976
36190
  if (!await fs37.pathExists(target)) {
35977
36191
  return true;
35978
36192
  }
@@ -35980,15 +36194,15 @@ async function shouldRebuildCachedAlipayMiniprogramPackage(pkgRoot, outDir, sour
35980
36194
  return false;
35981
36195
  }
35982
36196
  function hasEsmSyntax(source) {
35983
- return /\bimport\s|\bexport\s/.test(source);
36197
+ return ESM_SYNTAX_RE.test(source);
35984
36198
  }
35985
36199
  function rewriteAlipayWxmlSyntax(source) {
35986
- return source.replace(/\bwx:(if|elif|else|for|for-item|for-index|key)\b/g, (_2, directive) => `a:${directive}`).replace(/<\s*\/\s*wxs\b/g, "</import-sjs").replace(/<\s*wxs\b/g, "<import-sjs").replace(/<import-sjs([\s\S]*?)>/g, (tag) => {
35987
- return tag.replace(/\bsrc\s*=\s*/g, "from=").replace(/\bmodule\s*=\s*/g, "name=");
35988
- }).replace(/\selse(?=[\s/>])/g, " a:else");
36200
+ return source.replace(WX_DIRECTIVE_CAPTURE_RE, (_2, directive) => `a:${directive}`).replace(WXS_CLOSING_TAG_RE, "</import-sjs").replace(WXS_TAG_RE, "<import-sjs").replace(IMPORT_SJS_TAG_RE, (tag) => {
36201
+ return tag.replace(SRC_ATTRIBUTE_RE, "from=").replace(MODULE_ATTRIBUTE_RE, "name=");
36202
+ }).replace(ELSE_ATTRIBUTE_RE, " a:else");
35989
36203
  }
35990
36204
  function rewriteAlipayExtensionReferences(source) {
35991
- return source.replace(/\.wxml\b/g, ".axml").replace(/\.wxss\b/g, ".acss").replace(/\.wxs\b/g, ".sjs");
36205
+ return source.replace(WXML_EXTENSION_RE, ".axml").replace(WXSS_EXTENSION_RE, ".acss").replace(WXS_EXTENSION_RE, ".sjs");
35992
36206
  }
35993
36207
  function transformWxmlToAxmlForAlipay(source) {
35994
36208
  return rewriteAlipayWxmlSyntax(source);
@@ -36028,11 +36242,11 @@ async function transformJsModuleToCjsForAlipay(source) {
36028
36242
  let transformed = false;
36029
36243
  const exportAssignments = [];
36030
36244
  traverse(ast, {
36031
- ImportDeclaration(path81) {
36032
- const sourceLiteral = t2.stringLiteral(path81.node.source.value);
36033
- const specifiers = path81.node.specifiers ?? [];
36245
+ ImportDeclaration(path82) {
36246
+ const sourceLiteral = t2.stringLiteral(path82.node.source.value);
36247
+ const specifiers = path82.node.specifiers ?? [];
36034
36248
  if (specifiers.length === 0) {
36035
- path81.replaceWith(
36249
+ path82.replaceWith(
36036
36250
  t2.expressionStatement(
36037
36251
  t2.callExpression(t2.identifier("require"), [sourceLiteral])
36038
36252
  )
@@ -36040,7 +36254,7 @@ async function transformJsModuleToCjsForAlipay(source) {
36040
36254
  transformed = true;
36041
36255
  return;
36042
36256
  }
36043
- const requireId = path81.scope.generateUidIdentifier("imported");
36257
+ const requireId = path82.scope.generateUidIdentifier("imported");
36044
36258
  const statements = [
36045
36259
  t2.variableDeclaration("const", [
36046
36260
  t2.variableDeclarator(
@@ -36087,23 +36301,23 @@ async function transformJsModuleToCjsForAlipay(source) {
36087
36301
  ])
36088
36302
  );
36089
36303
  }
36090
- path81.replaceWithMultiple(statements);
36304
+ path82.replaceWithMultiple(statements);
36091
36305
  transformed = true;
36092
36306
  },
36093
- ExportDefaultDeclaration(path81) {
36094
- const declaration = path81.node.declaration;
36307
+ ExportDefaultDeclaration(path82) {
36308
+ const declaration = path82.node.declaration;
36095
36309
  if (t2.isFunctionDeclaration(declaration) || t2.isClassDeclaration(declaration)) {
36096
- const exportId = declaration.id ?? path81.scope.generateUidIdentifier("defaultExport");
36310
+ const exportId = declaration.id ?? path82.scope.generateUidIdentifier("defaultExport");
36097
36311
  if (!declaration.id) {
36098
36312
  declaration.id = exportId;
36099
36313
  }
36100
- path81.replaceWith(declaration);
36314
+ path82.replaceWith(declaration);
36101
36315
  exportAssignments.push(createExportsAssignment("default", exportId));
36102
36316
  transformed = true;
36103
36317
  return;
36104
36318
  }
36105
- const targetId = path81.scope.generateUidIdentifier("defaultExport");
36106
- path81.replaceWith(
36319
+ const targetId = path82.scope.generateUidIdentifier("defaultExport");
36320
+ path82.replaceWith(
36107
36321
  t2.variableDeclaration("const", [
36108
36322
  t2.variableDeclarator(targetId, declaration)
36109
36323
  ])
@@ -36111,10 +36325,10 @@ async function transformJsModuleToCjsForAlipay(source) {
36111
36325
  exportAssignments.push(createExportsAssignment("default", targetId));
36112
36326
  transformed = true;
36113
36327
  },
36114
- ExportNamedDeclaration(path81) {
36115
- const declaration = path81.node.declaration;
36328
+ ExportNamedDeclaration(path82) {
36329
+ const declaration = path82.node.declaration;
36116
36330
  if (declaration) {
36117
- path81.replaceWith(declaration);
36331
+ path82.replaceWith(declaration);
36118
36332
  const names = Object.keys(t2.getBindingIdentifiers(declaration));
36119
36333
  for (const name of names) {
36120
36334
  exportAssignments.push(createExportsAssignment(name, t2.identifier(name)));
@@ -36122,19 +36336,19 @@ async function transformJsModuleToCjsForAlipay(source) {
36122
36336
  transformed = true;
36123
36337
  return;
36124
36338
  }
36125
- const specifiers = path81.node.specifiers ?? [];
36339
+ const specifiers = path82.node.specifiers ?? [];
36126
36340
  if (specifiers.length === 0) {
36127
- path81.remove();
36341
+ path82.remove();
36128
36342
  transformed = true;
36129
36343
  return;
36130
36344
  }
36131
- if (path81.node.source) {
36132
- const requireId = path81.scope.generateUidIdentifier("reExported");
36345
+ if (path82.node.source) {
36346
+ const requireId = path82.scope.generateUidIdentifier("reExported");
36133
36347
  const statements2 = [
36134
36348
  t2.variableDeclaration("const", [
36135
36349
  t2.variableDeclarator(
36136
36350
  requireId,
36137
- t2.callExpression(t2.identifier("require"), [t2.stringLiteral(path81.node.source.value)])
36351
+ t2.callExpression(t2.identifier("require"), [t2.stringLiteral(path82.node.source.value)])
36138
36352
  )
36139
36353
  ])
36140
36354
  ];
@@ -36146,7 +36360,7 @@ async function transformJsModuleToCjsForAlipay(source) {
36146
36360
  const exportedName = getModuleExportName(specifier.exported);
36147
36361
  statements2.push(createExportsAssignment(exportedName, createRequireMemberExpression(requireId, localName)));
36148
36362
  }
36149
- path81.replaceWithMultiple(statements2);
36363
+ path82.replaceWithMultiple(statements2);
36150
36364
  transformed = true;
36151
36365
  return;
36152
36366
  }
@@ -36159,7 +36373,7 @@ async function transformJsModuleToCjsForAlipay(source) {
36159
36373
  const exportedName = getModuleExportName(specifier.exported);
36160
36374
  statements.push(createExportsAssignment(exportedName, t2.identifier(localName)));
36161
36375
  }
36162
- path81.replaceWithMultiple(statements);
36376
+ path82.replaceWithMultiple(statements);
36163
36377
  transformed = true;
36164
36378
  }
36165
36379
  });
@@ -36181,7 +36395,7 @@ async function normalizeMiniprogramPackageForAlipay(pkgRoot) {
36181
36395
  }
36182
36396
  const initialFiles = await collectFiles(pkgRoot);
36183
36397
  const renameTasks = initialFiles.map((filePath) => {
36184
- const ext = path72.extname(filePath);
36398
+ const ext = path73.extname(filePath);
36185
36399
  const nextExt = ALIPAY_EXTENSION_MAP[ext];
36186
36400
  if (!nextExt) {
36187
36401
  return null;
@@ -36199,7 +36413,7 @@ async function normalizeMiniprogramPackageForAlipay(pkgRoot) {
36199
36413
  }
36200
36414
  const normalizedFiles = await collectFiles(pkgRoot);
36201
36415
  for (const filePath of normalizedFiles) {
36202
- const ext = path72.extname(filePath);
36416
+ const ext = path73.extname(filePath);
36203
36417
  if (!ALIPAY_TEXT_FILE_EXTENSIONS.has(ext)) {
36204
36418
  continue;
36205
36419
  }
@@ -36218,14 +36432,14 @@ async function normalizeMiniprogramPackageForAlipay(pkgRoot) {
36218
36432
  }
36219
36433
  }
36220
36434
  async function hoistNestedMiniprogramDependenciesForAlipay(pkgRoot, outDir) {
36221
- const nestedRoot = path72.resolve(pkgRoot, "miniprogram_npm");
36435
+ const nestedRoot = path73.resolve(pkgRoot, "miniprogram_npm");
36222
36436
  if (!await fs37.pathExists(nestedRoot)) {
36223
36437
  return;
36224
36438
  }
36225
36439
  const entries = await fs37.readdir(nestedRoot);
36226
36440
  for (const name of entries) {
36227
- const source = path72.resolve(nestedRoot, name);
36228
- const target = path72.resolve(outDir, name);
36441
+ const source = path73.resolve(nestedRoot, name);
36442
+ const target = path73.resolve(outDir, name);
36229
36443
  if (await fs37.pathExists(target)) {
36230
36444
  continue;
36231
36445
  }
@@ -36237,11 +36451,11 @@ async function hoistNestedMiniprogramDependenciesForAlipay(pkgRoot, outDir) {
36237
36451
  }
36238
36452
  }
36239
36453
  async function copyEsModuleDirectoryForAlipay(sourceRoot, targetRoot) {
36240
- const sourceDir = path72.resolve(sourceRoot, "es");
36454
+ const sourceDir = path73.resolve(sourceRoot, "es");
36241
36455
  if (!await fs37.pathExists(sourceDir)) {
36242
36456
  return false;
36243
36457
  }
36244
- await fs37.copy(sourceDir, path72.resolve(targetRoot, "es"), {
36458
+ await fs37.copy(sourceDir, path73.resolve(targetRoot, "es"), {
36245
36459
  overwrite: true
36246
36460
  });
36247
36461
  return true;
@@ -36255,7 +36469,18 @@ function createPackageBuilder(ctx, oxcVitePlugin) {
36255
36469
  async function shouldSkipBuild(outDir, isOutdated) {
36256
36470
  return !isOutdated && await fs37.pathExists(outDir);
36257
36471
  }
36258
- async function bundleBuild({ entry, name, options, outDir }) {
36472
+ function resolveBuildOutDir(options, fallbackOutDir) {
36473
+ const rawOutDir = options?.build?.outDir;
36474
+ if (typeof rawOutDir !== "string" || !rawOutDir.trim()) {
36475
+ return fallbackOutDir;
36476
+ }
36477
+ if (path73.isAbsolute(rawOutDir)) {
36478
+ return rawOutDir;
36479
+ }
36480
+ const root = typeof options.root === "string" && options.root ? options.root : ctx.configService?.cwd ?? process11.cwd();
36481
+ return path73.resolve(root, rawOutDir);
36482
+ }
36483
+ function resolvePackageBuildTarget({ entry, name, options, outDir }) {
36259
36484
  const defineImportMetaEnv = ctx.configService?.defineImportMetaEnv ?? {};
36260
36485
  const mergedOptions = defu9(options, {
36261
36486
  configFile: false,
@@ -36296,34 +36521,50 @@ function createPackageBuilder(ctx, oxcVitePlugin) {
36296
36521
  } else if (isObject10(resolvedOptions)) {
36297
36522
  finalOptions = resolvedOptions;
36298
36523
  }
36299
- if (finalOptions) {
36300
- if (oxcVitePlugin) {
36301
- const toPluginArray = (plugins) => {
36302
- const queue = [];
36303
- const result = [];
36304
- if (plugins) {
36305
- queue.push(plugins);
36524
+ return {
36525
+ outDir: resolveBuildOutDir(finalOptions ?? mergedOptions, outDir),
36526
+ options: finalOptions
36527
+ };
36528
+ }
36529
+ async function runResolvedBundleBuild(finalOptions) {
36530
+ if (!finalOptions) {
36531
+ return;
36532
+ }
36533
+ if (oxcVitePlugin) {
36534
+ const toPluginArray = (plugins) => {
36535
+ const queue = [];
36536
+ const result = [];
36537
+ if (plugins) {
36538
+ queue.push(plugins);
36539
+ }
36540
+ while (queue.length > 0) {
36541
+ const current2 = queue.shift();
36542
+ if (!current2) {
36543
+ continue;
36306
36544
  }
36307
- while (queue.length > 0) {
36308
- const current2 = queue.shift();
36309
- if (!current2) {
36310
- continue;
36311
- }
36312
- if (Array.isArray(current2)) {
36313
- queue.unshift(...current2);
36314
- continue;
36315
- }
36316
- result.push(current2);
36545
+ if (Array.isArray(current2)) {
36546
+ queue.unshift(...current2);
36547
+ continue;
36317
36548
  }
36318
- return result;
36319
- };
36320
- const existing = toPluginArray(finalOptions.plugins);
36321
- const hasPlugin = existing.includes(oxcVitePlugin);
36322
- const nextPlugins = hasPlugin ? existing : [oxcVitePlugin, ...existing];
36323
- finalOptions.plugins = nextPlugins;
36324
- }
36325
- await viteBuild(finalOptions);
36549
+ result.push(current2);
36550
+ }
36551
+ return result;
36552
+ };
36553
+ const existing = toPluginArray(finalOptions.plugins);
36554
+ const hasPlugin = existing.includes(oxcVitePlugin);
36555
+ const nextPlugins = hasPlugin ? existing : [oxcVitePlugin, ...existing];
36556
+ finalOptions.plugins = nextPlugins;
36326
36557
  }
36558
+ await viteBuild(finalOptions);
36559
+ }
36560
+ async function bundleBuild({ entry, name, options, outDir }) {
36561
+ const resolvedTarget = resolvePackageBuildTarget({
36562
+ entry,
36563
+ name,
36564
+ options,
36565
+ outDir
36566
+ });
36567
+ await runResolvedBundleBuild(resolvedTarget.options);
36327
36568
  }
36328
36569
  async function copyBuild({ from, to }) {
36329
36570
  await fs37.copy(
@@ -36340,8 +36581,24 @@ function createPackageBuilder(ctx, oxcVitePlugin) {
36340
36581
  const { packageJson: targetJson, rootPath } = packageInfo;
36341
36582
  const dependencies = targetJson.dependencies ?? {};
36342
36583
  const keys = Object.keys(dependencies);
36343
- const destOutDir = path72.resolve(outDir, dep);
36344
36584
  if (isMiniprogramPackage(targetJson)) {
36585
+ const sourceDir = path73.resolve(
36586
+ rootPath,
36587
+ targetJson.miniprogram
36588
+ );
36589
+ const resolvedTarget = resolvePackageBuildTarget({
36590
+ entry: {
36591
+ index: sourceDir
36592
+ },
36593
+ name: dep,
36594
+ options,
36595
+ outDir: path73.resolve(outDir, dep)
36596
+ });
36597
+ const destOutDir = resolvedTarget.outDir;
36598
+ if (!resolvedTarget.options) {
36599
+ npmLogger.info(`[npm] \u4F9D\u8D56 \`${dep}\` \u88AB npm.buildOptions \u8DF3\u8FC7\u5904\u7406!`);
36600
+ return;
36601
+ }
36345
36602
  if (await shouldSkipBuild(destOutDir, isDependenciesCacheOutdate)) {
36346
36603
  const alipayNpmDistDirName = getAlipayNpmDistDirName(ctx.configService.weappViteConfig?.npm?.alipayNpmMode);
36347
36604
  const shouldRebuildAlipayPackage = ctx.configService.platform === "alipay" ? await shouldRebuildCachedAlipayMiniprogramPackage(destOutDir, outDir, rootPath, alipayNpmDistDirName) : false;
@@ -36351,10 +36608,7 @@ function createPackageBuilder(ctx, oxcVitePlugin) {
36351
36608
  }
36352
36609
  }
36353
36610
  await copyBuild({
36354
- from: path72.resolve(
36355
- rootPath,
36356
- targetJson.miniprogram
36357
- ),
36611
+ from: sourceDir,
36358
36612
  to: destOutDir,
36359
36613
  name: dep
36360
36614
  });
@@ -36384,8 +36638,21 @@ function createPackageBuilder(ctx, oxcVitePlugin) {
36384
36638
  npmLogger.warn(`[npm] \u65E0\u6CD5\u89E3\u6790\u6A21\u5757 \`${dep}\`\uFF0C\u8DF3\u8FC7\u5904\u7406!`);
36385
36639
  return;
36386
36640
  }
36641
+ const resolvedTarget = resolvePackageBuildTarget({
36642
+ entry: {
36643
+ index
36644
+ },
36645
+ name: dep,
36646
+ options,
36647
+ outDir: path73.resolve(outDir, dep)
36648
+ });
36649
+ const destOutDir = resolvedTarget.outDir;
36650
+ if (!resolvedTarget.options) {
36651
+ npmLogger.info(`[npm] \u4F9D\u8D56 \`${dep}\` \u88AB npm.buildOptions \u8DF3\u8FC7\u5904\u7406!`);
36652
+ return;
36653
+ }
36387
36654
  if (!isDependenciesCacheOutdate && await fs37.pathExists(destOutDir)) {
36388
- const destEntry = path72.resolve(destOutDir, "index.js");
36655
+ const destEntry = path73.resolve(destOutDir, "index.js");
36389
36656
  if (await fs37.pathExists(destEntry)) {
36390
36657
  const [srcStat, destStat] = await Promise.all([fs37.stat(index), fs37.stat(destEntry)]);
36391
36658
  if (srcStat.mtimeMs <= destStat.mtimeMs) {
@@ -36394,14 +36661,7 @@ function createPackageBuilder(ctx, oxcVitePlugin) {
36394
36661
  }
36395
36662
  }
36396
36663
  }
36397
- await bundleBuild({
36398
- entry: {
36399
- index
36400
- },
36401
- name: dep,
36402
- options,
36403
- outDir: destOutDir
36404
- });
36664
+ await runResolvedBundleBuild(resolvedTarget.options);
36405
36665
  if (keys.length > 0) {
36406
36666
  await Promise.all(
36407
36667
  keys.filter((x3) => isBuiltin(x3)).map((x3) => {
@@ -36418,7 +36678,7 @@ function createPackageBuilder(ctx, oxcVitePlugin) {
36418
36678
  npmLogger.success(`[npm] \`${dep}\` \u4F9D\u8D56\u5904\u7406\u5B8C\u6210!`);
36419
36679
  }
36420
36680
  buildPackage = async ({ dep, outDir, options, isDependenciesCacheOutdate }) => {
36421
- const taskKey = `${path72.resolve(outDir)}::${dep}`;
36681
+ const taskKey = `${path73.resolve(outDir)}::${dep}`;
36422
36682
  const pending = packageBuildInFlight.get(taskKey);
36423
36683
  if (pending) {
36424
36684
  return pending;
@@ -36449,21 +36709,49 @@ function createPackageBuilder(ctx, oxcVitePlugin) {
36449
36709
  init_esm_shims();
36450
36710
  import { isObject as isObject11, objectHash } from "@weapp-core/shared";
36451
36711
  import fs38 from "fs-extra";
36452
- import path73 from "pathe";
36712
+ import path74 from "pathe";
36713
+ var CACHE_KEY_RE = /[\\/]/;
36714
+ function serializeDependencyScope(scope) {
36715
+ if (scope === false) {
36716
+ return false;
36717
+ }
36718
+ if (!Array.isArray(scope)) {
36719
+ return void 0;
36720
+ }
36721
+ return scope.map((item) => {
36722
+ return typeof item === "string" ? item : item.toString();
36723
+ });
36724
+ }
36725
+ function resolveMainPackageDependencyScope(ctx) {
36726
+ const configService = requireConfigService(ctx, "\u8BFB\u53D6\u4E3B\u5305 npm \u4F9D\u8D56\u8303\u56F4\u524D\u5FC5\u987B\u521D\u59CB\u5316 configService\u3002");
36727
+ return configService.weappViteConfig?.npm?.mainPackage?.dependencies;
36728
+ }
36453
36729
  function createDependenciesCache(ctx) {
36454
36730
  function getDependenciesCacheFilePath(key = "/") {
36455
36731
  const configService = requireConfigService(ctx, "\u751F\u6210 npm \u7F13\u5B58\u8DEF\u5F84\u524D\u5FC5\u987B\u521D\u59CB\u5316 configService\u3002");
36456
- return path73.resolve(configService.cwd, `node_modules/weapp-vite/.cache/${key.replace(/[\\/]/g, "-")}.json`);
36732
+ return path74.resolve(configService.cwd, `node_modules/weapp-vite/.cache/${key.replace(CACHE_KEY_RE, "-")}.json`);
36457
36733
  }
36458
- function dependenciesCacheHash() {
36734
+ function resolveDependencyScope(root) {
36735
+ if (root === "__all__") {
36736
+ return void 0;
36737
+ }
36738
+ if (root && root !== "/") {
36739
+ return ctx.scanService?.subPackageMap.get(root)?.subPackage.dependencies;
36740
+ }
36741
+ return resolveMainPackageDependencyScope(ctx);
36742
+ }
36743
+ function dependenciesCacheHash(root) {
36459
36744
  const configService = requireConfigService(ctx, "\u8BFB\u53D6\u4F9D\u8D56\u7F13\u5B58\u54C8\u5E0C\u524D\u5FC5\u987B\u521D\u59CB\u5316 configService\u3002");
36460
- return objectHash(configService.packageJson.dependencies ?? {});
36745
+ return objectHash({
36746
+ dependencies: configService.packageJson.dependencies ?? {},
36747
+ scope: serializeDependencyScope(resolveDependencyScope(root))
36748
+ });
36461
36749
  }
36462
36750
  async function writeDependenciesCache(root) {
36463
36751
  const configService = requireConfigService(ctx, "\u5199\u5165 npm \u7F13\u5B58\u524D\u5FC5\u987B\u521D\u59CB\u5316 configService\u3002");
36464
36752
  if (configService.weappViteConfig?.npm?.cache) {
36465
36753
  await fs38.outputJSON(getDependenciesCacheFilePath(root), {
36466
- hash: dependenciesCacheHash()
36754
+ hash: dependenciesCacheHash(root)
36467
36755
  });
36468
36756
  }
36469
36757
  }
@@ -36477,7 +36765,7 @@ function createDependenciesCache(ctx) {
36477
36765
  if (ctx.configService?.weappViteConfig?.npm?.cache) {
36478
36766
  const json = await readDependenciesCache(root);
36479
36767
  if (isObject11(json)) {
36480
- return dependenciesCacheHash() !== json.hash;
36768
+ return dependenciesCacheHash(root) !== json.hash;
36481
36769
  }
36482
36770
  return true;
36483
36771
  }
@@ -36485,7 +36773,7 @@ function createDependenciesCache(ctx) {
36485
36773
  }
36486
36774
  return {
36487
36775
  getDependenciesCacheFilePath,
36488
- dependenciesCacheHash,
36776
+ dependenciesCacheHash: () => dependenciesCacheHash(),
36489
36777
  writeDependenciesCache,
36490
36778
  readDependenciesCache,
36491
36779
  checkDependenciesCacheOutdate
@@ -36494,7 +36782,7 @@ function createDependenciesCache(ctx) {
36494
36782
 
36495
36783
  // src/runtime/npmPlugin/relations.ts
36496
36784
  init_esm_shims();
36497
- import path74 from "pathe";
36785
+ import path75 from "pathe";
36498
36786
  function normalizeRelativeDir(value) {
36499
36787
  const normalized = toPosixPath(value).replace(/\/+$/, "");
36500
36788
  const trimmed = normalized.startsWith("./") ? normalized.slice(2) : normalized;
@@ -36543,13 +36831,13 @@ function getPackNpmRelationList(ctx) {
36543
36831
  return [
36544
36832
  {
36545
36833
  ...packNpmRelationList[0],
36546
- miniprogramNpmDistDir: path74.join("dist", configService.platform, resolvePlatformProjectRoot(configService))
36834
+ miniprogramNpmDistDir: path75.join("dist", configService.platform, resolvePlatformProjectRoot(configService))
36547
36835
  }
36548
36836
  ];
36549
36837
  }
36550
36838
  return packNpmRelationList.map((entry) => {
36551
36839
  const rawDir = entry.miniprogramNpmDistDir;
36552
- if (!rawDir || path74.isAbsolute(rawDir)) {
36840
+ if (!rawDir || path75.isAbsolute(rawDir)) {
36553
36841
  return entry;
36554
36842
  }
36555
36843
  const trimmed = normalizeRelativeDir(rawDir);
@@ -36560,12 +36848,83 @@ function getPackNpmRelationList(ctx) {
36560
36848
  }
36561
36849
  return {
36562
36850
  ...entry,
36563
- miniprogramNpmDistDir: path74.join("dist", configService.platform, trimmed)
36851
+ miniprogramNpmDistDir: path75.join("dist", configService.platform, trimmed)
36564
36852
  };
36565
36853
  });
36566
36854
  }
36567
36855
 
36568
36856
  // src/runtime/npmPlugin/service.ts
36857
+ var LEADING_SLASHES_RE = /^\/+/;
36858
+ function matchDependencyName(patterns, dep) {
36859
+ return patterns.some((pattern) => {
36860
+ if (typeof pattern === "string") {
36861
+ return pattern === dep;
36862
+ }
36863
+ pattern.lastIndex = 0;
36864
+ return pattern.test(dep);
36865
+ });
36866
+ }
36867
+ function resolveDependencyId2(value) {
36868
+ const normalized = toPosixPath(value).replace(LEADING_SLASHES_RE, "");
36869
+ const segments = normalized.split("/").filter(Boolean);
36870
+ if (segments.length === 0) {
36871
+ return "";
36872
+ }
36873
+ if (normalized.startsWith("@") && segments.length > 1) {
36874
+ return `${segments[0]}/${segments[1]}`;
36875
+ }
36876
+ return segments[0];
36877
+ }
36878
+ function matchDependencyPath(patterns, value) {
36879
+ const dependencyId = resolveDependencyId2(value);
36880
+ return patterns.some((pattern) => {
36881
+ if (typeof pattern === "string") {
36882
+ return dependencyId === pattern || value === pattern || value.startsWith(`${pattern}/`);
36883
+ }
36884
+ pattern.lastIndex = 0;
36885
+ if (pattern.test(dependencyId)) {
36886
+ return true;
36887
+ }
36888
+ pattern.lastIndex = 0;
36889
+ return pattern.test(value);
36890
+ });
36891
+ }
36892
+ function resolveTargetDependencies(allDependencies, patterns) {
36893
+ if (patterns === false) {
36894
+ return [];
36895
+ }
36896
+ if (!Array.isArray(patterns)) {
36897
+ return allDependencies;
36898
+ }
36899
+ const selected = /* @__PURE__ */ new Set();
36900
+ for (const dep of allDependencies) {
36901
+ if (matchDependencyName(patterns, dep)) {
36902
+ selected.add(dep);
36903
+ }
36904
+ }
36905
+ for (const pattern of patterns) {
36906
+ if (typeof pattern === "string") {
36907
+ selected.add(pattern);
36908
+ }
36909
+ }
36910
+ return [...selected];
36911
+ }
36912
+ function hasSameDependencySet(source, target) {
36913
+ if (source.length !== target.length) {
36914
+ return false;
36915
+ }
36916
+ return source.every((dep) => target.includes(dep));
36917
+ }
36918
+ function resolveMainPackageDependencyPatterns(ctx) {
36919
+ return ctx.configService?.weappViteConfig?.npm?.mainPackage?.dependencies;
36920
+ }
36921
+ function hasLocalSubPackageNpmConfig(ctx) {
36922
+ const npmSubPackages = ctx.configService?.weappViteConfig?.npm?.subPackages;
36923
+ if (npmSubPackages && Object.values(npmSubPackages).some((config) => Array.isArray(config?.dependencies) && config.dependencies.length > 0)) {
36924
+ return true;
36925
+ }
36926
+ return false;
36927
+ }
36569
36928
  function createNpmService(ctx) {
36570
36929
  const oxcRuntimeSupport = createOxcRuntimeSupport();
36571
36930
  const oxcVitePlugin = oxcRuntimeSupport.vitePlugin;
@@ -36582,84 +36941,95 @@ function createNpmService(ctx) {
36582
36941
  return;
36583
36942
  }
36584
36943
  debug?.("buildNpm start");
36944
+ if (ctx.scanService && hasLocalSubPackageNpmConfig(ctx) && typeof ctx.scanService.loadAppEntry === "function") {
36945
+ await ctx.scanService.loadAppEntry();
36946
+ if (typeof ctx.scanService.loadSubPackages === "function") {
36947
+ ctx.scanService.loadSubPackages();
36948
+ }
36949
+ }
36585
36950
  const packNpmRelationList = getPackNpmRelationList(ctx);
36586
36951
  const [mainRelation, ...subRelations] = packNpmRelationList;
36587
- const packageJsonPath = path75.resolve(ctx.configService.cwd, mainRelation.packageJsonPath);
36952
+ const packageJsonPath = path76.resolve(ctx.configService.cwd, mainRelation.packageJsonPath);
36588
36953
  if (await fs39.pathExists(packageJsonPath)) {
36589
36954
  const pkgJson = await fs39.readJson(packageJsonPath);
36590
36955
  const npmDistDirName = getNpmDistDirName();
36591
- const outDir = path75.resolve(ctx.configService.cwd, mainRelation.miniprogramNpmDistDir, npmDistDirName);
36956
+ const outDir = path76.resolve(ctx.configService.cwd, mainRelation.miniprogramNpmDistDir, npmDistDirName);
36957
+ const cachedSourceOutDir = path76.resolve(ctx.configService.cwd, "node_modules/weapp-vite/.cache/npm-source", npmDistDirName);
36958
+ const localSubPackageOutRoot = ctx.configService.outDir || path76.resolve(ctx.configService.cwd, mainRelation.miniprogramNpmDistDir);
36592
36959
  if (pkgJson.dependencies) {
36593
- const dependencies = Object.keys(pkgJson.dependencies);
36594
- if (dependencies.length > 0) {
36595
- const isDependenciesCacheOutdate = await cache2.checkDependenciesCacheOutdate();
36960
+ const allDependencies = Object.keys(pkgJson.dependencies);
36961
+ const mainDependencyPatterns = resolveMainPackageDependencyPatterns(ctx);
36962
+ const mainDependencies = resolveTargetDependencies(allDependencies, mainDependencyPatterns);
36963
+ const sourceOutDir = hasSameDependencySet(allDependencies, mainDependencies) ? outDir : cachedSourceOutDir;
36964
+ const localSubPackageMetas = [...ctx.scanService?.subPackageMap.values() ?? []].filter((meta) => Array.isArray(meta.subPackage.dependencies) && meta.subPackage.dependencies.length > 0);
36965
+ const buildTargetDependencies = async (args) => {
36966
+ const isNpmDistMissing = !await fs39.pathExists(args.npmDistDir);
36967
+ const isDependenciesCacheOutdate = isNpmDistMissing || await cache2.checkDependenciesCacheOutdate(args.cacheKey);
36968
+ if (isDependenciesCacheOutdate) {
36969
+ await fs39.remove(args.npmDistDir);
36970
+ }
36971
+ if (args.dependencies.length === 0) {
36972
+ await fs39.remove(args.npmDistDir);
36973
+ await cache2.writeDependenciesCache(args.cacheKey);
36974
+ return;
36975
+ }
36596
36976
  await Promise.all(
36597
- dependencies.map((dep) => {
36977
+ args.dependencies.map((dep) => {
36598
36978
  return builder.buildPackage({
36599
36979
  dep,
36600
- outDir,
36980
+ outDir: args.npmDistDir,
36601
36981
  options,
36602
36982
  isDependenciesCacheOutdate
36603
36983
  });
36604
36984
  })
36605
36985
  );
36606
- await cache2.writeDependenciesCache();
36607
- const targetDirs = [
36608
- ...subRelations.map((x3) => {
36609
- return {
36610
- npmDistDir: path75.resolve(ctx.configService.cwd, x3.miniprogramNpmDistDir, npmDistDirName)
36611
- };
36612
- }),
36613
- ...[...ctx.scanService.independentSubPackageMap.values()].map((x3) => {
36614
- const dependencies2 = x3.subPackage.dependencies;
36615
- return {
36616
- root: x3.subPackage.root,
36617
- dependencies: dependencies2,
36618
- npmDistDir: path75.resolve(ctx.configService.cwd, mainRelation.miniprogramNpmDistDir, x3.subPackage.root, npmDistDirName)
36619
- };
36620
- })
36621
- ];
36622
- const uniqueTargetDirs = Array.from(
36623
- new Map(
36624
- targetDirs.map((item) => [item.npmDistDir, item])
36625
- ).values()
36626
- );
36627
- await Promise.all(uniqueTargetDirs.map(async (x3) => {
36628
- if (x3.root) {
36629
- const isDependenciesCacheOutdate2 = await cache2.checkDependenciesCacheOutdate(x3.root);
36630
- if (isDependenciesCacheOutdate2 || !await fs39.pathExists(x3.npmDistDir)) {
36631
- await fs39.copy(outDir, x3.npmDistDir, {
36632
- overwrite: true,
36633
- filter: (src) => {
36634
- if (Array.isArray(x3.dependencies)) {
36635
- const relPath = toPosixPath(path75.relative(outDir, src));
36636
- if (relPath === "") {
36637
- return true;
36638
- }
36639
- return regExpTest(x3.dependencies, relPath);
36640
- }
36986
+ await cache2.writeDependenciesCache(args.cacheKey);
36987
+ };
36988
+ if (sourceOutDir !== outDir) {
36989
+ await buildTargetDependencies({
36990
+ cacheKey: "__all__",
36991
+ dependencies: allDependencies,
36992
+ npmDistDir: sourceOutDir
36993
+ });
36994
+ }
36995
+ await buildTargetDependencies({
36996
+ dependencies: mainDependencies,
36997
+ npmDistDir: outDir
36998
+ });
36999
+ if (mainDependencies.length === 0) {
37000
+ await Promise.all(subRelations.map((relation) => {
37001
+ return fs39.remove(path76.resolve(ctx.configService.cwd, relation.miniprogramNpmDistDir, npmDistDirName));
37002
+ }));
37003
+ } else {
37004
+ await Promise.all(subRelations.map(async (relation) => {
37005
+ const targetDir = path76.resolve(ctx.configService.cwd, relation.miniprogramNpmDistDir, npmDistDirName);
37006
+ await fs39.remove(targetDir);
37007
+ await fs39.copy(outDir, targetDir, {
37008
+ overwrite: true
37009
+ });
37010
+ }));
37011
+ }
37012
+ await Promise.all(Array.from(localSubPackageMetas, async (meta) => {
37013
+ const targetDir = path76.resolve(localSubPackageOutRoot, meta.subPackage.root, npmDistDirName);
37014
+ const isDependenciesCacheOutdate = await cache2.checkDependenciesCacheOutdate(meta.subPackage.root);
37015
+ if (isDependenciesCacheOutdate || !await fs39.pathExists(targetDir)) {
37016
+ await fs39.remove(targetDir);
37017
+ await fs39.copy(sourceOutDir, targetDir, {
37018
+ overwrite: true,
37019
+ filter: (src) => {
37020
+ if (Array.isArray(meta.subPackage.dependencies)) {
37021
+ const relPath = toPosixPath(path76.relative(sourceOutDir, src));
37022
+ if (relPath === "") {
36641
37023
  return true;
36642
37024
  }
36643
- });
36644
- }
36645
- await cache2.writeDependenciesCache(x3.root);
36646
- } else {
36647
- await fs39.copy(outDir, x3.npmDistDir, {
36648
- overwrite: true,
36649
- filter: (src) => {
36650
- if (Array.isArray(x3.dependencies)) {
36651
- const relPath = toPosixPath(path75.relative(outDir, src));
36652
- if (relPath === "") {
36653
- return true;
36654
- }
36655
- return regExpTest(x3.dependencies, relPath);
36656
- }
36657
- return true;
37025
+ return matchDependencyPath(meta.subPackage.dependencies, relPath);
36658
37026
  }
36659
- });
36660
- }
36661
- }));
36662
- }
37027
+ return true;
37028
+ }
37029
+ });
37030
+ }
37031
+ await cache2.writeDependenciesCache(meta.subPackage.root);
37032
+ }));
36663
37033
  }
36664
37034
  }
36665
37035
  debug?.("buildNpm end");
@@ -37770,12 +38140,12 @@ init_esm_shims();
37770
38140
  // src/runtime/scanPlugin/service.ts
37771
38141
  init_esm_shims();
37772
38142
  import { isObject as isObject12 } from "@weapp-core/shared";
37773
- import path79 from "pathe";
38143
+ import path80 from "pathe";
37774
38144
 
37775
38145
  // src/runtime/scanPlugin/styleEntries/index.ts
37776
38146
  init_esm_shims();
37777
38147
  import fs42 from "fs-extra";
37778
- import path78 from "pathe";
38148
+ import path79 from "pathe";
37779
38149
 
37780
38150
  // src/runtime/scanPlugin/styleEntries/config.ts
37781
38151
  init_esm_shims();
@@ -37846,7 +38216,7 @@ function coerceStyleConfig(entry) {
37846
38216
  // src/runtime/scanPlugin/styleEntries/entries.ts
37847
38217
  init_esm_shims();
37848
38218
  import fs41 from "fs-extra";
37849
- import path76 from "pathe";
38219
+ import path77 from "pathe";
37850
38220
 
37851
38221
  // src/runtime/scanPlugin/styleEntries/patterns.ts
37852
38222
  init_esm_shims();
@@ -37930,18 +38300,18 @@ function addStyleEntry(descriptor, absolutePath, posixOutput, root, normalizedRo
37930
38300
  source: descriptor.source,
37931
38301
  absolutePath,
37932
38302
  outputRelativePath: posixOutput,
37933
- inputExtension: path76.extname(absolutePath).toLowerCase(),
38303
+ inputExtension: path77.extname(absolutePath).toLowerCase(),
37934
38304
  scope: descriptor.scope,
37935
38305
  include,
37936
38306
  exclude
37937
38307
  });
37938
38308
  }
37939
38309
  function appendDefaultScopedStyleEntries(root, normalizedRoot, service, dedupe, normalized) {
37940
- const absoluteSubRoot = path76.resolve(service.absoluteSrcRoot, root);
38310
+ const absoluteSubRoot = path77.resolve(service.absoluteSrcRoot, root);
37941
38311
  for (const { base, scope } of DEFAULT_SCOPED_FILES) {
37942
38312
  for (const ext of DEFAULT_SCOPED_EXTENSIONS) {
37943
38313
  const filename = `${base}${ext}`;
37944
- const absolutePath = path76.resolve(absoluteSubRoot, filename);
38314
+ const absolutePath = path77.resolve(absoluteSubRoot, filename);
37945
38315
  if (!fs41.existsSync(absolutePath)) {
37946
38316
  continue;
37947
38317
  }
@@ -37966,7 +38336,7 @@ function appendDefaultScopedStyleEntries(root, normalizedRoot, service, dedupe,
37966
38336
 
37967
38337
  // src/runtime/scanPlugin/styleEntries/resolve.ts
37968
38338
  init_esm_shims();
37969
- import path77 from "pathe";
38339
+ import path78 from "pathe";
37970
38340
  function resolveStyleEntryAbsolutePath(source, subPackageRoot, configService) {
37971
38341
  const service = configService;
37972
38342
  if (!service) {
@@ -37977,17 +38347,17 @@ function resolveStyleEntryAbsolutePath(source, subPackageRoot, configService) {
37977
38347
  return void 0;
37978
38348
  }
37979
38349
  const srcRoot = service.absoluteSrcRoot;
37980
- const absoluteSubRoot = path77.resolve(srcRoot, subPackageRoot);
38350
+ const absoluteSubRoot = path78.resolve(srcRoot, subPackageRoot);
37981
38351
  const normalizedEntry = toPosixPath(trimmed);
37982
38352
  const normalizedRoot = toPosixPath(subPackageRoot);
37983
38353
  const candidates = [];
37984
- if (path77.isAbsolute(trimmed)) {
38354
+ if (path78.isAbsolute(trimmed)) {
37985
38355
  candidates.push(trimmed);
37986
38356
  } else if (normalizedEntry === normalizedRoot || normalizedEntry.startsWith(`${normalizedRoot}/`)) {
37987
- candidates.push(path77.resolve(srcRoot, trimmed));
38357
+ candidates.push(path78.resolve(srcRoot, trimmed));
37988
38358
  } else {
37989
- candidates.push(path77.resolve(absoluteSubRoot, trimmed));
37990
- candidates.push(path77.resolve(srcRoot, trimmed));
38359
+ candidates.push(path78.resolve(absoluteSubRoot, trimmed));
38360
+ candidates.push(path78.resolve(srcRoot, trimmed));
37991
38361
  }
37992
38362
  for (const candidate of candidates) {
37993
38363
  if (isPathInside(srcRoot, candidate)) {
@@ -38015,7 +38385,7 @@ function inferScopeFromRelativePath(relativePath) {
38015
38385
  if (cleaned.includes("/")) {
38016
38386
  return void 0;
38017
38387
  }
38018
- const base = path77.posix.basename(cleaned, path77.posix.extname(cleaned));
38388
+ const base = path78.posix.basename(cleaned, path78.posix.extname(cleaned));
38019
38389
  if (base === "pages") {
38020
38390
  return "pages";
38021
38391
  }
@@ -38057,7 +38427,7 @@ function normalizeSubPackageStyleEntries(styles, subPackage, configService) {
38057
38427
  default2.warn(`[\u5206\u5305] \u5206\u5305 ${root} \u6837\u5F0F\u5165\u53E3 \`${descriptor.source}\` \u5BF9\u5E94\u6587\u4EF6\u4E0D\u5B58\u5728\uFF0C\u5DF2\u5FFD\u7565\u3002`);
38058
38428
  continue;
38059
38429
  }
38060
- const ext = path78.extname(absolutePath).toLowerCase();
38430
+ const ext = path79.extname(absolutePath).toLowerCase();
38061
38431
  if (!SUPPORTED_SHARED_STYLE_EXTS.has(ext)) {
38062
38432
  default2.warn(`[\u5206\u5305] \u5206\u5305 ${root} \u6837\u5F0F\u5165\u53E3 \`${descriptor.source}\` \u5F53\u524D\u4EC5\u652F\u6301\u4EE5\u4E0B\u683C\u5F0F\uFF1A${SUPPORTED_SHARED_STYLE_EXTENSIONS.join(", ")}\uFF0C\u5DF2\u5FFD\u7565\u3002`);
38063
38433
  continue;
@@ -38109,7 +38479,7 @@ function createScanService(ctx) {
38109
38479
  return scanState.appEntry;
38110
38480
  }
38111
38481
  const appDirname = ctx.configService.absoluteSrcRoot;
38112
- const appBasename = path79.resolve(appDirname, "app");
38482
+ const appBasename = path80.resolve(appDirname, "app");
38113
38483
  let { path: appConfigFile } = await findJsonEntry(appBasename);
38114
38484
  const { path: appEntryPath } = await findJsEntry(appBasename);
38115
38485
  let configFromVue;
@@ -38118,14 +38488,14 @@ function createScanService(ctx) {
38118
38488
  vueAppPath = await findVueEntry(appBasename);
38119
38489
  }
38120
38490
  if (!appConfigFile && vueAppPath) {
38121
- const { extractConfigFromVue: extractConfigFromVue2 } = await import("./file-IRTTGBIN.mjs");
38491
+ const { extractConfigFromVue: extractConfigFromVue2 } = await import("./file-VKNW65BI.mjs");
38122
38492
  configFromVue = await extractConfigFromVue2(vueAppPath);
38123
38493
  if (configFromVue) {
38124
38494
  appConfigFile = vueAppPath;
38125
38495
  }
38126
38496
  }
38127
38497
  if (ctx.configService.absolutePluginRoot) {
38128
- const pluginBasename = path79.resolve(ctx.configService.absolutePluginRoot, "plugin");
38498
+ const pluginBasename = path80.resolve(ctx.configService.absolutePluginRoot, "plugin");
38129
38499
  const { path: pluginConfigFile } = await findJsonEntry(pluginBasename);
38130
38500
  if (pluginConfigFile) {
38131
38501
  const pluginConfig = await ctx.jsonService.read(pluginConfigFile);
@@ -38154,14 +38524,14 @@ function createScanService(ctx) {
38154
38524
  scanState.appEntry = resolvedAppEntry;
38155
38525
  const { sitemapLocation = "sitemap.json", themeLocation = "theme.json" } = config;
38156
38526
  if (sitemapLocation) {
38157
- const { path: sitemapJsonPath } = await findJsonEntry(path79.resolve(appDirname, sitemapLocation));
38527
+ const { path: sitemapJsonPath } = await findJsonEntry(path80.resolve(appDirname, sitemapLocation));
38158
38528
  if (sitemapJsonPath) {
38159
38529
  resolvedAppEntry.sitemapJsonPath = sitemapJsonPath;
38160
38530
  resolvedAppEntry.sitemapJson = await ctx.jsonService.read(sitemapJsonPath);
38161
38531
  }
38162
38532
  }
38163
38533
  if (themeLocation) {
38164
- const { path: themeJsonPath } = await findJsonEntry(path79.resolve(appDirname, themeLocation));
38534
+ const { path: themeJsonPath } = await findJsonEntry(path80.resolve(appDirname, themeLocation));
38165
38535
  if (themeJsonPath) {
38166
38536
  resolvedAppEntry.themeJsonPath = themeJsonPath;
38167
38537
  resolvedAppEntry.themeJson = await ctx.jsonService.read(themeJsonPath);
@@ -38195,7 +38565,8 @@ function createScanService(ctx) {
38195
38565
  entries: resolveSubPackageEntries(subPackage)
38196
38566
  };
38197
38567
  const subPackageConfig = configService.weappViteConfig?.subPackages?.[subPackage.root];
38198
- meta.subPackage.dependencies = subPackageConfig?.dependencies;
38568
+ const npmSubPackageConfig = configService.weappViteConfig?.npm?.subPackages?.[subPackage.root];
38569
+ meta.subPackage.dependencies = npmSubPackageConfig?.dependencies;
38199
38570
  meta.subPackage.inlineConfig = subPackageConfig?.inlineConfig;
38200
38571
  meta.autoImportComponents = subPackageConfig?.autoImportComponents;
38201
38572
  meta.styleEntries = normalizeSubPackageStyleEntries(
@@ -38223,12 +38594,12 @@ function createScanService(ctx) {
38223
38594
  }
38224
38595
  }
38225
38596
  if (scanState.appEntry) {
38226
- return Array.from(subPackageMap.values());
38597
+ return [...subPackageMap.values()];
38227
38598
  }
38228
38599
  throw new Error(`\u5728 ${configService.absoluteSrcRoot} \u76EE\u5F55\u4E0B\u6CA1\u6709\u627E\u5230 \`app.json\`, \u8BF7\u786E\u4FDD\u4F60\u521D\u59CB\u5316\u4E86\u5C0F\u7A0B\u5E8F\u9879\u76EE\uFF0C\u6216\u8005\u5728 \`vite.config.ts\` \u4E2D\u8BBE\u7F6E\u7684\u6B63\u786E\u7684 \`weapp.srcRoot\` \u914D\u7F6E\u8DEF\u5F84 `);
38229
38600
  }
38230
38601
  function isMainPackageFileName(fileName) {
38231
- return Array.from(independentSubPackageMap.keys()).every((root) => {
38602
+ return [...independentSubPackageMap.keys()].every((root) => {
38232
38603
  return !fileName.startsWith(root);
38233
38604
  });
38234
38605
  }
@@ -38280,7 +38651,7 @@ function createScanService(ctx) {
38280
38651
  }
38281
38652
  },
38282
38653
  drainIndependentDirtyRoots() {
38283
- const roots = Array.from(independentDirtyRoots);
38654
+ const roots = [...independentDirtyRoots];
38284
38655
  independentDirtyRoots.clear();
38285
38656
  return roots;
38286
38657
  }
@@ -38439,7 +38810,7 @@ function createWebServicePlugin(ctx) {
38439
38810
  init_esm_shims();
38440
38811
  import { removeExtensionDeep as removeExtensionDeep15 } from "@weapp-core/shared";
38441
38812
  import fs43 from "fs-extra";
38442
- import path80 from "pathe";
38813
+ import path81 from "pathe";
38443
38814
  function createWxmlService(ctx) {
38444
38815
  const { depsMap, tokenMap, componentsMap, cache: cache2, emittedCode } = ctx.runtimeState.wxml;
38445
38816
  async function addDeps(filepath, deps = []) {
@@ -38555,7 +38926,7 @@ function createWxmlService(ctx) {
38555
38926
  return cached;
38556
38927
  }
38557
38928
  }
38558
- const dirname5 = path80.dirname(filepath);
38929
+ const dirname5 = path81.dirname(filepath);
38559
38930
  const wxml = await fs43.readFile(filepath, "utf8");
38560
38931
  const res = analyze(wxml);
38561
38932
  tokenMap.set(filepath, res);
@@ -38564,9 +38935,9 @@ function createWxmlService(ctx) {
38564
38935
  filepath,
38565
38936
  res.deps.filter((x3) => isImportTag(x3.tagName) && isTemplate(x3.value)).map((x3) => {
38566
38937
  if (x3.value.startsWith("/")) {
38567
- return path80.resolve(configService.absoluteSrcRoot, x3.value.slice(1));
38938
+ return path81.resolve(configService.absoluteSrcRoot, x3.value.slice(1));
38568
38939
  } else {
38569
- return path80.resolve(dirname5, x3.value);
38940
+ return path81.resolve(dirname5, x3.value);
38570
38941
  }
38571
38942
  })
38572
38943
  );