@@ -10,7 +10,7 @@ import type {
1010import fs from 'node:fs' ;
1111import { cpus as nodeCpus } from 'node:os' ;
1212import { Worker } from 'node:worker_threads' ;
13- import { dirname , extname , isAbsolute , join , resolve } from 'node:path' ;
13+ import { isAbsolute , resolve } from 'node:path' ;
1414import { ensureDir } from './node-system' ;
1515import { normalizePath } from '../../utils/fs' ;
1616
@@ -58,20 +58,9 @@ export async function createNodeMainProcess(sys: System, opts: StaticGenerateOpt
5858
5959 // Launch the worker using the package's index module, which bootstraps the worker thread.
6060 if ( typeof __filename === 'string' ) {
61- // CommonJS path
62- const ext = extname ( __filename ) || '.js' ;
63- workerFilePath = join ( dirname ( __filename ) , `index${ ext } ` ) ;
61+ workerFilePath = __filename ;
6462 } else {
65- // ESM path (import.meta.url)
66- const thisUrl = new URL ( import . meta. url ) ;
67- const pathname = thisUrl . pathname || '' ;
68- let ext = '.js' ;
69- if ( pathname . endsWith ( '.ts' ) ) {
70- ext = '.ts' ;
71- } else if ( pathname . endsWith ( '.mjs' ) ) {
72- ext = '.mjs' ;
73- }
74- workerFilePath = new URL ( `./index${ ext } ` , thisUrl ) ;
63+ workerFilePath = import . meta. url ;
7564 }
7665
7766 if ( typeof workerFilePath === 'string' && workerFilePath . startsWith ( 'file://' ) ) {
0 commit comments