@@ -4,7 +4,10 @@ import path from "node:path";
4
4
import cp from "node:child_process" ;
5
5
import { minifyAll } from "./minimize-js.js" ;
6
6
import { buildSync , BuildOptions } from "esbuild" ;
7
+ import { exit } from "node:process" ;
8
+ import { createRequire as topLevelCreateRequire } from "node:module" ;
7
9
10
+ const require = topLevelCreateRequire ( import . meta. url ) ;
8
11
const __dirname = url . fileURLToPath ( new URL ( "." , import . meta. url ) ) ;
9
12
const appPath = process . cwd ( ) ;
10
13
const appPublicPath = path . join ( appPath , "public" ) ;
@@ -17,7 +20,8 @@ export type PublicFiles = {
17
20
18
21
export async function build ( ) {
19
22
// Pre-build validation
20
- printVersion ( ) ;
23
+ printNextjsVersion ( ) ;
24
+ printOpenNextVersion ( ) ;
21
25
checkRunningInsideNextjsApp ( ) ;
22
26
const { root : monorepoRoot , packager } = findMonorepoRoot ( ) ;
23
27
@@ -109,10 +113,24 @@ function printHeader(header: string) {
109
113
) ;
110
114
}
111
115
112
- function printVersion ( ) {
113
- const pathToPackageJson = path . join ( __dirname , "../package.json" ) ;
114
- const pkg = JSON . parse ( fs . readFileSync ( pathToPackageJson , "utf-8" ) ) ;
115
- console . info ( `Using v${ pkg . version } ` ) ;
116
+ function printNextjsVersion ( ) {
117
+ cp . spawnSync (
118
+ "node" ,
119
+ [
120
+ "-e" ,
121
+ `"console.info('Next.js v' + require('next/package.json').version)"` ,
122
+ ] ,
123
+ {
124
+ stdio : "inherit" ,
125
+ cwd : appPath ,
126
+ shell : true ,
127
+ }
128
+ ) ;
129
+ }
130
+
131
+ function printOpenNextVersion ( ) {
132
+ const onVersion = require ( path . join ( __dirname , "../package.json" ) ) . version ;
133
+ console . info ( `OpenNext v${ onVersion } ` ) ;
116
134
}
117
135
118
136
function injectMiddlewareGeolocation ( outputPath : string , packagePath : string ) {
0 commit comments