rspack-plugin-cloudflare 0.4.1 → 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 +7 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3046,6 +3046,7 @@ window.location.replace(first);
|
|
|
3046
3046
|
// src/dev.ts
|
|
3047
3047
|
const PLUGIN_NAME$1 = "rspack-plugin-cloudflare";
|
|
3048
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";
|
|
3049
3050
|
const MINIFLARE_PATH_RE = /^\/(?:cdn-cgi\/local|__cf_local)\//;
|
|
3050
3051
|
const LEGACY_PATH_REWRITES = [
|
|
3051
3052
|
["/cdn-cgi/handler", "/cdn-cgi/local"],
|
|
@@ -3059,6 +3060,11 @@ function rewriteLegacyMiniflarePath(pathname) {
|
|
|
3059
3060
|
for (const [oldPrefix, newPrefix] of LEGACY_PATH_REWRITES) if (pathname === oldPrefix || pathname.startsWith(`${oldPrefix}/`)) return newPrefix + pathname.slice(oldPrefix.length);
|
|
3060
3061
|
return pathname;
|
|
3061
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
|
+
}
|
|
3062
3068
|
/** Runs the entry Worker and any auxiliary Workers in one Miniflare, routing dev server requests like Cloudflare does. */
|
|
3063
3069
|
var DevSession = class DevSession {
|
|
3064
3070
|
/** Reads every Worker's config before the session starts, since `cloudflare.config.ts` can only be loaded asynchronously. */
|
|
@@ -3403,7 +3409,7 @@ var DevSession = class DevSession {
|
|
|
3403
3409
|
/** Connect middleware that sends each request through Cloudflare's router Worker, or straight to the Worker without assets. */
|
|
3404
3410
|
async handle(req, res, next) {
|
|
3405
3411
|
const url = getRequestUrl(req);
|
|
3406
|
-
if (DEV_SERVER_PATH_RE.test(url.pathname)) {
|
|
3412
|
+
if (DEV_SERVER_PATH_RE.test(url.pathname) || url.pathname.startsWith(getLazyCompilationPrefix(this.#compiler))) {
|
|
3407
3413
|
next();
|
|
3408
3414
|
return;
|
|
3409
3415
|
}
|