1+ import { createRequire } from 'node:module' ;
12import type { MetroConfig } from 'metro-config' ;
23
4+ const require = createRequire ( import . meta. url ) ;
5+
36export type Serializer = NonNullable <
47 NonNullable < MetroConfig [ 'serializer' ] > [ 'customSerializer' ]
58> ;
69
710const getBaseSerializer = ( ) : Serializer => {
8- const baseJSBundle = require ( 'metro/private/DeltaBundler/Serializers/baseJSBundle' ) ;
11+ const baseJSBundle = require (
12+ 'metro/private/DeltaBundler/Serializers/baseJSBundle'
13+ ) ;
914 const bundleToString = require ( 'metro/private/lib/bundleToString' ) ;
1015
1116 return ( entryPoint , prepend , graph , bundleOptions ) =>
@@ -20,19 +25,16 @@ export const getHarnessSerializer = (): Serializer => {
2025
2126 return async ( entryPoint , preModules , graph , options ) => {
2227 if ( options . modulesOnly ) {
23- // This is most likely a test file
2428 return baseSerializer ( entryPoint , preModules , graph , {
2529 ...options ,
2630 processModuleFilter : ( mod ) => {
2731 if (
2832 options . processModuleFilter &&
2933 ! options . processModuleFilter ( mod )
3034 ) {
31- // If the module is not allowed by the processModuleFilter, skip it
3235 return false ;
3336 }
3437
35- // If the module is in the main entry point, skip it
3638 return ! mainEntryPointModules . has ( mod . path ) ;
3739 } ,
3840 } ) ;
0 commit comments