miniflare 0.0.0-e4fe35cc5 → 0.0.0-e7ea6005c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/src/index.js CHANGED
@@ -2547,7 +2547,7 @@ __export(src_exports, {
2547
2547
  _transformsForContentEncodingAndContentType: () => _transformsForContentEncodingAndContentType,
2548
2548
  base64Decode: () => base64Decode,
2549
2549
  base64Encode: () => base64Encode,
2550
- buildAssetsManifest: () => buildAssetsManifest,
2550
+ buildAssetManifest: () => buildAssetManifest,
2551
2551
  compileModuleRules: () => compileModuleRules,
2552
2552
  coupleWebSocket: () => coupleWebSocket,
2553
2553
  createFetchMock: () => createFetchMock,
@@ -2567,6 +2567,7 @@ __export(src_exports, {
2567
2567
  getFreshSourceMapSupport: () => getFreshSourceMapSupport,
2568
2568
  getGlobalServices: () => getGlobalServices,
2569
2569
  getMiniflareObjectBindings: () => getMiniflareObjectBindings,
2570
+ getNodeCompat: () => getNodeCompat,
2570
2571
  getPersistPath: () => getPersistPath,
2571
2572
  getRootPath: () => getRootPath,
2572
2573
  globsToRegExps: () => globsToRegExps,
@@ -3785,8 +3786,15 @@ var QueueConsumerOptionsSchema = /* @__PURE__ */ import_zod2.z.object({
3785
3786
  maxBatchTimeout: import_zod2.z.number().min(0).max(30).optional(),
3786
3787
  // seconds
3787
3788
  maxRetires: import_zod2.z.number().min(0).max(100).optional(),
3789
+ // deprecated
3790
+ maxRetries: import_zod2.z.number().min(0).max(100).optional(),
3788
3791
  deadLetterQueue: import_zod2.z.ostring(),
3789
3792
  retryDelay: QueueMessageDelaySchema
3793
+ }).transform((queue) => {
3794
+ if (queue.maxRetires !== void 0) {
3795
+ queue.maxRetries = queue.maxRetires;
3796
+ }
3797
+ return queue;
3790
3798
  });
3791
3799
  var QueueConsumerSchema = /* @__PURE__ */ import_zod2.z.intersection(
3792
3800
  QueueConsumerOptionsSchema,
@@ -4587,7 +4595,7 @@ var import_undici4 = require("undici");
4587
4595
  // src/plugins/assets/index.ts
4588
4596
  var import_node_crypto = __toESM(require("node:crypto"));
4589
4597
  var import_promises7 = __toESM(require("node:fs/promises"));
4590
- var import_node_path = __toESM(require("node:path"));
4598
+ var import_node_path2 = __toESM(require("node:path"));
4591
4599
 
4592
4600
  // ../workers-shared/utils/constants.ts
4593
4601
  var HEADER_SIZE = 20;
@@ -4616,10 +4624,13 @@ var AssetConfigSchema = import_zod4.z.object({
4616
4624
  });
4617
4625
 
4618
4626
  // ../workers-shared/utils/helpers.ts
4627
+ var import_node_path = require("node:path");
4619
4628
  var import_mime = __toESM(require_mime());
4620
- var encodeFilePath = (filePath, sep) => {
4621
- const encodedPath = filePath.split(sep).map((segment) => encodeURIComponent(segment)).join("/");
4622
- return "/" + encodedPath;
4629
+ var normalizeFilePath = (relativeFilepath) => {
4630
+ if ((0, import_node_path.isAbsolute)(relativeFilepath)) {
4631
+ throw new Error(`Expected relative path`);
4632
+ }
4633
+ return "/" + relativeFilepath.split(import_node_path.sep).join("/");
4623
4634
  };
4624
4635
  var getContentType = (absFilePath) => {
4625
4636
  let contentType = (0, import_mime.getType)(absFilePath) || "application/octet-stream";
@@ -4945,6 +4956,12 @@ var Runtime = class {
4945
4956
  }
4946
4957
  };
4947
4958
 
4959
+ // src/plugins/assets/constants.ts
4960
+ var ASSETS_PLUGIN_NAME = "assets";
4961
+ var ASSETS_SERVICE_NAME = `${ASSETS_PLUGIN_NAME}:assets-service`;
4962
+ var ROUTER_SERVICE_NAME = `${ASSETS_PLUGIN_NAME}:router`;
4963
+ var ASSETS_KV_SERVICE_NAME = `${ASSETS_PLUGIN_NAME}:kv`;
4964
+
4948
4965
  // src/plugins/cache/index.ts
4949
4966
  var import_promises4 = __toESM(require("fs/promises"));
4950
4967
 
@@ -5482,6 +5499,51 @@ var import_util = require("util");
5482
5499
  var import_acorn = require("acorn");
5483
5500
  var import_acorn_walk = require("acorn-walk");
5484
5501
  var import_zod9 = require("zod");
5502
+
5503
+ // src/plugins/core/node-compat.ts
5504
+ function getNodeCompat(compatibilityDate = "2000-01-01", compatibilityFlags, opts) {
5505
+ const { nodeCompat = false } = opts ?? {};
5506
+ const {
5507
+ hasNodejsAlsFlag,
5508
+ hasNodejsCompatFlag,
5509
+ hasNodejsCompatV2Flag,
5510
+ hasNoNodejsCompatV2Flag,
5511
+ hasExperimentalNodejsCompatV2Flag
5512
+ } = parseNodeCompatibilityFlags(compatibilityFlags);
5513
+ const nodeCompatSwitchOverDate = "2024-09-23";
5514
+ const legacy = nodeCompat === true;
5515
+ let mode = null;
5516
+ if (hasNodejsCompatV2Flag || hasNodejsCompatFlag && compatibilityDate >= nodeCompatSwitchOverDate && !hasNoNodejsCompatV2Flag) {
5517
+ mode = "v2";
5518
+ } else if (hasNodejsCompatFlag) {
5519
+ mode = "v1";
5520
+ } else if (hasNodejsAlsFlag) {
5521
+ mode = "als";
5522
+ } else if (legacy) {
5523
+ mode = "legacy";
5524
+ }
5525
+ return {
5526
+ mode,
5527
+ hasNodejsAlsFlag,
5528
+ hasNodejsCompatFlag,
5529
+ hasNodejsCompatV2Flag,
5530
+ hasNoNodejsCompatV2Flag,
5531
+ hasExperimentalNodejsCompatV2Flag
5532
+ };
5533
+ }
5534
+ function parseNodeCompatibilityFlags(compatibilityFlags) {
5535
+ return {
5536
+ hasNodejsAlsFlag: compatibilityFlags.includes("nodejs_als"),
5537
+ hasNodejsCompatFlag: compatibilityFlags.includes("nodejs_compat"),
5538
+ hasNodejsCompatV2Flag: compatibilityFlags.includes("nodejs_compat_v2"),
5539
+ hasNoNodejsCompatV2Flag: compatibilityFlags.includes("no_nodejs_compat_v2"),
5540
+ hasExperimentalNodejsCompatV2Flag: compatibilityFlags.includes(
5541
+ "experimental:nodejs_compat_v2"
5542
+ )
5543
+ };
5544
+ }
5545
+
5546
+ // src/plugins/core/modules.ts
5485
5547
  var SUGGEST_BUNDLE = "If you're trying to import an npm package, you'll need to bundle your Worker first.";
5486
5548
  var SUGGEST_NODE = "If you're trying to import a Node.js built-in module, or an npm package that uses Node.js built-ins, you'll either need to:\n- Bundle your Worker, configuring your bundler to polyfill Node.js built-ins\n- Configure your bundler to load Workers-compatible builds by changing the main fields/conditions\n- Enable the `nodejs_compat` compatibility flag and use the `NodeJsCompatModule` module type\n- Find an alternative package that doesn't require Node.js built-ins";
5487
5549
  var builtinModulesWithPrefix = import_module.builtinModules.concat(
@@ -5589,15 +5651,18 @@ function getResolveErrorPrefix(referencingPath) {
5589
5651
  return `Unable to resolve "${relative}" dependency`;
5590
5652
  }
5591
5653
  var ModuleLocator = class {
5592
- constructor(modulesRoot, additionalModuleNames, rules = [], compatibilityFlags) {
5654
+ constructor(modulesRoot, additionalModuleNames, rules = [], compatibilityDate, compatibilityFlags) {
5593
5655
  this.modulesRoot = modulesRoot;
5594
5656
  this.additionalModuleNames = additionalModuleNames;
5595
5657
  rules = rules.concat(DEFAULT_MODULE_RULES);
5596
5658
  this.#compiledRules = compileModuleRules(rules);
5597
- this.#nodejsCompat = compatibilityFlags?.includes("nodejs_compat") ?? false;
5659
+ this.#nodejsCompatMode = getNodeCompat(
5660
+ compatibilityDate,
5661
+ compatibilityFlags ?? []
5662
+ ).mode;
5598
5663
  }
5599
5664
  #compiledRules;
5600
- #nodejsCompat;
5665
+ #nodejsCompatMode;
5601
5666
  #visitedPaths = /* @__PURE__ */ new Set();
5602
5667
  modules = [];
5603
5668
  visitEntrypoint(code, modulePath) {
@@ -5681,7 +5746,14 @@ ${dim(modulesConfig)}`;
5681
5746
  }
5682
5747
  const spec = specExpression.value;
5683
5748
  const isNodeJsCompatModule = referencingType === "NodeJsCompatModule";
5684
- if (this.#nodejsCompat && spec.startsWith("node:") || spec.startsWith("cloudflare:") || spec.startsWith("workerd:") || isNodeJsCompatModule && builtinModulesWithPrefix.includes(spec) || this.additionalModuleNames.includes(spec)) {
5749
+ if (
5750
+ // `cloudflare:` and `workerd:` imports don't need to be included explicitly
5751
+ spec.startsWith("cloudflare:") || spec.startsWith("workerd:") || // Node.js compat v1 requires imports to be prefixed with `node:`
5752
+ this.#nodejsCompatMode === "v1" && spec.startsWith("node:") || // Node.js compat modules and v2 can also handle non-prefixed imports
5753
+ (this.#nodejsCompatMode === "v2" || isNodeJsCompatModule) && builtinModulesWithPrefix.includes(spec) || // Async Local Storage mode (node_als) only deals with `node:async_hooks` imports
5754
+ this.#nodejsCompatMode === "als" && spec === "node:async_hooks" || // Any "additional" external modules can be ignored
5755
+ this.additionalModuleNames.includes(spec)
5756
+ ) {
5685
5757
  return;
5686
5758
  }
5687
5759
  if (maybeGetStringScriptPathIndex(referencingName) !== void 0) {
@@ -6866,7 +6938,11 @@ var CoreOptionsSchemaInput = import_zod12.z.intersection(
6866
6938
  unsafeEphemeralDurableObjects: import_zod12.z.boolean().optional(),
6867
6939
  unsafeDirectSockets: UnsafeDirectSocketSchema.array().optional(),
6868
6940
  unsafeEvalBinding: import_zod12.z.string().optional(),
6869
- unsafeUseModuleFallbackService: import_zod12.z.boolean().optional()
6941
+ unsafeUseModuleFallbackService: import_zod12.z.boolean().optional(),
6942
+ /** Used to set the vitest pool worker SELF binding to point to the router worker if there are assets.
6943
+ (If there are assets but we're not using vitest, the miniflare entry worker can point directly to RW.)
6944
+ */
6945
+ hasAssetsAndIsVitest: import_zod12.z.boolean().optional()
6870
6946
  })
6871
6947
  );
6872
6948
  var CoreOptionsSchema = CoreOptionsSchemaInput.transform((value) => {
@@ -6931,7 +7007,7 @@ var SCRIPT_CUSTOM_SERVICE = `addEventListener("fetch", (event) => {
6931
7007
  request.headers.set("${CoreHeaders.ORIGINAL_URL}", request.url);
6932
7008
  event.respondWith(${CoreBindings.SERVICE_LOOPBACK}.fetch(request));
6933
7009
  })`;
6934
- function getCustomServiceDesignator(refererName, workerIndex, kind, name, service) {
7010
+ function getCustomServiceDesignator(refererName, workerIndex, kind, name, service, hasAssetsAndIsVitest = false) {
6935
7011
  let serviceName;
6936
7012
  let entrypoint;
6937
7013
  if (typeof service === "function") {
@@ -6948,7 +7024,7 @@ function getCustomServiceDesignator(refererName, workerIndex, kind, name, servic
6948
7024
  serviceName = getBuiltinServiceName(workerIndex, kind, name);
6949
7025
  }
6950
7026
  } else if (service === kCurrentWorker) {
6951
- serviceName = getUserServiceName(refererName);
7027
+ serviceName = hasAssetsAndIsVitest ? ROUTER_SERVICE_NAME : getUserServiceName(refererName);
6952
7028
  } else {
6953
7029
  serviceName = getUserServiceName(service);
6954
7030
  }
@@ -7059,7 +7135,8 @@ var CORE_PLUGIN = {
7059
7135
  workerIndex,
7060
7136
  "#" /* UNKNOWN */,
7061
7137
  name,
7062
- service
7138
+ service,
7139
+ options.hasAssetsAndIsVitest
7063
7140
  )
7064
7141
  };
7065
7142
  })
@@ -7281,7 +7358,8 @@ Ensure ${stringName} doesn't include unbundled \`import\`s.`
7281
7358
  workerIndex,
7282
7359
  "$" /* KNOWN */,
7283
7360
  CUSTOM_SERVICE_KNOWN_OUTBOUND,
7284
- options.outboundService
7361
+ options.outboundService,
7362
+ options.hasAssetsAndIsVitest
7285
7363
  ),
7286
7364
  cacheApiOutbound: { name: getCacheServiceName(workerIndex) },
7287
7365
  moduleFallback: options.unsafeUseModuleFallbackService && sharedOptions.unsafeModuleFallbackService !== void 0 ? `localhost:${loopbackPort}` : void 0
@@ -7444,6 +7522,7 @@ function getWorkerScript(options, workerIndex, additionalModuleNames) {
7444
7522
  modulesRoot,
7445
7523
  additionalModuleNames,
7446
7524
  options.modulesRules,
7525
+ options.compatibilityDate,
7447
7526
  options.compatibilityFlags
7448
7527
  );
7449
7528
  locator.visitEntrypoint(code, scriptPath);
@@ -7454,21 +7533,17 @@ function getWorkerScript(options, workerIndex, additionalModuleNames) {
7454
7533
  }
7455
7534
  }
7456
7535
 
7457
- // src/plugins/assets/constants.ts
7458
- var ASSETS_PLUGIN_NAME = "assets";
7459
- var ASSETS_SERVICE_NAME = `${ASSETS_PLUGIN_NAME}:assets-service`;
7460
- var ROUTER_SERVICE_NAME = `${ASSETS_PLUGIN_NAME}:router`;
7461
- var ASSETS_KV_SERVICE_NAME = `${ASSETS_PLUGIN_NAME}:kv`;
7462
-
7463
7536
  // src/plugins/assets/schema.ts
7464
7537
  var import_zod13 = require("zod");
7465
7538
  var AssetsOptionsSchema = import_zod13.z.object({
7466
7539
  assets: import_zod13.z.object({
7540
+ // User worker name or vitest runner - this is only ever set inside miniflare
7541
+ // The assets plugin needs access to the worker name to create the router worker - user worker binding
7467
7542
  workerName: import_zod13.z.string().optional(),
7468
- path: PathSchema,
7469
- bindingName: import_zod13.z.string().optional(),
7470
- routingConfig: RoutingConfigSchema,
7471
- assetConfig: AssetConfigSchema
7543
+ directory: PathSchema,
7544
+ binding: import_zod13.z.string().optional(),
7545
+ routingConfig: RoutingConfigSchema.optional(),
7546
+ assetConfig: AssetConfigSchema.optional()
7472
7547
  }).optional()
7473
7548
  });
7474
7549
 
@@ -7476,35 +7551,37 @@ var AssetsOptionsSchema = import_zod13.z.object({
7476
7551
  var ASSETS_PLUGIN = {
7477
7552
  options: AssetsOptionsSchema,
7478
7553
  async getBindings(options) {
7479
- if (!options.assets?.bindingName) {
7554
+ if (!options.assets?.binding) {
7480
7555
  return [];
7481
7556
  }
7482
7557
  return [
7483
7558
  {
7484
7559
  // binding between User Worker and Asset Worker
7485
- name: options.assets.bindingName,
7560
+ name: options.assets.binding,
7486
7561
  service: { name: ASSETS_SERVICE_NAME }
7487
7562
  }
7488
7563
  ];
7489
7564
  },
7490
7565
  async getNodeBindings(options) {
7491
- if (!options.assets?.bindingName) {
7566
+ if (!options.assets?.binding) {
7492
7567
  return {};
7493
7568
  }
7494
7569
  return {
7495
- [options.assets.bindingName]: new ProxyNodeBinding()
7570
+ [options.assets.binding]: new ProxyNodeBinding()
7496
7571
  };
7497
7572
  },
7498
7573
  async getServices({ options }) {
7499
7574
  if (!options.assets) {
7500
7575
  return [];
7501
7576
  }
7502
- const assetsReverseMap = await createReverseMap(options.assets?.path);
7503
7577
  const storageServiceName = `${ASSETS_PLUGIN_NAME}:storage`;
7504
7578
  const storageService = {
7505
7579
  name: storageServiceName,
7506
- disk: { path: options.assets.path, writable: true }
7580
+ disk: { path: options.assets.directory, writable: true }
7507
7581
  };
7582
+ const { encodedAssetManifest, assetsReverseMap } = await buildAssetManifest(
7583
+ options.assets.directory
7584
+ );
7508
7585
  const namespaceService = {
7509
7586
  name: ASSETS_KV_SERVICE_NAME,
7510
7587
  worker: {
@@ -7523,12 +7600,11 @@ var ASSETS_PLUGIN = {
7523
7600
  },
7524
7601
  {
7525
7602
  name: "ASSETS_REVERSE_MAP",
7526
- json: assetsReverseMap
7603
+ json: JSON.stringify(assetsReverseMap)
7527
7604
  }
7528
7605
  ]
7529
7606
  }
7530
7607
  };
7531
- const assetsManifest = await buildAssetsManifest(options.assets.path);
7532
7608
  const assetService = {
7533
7609
  name: ASSETS_SERVICE_NAME,
7534
7610
  worker: {
@@ -7546,11 +7622,11 @@ var ASSETS_PLUGIN = {
7546
7622
  },
7547
7623
  {
7548
7624
  name: "ASSETS_MANIFEST",
7549
- data: assetsManifest
7625
+ data: encodedAssetManifest
7550
7626
  },
7551
7627
  {
7552
7628
  name: "CONFIG",
7553
- json: JSON.stringify(options.assets.assetConfig)
7629
+ json: JSON.stringify(options.assets.assetConfig ?? {})
7554
7630
  }
7555
7631
  ]
7556
7632
  }
@@ -7584,20 +7660,21 @@ var ASSETS_PLUGIN = {
7584
7660
  return [storageService, namespaceService, assetService, routerService];
7585
7661
  }
7586
7662
  };
7587
- var buildAssetsManifest = async (dir) => {
7588
- const manifest = await walk(dir);
7663
+ var buildAssetManifest = async (dir) => {
7664
+ const { manifest, assetsReverseMap } = await walk(dir);
7589
7665
  const sortedAssetManifest = sortManifest(manifest);
7590
7666
  const encodedAssetManifest = encodeManifest(sortedAssetManifest);
7591
- return encodedAssetManifest;
7667
+ return { encodedAssetManifest, assetsReverseMap };
7592
7668
  };
7593
7669
  var walk = async (dir) => {
7594
7670
  const files = await import_promises7.default.readdir(dir, { recursive: true });
7595
7671
  const manifest = [];
7672
+ const assetsReverseMap = {};
7596
7673
  let counter = 0;
7597
7674
  await Promise.all(
7598
7675
  files.map(async (file) => {
7599
- const filepath = import_node_path.default.join(dir, file);
7600
- const relativeFilepath = import_node_path.default.relative(dir, filepath);
7676
+ const filepath = import_node_path2.default.join(dir, file);
7677
+ const relativeFilepath = import_node_path2.default.relative(dir, filepath);
7601
7678
  const filestat = await import_promises7.default.stat(filepath);
7602
7679
  if (filestat.isSymbolicLink() || filestat.isDirectory()) {
7603
7680
  return;
@@ -7619,9 +7696,19 @@ Cloudflare Workers supports assets with sizes of up to ${prettyBytes(
7619
7696
  Ensure all assets in your assets directory "${dir}" conform with the Workers maximum size requirement.`
7620
7697
  );
7621
7698
  }
7622
- manifest.push(
7623
- await hashPath(encodeFilePath(relativeFilepath, import_node_path.default.sep))
7624
- );
7699
+ const [pathHash, contentHash] = await Promise.all([
7700
+ hashPath(normalizeFilePath(relativeFilepath)),
7701
+ // used absolute filepath here so that changes to the enclosing asset folder will be registered
7702
+ hashPath(filepath + filestat.mtimeMs.toString())
7703
+ ]);
7704
+ manifest.push({
7705
+ pathHash,
7706
+ contentHash
7707
+ });
7708
+ assetsReverseMap[bytesToHex(contentHash)] = {
7709
+ filePath: relativeFilepath,
7710
+ contentType: getContentType(filepath)
7711
+ };
7625
7712
  counter++;
7626
7713
  }
7627
7714
  })
@@ -7633,23 +7720,23 @@ Cloudflare Workers supports up to ${MAX_ASSET_COUNT.toLocaleString()} assets in
7633
7720
  Ensure your assets directory contains a maximum of ${MAX_ASSET_COUNT.toLocaleString()} files, and that you have specified your assets directory correctly.`
7634
7721
  );
7635
7722
  }
7636
- return manifest;
7723
+ return { manifest, assetsReverseMap };
7637
7724
  };
7638
7725
  var sortManifest = (manifest) => {
7639
7726
  return manifest.sort(comparisonFn);
7640
7727
  };
7641
7728
  var comparisonFn = (a, b) => {
7642
- if (a.length < b.length) {
7729
+ if (a.pathHash.length < b.pathHash.length) {
7643
7730
  return -1;
7644
7731
  }
7645
- if (a.length > b.length) {
7732
+ if (a.pathHash.length > b.pathHash.length) {
7646
7733
  return 1;
7647
7734
  }
7648
- for (const [i, v] of a.entries()) {
7649
- if (v < b[i]) {
7735
+ for (const [i, v] of a.pathHash.entries()) {
7736
+ if (v < b.pathHash[i]) {
7650
7737
  return -1;
7651
7738
  }
7652
- if (v > b[i]) {
7739
+ if (v > b.pathHash[i]) {
7653
7740
  return 1;
7654
7741
  }
7655
7742
  }
@@ -7661,34 +7748,14 @@ var encodeManifest = (manifest) => {
7661
7748
  );
7662
7749
  for (const [i, entry] of manifest.entries()) {
7663
7750
  const entryOffset = HEADER_SIZE + i * ENTRY_SIZE;
7664
- assetManifestBytes.set(entry, entryOffset + PATH_HASH_OFFSET);
7665
- assetManifestBytes.set(entry, entryOffset + CONTENT_HASH_OFFSET);
7751
+ assetManifestBytes.set(entry.pathHash, entryOffset + PATH_HASH_OFFSET);
7752
+ assetManifestBytes.set(
7753
+ entry.contentHash,
7754
+ entryOffset + CONTENT_HASH_OFFSET
7755
+ );
7666
7756
  }
7667
7757
  return assetManifestBytes;
7668
7758
  };
7669
- var createReverseMap = async (dir) => {
7670
- const files = await import_promises7.default.readdir(dir, { recursive: true });
7671
- const assetsReverseMap = {};
7672
- await Promise.all(
7673
- files.map(async (file) => {
7674
- const filepath = import_node_path.default.join(dir, file);
7675
- const relativeFilepath = import_node_path.default.relative(dir, filepath);
7676
- const filestat = await import_promises7.default.stat(filepath);
7677
- if (filestat.isSymbolicLink() || filestat.isDirectory()) {
7678
- return;
7679
- } else {
7680
- const pathHash = bytesToHex(
7681
- await hashPath(encodeFilePath(relativeFilepath, import_node_path.default.sep))
7682
- );
7683
- assetsReverseMap[pathHash] = {
7684
- filePath: relativeFilepath,
7685
- contentType: getContentType(filepath)
7686
- };
7687
- }
7688
- })
7689
- );
7690
- return JSON.stringify(assetsReverseMap);
7691
- };
7692
7759
  var bytesToHex = (buffer) => {
7693
7760
  return [...new Uint8Array(buffer)].map((b) => b.toString(16).padStart(2, "0")).join("");
7694
7761
  };
@@ -8266,7 +8333,11 @@ var QUEUES_PLUGIN = {
8266
8333
  { name: "broker.worker.js", esModule: broker_worker_default() }
8267
8334
  ],
8268
8335
  durableObjectNamespaces: [
8269
- { className: QUEUE_BROKER_OBJECT_CLASS_NAME, uniqueKey }
8336
+ {
8337
+ className: QUEUE_BROKER_OBJECT_CLASS_NAME,
8338
+ uniqueKey,
8339
+ preventEviction: true
8340
+ }
8270
8341
  ],
8271
8342
  // Miniflare's Queue broker is in-memory only at the moment
8272
8343
  durableObjectStorage: { inMemory: kVoid },
@@ -9084,8 +9155,15 @@ function getQueueProducers(allWorkerOpts) {
9084
9155
  ])
9085
9156
  );
9086
9157
  }
9087
- for (const [bindingName, opts] of Object.entries(workerProducers)) {
9088
- queueProducers.set(bindingName, { workerName, ...opts });
9158
+ const producersIterable = Object.entries(
9159
+ workerProducers
9160
+ );
9161
+ for (const [bindingName, opts] of producersIterable) {
9162
+ if (typeof opts === "string") {
9163
+ queueProducers.set(bindingName, { workerName, queueName: opts });
9164
+ } else {
9165
+ queueProducers.set(bindingName, { workerName, ...opts });
9166
+ }
9089
9167
  }
9090
9168
  }
9091
9169
  }
@@ -9568,6 +9646,9 @@ var Miniflare2 = class {
9568
9646
  const proxyBindings = [];
9569
9647
  const allWorkerBindings = /* @__PURE__ */ new Map();
9570
9648
  const wrappedBindingsToPopulate = [];
9649
+ if (this.#workerOpts[0].assets.assets) {
9650
+ this.#workerOpts[0].assets.assets.workerName = this.#workerOpts[0].core.name;
9651
+ }
9571
9652
  for (let i = 0; i < allWorkerOpts.length; i++) {
9572
9653
  const previousWorkerOpts = allPreviousWorkerOpts?.[i];
9573
9654
  const workerOpts = allWorkerOpts[i];
@@ -9687,8 +9768,11 @@ var Miniflare2 = class {
9687
9768
  const globalServices = getGlobalServices({
9688
9769
  sharedOptions: sharedOpts.core,
9689
9770
  allWorkerRoutes,
9690
- // if Workers + Assets project, point to router Worker service rather than user Worker
9691
- fallbackWorkerName: this.#workerOpts[0].assets.assets ? ROUTER_SERVICE_NAME : getUserServiceName(this.#workerOpts[0].core.name),
9771
+ // if Workers + Assets project but NOT Vitest, point to router Worker instead
9772
+ // if Vitest with assets, the self binding on the test runner will point to RW
9773
+ fallbackWorkerName: this.#workerOpts[0].assets.assets && !this.#workerOpts[0].core.name?.startsWith(
9774
+ "vitest-pool-workers-runner-"
9775
+ ) ? ROUTER_SERVICE_NAME : getUserServiceName(this.#workerOpts[0].core.name),
9692
9776
  loopbackPort,
9693
9777
  log: this.#log,
9694
9778
  proxyBindings
@@ -10195,7 +10279,7 @@ var Miniflare2 = class {
10195
10279
  _transformsForContentEncodingAndContentType,
10196
10280
  base64Decode,
10197
10281
  base64Encode,
10198
- buildAssetsManifest,
10282
+ buildAssetManifest,
10199
10283
  compileModuleRules,
10200
10284
  coupleWebSocket,
10201
10285
  createFetchMock,
@@ -10215,6 +10299,7 @@ var Miniflare2 = class {
10215
10299
  getFreshSourceMapSupport,
10216
10300
  getGlobalServices,
10217
10301
  getMiniflareObjectBindings,
10302
+ getNodeCompat,
10218
10303
  getPersistPath,
10219
10304
  getRootPath,
10220
10305
  globsToRegExps,