rspack-plugin-cloudflare 0.4.0 → 0.4.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
@@ -300,9 +300,6 @@ function createWorkerConfig(options) {
300
300
  const OMITTED_CONFIG_KEYS = /* @__PURE__ */ new Set([
301
301
  "configPath",
302
302
  "userConfigPath",
303
- "topLevelName",
304
- "definedEnvironments",
305
- "targetEnvironment",
306
303
  "build",
307
304
  "define",
308
305
  "alias",
@@ -3049,6 +3046,7 @@ window.location.replace(first);
3049
3046
  // src/dev.ts
3050
3047
  const PLUGIN_NAME$1 = "rspack-plugin-cloudflare";
3051
3048
  const DEV_SERVER_PATH_RE = /^\/(?:webpack-dev-server|__webpack_dev_server__|__open-in-editor|lazy-compilation-using-)/;
3049
+ const LAZY_COMPILATION_PREFIX = "/_rspack/lazy/trigger";
3052
3050
  const MINIFLARE_PATH_RE = /^\/(?:cdn-cgi\/local|__cf_local)\//;
3053
3051
  const LEGACY_PATH_REWRITES = [
3054
3052
  ["/cdn-cgi/handler", "/cdn-cgi/local"],
@@ -3062,6 +3060,11 @@ function rewriteLegacyMiniflarePath(pathname) {
3062
3060
  for (const [oldPrefix, newPrefix] of LEGACY_PATH_REWRITES) if (pathname === oldPrefix || pathname.startsWith(`${oldPrefix}/`)) return newPrefix + pathname.slice(oldPrefix.length);
3063
3061
  return pathname;
3064
3062
  }
3063
+ function getLazyCompilationPrefix(compiler) {
3064
+ const { lazyCompilation } = compiler.options;
3065
+ if (typeof lazyCompilation === "object" && lazyCompilation.prefix) return lazyCompilation.prefix;
3066
+ return LAZY_COMPILATION_PREFIX;
3067
+ }
3065
3068
  /** Runs the entry Worker and any auxiliary Workers in one Miniflare, routing dev server requests like Cloudflare does. */
3066
3069
  var DevSession = class DevSession {
3067
3070
  /** Reads every Worker's config before the session starts, since `cloudflare.config.ts` can only be loaded asynchronously. */
@@ -3406,7 +3409,7 @@ var DevSession = class DevSession {
3406
3409
  /** Connect middleware that sends each request through Cloudflare's router Worker, or straight to the Worker without assets. */
3407
3410
  async handle(req, res, next) {
3408
3411
  const url = getRequestUrl(req);
3409
- if (DEV_SERVER_PATH_RE.test(url.pathname)) {
3412
+ if (DEV_SERVER_PATH_RE.test(url.pathname) || url.pathname.startsWith(getLazyCompilationPrefix(this.#compiler))) {
3410
3413
  next();
3411
3414
  return;
3412
3415
  }