@@ -52,7 +52,7 @@ function generateConfig({ externals, format, exports, // eslint-disable-next-lin
5252 let plugins = [ ] ;
5353 let extensions = [ ".js" ] ;
5454
55- if ( esnext || typescript || jsx ) {
55+ if ( esnext || typescript || jsx || compact === "minify" || compact === "mangle" ) {
5656 // TODO: Improve error message (correct extension name)
5757 let { default : swc } = loadExtension ( "rollup-plugin-swc" ,
5858 "failed to activate SWC" ) ;
@@ -68,7 +68,8 @@ function generateConfig({ externals, format, exports, // eslint-disable-next-lin
6868 typescript,
6969 jsx,
7070 sourcemaps,
71- browsers
71+ browsers,
72+ compact
7273 } ) ;
7374 plugins . push ( swc ( swcConfig ) ) ;
7475 }
@@ -79,7 +80,9 @@ function generateConfig({ externals, format, exports, // eslint-disable-next-lin
7980 ] ) ;
8081 if ( compact ) {
8182 cfg . compact = true ;
82- plugins = plugins . concat ( determineCompacting ( compact ) ) ;
83+ }
84+ if ( compact === true || compact === "compact" ) {
85+ plugins = plugins . concat ( require ( "rollup-plugin-cleanup" ) ( ) ) ;
8386 }
8487 cfg . plugins = plugins ;
8588
@@ -124,23 +127,3 @@ function determineModuleFormat(format = "esm") {
124127 return _format ;
125128 }
126129}
127-
128- function determineCompacting ( type = true ) {
129- switch ( type ) {
130- case true : // default
131- case "compact" :
132- return require ( "rollup-plugin-cleanup" ) ( ) ;
133- case "minify" :
134- var options = { compress : false , mangle : false } ; // eslint-disable-line no-var
135- break ;
136- case "mangle" :
137- options = { compress : false , mangle : true } ;
138- break ;
139- default :
140- abort ( `unknown compacting option ${ type } ` ) ;
141- }
142-
143- let { terser } = loadExtension ( "rollup-plugin-terser" ,
144- "failed to activate minification" , "faucet-pipeline-jsmin" ) ;
145- return terser ( options ) ;
146- }
0 commit comments