@opennextjs/aws 3.9.6 → 3.9.8
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/adapters/composable-cache.d.ts +9 -1
- package/dist/adapters/composable-cache.js +10 -1
- package/dist/build/copyTracedFiles.js +8 -2
- package/dist/build/createServerBundle.js +1 -0
- package/dist/build/installDeps.js +17 -19
- package/dist/build/patch/codePatcher.d.ts +4 -0
- package/dist/build/patch/codePatcher.js +1 -0
- package/dist/build/patch/patches/index.d.ts +1 -0
- package/dist/build/patch/patches/index.js +1 -0
- package/dist/build/patch/patches/patchNextConfig.d.ts +2 -0
- package/dist/build/patch/patches/patchNextConfig.js +54 -0
- package/dist/types/cache.d.ts +7 -1
- package/package.json +1 -1
|
@@ -10,7 +10,15 @@ declare const _default: {
|
|
|
10
10
|
} | undefined>;
|
|
11
11
|
set(cacheKey: string, pendingEntry: Promise<ComposableCacheEntry>): Promise<void>;
|
|
12
12
|
refreshTags(): Promise<void>;
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The signature has changed in Next.js 16
|
|
15
|
+
* - Before Next.js 16, the method takes `...tags: string[]`
|
|
16
|
+
* - From Next.js 16, the method takes `tags: string[]`
|
|
17
|
+
*/
|
|
18
|
+
getExpiration(...tags: string[] | string[][]): Promise<number>;
|
|
19
|
+
/**
|
|
20
|
+
* This method is only used before Next.js 16
|
|
21
|
+
*/
|
|
14
22
|
expireTags(...tags: string[]): Promise<void>;
|
|
15
23
|
receiveExpiredTags(...tags: string[]): Promise<void>;
|
|
16
24
|
};
|
|
@@ -73,14 +73,23 @@ export default {
|
|
|
73
73
|
// We don't do anything for now, do we want to do something here ???
|
|
74
74
|
return;
|
|
75
75
|
},
|
|
76
|
+
/**
|
|
77
|
+
* The signature has changed in Next.js 16
|
|
78
|
+
* - Before Next.js 16, the method takes `...tags: string[]`
|
|
79
|
+
* - From Next.js 16, the method takes `tags: string[]`
|
|
80
|
+
*/
|
|
76
81
|
async getExpiration(...tags) {
|
|
77
82
|
if (globalThis.tagCache.mode === "nextMode") {
|
|
78
|
-
|
|
83
|
+
// Use `.flat()` to accommodate both signatures
|
|
84
|
+
return globalThis.tagCache.getLastRevalidated(tags.flat());
|
|
79
85
|
}
|
|
80
86
|
// We always return 0 here, original tag cache are handled directly in the get part
|
|
81
87
|
// TODO: We need to test this more, i'm not entirely sure that this is working as expected
|
|
82
88
|
return 0;
|
|
83
89
|
},
|
|
90
|
+
/**
|
|
91
|
+
* This method is only used before Next.js 16
|
|
92
|
+
*/
|
|
84
93
|
async expireTags(...tags) {
|
|
85
94
|
if (globalThis.tagCache.mode === "nextMode") {
|
|
86
95
|
return writeTags(tags);
|
|
@@ -217,13 +217,19 @@ File ${serverPath} does not exist
|
|
|
217
217
|
});
|
|
218
218
|
readdirSync(standaloneNextDir)
|
|
219
219
|
.filter((fileOrDir) => !statSync(path.join(standaloneNextDir, fileOrDir)).isDirectory())
|
|
220
|
-
.forEach((file) =>
|
|
220
|
+
.forEach((file) => {
|
|
221
|
+
copyFileSync(path.join(standaloneNextDir, file), path.join(outputNextDir, file));
|
|
222
|
+
tracedFiles.push(path.join(outputNextDir, file));
|
|
223
|
+
});
|
|
221
224
|
// We then need to copy all the files at the root of server
|
|
222
225
|
mkdirSync(path.join(outputNextDir, "server"), { recursive: true });
|
|
223
226
|
readdirSync(standaloneServerDir)
|
|
224
227
|
.filter((fileOrDir) => !statSync(path.join(standaloneServerDir, fileOrDir)).isDirectory())
|
|
225
228
|
.filter((file) => file !== "server.js")
|
|
226
|
-
.forEach((file) =>
|
|
229
|
+
.forEach((file) => {
|
|
230
|
+
copyFileSync(path.join(standaloneServerDir, file), path.join(path.join(outputNextDir, "server"), file));
|
|
231
|
+
tracedFiles.push(path.join(outputNextDir, "server", file));
|
|
232
|
+
});
|
|
227
233
|
// Copy patch file
|
|
228
234
|
copyPatchFile(path.join(outputDir, packagePath));
|
|
229
235
|
// TODO: Recompute all the files.
|
|
@@ -127,6 +127,7 @@ async function generateBundle(name, options, fnOptions, codeCustomization) {
|
|
|
127
127
|
patches.patchBackgroundRevalidation,
|
|
128
128
|
patches.patchUseCacheForISR,
|
|
129
129
|
patches.patchNodeEnvironment,
|
|
130
|
+
patches.patchNextConfig,
|
|
130
131
|
...additionalCodePatches,
|
|
131
132
|
]);
|
|
132
133
|
// Build Lambda code
|
|
@@ -3,7 +3,6 @@ import os from "node:os";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { execSync } from "node:child_process";
|
|
5
5
|
import logger from "../logger.js";
|
|
6
|
-
const AFFECTED_NODE_VERSIONS = ["22.17.0", "22.17.1", "22.18.0"];
|
|
7
6
|
export function installDependencies(outputDir, installOptions) {
|
|
8
7
|
try {
|
|
9
8
|
if (!installOptions) {
|
|
@@ -37,28 +36,27 @@ export function installDependencies(outputDir, installOptions) {
|
|
|
37
36
|
});
|
|
38
37
|
// Copy the node_modules to the outputDir
|
|
39
38
|
fs.cpSync(path.join(tempInstallDir, "node_modules"), path.join(outputDir, "node_modules"), { recursive: true, force: true, dereference: true });
|
|
40
|
-
// This is a workaround for Node `22.17.0` and `22.17.1`
|
|
41
39
|
// https://github.com/nodejs/node/issues/59168
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
fs.copyFileSync(realFilePath, outputFilePath);
|
|
57
|
-
fs.chmodSync(outputFilePath, "755");
|
|
58
|
-
logger.debug(`Replaced symlink ${fileName} with actual file`);
|
|
40
|
+
// This is a workaround for all Node versions. It seems to be an issue continue to affect new versions aswell.
|
|
41
|
+
// Therefor I think the most logical solution is to always run this workaround instead of trying to figure out which versions are affected.
|
|
42
|
+
const tempBinDir = path.join(tempInstallDir, "node_modules", ".bin");
|
|
43
|
+
const outputBinDir = path.join(outputDir, "node_modules", ".bin");
|
|
44
|
+
for (const fileName of fs.readdirSync(tempBinDir)) {
|
|
45
|
+
const symlinkPath = path.join(tempBinDir, fileName);
|
|
46
|
+
const stat = fs.lstatSync(symlinkPath);
|
|
47
|
+
if (stat.isSymbolicLink()) {
|
|
48
|
+
const linkTarget = fs.readlinkSync(symlinkPath);
|
|
49
|
+
const realFilePath = path.resolve(tempBinDir, linkTarget);
|
|
50
|
+
const outputFilePath = path.join(outputBinDir, fileName);
|
|
51
|
+
if (fs.existsSync(outputFilePath)) {
|
|
52
|
+
fs.unlinkSync(outputFilePath);
|
|
59
53
|
}
|
|
54
|
+
fs.copyFileSync(realFilePath, outputFilePath);
|
|
55
|
+
fs.chmodSync(outputFilePath, "755");
|
|
56
|
+
logger.debug(`Replaced symlink ${fileName} with actual file`);
|
|
60
57
|
}
|
|
61
58
|
}
|
|
59
|
+
// End of Node Workaround
|
|
62
60
|
// Cleanup tempDir
|
|
63
61
|
fs.rmSync(tempInstallDir, { recursive: true, force: true });
|
|
64
62
|
logger.info(`Dependencies installed for ${name}`);
|
|
@@ -26,6 +26,10 @@ export type PatchCodeFn = (args: {
|
|
|
26
26
|
* Next.js manifests that are used by Next at runtime
|
|
27
27
|
*/
|
|
28
28
|
manifests: ReturnType<typeof getManifests>;
|
|
29
|
+
/**
|
|
30
|
+
* OpenNext build options
|
|
31
|
+
*/
|
|
32
|
+
buildOptions: buildHelper.BuildOptions;
|
|
29
33
|
}) => Promise<string>;
|
|
30
34
|
interface IndividualPatch {
|
|
31
35
|
pathFilter: RegExp;
|
|
@@ -4,3 +4,4 @@ export { patchFetchCacheForISR, patchUnstableCacheForISR, patchUseCacheForISR, }
|
|
|
4
4
|
export { patchFetchCacheSetMissingWaitUntil } from "./patchFetchCacheWaitUntil.js";
|
|
5
5
|
export { patchBackgroundRevalidation } from "./patchBackgroundRevalidation.js";
|
|
6
6
|
export { patchNodeEnvironment } from "./patchNodeEnvironment.js";
|
|
7
|
+
export { patchNextConfig } from "./patchNextConfig.js";
|
|
@@ -4,3 +4,4 @@ export { patchFetchCacheForISR, patchUnstableCacheForISR, patchUseCacheForISR, }
|
|
|
4
4
|
export { patchFetchCacheSetMissingWaitUntil } from "./patchFetchCacheWaitUntil.js";
|
|
5
5
|
export { patchBackgroundRevalidation } from "./patchBackgroundRevalidation.js";
|
|
6
6
|
export { patchNodeEnvironment } from "./patchNodeEnvironment.js";
|
|
7
|
+
export { patchNextConfig } from "./patchNextConfig.js";
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { buildSync } from "esbuild";
|
|
4
|
+
export const patchNextConfig = {
|
|
5
|
+
name: "patch-next-config",
|
|
6
|
+
patches: [
|
|
7
|
+
{
|
|
8
|
+
pathFilter: /required\-server\-files\.json$/,
|
|
9
|
+
versions: ">=16.1.0",
|
|
10
|
+
patchCode: async ({ code, buildOptions }) => {
|
|
11
|
+
// Find the next.config file with any supported extension
|
|
12
|
+
const tsExtensions = [".ts", ".mts", ".cts"];
|
|
13
|
+
const possibleExtensions = [...tsExtensions, ".mjs", ".js", ".cjs"];
|
|
14
|
+
let configPath;
|
|
15
|
+
let configExtension;
|
|
16
|
+
for (const ext of possibleExtensions) {
|
|
17
|
+
const testPath = path.join(buildOptions.appPath, `next.config${ext}`);
|
|
18
|
+
if (fs.existsSync(testPath)) {
|
|
19
|
+
configPath = testPath;
|
|
20
|
+
configExtension = ext;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (!configPath || !configExtension) {
|
|
25
|
+
throw new Error("Could not find next.config file");
|
|
26
|
+
}
|
|
27
|
+
let configToImport;
|
|
28
|
+
// Only compile if the extension is a TypeScript extension
|
|
29
|
+
if (tsExtensions.includes(configExtension)) {
|
|
30
|
+
buildSync({
|
|
31
|
+
entryPoints: [configPath],
|
|
32
|
+
outfile: path.join(buildOptions.tempBuildDir, "next.config.mjs"),
|
|
33
|
+
bundle: true,
|
|
34
|
+
format: "esm",
|
|
35
|
+
platform: "node",
|
|
36
|
+
});
|
|
37
|
+
configToImport = path.join(buildOptions.tempBuildDir, "next.config.mjs");
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// For .js, .mjs, .cjs, use the file directly
|
|
41
|
+
configToImport = configPath;
|
|
42
|
+
}
|
|
43
|
+
// In next 16.1+ we need to add `skipTrailingSlashRedirect` manually because next removes it from the config
|
|
44
|
+
const originalConfig = (await import(configToImport)).default;
|
|
45
|
+
const config = JSON.parse(code);
|
|
46
|
+
if (config.config.skipTrailingSlashRedirect === undefined) {
|
|
47
|
+
config.config.skipTrailingSlashRedirect =
|
|
48
|
+
originalConfig.skipTrailingSlashRedirect ?? false;
|
|
49
|
+
}
|
|
50
|
+
return JSON.stringify(config, null, 2);
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
};
|
package/dist/types/cache.d.ts
CHANGED
|
@@ -126,7 +126,13 @@ export interface ComposableCacheHandler {
|
|
|
126
126
|
get(cacheKey: string): Promise<ComposableCacheEntry | undefined>;
|
|
127
127
|
set(cacheKey: string, pendingEntry: Promise<ComposableCacheEntry>): Promise<void>;
|
|
128
128
|
refreshTags(): Promise<void>;
|
|
129
|
-
|
|
129
|
+
/**
|
|
130
|
+
* Next 16 takes an array of tags instead of variadic arguments
|
|
131
|
+
*/
|
|
132
|
+
getExpiration(...tags: string[] | string[][]): Promise<number>;
|
|
133
|
+
/**
|
|
134
|
+
* Removed from Next.js 16
|
|
135
|
+
*/
|
|
130
136
|
expireTags(...tags: string[]): Promise<void>;
|
|
131
137
|
/**
|
|
132
138
|
* This function is only there for older versions and do nothing
|