@opennextjs/aws 3.1.5 → 3.2.0
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/README.md +27 -22
- package/dist/adapters/binary.js +2 -0
- package/dist/adapters/cache.d.ts +3 -2
- package/dist/adapters/cache.js +2 -2
- package/dist/adapters/config/util.d.ts +2 -2
- package/dist/adapters/image-optimization-adapter.d.ts +2 -2
- package/dist/adapters/middleware.js +5 -52
- package/dist/adapters/plugins/image-optimization/image-optimization.d.ts +7 -4
- package/dist/adapters/plugins/image-optimization/image-optimization.js +2 -3
- package/dist/adapters/plugins/image-optimization/image-optimization.replacement.d.ts +3 -0
- package/dist/adapters/plugins/image-optimization/image-optimization.replacement.js +4 -7
- package/dist/adapters/warmer-function.js +2 -67
- package/dist/build/buildNextApp.d.ts +3 -0
- package/dist/build/buildNextApp.js +19 -0
- package/dist/build/bundleNextServer.js +2 -2
- package/dist/build/compileCache.d.ts +9 -0
- package/dist/build/compileCache.js +30 -0
- package/dist/build/compileConfig.d.ts +17 -3
- package/dist/build/compileConfig.js +56 -34
- package/dist/build/compileTagCacheProvider.d.ts +2 -0
- package/dist/build/compileTagCacheProvider.js +26 -0
- package/dist/build/createAssets.d.ts +11 -0
- package/dist/build/createAssets.js +161 -0
- package/dist/build/createImageOptimizationBundle.d.ts +2 -0
- package/dist/build/createImageOptimizationBundle.js +79 -0
- package/dist/build/createMiddleware.d.ts +10 -0
- package/dist/build/createMiddleware.js +55 -0
- package/dist/build/createRevalidationBundle.d.ts +2 -0
- package/dist/build/createRevalidationBundle.js +35 -0
- package/dist/build/createServerBundle.d.ts +2 -2
- package/dist/build/createServerBundle.js +27 -26
- package/dist/build/createWarmerBundle.d.ts +2 -0
- package/dist/build/createWarmerBundle.js +44 -0
- package/dist/build/edge/createEdgeBundle.d.ts +3 -3
- package/dist/build/edge/createEdgeBundle.js +3 -5
- package/dist/build/helper.d.ts +22 -5
- package/dist/build/helper.js +42 -11
- package/dist/build/installDeps.d.ts +2 -0
- package/dist/build/installDeps.js +36 -0
- package/dist/build/utils.d.ts +5 -0
- package/dist/build/utils.js +22 -0
- package/dist/build/validateConfig.d.ts +1 -1
- package/dist/build.d.ts +0 -4
- package/dist/build.js +26 -486
- package/dist/core/createMainHandler.d.ts +3 -3
- package/dist/core/requestHandler.d.ts +2 -2
- package/dist/core/requestHandler.js +1 -1
- package/dist/core/resolve.d.ts +13 -4
- package/dist/core/resolve.js +30 -5
- package/dist/core/routing/cacheInterceptor.d.ts +1 -1
- package/dist/core/routing/i18n/index.d.ts +1 -1
- package/dist/core/routing/i18n/index.js +3 -0
- package/dist/core/routing/matcher.d.ts +2 -1
- package/dist/core/routing/matcher.js +1 -1
- package/dist/core/routing/middleware.d.ts +6 -2
- package/dist/core/routing/middleware.js +7 -4
- package/dist/core/routing/util.d.ts +3 -2
- package/dist/core/routing/util.js +9 -3
- package/dist/core/routingHandler.d.ts +1 -1
- package/dist/helpers/withCloudflare.d.ts +1 -1
- package/dist/helpers/withSST.d.ts +1 -1
- package/dist/http/openNextResponse.d.ts +10 -2
- package/dist/http/openNextResponse.js +27 -0
- package/dist/http/request.d.ts +3 -2
- package/dist/http/util.d.ts +1 -1
- package/dist/{converters → overrides/converters}/aws-apigw-v1.d.ts +1 -1
- package/dist/{converters → overrides/converters}/aws-apigw-v1.js +2 -2
- package/dist/{converters → overrides/converters}/aws-apigw-v2.d.ts +1 -1
- package/dist/{converters → overrides/converters}/aws-apigw-v2.js +5 -4
- package/dist/{converters → overrides/converters}/aws-cloudfront.d.ts +1 -1
- package/dist/{converters → overrides/converters}/aws-cloudfront.js +6 -7
- package/dist/{converters → overrides/converters}/dummy.d.ts +1 -1
- package/dist/overrides/converters/edge.d.ts +6 -0
- package/dist/{converters → overrides/converters}/edge.js +1 -1
- package/dist/{converters → overrides/converters}/node.d.ts +1 -1
- package/dist/{converters → overrides/converters}/node.js +1 -1
- package/dist/overrides/converters/sqs-revalidate.d.ts +4 -0
- package/dist/overrides/imageLoader/dummy.d.ts +3 -0
- package/dist/overrides/imageLoader/dummy.js +8 -0
- package/dist/overrides/imageLoader/host.d.ts +1 -1
- package/dist/overrides/imageLoader/s3.d.ts +1 -1
- package/dist/overrides/incrementalCache/dummy.d.ts +3 -0
- package/dist/overrides/incrementalCache/dummy.js +13 -0
- package/dist/{cache/incremental → overrides/incrementalCache}/s3-lite.d.ts +1 -1
- package/dist/{cache/incremental → overrides/incrementalCache}/s3.d.ts +1 -1
- package/dist/{cache/incremental → overrides/incrementalCache}/types.d.ts +1 -1
- package/dist/overrides/originResolver/dummy.d.ts +3 -0
- package/dist/overrides/originResolver/dummy.js +7 -0
- package/dist/overrides/originResolver/pattern-env.d.ts +3 -0
- package/dist/overrides/originResolver/pattern-env.js +39 -0
- package/dist/overrides/queue/dummy.d.ts +3 -0
- package/dist/overrides/queue/dummy.js +7 -0
- package/dist/{queue → overrides/queue}/sqs-lite.d.ts +1 -1
- package/dist/{queue → overrides/queue}/sqs-lite.js +3 -3
- package/dist/{queue → overrides/queue}/sqs.d.ts +1 -1
- package/dist/{queue → overrides/queue}/sqs.js +1 -1
- package/dist/overrides/tagCache/dummy.d.ts +3 -0
- package/dist/overrides/tagCache/dummy.js +17 -0
- package/dist/{cache/tag → overrides/tagCache}/dynamodb-lite.d.ts +1 -1
- package/dist/{cache/tag → overrides/tagCache}/dynamodb-lite.js +1 -1
- package/dist/{cache/tag → overrides/tagCache}/dynamodb.d.ts +1 -1
- package/dist/{cache/tag → overrides/tagCache}/dynamodb.js +1 -1
- package/dist/overrides/warmer/aws-lambda.d.ts +3 -0
- package/dist/overrides/warmer/aws-lambda.js +59 -0
- package/dist/overrides/warmer/dummy.d.ts +3 -0
- package/dist/overrides/warmer/dummy.js +7 -0
- package/dist/overrides/wrappers/aws-lambda-streaming.d.ts +7 -0
- package/dist/{wrappers → overrides/wrappers}/aws-lambda-streaming.js +1 -1
- package/dist/overrides/wrappers/aws-lambda.d.ts +7 -0
- package/dist/{wrappers → overrides/wrappers}/cloudflare.d.ts +2 -2
- package/dist/overrides/wrappers/dummy.d.ts +7 -0
- package/dist/overrides/wrappers/dummy.js +6 -0
- package/dist/overrides/wrappers/node.d.ts +7 -0
- package/dist/{wrappers → overrides/wrappers}/node.js +1 -1
- package/dist/plugins/edge.d.ts +2 -2
- package/dist/plugins/replacement.d.ts +1 -1
- package/dist/plugins/resolve.d.ts +4 -2
- package/dist/plugins/resolve.js +32 -20
- package/dist/types/aws-lambda.d.ts +3 -2
- package/dist/{cache/next-types.d.ts → types/cache.d.ts} +1 -0
- package/dist/types/next-types.d.ts +3 -1
- package/dist/types/open-next.d.ts +39 -13
- package/package.json +3 -4
- package/dist/converters/edge.d.ts +0 -6
- package/dist/converters/sqs-revalidate.d.ts +0 -4
- package/dist/wrappers/aws-lambda-streaming.d.ts +0 -7
- package/dist/wrappers/aws-lambda.d.ts +0 -7
- package/dist/wrappers/node.d.ts +0 -7
- /package/dist/{converters → overrides/converters}/dummy.js +0 -0
- /package/dist/{converters → overrides/converters}/sqs-revalidate.js +0 -0
- /package/dist/{converters → overrides/converters}/utils.d.ts +0 -0
- /package/dist/{converters → overrides/converters}/utils.js +0 -0
- /package/dist/{cache/incremental → overrides/incrementalCache}/s3-lite.js +0 -0
- /package/dist/{cache/incremental → overrides/incrementalCache}/s3.js +0 -0
- /package/dist/{cache/incremental → overrides/incrementalCache}/types.js +0 -0
- /package/dist/{queue → overrides/queue}/types.d.ts +0 -0
- /package/dist/{cache/tag → overrides/queue}/types.js +0 -0
- /package/dist/{cache/tag → overrides/tagCache}/constants.d.ts +0 -0
- /package/dist/{cache/tag → overrides/tagCache}/constants.js +0 -0
- /package/dist/{cache/tag → overrides/tagCache}/types.d.ts +0 -0
- /package/dist/{queue → overrides/tagCache}/types.js +0 -0
- /package/dist/{wrappers → overrides/wrappers}/aws-lambda.js +0 -0
- /package/dist/{wrappers → overrides/wrappers}/cloudflare.js +0 -0
- /package/dist/{cache/next-types.js → types/cache.js} +0 -0
package/dist/build/helper.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import { createRequire
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import url from "node:url";
|
|
5
|
-
import { build as buildAsync, buildSync
|
|
5
|
+
import { build as buildAsync, buildSync } from "esbuild";
|
|
6
6
|
import logger from "../logger.js";
|
|
7
|
-
const require =
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
8
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
9
|
-
export function normalizeOptions(config) {
|
|
9
|
+
export function normalizeOptions(config, distDir, tempBuildDir) {
|
|
10
10
|
const appPath = path.join(process.cwd(), config.appPath || ".");
|
|
11
11
|
const buildOutputPath = path.join(process.cwd(), config.buildOutputPath || ".");
|
|
12
12
|
const outputDir = path.join(buildOutputPath, ".open-next");
|
|
@@ -26,14 +26,16 @@ export function normalizeOptions(config) {
|
|
|
26
26
|
appPackageJsonPath,
|
|
27
27
|
appPath,
|
|
28
28
|
appPublicPath: path.join(appPath, "public"),
|
|
29
|
+
buildDir: path.join(outputDir, ".build"),
|
|
29
30
|
config,
|
|
30
31
|
debug: Boolean(process.env.OPEN_NEXT_DEBUG) ?? false,
|
|
31
32
|
monorepoRoot,
|
|
32
33
|
nextVersion: getNextVersion(appPath),
|
|
33
34
|
openNextVersion: getOpenNextVersion(),
|
|
35
|
+
openNextDistDir: distDir,
|
|
34
36
|
outputDir,
|
|
35
37
|
packager,
|
|
36
|
-
|
|
38
|
+
tempBuildDir,
|
|
37
39
|
};
|
|
38
40
|
}
|
|
39
41
|
function findMonorepoRoot(appPath) {
|
|
@@ -56,6 +58,7 @@ function findMonorepoRoot(appPath) {
|
|
|
56
58
|
// note: a lock file (package-lock.json, yarn.lock, or pnpm-lock.yaml) is
|
|
57
59
|
// not found in the app's directory or any of its parent directories.
|
|
58
60
|
// We are going to assume that the app is not part of a monorepo.
|
|
61
|
+
logger.warn("No lockfile found");
|
|
59
62
|
return { root: appPath, packager: "npm" };
|
|
60
63
|
}
|
|
61
64
|
function findNextPackageJsonPath(appPath, root) {
|
|
@@ -158,10 +161,7 @@ export function getHtmlPages(dotNextPath) {
|
|
|
158
161
|
return Object.entries(JSON.parse(manifest))
|
|
159
162
|
.filter(([_, value]) => value.endsWith(".html"))
|
|
160
163
|
.map(([_, value]) => value.replace(/^pages\//, ""))
|
|
161
|
-
.reduce((acc, page) =>
|
|
162
|
-
acc.add(page);
|
|
163
|
-
return acc;
|
|
164
|
-
}, new Set());
|
|
164
|
+
.reduce((acc, page) => acc.add(page), new Set());
|
|
165
165
|
}
|
|
166
166
|
export function getBuildId(dotNextPath) {
|
|
167
167
|
return fs
|
|
@@ -200,9 +200,9 @@ export function compareSemver(v1, v2) {
|
|
|
200
200
|
return minor1 - minor2;
|
|
201
201
|
return patch1 - patch2;
|
|
202
202
|
}
|
|
203
|
-
export function copyOpenNextConfig(
|
|
203
|
+
export function copyOpenNextConfig(inputDir, outputDir, isEdge = false) {
|
|
204
204
|
// Copy open-next.config.mjs
|
|
205
|
-
fs.copyFileSync(path.join(
|
|
205
|
+
fs.copyFileSync(path.join(inputDir, isEdge ? "open-next.config.edge.mjs" : "open-next.config.mjs"), path.join(outputDir, "open-next.config.mjs"));
|
|
206
206
|
}
|
|
207
207
|
export function copyEnvFile(appPath, packagePath, outputPath) {
|
|
208
208
|
const baseAppPath = path.join(appPath, ".next/standalone", packagePath);
|
|
@@ -216,3 +216,34 @@ export function copyEnvFile(appPath, packagePath, outputPath) {
|
|
|
216
216
|
fs.copyFileSync(envProdPath, path.join(baseOutputPath, ".env.production"));
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* Check we are in a Nextjs app by looking for the Nextjs config file.
|
|
221
|
+
*/
|
|
222
|
+
export function checkRunningInsideNextjsApp(options) {
|
|
223
|
+
const { appPath } = options;
|
|
224
|
+
const extension = ["js", "cjs", "mjs", "ts"].find((ext) => fs.existsSync(path.join(appPath, `next.config.${ext}`)));
|
|
225
|
+
if (!extension) {
|
|
226
|
+
logger.error("Error: next.config.js not found. Please make sure you are running this command inside a Next.js app.");
|
|
227
|
+
process.exit(1);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
export function printNextjsVersion(options) {
|
|
231
|
+
logger.info(`Next.js version : ${options.nextVersion}`);
|
|
232
|
+
}
|
|
233
|
+
export function printOpenNextVersion(options) {
|
|
234
|
+
logger.info(`OpenNext v${options.openNextVersion}`);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Populates the build directory with the compiled configuration files.
|
|
238
|
+
*
|
|
239
|
+
* We need to get the build relative to the cwd to find the compiled config.
|
|
240
|
+
* This is needed for the case where the app is a single-version monorepo
|
|
241
|
+
* and the package.json is in the root of the monorepo where the build is in
|
|
242
|
+
* the app directory, but the compiled config is in the root of the monorepo.
|
|
243
|
+
*/
|
|
244
|
+
export function initOutputDir(options) {
|
|
245
|
+
fs.rmSync(options.outputDir, { recursive: true, force: true });
|
|
246
|
+
const { buildDir } = options;
|
|
247
|
+
fs.mkdirSync(buildDir, { recursive: true });
|
|
248
|
+
fs.cpSync(options.tempBuildDir, buildDir, { recursive: true });
|
|
249
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { execSync } from "child_process";
|
|
5
|
+
import logger from "../logger.js";
|
|
6
|
+
export function installDependencies(outputDir, installOptions) {
|
|
7
|
+
try {
|
|
8
|
+
if (!installOptions) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const name = outputDir.split("/").pop();
|
|
12
|
+
// First we create a tempDir
|
|
13
|
+
const tempInstallDir = fs.mkdtempSync(path.join(os.tmpdir(), `open-next-install-${name}`));
|
|
14
|
+
logger.info(`Installing dependencies for ${name}...`);
|
|
15
|
+
// We then need to run install in the tempDir
|
|
16
|
+
// We don't install in the output dir directly because it could contain a package.json, and npm would then try to reinstall not complete deps from tracing the files
|
|
17
|
+
const installCommand = `npm install --arch=${installOptions.arch ?? "arm64"} --platform=linux --target=${installOptions.nodeVersion ?? "18"} --libc=${installOptions.libc ?? "glibc"} ${installOptions.packages.join(" ")}`;
|
|
18
|
+
execSync(installCommand, {
|
|
19
|
+
stdio: "pipe",
|
|
20
|
+
cwd: tempInstallDir,
|
|
21
|
+
env: {
|
|
22
|
+
...process.env,
|
|
23
|
+
SHARP_IGNORE_GLOBAL_LIBVIPS: "1",
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
// Copy the node_modules to the outputDir
|
|
27
|
+
fs.cpSync(path.join(tempInstallDir, "node_modules"), path.join(outputDir, "node_modules"), { recursive: true, force: true, dereference: true });
|
|
28
|
+
// Cleanup tempDir
|
|
29
|
+
fs.rmSync(tempInstallDir, { recursive: true, force: true });
|
|
30
|
+
logger.info(`Dependencies installed for ${name}`);
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
logger.error(e.stdout.toString());
|
|
34
|
+
logger.error("Could not install dependencies");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import os from "node:os";
|
|
2
|
+
import logger from "../logger.js";
|
|
3
|
+
export function printHeader(header) {
|
|
4
|
+
header = `OpenNext — ${header}`;
|
|
5
|
+
logger.info([
|
|
6
|
+
"",
|
|
7
|
+
"┌" + "─".repeat(header.length + 2) + "┐",
|
|
8
|
+
`│ ${header} │`,
|
|
9
|
+
"└" + "─".repeat(header.length + 2) + "┘",
|
|
10
|
+
"",
|
|
11
|
+
].join("\n"));
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Displays a warning on windows platform.
|
|
15
|
+
*/
|
|
16
|
+
export function showWarningOnWindows() {
|
|
17
|
+
if (os.platform() !== "win32")
|
|
18
|
+
return;
|
|
19
|
+
logger.warn("OpenNext is not fully compatible with Windows.");
|
|
20
|
+
logger.warn("For optimal performance, it is recommended to use Windows Subsystem for Linux (WSL).");
|
|
21
|
+
logger.warn("While OpenNext may function on Windows, it could encounter unpredictable failures during runtime.");
|
|
22
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { OpenNextConfig } from "../types/open-next";
|
|
1
|
+
import type { OpenNextConfig } from "../types/open-next";
|
|
2
2
|
export declare function validateConfig(config: OpenNextConfig): void;
|
package/dist/build.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import { BuildOptions } from "./build/helper.js";
|
|
2
1
|
export type PublicFiles = {
|
|
3
2
|
files: string[];
|
|
4
3
|
};
|
|
5
4
|
export declare function build(openNextConfigPath?: string, nodeExternals?: string): Promise<void>;
|
|
6
|
-
/***************************/
|
|
7
|
-
/***************************/
|
|
8
|
-
export declare function compileCache(options: BuildOptions, format?: "cjs" | "esm"): string;
|