Skip to content

Commit fc68171

Browse files
committed
move helper function into compileConfig
1 parent 1522cd9 commit fc68171

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

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

+26-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { buildSync } from "esbuild";
66
import type { OpenNextConfig } from "types/open-next.js";
77

88
import logger from "../logger.js";
9-
import { buildDevConfig } from "./helper.js";
9+
import { DEV_CONFIG } from "./constant.js";
1010
import { validateConfig } from "./validateConfig.js";
1111

1212
/**
@@ -129,3 +129,28 @@ export function compileOpenNextConfigEdge(
129129
external: externals,
130130
});
131131
}
132+
133+
function buildDevConfig(outputPath: string, externals: string[]) {
134+
buildSync({
135+
stdin: {
136+
contents: DEV_CONFIG,
137+
resolveDir: process.cwd(),
138+
loader: "ts",
139+
sourcefile: "open-next.config.ts",
140+
},
141+
outfile: outputPath,
142+
bundle: true,
143+
format: "esm",
144+
target: ["node18"],
145+
external: externals,
146+
platform: "node",
147+
banner: {
148+
js: [
149+
"import { createRequire as topLevelCreateRequire } from 'module';",
150+
"const require = topLevelCreateRequire(import.meta.url);",
151+
"import bannerUrl from 'url';",
152+
"const __dirname = bannerUrl.fileURLToPath(new URL('.', import.meta.url));",
153+
].join(""),
154+
},
155+
});
156+
}

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

-26
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import type {
1111
} from "types/open-next.js";
1212

1313
import logger from "../logger.js";
14-
import { DEV_CONFIG } from "./constant.js";
1514

1615
const require = createRequire(import.meta.url);
1716
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
@@ -441,28 +440,3 @@ export async function isEdgeRuntime(
441440
export function getPackagePath(options: BuildOptions) {
442441
return path.relative(options.monorepoRoot, options.appBuildOutputPath);
443442
}
444-
445-
export function buildDevConfig(outputPath: string, externals: string[]) {
446-
buildSync({
447-
stdin: {
448-
contents: DEV_CONFIG,
449-
resolveDir: process.cwd(),
450-
loader: "ts",
451-
sourcefile: "open-next.config.ts",
452-
},
453-
outfile: outputPath,
454-
bundle: true,
455-
format: "esm",
456-
target: ["node18"],
457-
external: externals,
458-
platform: "node",
459-
banner: {
460-
js: [
461-
"import { createRequire as topLevelCreateRequire } from 'module';",
462-
"const require = topLevelCreateRequire(import.meta.url);",
463-
"import bannerUrl from 'url';",
464-
"const __dirname = bannerUrl.fileURLToPath(new URL('.', import.meta.url));",
465-
].join(""),
466-
},
467-
});
468-
}

0 commit comments

Comments
 (0)