@opennextjs/aws 3.9.9 → 3.9.11
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/build/createServerBundle.js +1 -1
- package/dist/build/helper.d.ts +21 -1
- package/dist/build/helper.js +27 -2
- package/dist/build/patch/patches/index.d.ts +1 -1
- package/dist/build/patch/patches/index.js +1 -1
- package/dist/build/patch/patches/patchEnvVar.d.ts +2 -1
- package/dist/build/patch/patches/patchEnvVar.js +30 -26
- package/dist/build/patch/patches/patchOriginalNextConfig.d.ts +6 -4
- package/dist/build/patch/patches/patchOriginalNextConfig.js +10 -6
- package/package.json +1 -1
|
@@ -123,7 +123,7 @@ async function generateBundle(name, options, fnOptions, codeCustomization) {
|
|
|
123
123
|
patches.patchFetchCacheForISR,
|
|
124
124
|
patches.patchUnstableCacheForISR,
|
|
125
125
|
patches.patchNextServer,
|
|
126
|
-
patches.
|
|
126
|
+
patches.getEnvVarsPatch(options),
|
|
127
127
|
patches.patchBackgroundRevalidation,
|
|
128
128
|
patches.patchUseCacheForISR,
|
|
129
129
|
patches.patchNodeEnvironment,
|
package/dist/build/helper.d.ts
CHANGED
|
@@ -15,9 +15,20 @@ export declare function normalizeOptions(config: OpenNextConfig, distDir: string
|
|
|
15
15
|
openNextVersion: string;
|
|
16
16
|
openNextDistDir: string;
|
|
17
17
|
outputDir: string;
|
|
18
|
-
packager: "
|
|
18
|
+
packager: "npm" | "pnpm" | "yarn" | "bun";
|
|
19
19
|
tempBuildDir: string;
|
|
20
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Given the path to a project this function detects the project's repository root (whether the project is in a simple
|
|
23
|
+
* repository or a monorepo) as well as the package manager being used.
|
|
24
|
+
*
|
|
25
|
+
* @param appPath The project's path
|
|
26
|
+
* @returns An object containing the root of the project's repo/monorepo as well as the package manager that it uses.
|
|
27
|
+
*/
|
|
28
|
+
export declare function findPackagerAndRoot(appPath: string): {
|
|
29
|
+
root: string;
|
|
30
|
+
packager: "npm" | "pnpm" | "yarn" | "bun";
|
|
31
|
+
};
|
|
21
32
|
export declare function esbuildSync(esbuildOptions: ESBuildOptions, options: BuildOptions): void;
|
|
22
33
|
export declare function esbuildAsync(esbuildOptions: ESBuildOptions, options: BuildOptions): Promise<void>;
|
|
23
34
|
/**
|
|
@@ -83,3 +94,12 @@ export declare function initOutputDir(options: BuildOptions): void;
|
|
|
83
94
|
*/
|
|
84
95
|
export declare function isEdgeRuntime(overrides: DefaultOverrideOptions | undefined): Promise<boolean | undefined>;
|
|
85
96
|
export declare function getPackagePath(options: BuildOptions): string;
|
|
97
|
+
/**
|
|
98
|
+
* Returns the Next.js runtime used: "webpack" or "turbopack"
|
|
99
|
+
*
|
|
100
|
+
* Must be called after building the Next.js app.
|
|
101
|
+
*
|
|
102
|
+
* @param options
|
|
103
|
+
* @returns the Next.js runtime used: "webpack" or "turbopack"
|
|
104
|
+
*/
|
|
105
|
+
export declare function getBundlerRuntime(options: BuildOptions): "webpack" | "turbopack";
|
package/dist/build/helper.js
CHANGED
|
@@ -10,7 +10,7 @@ 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");
|
|
13
|
-
const { root: monorepoRoot, packager } =
|
|
13
|
+
const { root: monorepoRoot, packager } = findPackagerAndRoot(path.join(process.cwd(), config.appPath || "."));
|
|
14
14
|
let appPackageJsonPath;
|
|
15
15
|
if (config.packageJsonPath) {
|
|
16
16
|
const _pkgPath = path.join(process.cwd(), config.packageJsonPath);
|
|
@@ -41,7 +41,14 @@ export function normalizeOptions(config, distDir, tempBuildDir) {
|
|
|
41
41
|
tempBuildDir,
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Given the path to a project this function detects the project's repository root (whether the project is in a simple
|
|
46
|
+
* repository or a monorepo) as well as the package manager being used.
|
|
47
|
+
*
|
|
48
|
+
* @param appPath The project's path
|
|
49
|
+
* @returns An object containing the root of the project's repo/monorepo as well as the package manager that it uses.
|
|
50
|
+
*/
|
|
51
|
+
export function findPackagerAndRoot(appPath) {
|
|
45
52
|
let currentPath = appPath;
|
|
46
53
|
while (currentPath !== "/") {
|
|
47
54
|
const found = [
|
|
@@ -324,3 +331,21 @@ export async function isEdgeRuntime(overrides) {
|
|
|
324
331
|
export function getPackagePath(options) {
|
|
325
332
|
return path.relative(options.monorepoRoot, options.appBuildOutputPath);
|
|
326
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* Returns the Next.js runtime used: "webpack" or "turbopack"
|
|
336
|
+
*
|
|
337
|
+
* Must be called after building the Next.js app.
|
|
338
|
+
*
|
|
339
|
+
* @param options
|
|
340
|
+
* @returns the Next.js runtime used: "webpack" or "turbopack"
|
|
341
|
+
*/
|
|
342
|
+
export function getBundlerRuntime(options) {
|
|
343
|
+
const dotNextPath = path.join(options.appPath, ".next");
|
|
344
|
+
if (fs.existsSync(path.join(dotNextPath, "server/webpack-runtime.js"))) {
|
|
345
|
+
return "webpack";
|
|
346
|
+
}
|
|
347
|
+
if (fs.existsSync(path.join(dotNextPath, "server/chunks/[turbopack]_runtime.js"))) {
|
|
348
|
+
return "turbopack";
|
|
349
|
+
}
|
|
350
|
+
throw new Error("Unable to determine Next.js runtime (webpack or turbopack)");
|
|
351
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { getEnvVarsPatch } from "./patchEnvVar.js";
|
|
2
2
|
export { patchNextServer } from "./patchNextServer.js";
|
|
3
3
|
export { patchFetchCacheForISR, patchUnstableCacheForISR, patchUseCacheForISR, } from "./patchFetchCacheISR.js";
|
|
4
4
|
export { patchFetchCacheSetMissingWaitUntil } from "./patchFetchCacheWaitUntil.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { getEnvVarsPatch } from "./patchEnvVar.js";
|
|
2
2
|
export { patchNextServer } from "./patchNextServer.js";
|
|
3
3
|
export { patchFetchCacheForISR, patchUnstableCacheForISR, patchUseCacheForISR, } from "./patchFetchCacheISR.js";
|
|
4
4
|
export { patchFetchCacheSetMissingWaitUntil } from "./patchFetchCacheWaitUntil.js";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as buildHelper from "../../helper.js";
|
|
1
2
|
import type { CodePatcher } from "../codePatcher";
|
|
2
3
|
/**
|
|
3
4
|
* Creates a rule to replace `process.env.${envVar}` by `value` in the condition of if statements
|
|
@@ -7,4 +8,4 @@ import type { CodePatcher } from "../codePatcher";
|
|
|
7
8
|
* @returns
|
|
8
9
|
*/
|
|
9
10
|
export declare const envVarRuleCreator: (envVar: string, value: string) => string;
|
|
10
|
-
export declare
|
|
11
|
+
export declare function getEnvVarsPatch(BuildOptions: buildHelper.BuildOptions): CodePatcher;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as buildHelper from "../../helper.js";
|
|
1
2
|
import { createPatchCode } from "../astCodePatcher.js";
|
|
2
3
|
/**
|
|
3
4
|
* Creates a rule to replace `process.env.${envVar}` by `value` in the condition of if statements
|
|
@@ -18,29 +19,32 @@ rule:
|
|
|
18
19
|
fix:
|
|
19
20
|
'${value}'
|
|
20
21
|
`;
|
|
21
|
-
export
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
22
|
+
export function getEnvVarsPatch(BuildOptions) {
|
|
23
|
+
const isTurbopack = buildHelper.getBundlerRuntime(BuildOptions) === "turbopack";
|
|
24
|
+
return {
|
|
25
|
+
name: "patch-env-vars",
|
|
26
|
+
patches: [
|
|
27
|
+
// This patch will set the `NEXT_RUNTIME` env var to "node" to avoid loading unnecessary edge deps at runtime
|
|
28
|
+
{
|
|
29
|
+
versions: ">=15.0.0",
|
|
30
|
+
pathFilter: /module\.compiled\.js$/,
|
|
31
|
+
contentFilter: /process\.env\.NEXT_RUNTIME/,
|
|
32
|
+
patchCode: createPatchCode(envVarRuleCreator("NEXT_RUNTIME", '"node"')),
|
|
33
|
+
},
|
|
34
|
+
// This patch will set `NODE_ENV` to production to avoid loading unnecessary dev deps at runtime
|
|
35
|
+
{
|
|
36
|
+
versions: ">=15.0.0",
|
|
37
|
+
pathFilter: /(module\.compiled|react\/index|react\/jsx-runtime|react-dom\/index)\.js$/,
|
|
38
|
+
contentFilter: /process\.env\.NODE_ENV/,
|
|
39
|
+
patchCode: createPatchCode(envVarRuleCreator("NODE_ENV", '"production"')),
|
|
40
|
+
},
|
|
41
|
+
// This patch will set `TURBOPACK` env to false to avoid loading turbopack related deps at runtime
|
|
42
|
+
{
|
|
43
|
+
versions: ">=15.0.0",
|
|
44
|
+
pathFilter: /module\.compiled\.js$/,
|
|
45
|
+
contentFilter: /process\.env\.TURBOPACK/,
|
|
46
|
+
patchCode: createPatchCode(envVarRuleCreator("TURBOPACK", JSON.stringify(isTurbopack))),
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import * as buildHelper from "../../helper.js";
|
|
2
2
|
/**
|
|
3
|
-
* Next 16.1
|
|
3
|
+
* Next 16.1.0-16.1.4 has missing fields in `required-server-files.json`:
|
|
4
|
+
* - `skipTrailingSlashRedirect`
|
|
5
|
+
* - `serverExternalPackages`
|
|
4
6
|
*
|
|
5
|
-
* This patch adds
|
|
7
|
+
* This patch adds them back in by compiling and importing the user's `next.config.js` file.
|
|
6
8
|
*
|
|
7
|
-
* It is a regression in https://github.com/vercel/next.js/pull/86830
|
|
8
|
-
*
|
|
9
|
+
* It is a regression in https://github.com/vercel/next.js/pull/86830 (16.1.0)
|
|
10
|
+
* Fixed in https://github.com/vercel/next.js/pull/88733 (16.1.4)
|
|
9
11
|
*/
|
|
10
12
|
export declare function patchOriginalNextConfig(options: buildHelper.BuildOptions): Promise<void>;
|
|
@@ -4,15 +4,18 @@ import { build } from "esbuild";
|
|
|
4
4
|
import { inlineRequireResolvePlugin } from "../../../plugins/inline-require-resolve.js";
|
|
5
5
|
import * as buildHelper from "../../helper.js";
|
|
6
6
|
/**
|
|
7
|
-
* Next 16.1
|
|
7
|
+
* Next 16.1.0-16.1.4 has missing fields in `required-server-files.json`:
|
|
8
|
+
* - `skipTrailingSlashRedirect`
|
|
9
|
+
* - `serverExternalPackages`
|
|
8
10
|
*
|
|
9
|
-
* This patch adds
|
|
11
|
+
* This patch adds them back in by compiling and importing the user's `next.config.js` file.
|
|
10
12
|
*
|
|
11
|
-
* It is a regression in https://github.com/vercel/next.js/pull/86830
|
|
12
|
-
*
|
|
13
|
+
* It is a regression in https://github.com/vercel/next.js/pull/86830 (16.1.0)
|
|
14
|
+
* Fixed in https://github.com/vercel/next.js/pull/88733 (16.1.4)
|
|
13
15
|
*/
|
|
14
16
|
export async function patchOriginalNextConfig(options) {
|
|
15
|
-
if (buildHelper.compareSemver(options.nextVersion, "<", "16.1.0")
|
|
17
|
+
if (buildHelper.compareSemver(options.nextVersion, "<", "16.1.0") ||
|
|
18
|
+
buildHelper.compareSemver(options.nextVersion, ">=", "16.1.4")) {
|
|
16
19
|
return;
|
|
17
20
|
}
|
|
18
21
|
// The manifests in both `.next` and `.next/standalone` folders
|
|
@@ -22,9 +25,10 @@ export async function patchOriginalNextConfig(options) {
|
|
|
22
25
|
if (fs.existsSync(manifestPath)) {
|
|
23
26
|
const manifest = JSON.parse(await fs.promises.readFile(manifestPath, "utf-8"));
|
|
24
27
|
if (manifest.config.skipTrailingSlashRedirect === undefined) {
|
|
25
|
-
const { skipTrailingSlashRedirect } = await importNextConfigFromSource(options);
|
|
28
|
+
const { skipTrailingSlashRedirect, serverExternalPackages } = await importNextConfigFromSource(options);
|
|
26
29
|
manifest.config.skipTrailingSlashRedirect =
|
|
27
30
|
skipTrailingSlashRedirect ?? false;
|
|
31
|
+
manifest.config.serverExternalPackages = serverExternalPackages ?? [];
|
|
28
32
|
await fs.promises.writeFile(manifestPath, JSON.stringify(manifest, null, 2), "utf-8");
|
|
29
33
|
if (fs.existsSync(manifestStandalonePath)) {
|
|
30
34
|
await fs.promises.writeFile(manifestStandalonePath, JSON.stringify(manifest, null, 2), "utf-8");
|