11import { includesAny , getPluginFunction } from "./utils"
22
33import type resolve from "@rollup/plugin-node-resolve"
4+ type RollupResolveOptions = Parameters < typeof resolve > [ 0 ]
45import type commonjs from "@rollup/plugin-commonjs"
6+ type RollupCommonjsOptions = Parameters < typeof commonjs > [ 0 ]
57import type { terser } from "rollup-plugin-terser"
8+ type RollupTerserOptions = Parameters < typeof terser > [ 0 ]
69import type sourcemaps from "rollup-plugin-sourcemaps"
10+ type RollupSourcemapsOptions = Parameters < typeof sourcemaps > [ 0 ]
711import type replace from "@rollup/plugin-replace"
12+ type RollupReplaceOptions = Parameters < typeof replace > [ 0 ]
813// @ts -ignore
914import type autoExternal from "rollup-plugin-auto-external"
15+ type RollupAutoexternalOptions = Parameters < typeof autoExternal > [ 0 ] & Record < string , any >
1016import type typescript from "@rollup/plugin-typescript"
17+ type RollupTypeScriptOptions = Parameters < typeof typescript > [ 0 ]
1118// @ts -ignore
1219import type coffeescript from "rollup-plugin-coffee-script"
20+ type RollupCoffeeOptions = Parameters < typeof coffeescript > [ 0 ] & Record < string , any >
1321import type json from "@rollup/plugin-json"
22+ type RollupJsonOptions = Parameters < typeof json > [ 0 ]
1423// @ts -ignore
1524import type cssOnly from "rollup-plugin-css-only"
25+ type RollupCssonlyOptions = Parameters < typeof cssOnly > [ 0 ] & Record < string , any >
1626import type babel from "@rollup/plugin-babel"
27+ type RollupBabelOptions = Parameters < typeof babel > [ 0 ]
1728import type { wasm } from "@rollup/plugin-wasm"
29+ type RollupWasmOptions = Parameters < typeof wasm > [ 0 ]
1830// @ts -ignore
1931import type { asc } from "rollup-plugin-assemblyscript"
32+ type RollupAscOptions = Parameters < typeof asc > [ 0 ] & Record < string , any >
2033import type visualizer from "rollup-plugin-visualizer"
34+ type RollupVisualizerOptions = Parameters < typeof visualizer > [ 0 ]
2135
2236export type Plugin =
2337 | "js"
@@ -35,20 +49,20 @@ export type Plugin =
3549 | "resolve"
3650 | "autoExternal"
3751 | "visualizer"
38- | [ "ts" , typeof typescript , boolean ?]
39- | [ "babel" , typeof babel , boolean ?]
40- | [ "coffee" , typeof coffeescript , boolean ?]
41- | [ "json" , typeof json , boolean ?]
42- | [ "css" , typeof cssOnly , boolean ?]
43- | [ "wasm" , typeof wasm , boolean ?]
44- | [ "as" , typeof asc , boolean ?]
45- | [ "terser" , typeof terser , boolean ?]
46- | [ "replace" , typeof replace , boolean ?]
47- | [ "sourcemaps" , typeof sourcemaps , boolean ?]
48- | [ "commonjs" , typeof commonjs , boolean ?]
49- | [ "resolve" , typeof resolve , boolean ?]
50- | [ "autoExternal" , typeof autoExternal , boolean ?]
51- | [ "visualizer" , typeof visualizer , boolean ?]
52+ | [ "ts" , RollupTypeScriptOptions , boolean ?]
53+ | [ "babel" , RollupBabelOptions , boolean ?]
54+ | [ "coffee" , RollupCoffeeOptions , boolean ?]
55+ | [ "json" , RollupJsonOptions , boolean ?]
56+ | [ "css" , RollupCssonlyOptions , boolean ?]
57+ | [ "wasm" , RollupWasmOptions , boolean ?]
58+ | [ "as" , RollupAscOptions , boolean ?]
59+ | [ "terser" , RollupTerserOptions , boolean ?]
60+ | [ "replace" , RollupReplaceOptions , boolean ?]
61+ | [ "sourcemaps" , RollupSourcemapsOptions , boolean ?]
62+ | [ "commonjs" , RollupCommonjsOptions , boolean ?]
63+ | [ "resolve" , RollupResolveOptions , boolean ?]
64+ | [ "autoExternal" , RollupAutoexternalOptions , boolean ?]
65+ | [ "visualizer" , RollupVisualizerOptions , boolean ?]
5266
5367export function createPlugins (
5468 inputPluginsNames : Array < Plugin > = [ "ts" , "js" , "json" , "coffee" ] ,
@@ -62,7 +76,7 @@ export function createPlugins(
6276 pushPlugin ( [ "ts" , ".ts" , "typescript" , "TypeScript" ] , [ "@rollup/plugin-typescript" ] , {
6377 noEmitOnError : false ,
6478 module : "ESNext" , // do not modify the imports
65- } )
79+ } as RollupTypeScriptOptions )
6680
6781 // coffeescript
6882 pushPlugin (
@@ -71,7 +85,7 @@ export function createPlugins(
7185 )
7286
7387 // json
74- pushPlugin ( [ "json" , ".json" , "JSON" ] , [ "@rollup/plugin-json" ] , { compact : true } )
88+ pushPlugin ( [ "json" , ".json" , "JSON" ] , [ "@rollup/plugin-json" ] , { compact : true } as RollupJsonOptions )
7589
7690 // css only
7791 const cssIndex = includesAny ( inputPluginsNames , [ "css" , ".css" ] )
@@ -84,7 +98,7 @@ export function createPlugins(
8498 ` )
8599 if ( typeof inputPluginsNames [ cssIndex ] === "string" ) {
86100 // plugin name only
87- plugins . push ( cssOnly ( { output : "dist/bundle.css" } ) )
101+ plugins . push ( cssOnly ( { output : "dist/bundle.css" } as RollupCssonlyOptions ) )
88102 } else {
89103 // plugin with options
90104 plugins . push ( cssOnly ( inputPluginsNames [ cssIndex ] [ 1 ] ) )
@@ -100,7 +114,7 @@ export function createPlugins(
100114 pushPlugin ( [ "babel" ] , [ "@rollup/plugin-babel" , "babel" ] , {
101115 extensions : [ ".js" , ".jsx" , ".mjs" , ".coffee" ] ,
102116 babelHelpers : "bundled" ,
103- } )
117+ } as RollupBabelOptions )
104118
105119 // wasm
106120 pushPlugin ( [ "wasm" , "WebAssembly" ] , [ "@rollup/plugin-wasm" , "wasm" ] )
@@ -109,7 +123,10 @@ export function createPlugins(
109123 pushPlugin ( [ "as" , "asc" , "assemblyscript" , "AssemblyScript" ] , [ "rollup-plugin-assemblyscript" , "asc" ] )
110124
111125 // visualizer
112- pushPlugin ( [ "visualizer" , "plot" ] , [ "rollup-plugin-visualizer" ] , { sourcemap : true , open : true } )
126+ pushPlugin ( [ "visualizer" , "plot" ] , [ "rollup-plugin-visualizer" ] , {
127+ sourcemap : true ,
128+ open : true ,
129+ } as RollupVisualizerOptions )
113130
114131 // extra plugins
115132 if ( extraPlugins !== undefined && typeof extraPlugins === "object" /*array*/ ) {
@@ -123,7 +140,7 @@ export function createPlugins(
123140 // Default plugins
124141
125142 // loading files with existing source maps
126- pushPlugin ( [ "sourcemaps" ] , [ "rollup-plugin-sourcemaps" ] , { } , true )
143+ pushPlugin ( [ "sourcemaps" ] , [ "rollup-plugin-sourcemaps" ] , { } as RollupSourcemapsOptions , true )
127144
128145 pushPlugin (
129146 [ "autoExternal" ] ,
@@ -132,7 +149,7 @@ export function createPlugins(
132149 builtins : true ,
133150 dependencies : false ,
134151 peerDependencies : false ,
135- } ,
152+ } as RollupAutoexternalOptions ,
136153 true
137154 )
138155
0 commit comments