this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: use the new regex utility for cross-platform paths (#271)

* refactor: use the new regex utility for cross-platform paths

* Update packages/cloudflare/src/cli/build/bundle-server.ts

* formatting

authored by

James Anderson and committed by
GitHub
27ab1ab2 6dd5ca42

+15 -5
+5
.changeset/rare-hornets-shake.md
··· 1 + --- 2 + "@opennextjs/cloudflare": patch 3 + --- 4 + 5 + refactor: use the new regex utility for constructing cross-platform paths
+7 -3
packages/cloudflare/src/cli/build/bundle-server.ts
··· 4 4 import { fileURLToPath } from "node:url"; 5 5 6 6 import type { BuildOptions } from "@opennextjs/aws/build/helper.js"; 7 + import { getCrossPlatformPathRegex } from "@opennextjs/aws/utils/regex.js"; 7 8 import { build, Plugin } from "esbuild"; 8 9 9 10 import { Config } from "../config.js"; ··· 183 184 name: "replaceRelative", 184 185 setup(build) { 185 186 // Note: we (empty) shim require-hook modules as they generate problematic code that uses requires 186 - build.onResolve({ filter: /^\.(\/|\\)require-hook$/ }, () => ({ 187 - path: path.join(config.paths.internal.templates, "shims", "empty.js"), 188 - })); 187 + build.onResolve( 188 + { filter: getCrossPlatformPathRegex(String.raw`^\./require-hook$`, { escape: false }) }, 189 + () => ({ 190 + path: path.join(config.paths.internal.templates, "shims", "empty.js"), 191 + }) 192 + ); 189 193 }, 190 194 }; 191 195 }
+3 -2
packages/cloudflare/src/cli/build/open-next/createServerBundle.ts
··· 16 16 import { openNextReplacementPlugin } from "@opennextjs/aws/plugins/replacement.js"; 17 17 import { openNextResolvePlugin } from "@opennextjs/aws/plugins/resolve.js"; 18 18 import type { FunctionOptions, SplittedFunctionOptions } from "@opennextjs/aws/types/open-next.js"; 19 + import { getCrossPlatformPathRegex } from "@opennextjs/aws/utils/regex.js"; 19 20 20 21 import { normalizePath } from "../utils/index.js"; 21 22 ··· 173 174 const plugins = [ 174 175 openNextReplacementPlugin({ 175 176 name: `requestHandlerOverride ${name}`, 176 - target: /core(\/|\\)requestHandler\.js/g, 177 + target: getCrossPlatformPathRegex("core/requestHandler.js"), 177 178 deletes: [ 178 179 ...(disableNextPrebundledReact ? ["applyNextjsPrebundledReact"] : []), 179 180 ...(disableRouting ? ["withRouting"] : []), ··· 181 182 }), 182 183 openNextReplacementPlugin({ 183 184 name: `utilOverride ${name}`, 184 - target: /core(\/|\\)util\.js/g, 185 + target: getCrossPlatformPathRegex("core/util.js"), 185 186 deletes: [ 186 187 ...(disableNextPrebundledReact ? ["requireHooks"] : []), 187 188 ...(isBefore13413 ? ["trustHostHeader"] : ["requestHandlerHost"]),