@@ -2,8 +2,14 @@ namespace $ {
22
33 setTimeout ( ( ) => $mol_wire_async ( $mol_build ) . start ( process . argv . slice ( 2 ) ) )
44
5+
6+
57 export class $mol_build extends $mol_object {
6-
8+ static is_internal ( dep : string ) {
9+ if ( dep . startsWith ( 'node:' ) ) return true
10+ return require ( 'module' ) . builtinModules . includes ( dep )
11+ }
12+
713 @ $mol_mem_key
814 static root ( [ root , paths ] : [ root : string , paths : readonly string [ ] ] ) {
915 this . $ . $mol_file . base = root
@@ -1240,7 +1246,8 @@ namespace $ {
12401246 json . version = version . join ( '.' )
12411247
12421248 for ( let dep of this . nodeDeps ( [ path , exclude ] ) . keys ( ) ) {
1243- if ( require ( 'module' ) . builtinModules . includes ( dep ) || dep . startsWith ( 'node:' ) ) continue
1249+
1250+ if ( $mol_build . is_internal ( dep ) ) continue
12441251 json . dependencies [ dep ] ??= `*`
12451252 }
12461253
@@ -1550,6 +1557,7 @@ namespace $ {
15501557
15511558 line . replace (
15521559 / \b (?: r e q u i r e | i m p o r t ) \( \s * [ ' " ] ( [ ^ " ' ( ) ] * ?) [ ' " ] \s * \) / ig , ( str , path ) => {
1560+ if ( $mol_build . is_internal ( path ) ) return str
15531561 path = path . replace ( / ( \/ [ ^ \/ . ] + ) $ / , '$1.js' ) . replace ( / \/ $ / , '/index.js' )
15541562 if ( path [ 0 ] === '.' ) path = '../' + path
15551563 $mol_build_depsMerge ( depends , { [ path ] : priority } )
@@ -1588,7 +1596,7 @@ namespace $ {
15881596
15891597 line . replace (
15901598 / \b (?: r e q u i r e | i m p o r t ) \( \s * [ ' " ] ( [ ^ " ' ( ) ] * ?) [ ' " ] \s * \) / ig , ( str , path ) => {
1591- if ( path . startsWith ( 'node:' ) ) return str
1599+ if ( $mol_build . is_internal ( path ) ) return str
15921600 $mol_build_depsMerge ( depends , { [ path ] : priority } )
15931601 return str
15941602 }
0 commit comments