Skip to content

Commit 60e3fa4

Browse files
committed
feat: support absolute paths when compiling opennext configs
1 parent fe913bb commit 60e3fa4

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@opennextjs/aws": minor
3+
---
4+
5+
feat: support absolute paths when compiling opennext configs

packages/open-next/src/build.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import path from "node:path";
12
import url from "node:url";
23

34
import {
@@ -32,8 +33,9 @@ export async function build(
3233
const openNextDistDir = url.fileURLToPath(new URL(".", import.meta.url));
3334

3435
const { config, buildDir } = await compileOpenNextConfig(
35-
baseDir,
36-
openNextConfigPath,
36+
openNextConfigPath && path.isAbsolute(openNextConfigPath)
37+
? openNextConfigPath
38+
: path.join(baseDir, openNextConfigPath ?? "open-next.config.ts"),
3739
{ nodeExternals },
3840
);
3941

packages/open-next/src/build/compileConfig.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,15 @@ import { validateConfig } from "./validateConfig.js";
1313
*
1414
* The configuration is always compiled for Node.js and for the edge only if needed.
1515
*
16-
* @param baseDir Directory where to look for the configuration.
17-
* @param openNextConfigPath Override the default configuration when provided. Relative to baseDir.
16+
* @param sourcePath Path to the configuration file.
1817
* @param nodeExternals Coma separated list of Externals for the Node.js compilation.
1918
* @param compileEdge Force compiling for the edge runtime when true
2019
* @return The configuration and the build directory.
2120
*/
2221
export async function compileOpenNextConfig(
23-
baseDir: string,
24-
openNextConfigPath?: string,
22+
sourcePath: string,
2523
{ nodeExternals = "", compileEdge = false } = {},
2624
) {
27-
const sourcePath = path.join(
28-
baseDir,
29-
openNextConfigPath ?? "open-next.config.ts",
30-
);
31-
3225
const buildDir = fs.mkdtempSync(path.join(os.tmpdir(), "open-next-tmp"));
3326
let configPath = compileOpenNextConfigNode(
3427
sourcePath,

0 commit comments

Comments
 (0)