File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -905,11 +905,14 @@ class NodeRuntimeDriver implements RuntimeDriver {
905905 // where the CJS transform succeeds, return transformed CJS code instead.
906906 if ( this . _isOverlayEsmEntry ( hostPath ) ) {
907907 const transformed = transformSourceForRequireSync ( content , scriptPath ) ;
908- if ( transformed !== content ) {
909- // Transform succeeded: use CJS version (fast in-process require)
908+ // Check if the transform actually converted ESM to CJS (not just stripped shebang).
909+ // The require-setup marker indicates a successful ESM→CJS conversion.
910+ const REQUIRE_ESM_MARKER = "/*__secure_exec_require_esm__*/" ;
911+ if ( transformed . startsWith ( REQUIRE_ESM_MARKER ) ) {
912+ console . error ( `[_resolveEntry] ESM→CJS transform OK: ${ scriptPath } (${ content . length } →${ transformed . length } )` ) ;
910913 return { code : transformed , filePath : scriptPath } ;
911914 }
912- // Transform failed: fall through to raw ESM (slow but correct)
915+ console . error ( `[_resolveEntry] ESM→CJS transform skipped: ${ scriptPath } ( ${ content . length } bytes, no marker), using V8 ESM` ) ;
913916 }
914917 return { code : content , filePath : scriptPath } ;
915918 } catch {
You can’t perform that action at this time.
0 commit comments