import Proof , { ProofPlugin , TestRunner } from '@proof-ui/core' ; import path from 'path' ; import 'core-js' ; import 'regenerator-runtime/runtime' ; export interface BabelPluginConfig { config : Record < string , any > ; } export default class BabelPlugin implements ProofPlugin { private readonly options : BabelPluginConfig ; constructor ( options ? ) { this . options = options ?? { config : { presets : [ '@babel/preset-env' ] , } , } ; } apply ( proof ) { proof . hooks . testRunner . tap ( 'babel' , ( runner ) => { runner . hooks . files . tap ( 'babel' , ( files ) => { const relativePaths = files . map ( ( p ) => path . resolve ( p ) ) ; require ( '@babel/register' ) ( { babelrc : false , ignore : [ ( fPath ) => { return ! relativePaths . includes ( fPath ) ; } , ] , ... this . options . config , } ) ; } ) ; } ) ; } }