From 7beaf82a6575067a2213acca711f4804bd121ea4 Mon Sep 17 00:00:00 2001 From: Costin Sin Date: Mon, 8 Jul 2024 21:02:53 +0300 Subject: [PATCH] [windows] Add Windows compatibility for the `replacement` ESBuild plugin (#465) * [windows] Add Windows compatibility for the `replacement` ESBuild plugin Previously, the separator for the filter regex was hardcoded to / (Unix separator). Now, we're also taking account for the \ (Windows separator) in the filter regex. Signed-off-by: Costin-Robert Sin * Create shy-cups-notice.md --------- Signed-off-by: Costin-Robert Sin Co-authored-by: conico974 --- .changeset/shy-cups-notice.md | 5 +++++ packages/open-next/src/build.ts | 3 ++- packages/open-next/src/build/createServerBundle.ts | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 .changeset/shy-cups-notice.md diff --git a/.changeset/shy-cups-notice.md b/.changeset/shy-cups-notice.md new file mode 100644 index 00000000..f63ff5b9 --- /dev/null +++ b/.changeset/shy-cups-notice.md @@ -0,0 +1,5 @@ +--- +"open-next": patch +--- + +[windows] Add Windows compatibility for the `replacement` ESBuild plugin diff --git a/packages/open-next/src/build.ts b/packages/open-next/src/build.ts index 201a6c16..f0f30d03 100755 --- a/packages/open-next/src/build.ts +++ b/packages/open-next/src/build.ts @@ -335,7 +335,8 @@ async function createImageOptimizationBundle(config: OpenNextConfig) { plugins.push( openNextReplacementPlugin({ name: "opennext-14.1.1-image-optimization", - target: /plugins\/image-optimization\/image-optimization\.js/g, + target: + /plugins(\/|\\)image-optimization(\/|\\)image-optimization\.js/g, replacements: [ require.resolve( "./adapters/plugins/image-optimization/image-optimization.replacement.js", diff --git a/packages/open-next/src/build/createServerBundle.ts b/packages/open-next/src/build/createServerBundle.ts index af223502..16772b96 100644 --- a/packages/open-next/src/build/createServerBundle.ts +++ b/packages/open-next/src/build/createServerBundle.ts @@ -207,7 +207,7 @@ async function generateBundle( const plugins = [ openNextReplacementPlugin({ name: `requestHandlerOverride ${name}`, - target: /core\/requestHandler.js/g, + target: /core(\/|\\)requestHandler\.js/g, deletes: disableNextPrebundledReact ? ["applyNextjsPrebundledReact"] : [], replacements: disableRouting ? [ @@ -219,7 +219,7 @@ async function generateBundle( }), openNextReplacementPlugin({ name: `utilOverride ${name}`, - target: /core\/util.js/g, + target: /core(\/|\\)util\.js/g, deletes: [ ...(disableNextPrebundledReact ? ["requireHooks"] : []), ...(disableRouting ? ["trustHostHeader"] : []),