import { IPlugin } from "../i-plugin" ; import { isLegalArray , isLegalString } from "../../utils/utils" ; import { BabelFileResult , transform } from "@babel/core" ; author CaMnter
  abstract class BabelCodePlugin implements IPlugin { private _plugins : any ; private _result : string | undefined ; run ( code ) { this . _plugins = this . setPlugins ( ) ; let expectCode = '' ; if ( this . _plugins && isLegalArray ( this . _plugins ) && isLegalString ( code ) ) { const opts = { } ; opts . plugins = [ this . _plugins ] ; const result = transform ( code as string , opts ) ; if ( result && result . code && 'string' == typeof result . code ) { expectCode = result . code ; } } else { expectCode = code as string ; } return expectCode ; } get result ( ) : string | undefined { return this . _result ; } /**
     * set plugin
     */ abstract setPlugins ( ) ; get plugins ( ) : any { return this . _plugins ; } } export default BabelCodePlugin ;