import { xxh64 } from '@node-rs/xxhash' ; import { Options , transformJest } from '@swc-node/core' ; import type { Output } from '@swc/core' ; interface JestConfig26 { transform : [ match : string , transformerPath : string , options : Options ] [ ] ; } interface JestConfig27 { transformerConfig : Options ; } function getJestTransformConfig ( jestConfig ) { if ( 'transformerConfig' in jestConfig ) { return jestConfig . transformerConfig ; } if ( 'transform' in jestConfig ) { return jestConfig . transform . find ( ( [ , transformerPath ] ) => transformerPath === __filename ) ?. [ 2 ] ?? { } ; } return { } ; } export = { process ( src , path , jestConfig ) { if ( /\.(tsx?|jsx?|mjs)$/ . test ( path ) ) { return transformJest ( src , path , getJestTransformConfig ( jestConfig ) ) ; } return src ; } , getCacheKey ( src , _filepath , config ) { return xxh64 ( src + JSON . stringify ( config ) ) . toString ( 16 ) ; } , } ;