@@ -185,55 +185,24 @@ export class ProcessManager {
185185 } ;
186186
187187 if ( usePacked ) {
188- // macOS: utilityProcess 不在 Dock 显示图标; Windows: spawn 更稳定
189- if ( process . platform === 'win32' ) {
190- this . logger . info ( `Starting frontend (spawn): node ${ serverJs } ` ) ;
191- const procEnv = {
192- ...process . env ,
193- ...env ,
194- NODE_PATH : path . join ( nextDir , 'node_modules' ) ,
195- } ;
196- this . frontendProcess = spawn ( 'node' , [ serverJs ] , {
197- cwd : nextDir ,
198- env : procEnv ,
199- stdio : [ 'ignore' , 'pipe' , 'pipe' ] ,
200- detached : false ,
201- shell : false ,
202- } ) ;
203- this . frontendProcess . stdout ?. on ( 'data' , ( data ) => {
204- this . logger . debug ( `[Frontend] ${ data . toString ( ) . trim ( ) } ` ) ;
205- } ) ;
206- this . frontendProcess . stderr ?. on ( 'data' , ( data ) => {
207- this . logger . debug ( `[Frontend] ${ data . toString ( ) . trim ( ) } ` ) ;
208- } ) ;
209- this . frontendProcess . on ( 'error' , ( error ) => {
210- this . logger . error ( 'Frontend process error' , error ) ;
211- } ) ;
212- this . frontendProcess . on ( 'exit' , ( code ) => {
213- if ( code !== 0 ) {
214- this . logger . warn ( `Frontend exited with code ${ code } ` ) ;
215- }
216- } ) ;
217- } else {
218- this . logger . info ( `Starting frontend (utilityProcess): ${ serverJs } ` ) ;
219- const up = utilityProcess . fork ( serverJs , [ ] , {
220- cwd : nextDir ,
221- env,
222- stdio : 'pipe' ,
223- } ) ;
224- up . stdout ?. on ( 'data' , ( data : Buffer ) => {
225- this . logger . debug ( `[Frontend] ${ data . toString ( ) . trim ( ) } ` ) ;
226- } ) ;
227- up . stderr ?. on ( 'data' , ( data : Buffer ) => {
228- this . logger . debug ( `[Frontend] ${ data . toString ( ) . trim ( ) } ` ) ;
229- } ) ;
230- up . on ( 'exit' , ( code ) => {
231- if ( code !== 0 ) {
232- this . logger . warn ( `Frontend exited with code ${ code } ` ) ;
233- }
234- } ) ;
235- this . frontendProcess = up as unknown as ChildProcess ;
236- }
188+ this . logger . info ( `Starting frontend (utilityProcess): ${ serverJs } ` ) ;
189+ const up = utilityProcess . fork ( serverJs , [ ] , {
190+ cwd : nextDir ,
191+ env : { ...process . env , ...env } ,
192+ stdio : 'pipe' ,
193+ } ) ;
194+ up . stdout ?. on ( 'data' , ( data : Buffer ) => {
195+ this . logger . debug ( `[Frontend] ${ data . toString ( ) . trim ( ) } ` ) ;
196+ } ) ;
197+ up . stderr ?. on ( 'data' , ( data : Buffer ) => {
198+ this . logger . debug ( `[Frontend] ${ data . toString ( ) . trim ( ) } ` ) ;
199+ } ) ;
200+ up . on ( 'exit' , ( code ) => {
201+ if ( code !== 0 ) {
202+ this . logger . warn ( `Frontend exited with code ${ code } ` ) ;
203+ }
204+ } ) ;
205+ this . frontendProcess = up as unknown as ChildProcess ;
237206 } else {
238207 // 开发模式:用 next start
239208 this . logger . info ( 'Starting frontend (dev mode): next start' ) ;
0 commit comments