weapp-vite 5.1.3 → 5.1.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.
@@ -4646,9 +4646,9 @@ init_esm_shims();
4646
4646
  init_esm_shims();
4647
4647
  import { removeExtension, removeExtensionDeep } from "@weapp-core/shared";
4648
4648
 
4649
- // ../../node_modules/.pnpm/lru-cache@11.1.0/node_modules/lru-cache/dist/esm/index.js
4649
+ // ../../node_modules/.pnpm/lru-cache@11.2.1/node_modules/lru-cache/dist/esm/index.js
4650
4650
  init_esm_shims();
4651
- var perf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
4651
+ var defaultPerf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
4652
4652
  var warned = /* @__PURE__ */ new Set();
4653
4653
  var PROCESS = typeof process === "object" && !!process ? process : {};
4654
4654
  var emitWarning = /* @__PURE__ */ __name((msg, type, code, fn) => {
@@ -4749,6 +4749,13 @@ var LRUCache = class _LRUCache {
4749
4749
  #disposeAfter;
4750
4750
  #fetchMethod;
4751
4751
  #memoMethod;
4752
+ #perf;
4753
+ /**
4754
+ * {@link LRUCache.OptionsBase.perf}
4755
+ */
4756
+ get perf() {
4757
+ return this.#perf;
4758
+ }
4752
4759
  /**
4753
4760
  * {@link LRUCache.OptionsBase.ttl}
4754
4761
  */
@@ -4917,7 +4924,13 @@ var LRUCache = class _LRUCache {
4917
4924
  return this.#disposeAfter;
4918
4925
  }
4919
4926
  constructor(options) {
4920
- const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, onInsert, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort } = options;
4927
+ const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, onInsert, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, perf } = options;
4928
+ if (perf !== void 0) {
4929
+ if (typeof perf?.now !== "function") {
4930
+ throw new TypeError("perf option must have a now() method if specified");
4931
+ }
4932
+ }
4933
+ this.#perf = perf ?? defaultPerf;
4921
4934
  if (max !== 0 && !isPosInt(max)) {
4922
4935
  throw new TypeError("max option must be a nonnegative integer");
4923
4936
  }
@@ -5026,7 +5039,7 @@ var LRUCache = class _LRUCache {
5026
5039
  const starts = new ZeroArray(this.#max);
5027
5040
  this.#ttls = ttls;
5028
5041
  this.#starts = starts;
5029
- this.#setItemTTL = (index, ttl, start = perf.now()) => {
5042
+ this.#setItemTTL = (index, ttl, start = this.#perf.now()) => {
5030
5043
  starts[index] = ttl !== 0 ? start : 0;
5031
5044
  ttls[index] = ttl;
5032
5045
  if (ttl !== 0 && this.ttlAutopurge) {
@@ -5041,7 +5054,7 @@ var LRUCache = class _LRUCache {
5041
5054
  }
5042
5055
  };
5043
5056
  this.#updateItemAge = (index) => {
5044
- starts[index] = ttls[index] !== 0 ? perf.now() : 0;
5057
+ starts[index] = ttls[index] !== 0 ? this.#perf.now() : 0;
5045
5058
  };
5046
5059
  this.#statusTTL = (status, index) => {
5047
5060
  if (ttls[index]) {
@@ -5057,7 +5070,7 @@ var LRUCache = class _LRUCache {
5057
5070
  };
5058
5071
  let cachedNow = 0;
5059
5072
  const getNow = /* @__PURE__ */ __name(() => {
5060
- const n5 = perf.now();
5073
+ const n5 = this.#perf.now();
5061
5074
  if (this.ttlResolution > 0) {
5062
5075
  cachedNow = n5;
5063
5076
  const t5 = setTimeout(() => cachedNow = 0, this.ttlResolution);
@@ -5365,7 +5378,7 @@ var LRUCache = class _LRUCache {
5365
5378
  const ttl = this.#ttls[i2];
5366
5379
  const start = this.#starts[i2];
5367
5380
  if (ttl && start) {
5368
- const remain = ttl - (perf.now() - start);
5381
+ const remain = ttl - (this.#perf.now() - start);
5369
5382
  entry.ttl = remain;
5370
5383
  entry.start = Date.now();
5371
5384
  }
@@ -5402,7 +5415,7 @@ var LRUCache = class _LRUCache {
5402
5415
  };
5403
5416
  if (this.#ttls && this.#starts) {
5404
5417
  entry.ttl = this.#ttls[i2];
5405
- const age = perf.now() - this.#starts[i2];
5418
+ const age = this.#perf.now() - this.#starts[i2];
5406
5419
  entry.start = Math.floor(Date.now() - age);
5407
5420
  }
5408
5421
  if (this.#sizes) {
@@ -5429,7 +5442,7 @@ var LRUCache = class _LRUCache {
5429
5442
  for (const [key, entry] of arr) {
5430
5443
  if (entry.start) {
5431
5444
  const age = Date.now() - entry.start;
5432
- entry.start = perf.now() - age;
5445
+ entry.start = this.#perf.now() - age;
5433
5446
  }
5434
5447
  this.set(key, entry.value, entry);
5435
5448
  }
@@ -5712,7 +5725,7 @@ var LRUCache = class _LRUCache {
5712
5725
  const bf2 = p3;
5713
5726
  if (this.#valList[index] === p3) {
5714
5727
  if (v4 === void 0) {
5715
- if (bf2.__staleWhileFetching) {
5728
+ if (bf2.__staleWhileFetching !== void 0) {
5716
5729
  this.#valList[index] = bf2.__staleWhileFetching;
5717
5730
  } else {
5718
5731
  this.#delete(k3, "fetch");
@@ -6074,7 +6087,7 @@ import fs from "fs-extra";
6074
6087
  import path from "pathe";
6075
6088
  function isJsOrTs(name) {
6076
6089
  if (typeof name === "string") {
6077
- return jsExtensions.some((x4) => name.endsWith(`.${x4}`));
6090
+ return /\.[jt]s$/.test(name);
6078
6091
  }
6079
6092
  return false;
6080
6093
  }
@@ -8176,7 +8189,7 @@ var esm_default = {
8176
8189
  FSWatcher
8177
8190
  };
8178
8191
 
8179
- // ../../node_modules/.pnpm/p-queue@8.1.0/node_modules/p-queue/dist/index.js
8192
+ // ../../node_modules/.pnpm/p-queue@8.1.1/node_modules/p-queue/dist/index.js
8180
8193
  init_esm_shims();
8181
8194
 
8182
8195
  // ../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.mjs
@@ -8280,10 +8293,10 @@ function pTimeout(promise, options) {
8280
8293
  }
8281
8294
  __name(pTimeout, "pTimeout");
8282
8295
 
8283
- // ../../node_modules/.pnpm/p-queue@8.1.0/node_modules/p-queue/dist/priority-queue.js
8296
+ // ../../node_modules/.pnpm/p-queue@8.1.1/node_modules/p-queue/dist/priority-queue.js
8284
8297
  init_esm_shims();
8285
8298
 
8286
- // ../../node_modules/.pnpm/p-queue@8.1.0/node_modules/p-queue/dist/lower-bound.js
8299
+ // ../../node_modules/.pnpm/p-queue@8.1.1/node_modules/p-queue/dist/lower-bound.js
8287
8300
  init_esm_shims();
8288
8301
  function lowerBound(array, value, comparator) {
8289
8302
  let first = 0;
@@ -8302,7 +8315,7 @@ function lowerBound(array, value, comparator) {
8302
8315
  }
8303
8316
  __name(lowerBound, "lowerBound");
8304
8317
 
8305
- // ../../node_modules/.pnpm/p-queue@8.1.0/node_modules/p-queue/dist/priority-queue.js
8318
+ // ../../node_modules/.pnpm/p-queue@8.1.1/node_modules/p-queue/dist/priority-queue.js
8306
8319
  var PriorityQueue = class {
8307
8320
  static {
8308
8321
  __name(this, "PriorityQueue");
@@ -8348,7 +8361,7 @@ var PriorityQueue = class {
8348
8361
  }
8349
8362
  };
8350
8363
 
8351
- // ../../node_modules/.pnpm/p-queue@8.1.0/node_modules/p-queue/dist/index.js
8364
+ // ../../node_modules/.pnpm/p-queue@8.1.1/node_modules/p-queue/dist/index.js
8352
8365
  var PQueue = class extends import_index.default {
8353
8366
  static {
8354
8367
  __name(this, "PQueue");
@@ -8559,9 +8572,9 @@ var PQueue = class extends import_index.default {
8559
8572
  return new Promise((resolve8, reject) => {
8560
8573
  this.#queue.enqueue(async () => {
8561
8574
  this.#pending++;
8562
- this.#intervalCount++;
8563
8575
  try {
8564
8576
  options.signal?.throwIfAborted();
8577
+ this.#intervalCount++;
8565
8578
  let operation = function_({
8566
8579
  signal: options.signal
8567
8580
  });
@@ -14744,7 +14757,7 @@ var BuildService2 = class {
14744
14757
  ];
14745
14758
  return {
14746
14759
  build: {
14747
- rollupOptions: {
14760
+ rolldownOptions: {
14748
14761
  output: {
14749
14762
  // https://rolldown.rs/guide/in-depth/advanced-chunks
14750
14763
  advancedChunks: {
@@ -14787,7 +14800,8 @@ var BuildService2 = class {
14787
14800
  process2.env.NODE_ENV = "development";
14788
14801
  }
14789
14802
  debug?.("dev build watcher start");
14790
- const watcher = await build(this.configService.merge(void 0, this.sharedBuildConfig));
14803
+ const buildOptions = this.configService.merge(void 0, this.sharedBuildConfig);
14804
+ const watcher = await build(buildOptions);
14791
14805
  if (this.checkWorkersOptions()) {
14792
14806
  this.devWorkers();
14793
14807
  esm_default.watch(path6.resolve(this.configService.absoluteSrcRoot, this.scanService.workersDir), {
@@ -22671,7 +22685,7 @@ __name(getCssRealPath, "getCssRealPath");
22671
22685
  init_esm_shims();
22672
22686
  import { defu as defu2 } from "@weapp-core/shared";
22673
22687
 
22674
- // ../../node_modules/.pnpm/magic-string@0.30.18/node_modules/magic-string/dist/magic-string.es.mjs
22688
+ // ../../node_modules/.pnpm/magic-string@0.30.19/node_modules/magic-string/dist/magic-string.es.mjs
22675
22689
  init_esm_shims();
22676
22690
 
22677
22691
  // ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
@@ -22762,7 +22776,7 @@ function encode(decoded) {
22762
22776
  }
22763
22777
  __name(encode, "encode");
22764
22778
 
22765
- // ../../node_modules/.pnpm/magic-string@0.30.18/node_modules/magic-string/dist/magic-string.es.mjs
22779
+ // ../../node_modules/.pnpm/magic-string@0.30.19/node_modules/magic-string/dist/magic-string.es.mjs
22766
22780
  var BitSet = class _BitSet {
22767
22781
  static {
22768
22782
  __name(this, "BitSet");
@@ -23219,6 +23233,9 @@ var MagicString = class _MagicString {
23219
23233
  }
23220
23234
  if (chunk.outro.length) mappings.advance(chunk.outro);
23221
23235
  });
23236
+ if (this.outro) {
23237
+ mappings.advance(this.outro);
23238
+ }
23222
23239
  return {
23223
23240
  file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
23224
23241
  sources: [
@@ -23731,7 +23748,12 @@ var MagicString = class _MagicString {
23731
23748
  const { original } = this;
23732
23749
  const index = original.indexOf(string);
23733
23750
  if (index !== -1) {
23734
- this.overwrite(index, index + string.length, replacement);
23751
+ if (typeof replacement === "function") {
23752
+ replacement = replacement(string, index, original);
23753
+ }
23754
+ if (string !== replacement) {
23755
+ this.overwrite(index, index + string.length, replacement);
23756
+ }
23735
23757
  }
23736
23758
  return this;
23737
23759
  }
@@ -23746,7 +23768,11 @@ var MagicString = class _MagicString {
23746
23768
  const stringLength = string.length;
23747
23769
  for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
23748
23770
  const previous = original.slice(index, index + stringLength);
23749
- if (previous !== replacement) this.overwrite(index, index + stringLength, replacement);
23771
+ let _replacement = replacement;
23772
+ if (typeof replacement === "function") {
23773
+ _replacement = replacement(previous, index, original);
23774
+ }
23775
+ if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
23750
23776
  }
23751
23777
  return this;
23752
23778
  }
@@ -24265,6 +24291,18 @@ function weappVite(ctx, subPackageMeta) {
24265
24291
  const requireAsyncEmittedChunks = /* @__PURE__ */ new Set();
24266
24292
  let pq = [];
24267
24293
  return [
24294
+ {
24295
+ name: "weapp-vite:pre:wxss",
24296
+ enforce: "pre",
24297
+ resolveId: {
24298
+ filter: {
24299
+ id: /\.wxss$/
24300
+ },
24301
+ handler(id) {
24302
+ return id.replace(/\.wxss$/, ".css?wxss");
24303
+ }
24304
+ }
24305
+ },
24268
24306
  {
24269
24307
  name: "weapp-vite:pre",
24270
24308
  enforce: "pre",
@@ -24291,10 +24329,10 @@ function weappVite(ctx, subPackageMeta) {
24291
24329
  pq = scanService.loadSubPackages().filter((x4) => x4.subPackage.independent).map(async (x4) => {
24292
24330
  return {
24293
24331
  meta: x4,
24294
- rollup: await build2(configService.merge(x4, {
24332
+ rollup: await build2(configService.merge(x4, x4.subPackage.inlineConfig, {
24295
24333
  build: {
24296
24334
  write: false,
24297
- rollupOptions: {
24335
+ rolldownOptions: {
24298
24336
  output: {
24299
24337
  chunkFileNames() {
24300
24338
  return `${x4.subPackage.root}/[name].js`;
@@ -24312,12 +24350,15 @@ function weappVite(ctx, subPackageMeta) {
24312
24350
  }
24313
24351
  options.input = scanedInput;
24314
24352
  },
24315
- resolveId(id) {
24316
- configService.weappViteConfig?.debug?.resolveId?.(id, subPackageMeta);
24317
- if (id.endsWith(".wxss")) {
24318
- return id.replace(/\.wxss$/, ".css?wxss");
24319
- }
24320
- },
24353
+ // resolveId: {
24354
+ // filter: {
24355
+ // id: /\.wxss$/,
24356
+ // },
24357
+ // handler(id) {
24358
+ // configService.weappViteConfig?.debug?.resolveId?.(id, subPackageMeta)
24359
+ // return id.replace(/\.wxss$/, '.css?wxss')
24360
+ // },
24361
+ // },
24321
24362
  // 触发时机
24322
24363
  // https://github.com/rollup/rollup/blob/328fa2d18285185a20bf9b6fde646c3c28f284ae/src/ModuleLoader.ts#L284
24323
24364
  // 假如返回的是 null, 这时候才会往下添加到 this.graph.watchFiles
@@ -24444,14 +24485,14 @@ function weappVite(ctx, subPackageMeta) {
24444
24485
  {
24445
24486
  name: "weapp-vite:post",
24446
24487
  enforce: "post",
24447
- transform(code, id) {
24448
- if (isJsOrTs(id)) {
24488
+ transform: {
24489
+ filter: {
24490
+ id: /\.[jt]s$/
24491
+ },
24492
+ handler(code) {
24449
24493
  try {
24450
24494
  const ast = this.parse(code);
24451
- const { requireTokens } = collectRequireTokens(
24452
- // @ts-ignore
24453
- ast
24454
- );
24495
+ const { requireTokens } = collectRequireTokens(ast);
24455
24496
  return {
24456
24497
  code,
24457
24498
  ast,
@@ -24920,7 +24961,7 @@ var ConfigService2 = class {
24920
24961
  configFile: false
24921
24962
  }, loadedConfig, {
24922
24963
  build: {
24923
- rollupOptions: {
24964
+ rolldownOptions: {
24924
24965
  output: {
24925
24966
  format: "cjs",
24926
24967
  // strict: false,
@@ -25077,7 +25118,7 @@ var ConfigService2 = class {
25077
25118
  return new RegExp(`^${pkg.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")}(\\/|$)`);
25078
25119
  }));
25079
25120
  }
25080
- const rollupOptions = {
25121
+ const rolldownOptions = {
25081
25122
  external
25082
25123
  };
25083
25124
  if (this.options.isDev) {
@@ -25102,9 +25143,10 @@ var ConfigService2 = class {
25102
25143
  },
25103
25144
  minify: false,
25104
25145
  emptyOutDir: false,
25105
- rollupOptions: {
25106
- ...rollupOptions
25107
- }
25146
+ rolldownOptions: {
25147
+ ...rolldownOptions
25148
+ },
25149
+ sourcemap: true
25108
25150
  }
25109
25151
  });
25110
25152
  } else {
@@ -25118,8 +25160,8 @@ var ConfigService2 = class {
25118
25160
  build: {
25119
25161
  // https://github.com/vitejs/vite/blob/8bed1de5710f2a097af0e22a196545446d98f988/packages/vite/src/node/server/index.ts#L484
25120
25162
  emptyOutDir: false,
25121
- rollupOptions: {
25122
- ...rollupOptions
25163
+ rolldownOptions: {
25164
+ ...rolldownOptions
25123
25165
  }
25124
25166
  }
25125
25167
  });
@@ -25639,7 +25681,9 @@ var ScanService2 = class {
25639
25681
  subPackage,
25640
25682
  entries
25641
25683
  };
25642
- meta.subPackage.dependencies = this.configService.weappViteConfig?.subPackages?.[subPackage.root]?.dependencies;
25684
+ const subPackageConfig = this.configService.weappViteConfig?.subPackages?.[subPackage.root];
25685
+ meta.subPackage.dependencies = subPackageConfig?.dependencies;
25686
+ meta.subPackage.inlineConfig = subPackageConfig?.inlineConfig;
25643
25687
  metas.push(meta);
25644
25688
  this.subPackageMap.set(subPackage.root, meta);
25645
25689
  if (subPackage.independent) {