@opennextjs/aws 3.4.0 → 3.4.1
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/cache.js +4 -3
- package/dist/adapters/logger.js +2 -2
- package/dist/build/createAssets.js +1 -1
- package/dist/build/createServerBundle.js +4 -5
- package/dist/build/helper.d.ts +10 -1
- package/dist/build/helper.js +19 -3
- package/dist/core/edgeFunctionHandler.js +2 -1
- package/dist/overrides/tagCache/dynamodb-lite.js +8 -4
- package/dist/overrides/tagCache/dynamodb.js +8 -4
- package/dist/types/global.d.ts +12 -11
- package/package.json +1 -1
package/dist/adapters/cache.js
CHANGED
|
@@ -16,7 +16,7 @@ export default class Cache {
|
|
|
16
16
|
async get(key,
|
|
17
17
|
// fetchCache is for next 13.5 and above, kindHint is for next 14 and above and boolean is for earlier versions
|
|
18
18
|
options) {
|
|
19
|
-
if (globalThis.disableIncrementalCache) {
|
|
19
|
+
if (globalThis.openNextConfig.dangerous?.disableIncrementalCache) {
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
22
22
|
const softTags = typeof options === "object" ? options.softTags : [];
|
|
@@ -130,7 +130,7 @@ export default class Cache {
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
async set(key, data, ctx) {
|
|
133
|
-
if (globalThis.disableIncrementalCache) {
|
|
133
|
+
if (globalThis.openNextConfig.dangerous?.disableIncrementalCache) {
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
136
|
// This one might not even be necessary anymore
|
|
@@ -242,7 +242,8 @@ export default class Cache {
|
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
async revalidateTag(tags) {
|
|
245
|
-
|
|
245
|
+
const config = globalThis.openNextConfig.dangerous;
|
|
246
|
+
if (config?.disableTagCache || config?.disableIncrementalCache) {
|
|
246
247
|
return;
|
|
247
248
|
}
|
|
248
249
|
try {
|
package/dist/adapters/logger.js
CHANGED
|
@@ -21,9 +21,9 @@ const isDownplayedErrorLog = (errorLog) => DOWNPLAYED_ERROR_LOGS.some((downplaye
|
|
|
21
21
|
export function error(...args) {
|
|
22
22
|
// we try to catch errors from the aws-sdk client and downplay some of them
|
|
23
23
|
if (args.some((arg) => isDownplayedErrorLog(arg))) {
|
|
24
|
-
debug(...args);
|
|
24
|
+
return debug(...args);
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
if (args.some((arg) => isOpenNextError(arg))) {
|
|
27
27
|
// In case of an internal error, we log it with the appropriate log level
|
|
28
28
|
const error = args.find((arg) => isOpenNextError(arg));
|
|
29
29
|
if (error.logLevel < getOpenNextErrorLogLevel()) {
|
|
@@ -44,7 +44,7 @@ export function createStaticAssets(options) {
|
|
|
44
44
|
export function createCacheAssets(options) {
|
|
45
45
|
logger.info("Bundling cache assets...");
|
|
46
46
|
const { appBuildOutputPath, outputDir } = options;
|
|
47
|
-
const packagePath =
|
|
47
|
+
const packagePath = buildHelper.getPackagePath(options);
|
|
48
48
|
const buildId = buildHelper.getBuildId(appBuildOutputPath);
|
|
49
49
|
let useTagCache = false;
|
|
50
50
|
// Copy pages to cache folder
|
|
@@ -36,10 +36,9 @@ export async function createServerBundle(options) {
|
|
|
36
36
|
// We build every other function than default before so we know which route there is left
|
|
37
37
|
await Promise.all(promises);
|
|
38
38
|
const remainingRoutes = new Set();
|
|
39
|
-
const { appBuildOutputPath
|
|
40
|
-
const packagePath = path.relative(monorepoRoot, appBuildOutputPath);
|
|
39
|
+
const { appBuildOutputPath } = options;
|
|
41
40
|
// Find remaining routes
|
|
42
|
-
const serverPath = path.join(appBuildOutputPath, ".next
|
|
41
|
+
const serverPath = path.join(appBuildOutputPath, ".next/standalone", buildHelper.getPackagePath(options), ".next/server");
|
|
43
42
|
// Find app dir routes
|
|
44
43
|
if (fs.existsSync(path.join(serverPath, "app"))) {
|
|
45
44
|
const appPath = path.join(serverPath, "app");
|
|
@@ -78,7 +77,7 @@ async function generateBundle(name, options, fnOptions) {
|
|
|
78
77
|
// `node_modules` inside `.next/standalone`, and others inside
|
|
79
78
|
// `.next/standalone/package/path` (ie. `.next`, `server.js`).
|
|
80
79
|
// We need to output the handler file inside the package path.
|
|
81
|
-
const packagePath =
|
|
80
|
+
const packagePath = buildHelper.getPackagePath(options);
|
|
82
81
|
fs.mkdirSync(path.join(outputPath, packagePath), { recursive: true });
|
|
83
82
|
const ext = fnOptions.runtime === "deno" ? "mjs" : "cjs";
|
|
84
83
|
fs.copyFileSync(path.join(options.buildDir, `cache.${ext}`), path.join(outputPath, packagePath, "cache.cjs"));
|
|
@@ -110,7 +109,7 @@ async function generateBundle(name, options, fnOptions) {
|
|
|
110
109
|
buildHelper.compareSemver(options.nextVersion, "13.4.1") <= 0;
|
|
111
110
|
const overrides = fnOptions.override ?? {};
|
|
112
111
|
const isBefore13413 = buildHelper.compareSemver(options.nextVersion, "13.4.13") <= 0;
|
|
113
|
-
const isAfter141 = buildHelper.compareSemver(options.nextVersion, "14.
|
|
112
|
+
const isAfter141 = buildHelper.compareSemver(options.nextVersion, "14.1") >= 0;
|
|
114
113
|
const disableRouting = isBefore13413 || config.middleware?.external;
|
|
115
114
|
const plugins = [
|
|
116
115
|
openNextReplacementPlugin({
|
package/dist/build/helper.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare function normalizeOptions(config: OpenNextConfig, distDir: string
|
|
|
15
15
|
openNextVersion: string;
|
|
16
16
|
openNextDistDir: string;
|
|
17
17
|
outputDir: string;
|
|
18
|
-
packager: "
|
|
18
|
+
packager: "bun" | "npm" | "yarn" | "pnpm";
|
|
19
19
|
tempBuildDir: string;
|
|
20
20
|
};
|
|
21
21
|
export declare function esbuildSync(esbuildOptions: ESBuildOptions, options: BuildOptions): void;
|
|
@@ -51,6 +51,14 @@ export declare function getHtmlPages(dotNextPath: string): Set<string>;
|
|
|
51
51
|
export declare function getBuildId(dotNextPath: string): string;
|
|
52
52
|
export declare function getOpenNextVersion(): string;
|
|
53
53
|
export declare function getNextVersion(appPath: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* Compare two semver versions.
|
|
56
|
+
*
|
|
57
|
+
* @param v1 - First version. Can be "latest", otherwise it should be a valid semver version in the format of `major.minor.patch`. Usually is the next version from the package.json without canary suffix. If minor or patch are missing, they are considered 0.
|
|
58
|
+
* @param v2 - Second version. Should not be "latest", it should be a valid semver version in the format of `major.minor.patch`. If minor or patch are missing, they are considered 0.
|
|
59
|
+
* @example
|
|
60
|
+
* compareSemver("1.0.0", "1.0.0") // 0
|
|
61
|
+
*/
|
|
54
62
|
export declare function compareSemver(v1: string, v2: string): number;
|
|
55
63
|
export declare function copyOpenNextConfig(inputDir: string, outputDir: string, isEdge?: boolean): void;
|
|
56
64
|
export declare function copyEnvFile(appPath: string, packagePath: string, outputPath: string): void;
|
|
@@ -73,3 +81,4 @@ export declare function initOutputDir(options: BuildOptions): void;
|
|
|
73
81
|
* @returns Whether the edge runtime is used
|
|
74
82
|
*/
|
|
75
83
|
export declare function isEdgeRuntime(overrides: DefaultOverrideOptions | undefined): Promise<boolean | undefined>;
|
|
84
|
+
export declare function getPackagePath(options: BuildOptions): string;
|
package/dist/build/helper.js
CHANGED
|
@@ -45,10 +45,12 @@ function findMonorepoRoot(appPath) {
|
|
|
45
45
|
let currentPath = appPath;
|
|
46
46
|
while (currentPath !== "/") {
|
|
47
47
|
const found = [
|
|
48
|
+
// bun can generate yaml lock files (`bun install --yarn`) so bun should be before yarn
|
|
49
|
+
{ file: "bun.lockb", packager: "bun" },
|
|
50
|
+
{ file: "bun.lock", packager: "bun" },
|
|
48
51
|
{ file: "package-lock.json", packager: "npm" },
|
|
49
52
|
{ file: "yarn.lock", packager: "yarn" },
|
|
50
53
|
{ file: "pnpm-lock.yaml", packager: "pnpm" },
|
|
51
|
-
{ file: "bun.lockb", packager: "bun" },
|
|
52
54
|
].find((f) => fs.existsSync(path.join(currentPath, f.file)));
|
|
53
55
|
if (found) {
|
|
54
56
|
if (currentPath !== appPath) {
|
|
@@ -198,6 +200,14 @@ export function getNextVersion(appPath) {
|
|
|
198
200
|
// Drop the -canary.n suffix
|
|
199
201
|
return version.split("-")[0];
|
|
200
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Compare two semver versions.
|
|
205
|
+
*
|
|
206
|
+
* @param v1 - First version. Can be "latest", otherwise it should be a valid semver version in the format of `major.minor.patch`. Usually is the next version from the package.json without canary suffix. If minor or patch are missing, they are considered 0.
|
|
207
|
+
* @param v2 - Second version. Should not be "latest", it should be a valid semver version in the format of `major.minor.patch`. If minor or patch are missing, they are considered 0.
|
|
208
|
+
* @example
|
|
209
|
+
* compareSemver("1.0.0", "1.0.0") // 0
|
|
210
|
+
*/
|
|
201
211
|
export function compareSemver(v1, v2) {
|
|
202
212
|
if (v1 === "latest")
|
|
203
213
|
return 1;
|
|
@@ -209,8 +219,11 @@ export function compareSemver(v1, v2) {
|
|
|
209
219
|
// biome-ignore lint/style/noParameterAssign:
|
|
210
220
|
v2 = v2.substring(1);
|
|
211
221
|
}
|
|
212
|
-
const [major1, minor1, patch1] = v1.split(".").map(Number);
|
|
213
|
-
const [major2, minor2, patch2] = v2.split(".").map(Number);
|
|
222
|
+
const [major1, minor1 = 0, patch1 = 0] = v1.split(".").map(Number);
|
|
223
|
+
const [major2, minor2 = 0, patch2 = 0] = v2.split(".").map(Number);
|
|
224
|
+
if (Number.isNaN(major1) || Number.isNaN(major2)) {
|
|
225
|
+
throw new Error("The major version is required.");
|
|
226
|
+
}
|
|
214
227
|
if (major1 !== major2)
|
|
215
228
|
return major1 - major2;
|
|
216
229
|
if (minor1 !== minor2)
|
|
@@ -276,3 +289,6 @@ export async function isEdgeRuntime(overrides) {
|
|
|
276
289
|
}
|
|
277
290
|
return (await overrides?.wrapper?.())?.edgeRuntime;
|
|
278
291
|
}
|
|
292
|
+
export function getPackagePath(options) {
|
|
293
|
+
return path.relative(options.monorepoRoot, options.appBuildOutputPath);
|
|
294
|
+
}
|
|
@@ -6,7 +6,8 @@ export default async function edgeFunctionHandler(request) {
|
|
|
6
6
|
if (!correspondingRoute) {
|
|
7
7
|
throw new Error(`No route found for ${request.url}`);
|
|
8
8
|
}
|
|
9
|
-
const
|
|
9
|
+
const entry = await self._ENTRIES[`middleware_${correspondingRoute.name}`];
|
|
10
|
+
const result = await entry.default({
|
|
10
11
|
page: correspondingRoute.page,
|
|
11
12
|
request: {
|
|
12
13
|
...request,
|
|
@@ -49,8 +49,9 @@ function buildDynamoObject(path, tags, revalidatedAt) {
|
|
|
49
49
|
const tagCache = {
|
|
50
50
|
async getByPath(path) {
|
|
51
51
|
try {
|
|
52
|
-
if (globalThis.
|
|
52
|
+
if (globalThis.openNextConfig.dangerous?.disableTagCache) {
|
|
53
53
|
return [];
|
|
54
|
+
}
|
|
54
55
|
const { CACHE_DYNAMO_TABLE, NEXT_BUILD_ID } = process.env;
|
|
55
56
|
const result = await awsFetch(JSON.stringify({
|
|
56
57
|
TableName: CACHE_DYNAMO_TABLE,
|
|
@@ -79,8 +80,9 @@ const tagCache = {
|
|
|
79
80
|
},
|
|
80
81
|
async getByTag(tag) {
|
|
81
82
|
try {
|
|
82
|
-
if (globalThis.
|
|
83
|
+
if (globalThis.openNextConfig.dangerous?.disableTagCache) {
|
|
83
84
|
return [];
|
|
85
|
+
}
|
|
84
86
|
const { CACHE_DYNAMO_TABLE, NEXT_BUILD_ID } = process.env;
|
|
85
87
|
const result = await awsFetch(JSON.stringify({
|
|
86
88
|
TableName: CACHE_DYNAMO_TABLE,
|
|
@@ -107,8 +109,9 @@ const tagCache = {
|
|
|
107
109
|
},
|
|
108
110
|
async getLastModified(key, lastModified) {
|
|
109
111
|
try {
|
|
110
|
-
if (globalThis.
|
|
112
|
+
if (globalThis.openNextConfig.dangerous?.disableTagCache) {
|
|
111
113
|
return lastModified ?? Date.now();
|
|
114
|
+
}
|
|
112
115
|
const { CACHE_DYNAMO_TABLE } = process.env;
|
|
113
116
|
const result = await awsFetch(JSON.stringify({
|
|
114
117
|
TableName: CACHE_DYNAMO_TABLE,
|
|
@@ -139,8 +142,9 @@ const tagCache = {
|
|
|
139
142
|
async writeTags(tags) {
|
|
140
143
|
try {
|
|
141
144
|
const { CACHE_DYNAMO_TABLE } = process.env;
|
|
142
|
-
if (globalThis.
|
|
145
|
+
if (globalThis.openNextConfig.dangerous?.disableTagCache) {
|
|
143
146
|
return;
|
|
147
|
+
}
|
|
144
148
|
const dataChunks = chunk(tags, MAX_DYNAMO_BATCH_WRITE_ITEM_COUNT).map((Items) => ({
|
|
145
149
|
RequestItems: {
|
|
146
150
|
[CACHE_DYNAMO_TABLE ?? ""]: Items.map((Item) => ({
|
|
@@ -27,8 +27,9 @@ function buildDynamoObject(path, tags, revalidatedAt) {
|
|
|
27
27
|
const tagCache = {
|
|
28
28
|
async getByPath(path) {
|
|
29
29
|
try {
|
|
30
|
-
if (globalThis.
|
|
30
|
+
if (globalThis.openNextConfig.dangerous?.disableTagCache) {
|
|
31
31
|
return [];
|
|
32
|
+
}
|
|
32
33
|
const result = await dynamoClient.send(new QueryCommand({
|
|
33
34
|
TableName: CACHE_DYNAMO_TABLE,
|
|
34
35
|
IndexName: "revalidate",
|
|
@@ -52,8 +53,9 @@ const tagCache = {
|
|
|
52
53
|
},
|
|
53
54
|
async getByTag(tag) {
|
|
54
55
|
try {
|
|
55
|
-
if (globalThis.
|
|
56
|
+
if (globalThis.openNextConfig.dangerous?.disableTagCache) {
|
|
56
57
|
return [];
|
|
58
|
+
}
|
|
57
59
|
const { Items } = await dynamoClient.send(new QueryCommand({
|
|
58
60
|
TableName: CACHE_DYNAMO_TABLE,
|
|
59
61
|
KeyConditionExpression: "#tag = :tag",
|
|
@@ -75,8 +77,9 @@ const tagCache = {
|
|
|
75
77
|
},
|
|
76
78
|
async getLastModified(key, lastModified) {
|
|
77
79
|
try {
|
|
78
|
-
if (globalThis.
|
|
80
|
+
if (globalThis.openNextConfig.dangerous?.disableTagCache) {
|
|
79
81
|
return lastModified ?? Date.now();
|
|
82
|
+
}
|
|
80
83
|
const result = await dynamoClient.send(new QueryCommand({
|
|
81
84
|
TableName: CACHE_DYNAMO_TABLE,
|
|
82
85
|
IndexName: "revalidate",
|
|
@@ -102,8 +105,9 @@ const tagCache = {
|
|
|
102
105
|
},
|
|
103
106
|
async writeTags(tags) {
|
|
104
107
|
try {
|
|
105
|
-
if (globalThis.
|
|
108
|
+
if (globalThis.openNextConfig.dangerous?.disableTagCache) {
|
|
106
109
|
return;
|
|
110
|
+
}
|
|
107
111
|
const dataChunks = chunk(tags, MAX_DYNAMO_BATCH_WRITE_ITEM_COUNT).map((Items) => ({
|
|
108
112
|
RequestItems: {
|
|
109
113
|
[CACHE_DYNAMO_TABLE ?? ""]: Items.map((Item) => ({
|
package/dist/types/global.d.ts
CHANGED
|
@@ -29,16 +29,17 @@ export interface RequestData {
|
|
|
29
29
|
body?: ReadableStream<Uint8Array>;
|
|
30
30
|
signal: AbortSignal;
|
|
31
31
|
}
|
|
32
|
+
interface Entry {
|
|
33
|
+
default: (props: {
|
|
34
|
+
page: string;
|
|
35
|
+
request: RequestData;
|
|
36
|
+
}) => Promise<{
|
|
37
|
+
response: Response;
|
|
38
|
+
waitUntil: Promise<void>;
|
|
39
|
+
}>;
|
|
40
|
+
}
|
|
32
41
|
interface Entries {
|
|
33
|
-
[k: string]:
|
|
34
|
-
default: (props: {
|
|
35
|
-
page: string;
|
|
36
|
-
request: RequestData;
|
|
37
|
-
}) => Promise<{
|
|
38
|
-
response: Response;
|
|
39
|
-
waitUntil: Promise<void>;
|
|
40
|
-
}>;
|
|
41
|
-
};
|
|
42
|
+
[k: string]: Entry | Promise<Entry>;
|
|
42
43
|
}
|
|
43
44
|
export interface EdgeRoute {
|
|
44
45
|
name: string;
|
|
@@ -66,13 +67,13 @@ declare global {
|
|
|
66
67
|
var tagCache: TagCache;
|
|
67
68
|
/**
|
|
68
69
|
* A boolean that indicates if the DynamoDB cache is disabled.
|
|
69
|
-
*
|
|
70
|
+
* @deprecated This will be removed, use `globalThis.openNextConfig.dangerous?.disableTagCache` instead.
|
|
70
71
|
* Defined in esbuild banner for the cache adapter.
|
|
71
72
|
*/
|
|
72
73
|
var disableDynamoDBCache: boolean;
|
|
73
74
|
/**
|
|
74
75
|
* A boolean that indicates if the incremental cache is disabled.
|
|
75
|
-
*
|
|
76
|
+
* @deprecated This will be removed, use `globalThis.openNextConfig.dangerous?.disableIncrementalCache` instead.
|
|
76
77
|
* Defined in esbuild banner for the cache adapter.
|
|
77
78
|
*/
|
|
78
79
|
var disableIncrementalCache: boolean;
|