import dotProp = require ( 'dot-prop' ) ; import babel = require ( 'rollup-plugin-babel' ) ; import commonjs = require ( 'rollup-plugin-commonjs' ) ; import json = require ( 'rollup-plugin-json' ) ; import nodeResolve = require ( 'rollup-plugin-node-resolve' ) ; import mainEntry from 'rollup-plugin-main-entry' ; import replace = require ( 'rollup-plugin-replace' ) ; import subpathExternals from 'rollup-plugin-subpath-externals' ; import svg = require ( 'rollup-plugin-svg' ) ; import { terser } from 'rollup-plugin-terser' ; import babelrc from '@pectin/babelrc' ; import { CoreProperties as PackageManifest } from '@schemastore/package' ; import { Plugin } from 'rollup' ; import { RollupOutputOptions } from './getOutput' ; export async function getPlugins ( pkg , cwd , output ) { const env = dotProp . get ( output , 'env' ) ; const fmt = dotProp . get ( output , 'format' ) ; const min = fmt === 'umd' && env === 'production' ; const rc = await babelrc ( pkg , cwd , output ) ; return [ mainEntry ( pkg , cwd ) , subpathExternals ( pkg , output ) , nodeResolve ( { preferBuiltins : true , extensions : [ '.mjs' , '.js' , '.jsx' , '.json' , '.node' , '.ts' , '.tsx' ] , mainFields : [ 'module' , 'jsnext:main' , 'main' , ] , } ) , replace ( Object . assign ( env ? { 'process.env.NODE_ENV' : JSON . stringify ( env ) } : { } , { 'process.env.BROWSER' : JSON . stringify ( output . browser || false ) , 'process.env.VERSION' : JSON . stringify ( pkg . version ) , } ) ) , json ( ) , dotProp . get ( pkg , 'rollup.inlineSVG' ) && svg ( ) , babel ( rc ) , commonjs ( ) , min && terser ( { compress : { pure_getters : true , unsafe : true , unsafe_comps : true , } , mangle : { keep_classnames : true , keep_fnames : true , } , } ) , ] . filter ( x => Boolean ( x ) ) ; }