import anymatch from 'anymatch' ; import { ReboostInstance , ReboostPlugin } from '../../index' ; import { transformCommonJSToES6 } from './commonjs-to-es6' ; import { uniqueID } from '../../utils' ; export { transformCommonJSToES6 as runTransformation } ; export const CommonJSMode2Plugin = ( instance ) : ReboostPlugin => { const test = ( file ) => ( ! anymatch ( instance . config . commonJSInterop . exclude , file ) && anymatch ( instance . config . commonJSInterop . include , file ) ) ; return { name : 'core-commonjs-mode-2-plugin' , getCacheKey : ( { serializeObject } ) => serializeObject ( { include : instance . config . commonJSInterop . include , exclude : instance . config . commonJSInterop . exclude } ) , transformAST ( programPath , _ , filePath ) { if ( test ( filePath ) ) { transformCommonJSToES6 ( programPath , uniqueID ( 6 ) ) ; } } } ; } ;