rspack-plugin-cloudflare 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2,13 +2,13 @@ import { createRequire, isBuiltin } from "node:module";
2
2
  import fs, { existsSync, readFileSync } from "node:fs";
3
3
  import fs$1 from "node:fs/promises";
4
4
  import path, { relative } from "node:path";
5
- import { maybeStartOrUpdateRemoteProxySession, unstable_convertConfigBindingsToStartWorkerBindings, unstable_getMiniflareWorkerOptions, unstable_getVarsForDev, unstable_printBindings, unstable_readConfig, unstable_resolveNamedTunnel } from "wrangler";
5
+ import { maybeStartOrUpdateRemoteProxySession, unstable_getMiniflareWorkerOptions, unstable_getVarsForDev, unstable_readConfig, unstable_resolveNamedTunnel } from "wrangler";
6
6
  import { createHash, randomUUID } from "node:crypto";
7
7
  import { fileURLToPath } from "node:url";
8
8
  import { getCloudflarePreset } from "@cloudflare/unenv-preset";
9
+ import { convertConfigToBindings, getNodeCompat, normalizeAndValidateConfig, printBindings } from "@cloudflare/workers-utils";
9
10
  import { defineEnv } from "unenv";
10
11
  import { convertToWranglerConfig, loadAndParseConfig } from "@cloudflare/config";
11
- import { normalizeAndValidateConfig } from "@cloudflare/workers-utils";
12
12
  import { WebSocketServer } from "ws";
13
13
  import { cleanupContainers, createContainerDevPlan, generateContainerBuildId, prepareContainerImagesForDev, resolveDockerHost } from "@cloudflare/containers-shared";
14
14
  import { Readable } from "node:stream";
@@ -54,7 +54,6 @@ function getModuleTypes(worker) {
54
54
  }
55
55
  return types;
56
56
  }
57
- const miniflare = createRequire(import.meta.resolve("wrangler"))("miniflare");
58
57
  // src/nodejs-compat.ts
59
58
  function resolvePolyfill(specifier) {
60
59
  return fileURLToPath(import.meta.resolve(specifier));
@@ -75,7 +74,7 @@ function createInjectSource(inject, polyfills) {
75
74
  */
76
75
  function getNodeJsCompat(worker) {
77
76
  const { compatibility_date: compatibilityDate, compatibility_flags: compatibilityFlags } = worker.config;
78
- if (!miniflare.getNodeCompat(compatibilityDate, compatibilityFlags).isNodejsCompatEnabled) return;
77
+ if (!getNodeCompat(compatibilityDate, compatibilityFlags).isNodejsCompatEnabled) return;
79
78
  const { env } = defineEnv({ presets: [getCloudflarePreset({
80
79
  compatibilityDate,
81
80
  compatibilityFlags
@@ -533,6 +532,7 @@ async function resolveAuxiliaryWorker(context, options, auxiliary, clientOutputP
533
532
  function getWorkerResolvers(context, options, clientOutputPath) {
534
533
  return [() => resolveWorker(context, options, clientOutputPath), ...(options.auxiliaryWorkers ?? []).map((auxiliary) => () => resolveAuxiliaryWorker(context, options, auxiliary, clientOutputPath))];
535
534
  }
535
+ const miniflare = createRequire(import.meta.resolve("wrangler"))("miniflare");
536
536
  // workers-sdk/packages/workers-shared/utils/configuration/constants.ts
537
537
  const PERMITTED_STATUS_CODES = /* @__PURE__ */ new Set([
538
538
  200,
@@ -930,8 +930,11 @@ function parseRedirects(input, { htmlHandling = void 0, maxStaticRules = MAX_STA
930
930
  };
931
931
  const REPLACERS = [
932
932
  [/^\uFEFF/, () => EMPTY],
933
- [/\\?\s+$/, (match) => match.indexOf("\\") === 0 ? SPACE : EMPTY],
934
- [/\\\s/g, () => SPACE],
933
+ [/((?:\\\\)*?)(\\?\s+)$/, (_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY)],
934
+ [/(\\+?)\s/g, (_, m1) => {
935
+ const { length } = m1;
936
+ return m1.slice(0, length - length % 2) + SPACE;
937
+ }],
935
938
  [/[\\$.|*+(){^]/g, (match) => `\\${match}`],
936
939
  [/(?!\\)\?/g, () => "[^/]"],
937
940
  [/^\//, () => "^"],
@@ -956,7 +959,7 @@ function parseRedirects(input, { htmlHandling = void 0, maxStaticRules = MAX_STA
956
959
  const makeRegex = (pattern, ignoreCase) => {
957
960
  let source = regexCache[pattern];
958
961
  if (!source) {
959
- source = REPLACERS.reduce((prev, current) => prev.replace(current[0], current[1].bind(pattern)), pattern);
962
+ source = REPLACERS.reduce((prev, [matcher, replacer]) => prev.replace(matcher, replacer.bind(pattern)), pattern);
960
963
  regexCache[pattern] = source;
961
964
  }
962
965
  return ignoreCase ? new RegExp(source, "i") : new RegExp(source);
@@ -1767,6 +1770,7 @@ const types$1 = {
1767
1770
  "image/prs.pti": ["pti"],
1768
1771
  "image/vnd.adobe.photoshop": ["psd"],
1769
1772
  "image/vnd.airzip.accelerator.azv": ["azv"],
1773
+ "image/vnd.blockfact.facti": ["facti"],
1770
1774
  "image/vnd.dece.graphic": [
1771
1775
  "uvi",
1772
1776
  "uvvi",
@@ -2410,13 +2414,16 @@ var Mime = class {
2410
2414
  for (let [type, extensions] of Object.entries(typeMap)) {
2411
2415
  type = type.toLowerCase();
2412
2416
  extensions = extensions.map((ext) => ext.toLowerCase());
2413
- if (!__classPrivateFieldGet(this, _Mime_typeToExtensions, "f").has(type)) __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").set(type, /* @__PURE__ */ new Set());
2414
- const allExtensions = __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").get(type);
2417
+ let allExtensions = __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").get(type);
2418
+ if (!allExtensions) {
2419
+ allExtensions = /* @__PURE__ */ new Set();
2420
+ __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").set(type, allExtensions);
2421
+ }
2415
2422
  let first = true;
2416
2423
  for (let extension of extensions) {
2417
2424
  const starred = extension.startsWith("*");
2418
2425
  extension = starred ? extension.slice(1) : extension;
2419
- allExtensions?.add(extension);
2426
+ allExtensions.add(extension);
2420
2427
  if (first) __classPrivateFieldGet(this, _Mime_typeToExtension, "f").set(type, extension);
2421
2428
  first = false;
2422
2429
  if (starred) continue;
@@ -2442,14 +2449,15 @@ var Mime = class {
2442
2449
  }
2443
2450
  getAllExtensions(type) {
2444
2451
  if (typeof type !== "string") return null;
2445
- return __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").get(type.toLowerCase()) ?? null;
2452
+ type = type.split(";")[0].trim().toLowerCase();
2453
+ const extensions = __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").get(type);
2454
+ return extensions ? new Set(extensions) : null;
2446
2455
  }
2447
2456
  _freeze() {
2448
2457
  this.define = () => {
2449
2458
  throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances");
2450
2459
  };
2451
2460
  Object.freeze(this);
2452
- for (const extensions of __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").values()) Object.freeze(extensions);
2453
2461
  return this;
2454
2462
  }
2455
2463
  _getTestState() {
@@ -2783,7 +2791,7 @@ var DevWorker = class {
2783
2791
  const { config } = this.#resolved;
2784
2792
  this.#remoteProxy = await maybeStartOrUpdateRemoteProxySession({
2785
2793
  name: config.name,
2786
- bindings: unstable_convertConfigBindingsToStartWorkerBindings(config) ?? {},
2794
+ bindings: convertConfigToBindings(config, { usePreviewIds: true }),
2787
2795
  account_id: config.account_id,
2788
2796
  complianceRegion: config.compliance_region
2789
2797
  }, this.#remoteProxy);
@@ -3196,7 +3204,7 @@ var DevSession = class DevSession {
3196
3204
  #printReady() {
3197
3205
  for (const worker of this.#workers) {
3198
3206
  const { config, name } = worker.resolved;
3199
- unstable_printBindings(unstable_convertConfigBindingsToStartWorkerBindings(config), {
3207
+ printBindings(convertConfigToBindings(config, { usePreviewIds: true }), {
3200
3208
  name,
3201
3209
  local: true,
3202
3210
  warnIfNoBindings: false,