Skip to content

Commit 6f28517

Browse files
committed
refactor: fixes
1 parent 79e24ba commit 6f28517

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

packages/open-next/src/build.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import url from "node:url";
2+
13
import {
24
buildNextjsApp,
35
setStandaloneBuildMode,
@@ -12,7 +14,7 @@ import { createServerBundle } from "./build/createServerBundle.js";
1214
import { createWarmerBundle } from "./build/createWarmerBundle.js";
1315
import { generateOutput } from "./build/generateOutput.js";
1416
import * as buildHelper from "./build/helper.js";
15-
import { printHeader } from "./build/utils.js";
17+
import { printHeader, showWarningOnWindows } from "./build/utils.js";
1618
import logger from "./logger.js";
1719

1820
export type PublicFiles = {
@@ -23,9 +25,10 @@ export async function build(
2325
openNextConfigPath?: string,
2426
nodeExternals?: string,
2527
) {
26-
buildHelper.showWarningOnWindows();
28+
showWarningOnWindows();
2729

2830
const baseDir = process.cwd();
31+
const distDir = url.fileURLToPath(new URL(".", import.meta.url));
2932

3033
const { config, buildDir } = await compileOpenNextConfig(
3134
baseDir,
@@ -34,11 +37,7 @@ export async function build(
3437
);
3538

3639
// Initialize options
37-
const options = buildHelper.normalizeOptions(
38-
config,
39-
import.meta.url,
40-
buildDir,
41-
);
40+
const options = buildHelper.normalizeOptions(config, distDir, buildDir);
4241
logger.setLevel(options.debug ? "debug" : "info");
4342

4443
// Pre-build validation

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

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import fs from "node:fs";
22
import { createRequire } from "node:module";
3-
import os from "node:os";
43
import path from "node:path";
54
import url from "node:url";
65

@@ -20,7 +19,7 @@ export type BuildOptions = ReturnType<typeof normalizeOptions>;
2019

2120
export function normalizeOptions(
2221
config: OpenNextConfig,
23-
buildScriptPath: string,
22+
distDir: string,
2423
tempBuildDir: string,
2524
) {
2625
const appPath = path.join(process.cwd(), config.appPath || ".");
@@ -55,7 +54,7 @@ export function normalizeOptions(
5554
monorepoRoot,
5655
nextVersion: getNextVersion(appPath),
5756
openNextVersion: getOpenNextVersion(),
58-
openNextDistDir: url.fileURLToPath(new URL(".", buildScriptPath)),
57+
openNextDistDir: distDir,
5958
outputDir,
6059
packager,
6160
tempBuildDir,
@@ -312,21 +311,6 @@ export function copyEnvFile(
312311
}
313312
}
314313

315-
/**
316-
* Displays a warning on windows platform.
317-
*/
318-
export function showWarningOnWindows() {
319-
if (os.platform() !== "win32") return;
320-
321-
logger.warn("OpenNext is not fully compatible with Windows.");
322-
logger.warn(
323-
"For optimal performance, it is recommended to use Windows Subsystem for Linux (WSL).",
324-
);
325-
logger.warn(
326-
"While OpenNext may function on Windows, it could encounter unpredictable failures during runtime.",
327-
);
328-
}
329-
330314
/**
331315
* Check we are in a Nextjs app by looking for the Nextjs config file.
332316
*/

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import os from "node:os";
2+
13
import logger from "../logger.js";
24

35
export function printHeader(header: string) {
@@ -12,3 +14,18 @@ export function printHeader(header: string) {
1214
].join("\n"),
1315
);
1416
}
17+
18+
/**
19+
* Displays a warning on windows platform.
20+
*/
21+
export function showWarningOnWindows() {
22+
if (os.platform() !== "win32") return;
23+
24+
logger.warn("OpenNext is not fully compatible with Windows.");
25+
logger.warn(
26+
"For optimal performance, it is recommended to use Windows Subsystem for Linux (WSL).",
27+
);
28+
logger.warn(
29+
"While OpenNext may function on Windows, it could encounter unpredictable failures during runtime.",
30+
);
31+
}

0 commit comments

Comments
 (0)