From 6319adc7981dcab5d07d0d17788d798a41cf62a5 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Thu, 31 Jul 2025 10:49:30 +0200 Subject: [PATCH] bump @opennextjs/aws to 3.7.2 --- .changeset/funny-onions-behave.md | 7 ++ packages/cloudflare/package.json | 2 +- .../build/patches/plugins/dynamic-requires.ts | 20 ++--- .../src/cli/build/patches/plugins/find-dir.ts | 8 +- .../build/patches/plugins/instrumentation.ts | 34 ++++---- .../build/patches/plugins/load-manifest.ts | 18 ++--- .../cli/build/patches/plugins/next-server.ts | 36 ++++----- .../cli/build/patches/plugins/open-next.ts | 14 ++-- .../plugins/patch-depd-deprecations.ts | 8 +- .../src/cli/build/patches/plugins/require.ts | 80 +++++++++---------- .../build/patches/plugins/res-revalidate.ts | 18 ++--- .../cli/build/patches/plugins/use-cache.ts | 12 ++- pnpm-lock.yaml | 10 +-- 13 files changed, 124 insertions(+), 143 deletions(-) create mode 100644 .changeset/funny-onions-behave.md diff --git a/.changeset/funny-onions-behave.md b/.changeset/funny-onions-behave.md new file mode 100644 index 00000000..2d79b53b --- /dev/null +++ b/.changeset/funny-onions-behave.md @@ -0,0 +1,7 @@ +--- +"@opennextjs/cloudflare": patch +--- + +bump @opennextjs/aws to 3.7.2 + +See details at diff --git a/packages/cloudflare/package.json b/packages/cloudflare/package.json index da3a2d5d..29538c67 100644 --- a/packages/cloudflare/package.json +++ b/packages/cloudflare/package.json @@ -53,7 +53,7 @@ "homepage": "https://github.com/opennextjs/opennextjs-cloudflare", "dependencies": { "@dotenvx/dotenvx": "catalog:", - "@opennextjs/aws": "3.7.1", + "@opennextjs/aws": "3.7.2", "cloudflare": "^4.4.1", "enquirer": "^2.4.1", "glob": "catalog:", diff --git a/packages/cloudflare/src/cli/build/patches/plugins/dynamic-requires.ts b/packages/cloudflare/src/cli/build/patches/plugins/dynamic-requires.ts index bc86a280..116cb010 100644 --- a/packages/cloudflare/src/cli/build/patches/plugins/dynamic-requires.ts +++ b/packages/cloudflare/src/cli/build/patches/plugins/dynamic-requires.ts @@ -45,22 +45,18 @@ function getRequires(idVariable: string, files: string[], serverDir: string) { export function inlineDynamicRequires(updater: ContentUpdater, buildOpts: BuildOptions): Plugin { updater.updateContent("inline-node-module-loader", [ { - field: { - filter: getCrossPlatformPathRegex(String.raw`/module-loader/node-module-loader\.js$`, { - escape: false, - }), - contentFilter: /class NodeModuleLoader {/, - callback: async ({ contents }) => patchCode(contents, await getNodeModuleLoaderRule(buildOpts)), - }, + filter: getCrossPlatformPathRegex(String.raw`/module-loader/node-module-loader\.js$`, { + escape: false, + }), + contentFilter: /class NodeModuleLoader {/, + callback: async ({ contents }) => patchCode(contents, await getNodeModuleLoaderRule(buildOpts)), }, ]); updater.updateContent("inline-require-page", [ { - field: { - filter: getCrossPlatformPathRegex(String.raw`/next/dist/server/require\.js$`, { escape: false }), - contentFilter: /function requirePage\(/, - callback: async ({ contents }) => patchCode(contents, await getRequirePageRule(buildOpts)), - }, + filter: getCrossPlatformPathRegex(String.raw`/next/dist/server/require\.js$`, { escape: false }), + contentFilter: /function requirePage\(/, + callback: async ({ contents }) => patchCode(contents, await getRequirePageRule(buildOpts)), }, ]); return { name: "inline-dynamic-requires", setup() {} }; diff --git a/packages/cloudflare/src/cli/build/patches/plugins/find-dir.ts b/packages/cloudflare/src/cli/build/patches/plugins/find-dir.ts index 96ed5ef0..5f13be5d 100644 --- a/packages/cloudflare/src/cli/build/patches/plugins/find-dir.ts +++ b/packages/cloudflare/src/cli/build/patches/plugins/find-dir.ts @@ -13,11 +13,9 @@ import { getCrossPlatformPathRegex } from "@opennextjs/aws/utils/regex.js"; export function inlineFindDir(updater: ContentUpdater, buildOpts: BuildOptions): Plugin { return updater.updateContent("inline-find-dir", [ { - field: { - filter: getCrossPlatformPathRegex(String.raw`/next/dist/lib/find-pages-dir\.js$`, { escape: false }), - contentFilter: /function findDir\(/, - callback: async ({ contents }) => patchCode(contents, await getRule(buildOpts)), - }, + filter: getCrossPlatformPathRegex(String.raw`/next/dist/lib/find-pages-dir\.js$`, { escape: false }), + contentFilter: /function findDir\(/, + callback: async ({ contents }) => patchCode(contents, await getRule(buildOpts)), }, ]); } diff --git a/packages/cloudflare/src/cli/build/patches/plugins/instrumentation.ts b/packages/cloudflare/src/cli/build/patches/plugins/instrumentation.ts index 812e7aea..2bfc1f77 100644 --- a/packages/cloudflare/src/cli/build/patches/plugins/instrumentation.ts +++ b/packages/cloudflare/src/cli/build/patches/plugins/instrumentation.ts @@ -13,36 +13,30 @@ export function patchInstrumentation(updater: ContentUpdater, buildOpts: BuildOp updater.updateContent("patch-instrumentation-next15-4", [ { - field: { - filter: getCrossPlatformPathRegex( - String.raw`/server/lib/router-utils/instrumentation-globals.external\.js$`, - { - escape: false, - } - ), - contentFilter: /getInstrumentationModule\(/, - callback: ({ contents }) => patchCode(contents, getNext154Rule(builtInstrumentationPath)), - }, + filter: getCrossPlatformPathRegex( + String.raw`/server/lib/router-utils/instrumentation-globals.external\.js$`, + { + escape: false, + } + ), + contentFilter: /getInstrumentationModule\(/, + callback: ({ contents }) => patchCode(contents, getNext154Rule(builtInstrumentationPath)), }, ]); updater.updateContent("patch-instrumentation-next15", [ { - field: { - filter: /\.(js|mjs|cjs|jsx|ts|tsx)$/, - contentFilter: /async loadInstrumentationModule\(/, - callback: ({ contents }) => patchCode(contents, getNext15Rule(builtInstrumentationPath)), - }, + filter: /\.(js|mjs|cjs|jsx|ts|tsx)$/, + contentFilter: /async loadInstrumentationModule\(/, + callback: ({ contents }) => patchCode(contents, getNext15Rule(builtInstrumentationPath)), }, ]); updater.updateContent("patch-instrumentation-next14", [ { - field: { - filter: /\.(js|mjs|cjs|jsx|ts|tsx)$/, - contentFilter: /async prepareImpl\(/, - callback: ({ contents }) => patchCode(contents, getNext14Rule(builtInstrumentationPath)), - }, + filter: /\.(js|mjs|cjs|jsx|ts|tsx)$/, + contentFilter: /async prepareImpl\(/, + callback: ({ contents }) => patchCode(contents, getNext14Rule(builtInstrumentationPath)), }, ]); diff --git a/packages/cloudflare/src/cli/build/patches/plugins/load-manifest.ts b/packages/cloudflare/src/cli/build/patches/plugins/load-manifest.ts index 669397ee..d08f32c8 100644 --- a/packages/cloudflare/src/cli/build/patches/plugins/load-manifest.ts +++ b/packages/cloudflare/src/cli/build/patches/plugins/load-manifest.ts @@ -18,16 +18,14 @@ import { normalizePath } from "../../utils/normalize-path.js"; export function inlineLoadManifest(updater: ContentUpdater, buildOpts: BuildOptions): Plugin { return updater.updateContent("inline-load-manifest", [ { - field: { - filter: getCrossPlatformPathRegex(String.raw`/next/dist/server/load-manifest(\.external)?\.js$`, { - escape: false, - }), - contentFilter: /function loadManifest\(/, - callback: async ({ contents }) => { - contents = await patchCode(contents, await getLoadManifestRule(buildOpts)); - contents = await patchCode(contents, await getEvalManifestRule(buildOpts)); - return contents; - }, + filter: getCrossPlatformPathRegex(String.raw`/next/dist/server/load-manifest(\.external)?\.js$`, { + escape: false, + }), + contentFilter: /function loadManifest\(/, + callback: async ({ contents }) => { + contents = await patchCode(contents, await getLoadManifestRule(buildOpts)); + contents = await patchCode(contents, await getEvalManifestRule(buildOpts)); + return contents; }, }, ]); diff --git a/packages/cloudflare/src/cli/build/patches/plugins/next-server.ts b/packages/cloudflare/src/cli/build/patches/plugins/next-server.ts index 983e4513..69539a98 100644 --- a/packages/cloudflare/src/cli/build/patches/plugins/next-server.ts +++ b/packages/cloudflare/src/cli/build/patches/plugins/next-server.ts @@ -19,28 +19,26 @@ import { normalizePath } from "../../utils/index.js"; export function patchNextServer(updater: ContentUpdater, buildOpts: BuildOptions): Plugin { return updater.updateContent("next-server", [ { - field: { - filter: getCrossPlatformPathRegex(String.raw`/next/dist/server/next-server\.js$`, { - escape: false, - }), - contentFilter: /getBuildId\(/, - callback: async ({ contents }) => { - const { outputDir } = buildOpts; + filter: getCrossPlatformPathRegex(String.raw`/next/dist/server/next-server\.js$`, { + escape: false, + }), + contentFilter: /getBuildId\(/, + callback: async ({ contents }) => { + const { outputDir } = buildOpts; - contents = patchCode(contents, buildIdRule); + contents = patchCode(contents, buildIdRule); - const outputPath = path.join(outputDir, "server-functions/default"); - const cacheHandler = path.join(outputPath, getPackagePath(buildOpts), "cache.cjs"); - contents = patchCode(contents, createCacheHandlerRule(cacheHandler)); + const outputPath = path.join(outputDir, "server-functions/default"); + const cacheHandler = path.join(outputPath, getPackagePath(buildOpts), "cache.cjs"); + contents = patchCode(contents, createCacheHandlerRule(cacheHandler)); - const composableCacheHandler = path.join( - outputPath, - getPackagePath(buildOpts), - "composable-cache.cjs" - ); - contents = patchCode(contents, createComposableCacheHandlersRule(composableCacheHandler)); - return contents; - }, + const composableCacheHandler = path.join( + outputPath, + getPackagePath(buildOpts), + "composable-cache.cjs" + ); + contents = patchCode(contents, createComposableCacheHandlersRule(composableCacheHandler)); + return contents; }, }, ]); diff --git a/packages/cloudflare/src/cli/build/patches/plugins/open-next.ts b/packages/cloudflare/src/cli/build/patches/plugins/open-next.ts index dedbc75c..23bacbe4 100644 --- a/packages/cloudflare/src/cli/build/patches/plugins/open-next.ts +++ b/packages/cloudflare/src/cli/build/patches/plugins/open-next.ts @@ -21,14 +21,12 @@ export function patchResolveCache(updater: ContentUpdater, buildOpts: BuildOptio return updater.updateContent("patch-resolve-cache", [ { - field: { - filter: getCrossPlatformPathRegex(indexPath), - contentFilter: /cacheHandlerPath/, - callback: async ({ contents }) => { - contents = patchCode(contents, cacheHandlerRule); - contents = patchCode(contents, compositeCacheHandlerRule); - return contents; - }, + filter: getCrossPlatformPathRegex(indexPath), + contentFilter: /cacheHandlerPath/, + callback: async ({ contents }) => { + contents = patchCode(contents, cacheHandlerRule); + contents = patchCode(contents, compositeCacheHandlerRule); + return contents; }, }, ]); diff --git a/packages/cloudflare/src/cli/build/patches/plugins/patch-depd-deprecations.ts b/packages/cloudflare/src/cli/build/patches/plugins/patch-depd-deprecations.ts index 21aeffaa..3059cd21 100644 --- a/packages/cloudflare/src/cli/build/patches/plugins/patch-depd-deprecations.ts +++ b/packages/cloudflare/src/cli/build/patches/plugins/patch-depd-deprecations.ts @@ -10,11 +10,9 @@ import type { ContentUpdater, Plugin } from "@opennextjs/aws/plugins/content-upd export function patchDepdDeprecations(updater: ContentUpdater): Plugin { return updater.updateContent("patch-depd-deprecations", [ { - field: { - filter: /\.(js|mjs|cjs|jsx|ts|tsx)$/, - contentFilter: /argument fn must be a function/, - callback: ({ contents }) => patchCode(contents, rule), - }, + filter: /\.(js|mjs|cjs|jsx|ts|tsx)$/, + contentFilter: /argument fn must be a function/, + callback: ({ contents }) => patchCode(contents, rule), }, ]); } diff --git a/packages/cloudflare/src/cli/build/patches/plugins/require.ts b/packages/cloudflare/src/cli/build/patches/plugins/require.ts index 34c12855..9f18a2dd 100644 --- a/packages/cloudflare/src/cli/build/patches/plugins/require.ts +++ b/packages/cloudflare/src/cli/build/patches/plugins/require.ts @@ -3,49 +3,47 @@ import type { ContentUpdater, Plugin } from "@opennextjs/aws/plugins/content-upd export function fixRequire(updater: ContentUpdater): Plugin { return updater.updateContent("fix-require", [ { - field: { - filter: /\.(js|mjs|cjs|jsx|ts|tsx)$/, - contentFilter: /.*/, - callback: ({ contents }) => { - // `eval(...)` is not supported by workerd. - contents = contents.replaceAll(`eval("require")`, "require"); + filter: /\.(js|mjs|cjs|jsx|ts|tsx)$/, + contentFilter: /.*/, + callback: ({ contents }) => { + // `eval(...)` is not supported by workerd. + contents = contents.replaceAll(`eval("require")`, "require"); - // `@opentelemetry` has a few issues. - // - // Next.js has the following code in `next/dist/server/lib/trace/tracer.js`: - // - // try { - // api = require('@opentelemetry/api'); - // } catch (err) { - // api = require('next/dist/compiled/@opentelemetry/api'); - // } - // - // The intent is to allow users to install their own version of `@opentelemetry/api`. - // - // The problem is that even when users do not explicitly install `@opentelemetry/api`, - // `require('@opentelemetry/api')` resolves to the package which is a dependency - // of Next. - // - // The second problem is that when Next traces files, it would not copy the `api/build/esm` - // folder (used by the `module` conditions in package.json) it would only copy `api/build/src`. - // This could be solved by updating the next config: - // - // const nextConfig: NextConfig = { - // // ... - // outputFileTracingIncludes: { - // "*": ["./node_modules/@opentelemetry/api/build/**/*"], - // }, - // }; - // - // We can consider doing that when we want to enable users to install their own version - // of `@opentelemetry/api`. For now we simply use the pre-compiled version. - contents = contents.replace( - /require\(.@opentelemetry\/api.\)/g, - `require("next/dist/compiled/@opentelemetry/api")` - ); + // `@opentelemetry` has a few issues. + // + // Next.js has the following code in `next/dist/server/lib/trace/tracer.js`: + // + // try { + // api = require('@opentelemetry/api'); + // } catch (err) { + // api = require('next/dist/compiled/@opentelemetry/api'); + // } + // + // The intent is to allow users to install their own version of `@opentelemetry/api`. + // + // The problem is that even when users do not explicitly install `@opentelemetry/api`, + // `require('@opentelemetry/api')` resolves to the package which is a dependency + // of Next. + // + // The second problem is that when Next traces files, it would not copy the `api/build/esm` + // folder (used by the `module` conditions in package.json) it would only copy `api/build/src`. + // This could be solved by updating the next config: + // + // const nextConfig: NextConfig = { + // // ... + // outputFileTracingIncludes: { + // "*": ["./node_modules/@opentelemetry/api/build/**/*"], + // }, + // }; + // + // We can consider doing that when we want to enable users to install their own version + // of `@opentelemetry/api`. For now we simply use the pre-compiled version. + contents = contents.replace( + /require\(.@opentelemetry\/api.\)/g, + `require("next/dist/compiled/@opentelemetry/api")` + ); - return contents; - }, + return contents; }, }, ]); diff --git a/packages/cloudflare/src/cli/build/patches/plugins/res-revalidate.ts b/packages/cloudflare/src/cli/build/patches/plugins/res-revalidate.ts index 9fe79b1d..83342d92 100644 --- a/packages/cloudflare/src/cli/build/patches/plugins/res-revalidate.ts +++ b/packages/cloudflare/src/cli/build/patches/plugins/res-revalidate.ts @@ -68,16 +68,14 @@ export const patchResRevalidate: CodePatcher = { patches: [ { versions: ">=14.2.0", - field: { - pathFilter: getCrossPlatformPathRegex( - String.raw`(pages-api\.runtime\.prod\.js|node/api-resolver\.js)$`, - { - escape: false, - } - ), - contentFilter: /\.trustHostHeader/, - patchCode: async ({ code }) => patchCode(code, rule), - }, + pathFilter: getCrossPlatformPathRegex( + String.raw`(pages-api\.runtime\.prod\.js|node/api-resolver\.js)$`, + { + escape: false, + } + ), + contentFilter: /\.trustHostHeader/, + patchCode: async ({ code }) => patchCode(code, rule), }, ], }; diff --git a/packages/cloudflare/src/cli/build/patches/plugins/use-cache.ts b/packages/cloudflare/src/cli/build/patches/plugins/use-cache.ts index f2e90136..5587a2ee 100644 --- a/packages/cloudflare/src/cli/build/patches/plugins/use-cache.ts +++ b/packages/cloudflare/src/cli/build/patches/plugins/use-cache.ts @@ -31,13 +31,11 @@ export const patchUseCacheIO: CodePatcher = { patches: [ { versions: ">=15.3.1", - field: { - pathFilter: getCrossPlatformPathRegex(String.raw`server/app-render/async-local-storage\.js$`, { - escape: false, - }), - contentFilter: /createSnapshot/, - patchCode: async ({ code }) => patchCode(code, rule), - }, + pathFilter: getCrossPlatformPathRegex(String.raw`server/app-render/async-local-storage\.js$`, { + escape: false, + }), + contentFilter: /createSnapshot/, + patchCode: async ({ code }) => patchCode(code, rule), }, ], }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9c43f272..33488a29 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1041,8 +1041,8 @@ importers: specifier: 'catalog:' version: 1.31.0 '@opennextjs/aws': - specifier: 3.7.1 - version: 3.7.1 + specifier: 3.7.2 + version: 3.7.2 cloudflare: specifier: ^4.4.1 version: 4.4.1 @@ -3769,8 +3769,8 @@ packages: '@octokit/types@13.10.0': resolution: {integrity: sha512-ifLaO34EbbPj0Xgro4G5lP5asESjwHracYJvVaPIyXMuiuXLlhic3S47cBdTb+jfODkTE5YtGCLt3Ay3+J97sA==} - '@opennextjs/aws@3.7.1': - resolution: {integrity: sha512-ryV5cQucSJDU0TF3+Jzqn9g0/+zhUZgjNopSnchPvH0SxSAbKkNaNH7SlnWBhykjusqHaFzQ8dfEjcjAq7TJSQ==} + '@opennextjs/aws@3.7.2': + resolution: {integrity: sha512-OITG/97+ugbVI3G36/iYLKbRSyR5rG+Y99dsghSzei08tX2qQoNZ/WXlcPcF3yfKItsNOoRfDLOejeDK0XIPMw==} hasBin: true '@opentelemetry/api@1.9.0': @@ -13002,7 +13002,7 @@ snapshots: dependencies: '@octokit/openapi-types': 24.2.0 - '@opennextjs/aws@3.7.1': + '@opennextjs/aws@3.7.2': dependencies: '@ast-grep/napi': 0.35.0 '@aws-sdk/client-cloudfront': 3.398.0