Skip to content

Commit d00b3a1

Browse files
authored
bump @opennextjs/aws to 3.7.2 (#828)
1 parent 1a79710 commit d00b3a1

File tree

13 files changed

+124
-143
lines changed

13 files changed

+124
-143
lines changed

.changeset/funny-onions-behave.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@opennextjs/cloudflare": patch
3+
---
4+
5+
bump @opennextjs/aws to 3.7.2
6+
7+
See details at <https://github.com/opennextjs/opennextjs-aws/releases/tag/v3.7.2>

packages/cloudflare/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"homepage": "https://github.com/opennextjs/opennextjs-cloudflare",
5454
"dependencies": {
5555
"@dotenvx/dotenvx": "catalog:",
56-
"@opennextjs/aws": "3.7.1",
56+
"@opennextjs/aws": "3.7.2",
5757
"cloudflare": "^4.4.1",
5858
"enquirer": "^2.4.1",
5959
"glob": "catalog:",

packages/cloudflare/src/cli/build/patches/plugins/dynamic-requires.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,18 @@ function getRequires(idVariable: string, files: string[], serverDir: string) {
4545
export function inlineDynamicRequires(updater: ContentUpdater, buildOpts: BuildOptions): Plugin {
4646
updater.updateContent("inline-node-module-loader", [
4747
{
48-
field: {
49-
filter: getCrossPlatformPathRegex(String.raw`/module-loader/node-module-loader\.js$`, {
50-
escape: false,
51-
}),
52-
contentFilter: /class NodeModuleLoader {/,
53-
callback: async ({ contents }) => patchCode(contents, await getNodeModuleLoaderRule(buildOpts)),
54-
},
48+
filter: getCrossPlatformPathRegex(String.raw`/module-loader/node-module-loader\.js$`, {
49+
escape: false,
50+
}),
51+
contentFilter: /class NodeModuleLoader {/,
52+
callback: async ({ contents }) => patchCode(contents, await getNodeModuleLoaderRule(buildOpts)),
5553
},
5654
]);
5755
updater.updateContent("inline-require-page", [
5856
{
59-
field: {
60-
filter: getCrossPlatformPathRegex(String.raw`/next/dist/server/require\.js$`, { escape: false }),
61-
contentFilter: /function requirePage\(/,
62-
callback: async ({ contents }) => patchCode(contents, await getRequirePageRule(buildOpts)),
63-
},
57+
filter: getCrossPlatformPathRegex(String.raw`/next/dist/server/require\.js$`, { escape: false }),
58+
contentFilter: /function requirePage\(/,
59+
callback: async ({ contents }) => patchCode(contents, await getRequirePageRule(buildOpts)),
6460
},
6561
]);
6662
return { name: "inline-dynamic-requires", setup() {} };

packages/cloudflare/src/cli/build/patches/plugins/find-dir.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ import { getCrossPlatformPathRegex } from "@opennextjs/aws/utils/regex.js";
1313
export function inlineFindDir(updater: ContentUpdater, buildOpts: BuildOptions): Plugin {
1414
return updater.updateContent("inline-find-dir", [
1515
{
16-
field: {
17-
filter: getCrossPlatformPathRegex(String.raw`/next/dist/lib/find-pages-dir\.js$`, { escape: false }),
18-
contentFilter: /function findDir\(/,
19-
callback: async ({ contents }) => patchCode(contents, await getRule(buildOpts)),
20-
},
16+
filter: getCrossPlatformPathRegex(String.raw`/next/dist/lib/find-pages-dir\.js$`, { escape: false }),
17+
contentFilter: /function findDir\(/,
18+
callback: async ({ contents }) => patchCode(contents, await getRule(buildOpts)),
2119
},
2220
]);
2321
}

packages/cloudflare/src/cli/build/patches/plugins/instrumentation.ts

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,30 @@ export function patchInstrumentation(updater: ContentUpdater, buildOpts: BuildOp
1313

1414
updater.updateContent("patch-instrumentation-next15-4", [
1515
{
16-
field: {
17-
filter: getCrossPlatformPathRegex(
18-
String.raw`/server/lib/router-utils/instrumentation-globals.external\.js$`,
19-
{
20-
escape: false,
21-
}
22-
),
23-
contentFilter: /getInstrumentationModule\(/,
24-
callback: ({ contents }) => patchCode(contents, getNext154Rule(builtInstrumentationPath)),
25-
},
16+
filter: getCrossPlatformPathRegex(
17+
String.raw`/server/lib/router-utils/instrumentation-globals.external\.js$`,
18+
{
19+
escape: false,
20+
}
21+
),
22+
contentFilter: /getInstrumentationModule\(/,
23+
callback: ({ contents }) => patchCode(contents, getNext154Rule(builtInstrumentationPath)),
2624
},
2725
]);
2826

2927
updater.updateContent("patch-instrumentation-next15", [
3028
{
31-
field: {
32-
filter: /\.(js|mjs|cjs|jsx|ts|tsx)$/,
33-
contentFilter: /async loadInstrumentationModule\(/,
34-
callback: ({ contents }) => patchCode(contents, getNext15Rule(builtInstrumentationPath)),
35-
},
29+
filter: /\.(js|mjs|cjs|jsx|ts|tsx)$/,
30+
contentFilter: /async loadInstrumentationModule\(/,
31+
callback: ({ contents }) => patchCode(contents, getNext15Rule(builtInstrumentationPath)),
3632
},
3733
]);
3834

3935
updater.updateContent("patch-instrumentation-next14", [
4036
{
41-
field: {
42-
filter: /\.(js|mjs|cjs|jsx|ts|tsx)$/,
43-
contentFilter: /async prepareImpl\(/,
44-
callback: ({ contents }) => patchCode(contents, getNext14Rule(builtInstrumentationPath)),
45-
},
37+
filter: /\.(js|mjs|cjs|jsx|ts|tsx)$/,
38+
contentFilter: /async prepareImpl\(/,
39+
callback: ({ contents }) => patchCode(contents, getNext14Rule(builtInstrumentationPath)),
4640
},
4741
]);
4842

packages/cloudflare/src/cli/build/patches/plugins/load-manifest.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@ import { normalizePath } from "../../utils/normalize-path.js";
1818
export function inlineLoadManifest(updater: ContentUpdater, buildOpts: BuildOptions): Plugin {
1919
return updater.updateContent("inline-load-manifest", [
2020
{
21-
field: {
22-
filter: getCrossPlatformPathRegex(String.raw`/next/dist/server/load-manifest(\.external)?\.js$`, {
23-
escape: false,
24-
}),
25-
contentFilter: /function loadManifest\(/,
26-
callback: async ({ contents }) => {
27-
contents = await patchCode(contents, await getLoadManifestRule(buildOpts));
28-
contents = await patchCode(contents, await getEvalManifestRule(buildOpts));
29-
return contents;
30-
},
21+
filter: getCrossPlatformPathRegex(String.raw`/next/dist/server/load-manifest(\.external)?\.js$`, {
22+
escape: false,
23+
}),
24+
contentFilter: /function loadManifest\(/,
25+
callback: async ({ contents }) => {
26+
contents = await patchCode(contents, await getLoadManifestRule(buildOpts));
27+
contents = await patchCode(contents, await getEvalManifestRule(buildOpts));
28+
return contents;
3129
},
3230
},
3331
]);

packages/cloudflare/src/cli/build/patches/plugins/next-server.ts

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,26 @@ import { normalizePath } from "../../utils/index.js";
1919
export function patchNextServer(updater: ContentUpdater, buildOpts: BuildOptions): Plugin {
2020
return updater.updateContent("next-server", [
2121
{
22-
field: {
23-
filter: getCrossPlatformPathRegex(String.raw`/next/dist/server/next-server\.js$`, {
24-
escape: false,
25-
}),
26-
contentFilter: /getBuildId\(/,
27-
callback: async ({ contents }) => {
28-
const { outputDir } = buildOpts;
22+
filter: getCrossPlatformPathRegex(String.raw`/next/dist/server/next-server\.js$`, {
23+
escape: false,
24+
}),
25+
contentFilter: /getBuildId\(/,
26+
callback: async ({ contents }) => {
27+
const { outputDir } = buildOpts;
2928

30-
contents = patchCode(contents, buildIdRule);
29+
contents = patchCode(contents, buildIdRule);
3130

32-
const outputPath = path.join(outputDir, "server-functions/default");
33-
const cacheHandler = path.join(outputPath, getPackagePath(buildOpts), "cache.cjs");
34-
contents = patchCode(contents, createCacheHandlerRule(cacheHandler));
31+
const outputPath = path.join(outputDir, "server-functions/default");
32+
const cacheHandler = path.join(outputPath, getPackagePath(buildOpts), "cache.cjs");
33+
contents = patchCode(contents, createCacheHandlerRule(cacheHandler));
3534

36-
const composableCacheHandler = path.join(
37-
outputPath,
38-
getPackagePath(buildOpts),
39-
"composable-cache.cjs"
40-
);
41-
contents = patchCode(contents, createComposableCacheHandlersRule(composableCacheHandler));
42-
return contents;
43-
},
35+
const composableCacheHandler = path.join(
36+
outputPath,
37+
getPackagePath(buildOpts),
38+
"composable-cache.cjs"
39+
);
40+
contents = patchCode(contents, createComposableCacheHandlersRule(composableCacheHandler));
41+
return contents;
4442
},
4543
},
4644
]);

packages/cloudflare/src/cli/build/patches/plugins/open-next.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@ export function patchResolveCache(updater: ContentUpdater, buildOpts: BuildOptio
2121

2222
return updater.updateContent("patch-resolve-cache", [
2323
{
24-
field: {
25-
filter: getCrossPlatformPathRegex(indexPath),
26-
contentFilter: /cacheHandlerPath/,
27-
callback: async ({ contents }) => {
28-
contents = patchCode(contents, cacheHandlerRule);
29-
contents = patchCode(contents, compositeCacheHandlerRule);
30-
return contents;
31-
},
24+
filter: getCrossPlatformPathRegex(indexPath),
25+
contentFilter: /cacheHandlerPath/,
26+
callback: async ({ contents }) => {
27+
contents = patchCode(contents, cacheHandlerRule);
28+
contents = patchCode(contents, compositeCacheHandlerRule);
29+
return contents;
3230
},
3331
},
3432
]);

packages/cloudflare/src/cli/build/patches/plugins/patch-depd-deprecations.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ import type { ContentUpdater, Plugin } from "@opennextjs/aws/plugins/content-upd
1010
export function patchDepdDeprecations(updater: ContentUpdater): Plugin {
1111
return updater.updateContent("patch-depd-deprecations", [
1212
{
13-
field: {
14-
filter: /\.(js|mjs|cjs|jsx|ts|tsx)$/,
15-
contentFilter: /argument fn must be a function/,
16-
callback: ({ contents }) => patchCode(contents, rule),
17-
},
13+
filter: /\.(js|mjs|cjs|jsx|ts|tsx)$/,
14+
contentFilter: /argument fn must be a function/,
15+
callback: ({ contents }) => patchCode(contents, rule),
1816
},
1917
]);
2018
}

packages/cloudflare/src/cli/build/patches/plugins/require.ts

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,47 @@ import type { ContentUpdater, Plugin } from "@opennextjs/aws/plugins/content-upd
33
export function fixRequire(updater: ContentUpdater): Plugin {
44
return updater.updateContent("fix-require", [
55
{
6-
field: {
7-
filter: /\.(js|mjs|cjs|jsx|ts|tsx)$/,
8-
contentFilter: /.*/,
9-
callback: ({ contents }) => {
10-
// `eval(...)` is not supported by workerd.
11-
contents = contents.replaceAll(`eval("require")`, "require");
6+
filter: /\.(js|mjs|cjs|jsx|ts|tsx)$/,
7+
contentFilter: /.*/,
8+
callback: ({ contents }) => {
9+
// `eval(...)` is not supported by workerd.
10+
contents = contents.replaceAll(`eval("require")`, "require");
1211

13-
// `@opentelemetry` has a few issues.
14-
//
15-
// Next.js has the following code in `next/dist/server/lib/trace/tracer.js`:
16-
//
17-
// try {
18-
// api = require('@opentelemetry/api');
19-
// } catch (err) {
20-
// api = require('next/dist/compiled/@opentelemetry/api');
21-
// }
22-
//
23-
// The intent is to allow users to install their own version of `@opentelemetry/api`.
24-
//
25-
// The problem is that even when users do not explicitly install `@opentelemetry/api`,
26-
// `require('@opentelemetry/api')` resolves to the package which is a dependency
27-
// of Next.
28-
//
29-
// The second problem is that when Next traces files, it would not copy the `api/build/esm`
30-
// folder (used by the `module` conditions in package.json) it would only copy `api/build/src`.
31-
// This could be solved by updating the next config:
32-
//
33-
// const nextConfig: NextConfig = {
34-
// // ...
35-
// outputFileTracingIncludes: {
36-
// "*": ["./node_modules/@opentelemetry/api/build/**/*"],
37-
// },
38-
// };
39-
//
40-
// We can consider doing that when we want to enable users to install their own version
41-
// of `@opentelemetry/api`. For now we simply use the pre-compiled version.
42-
contents = contents.replace(
43-
/require\(.@opentelemetry\/api.\)/g,
44-
`require("next/dist/compiled/@opentelemetry/api")`
45-
);
12+
// `@opentelemetry` has a few issues.
13+
//
14+
// Next.js has the following code in `next/dist/server/lib/trace/tracer.js`:
15+
//
16+
// try {
17+
// api = require('@opentelemetry/api');
18+
// } catch (err) {
19+
// api = require('next/dist/compiled/@opentelemetry/api');
20+
// }
21+
//
22+
// The intent is to allow users to install their own version of `@opentelemetry/api`.
23+
//
24+
// The problem is that even when users do not explicitly install `@opentelemetry/api`,
25+
// `require('@opentelemetry/api')` resolves to the package which is a dependency
26+
// of Next.
27+
//
28+
// The second problem is that when Next traces files, it would not copy the `api/build/esm`
29+
// folder (used by the `module` conditions in package.json) it would only copy `api/build/src`.
30+
// This could be solved by updating the next config:
31+
//
32+
// const nextConfig: NextConfig = {
33+
// // ...
34+
// outputFileTracingIncludes: {
35+
// "*": ["./node_modules/@opentelemetry/api/build/**/*"],
36+
// },
37+
// };
38+
//
39+
// We can consider doing that when we want to enable users to install their own version
40+
// of `@opentelemetry/api`. For now we simply use the pre-compiled version.
41+
contents = contents.replace(
42+
/require\(.@opentelemetry\/api.\)/g,
43+
`require("next/dist/compiled/@opentelemetry/api")`
44+
);
4645

47-
return contents;
48-
},
46+
return contents;
4947
},
5048
},
5149
]);

0 commit comments

Comments
 (0)