@@ -19,40 +19,52 @@ const output = {
19
19
preserveModulesRoot : 'src' ,
20
20
} ;
21
21
22
- /** @type {Plugins } */
23
- const defaultPlugins = [
22
+ /**
23
+ * @param {import('rollup-plugin-node-externals').ExternalsOptions } externalsOptions
24
+ * @returns {Plugins }
25
+ */
26
+
27
+ const defaultPlugins = ( externalsOptions ) => [
24
28
nodeResolve ( {
25
29
extensions : [ '.cjs' , '.mjs' , '.js' , '.jsx' , '.ts' , '.tsx' , '.json' ] ,
26
30
} ) ,
27
31
commonjs ( ) ,
28
32
json ( ) ,
29
- nodeExternals ( ) ,
33
+ nodeExternals ( externalsOptions ) ,
30
34
] ;
31
35
32
36
/**
33
37
* @param {object } param0
34
38
* @param {Plugins } [param0.plugins]
35
39
* @param {Input } [param0.input]
40
+ * @param {import('rollup-plugin-node-externals').ExternalsOptions } [param0.externalsOptions]
41
+ * @param {import("rollup").RollupOptions["output"] } [param0.cjsOutputOptions]
36
42
* @returns {import("rollup").RollupOptions[] }
37
43
*/
38
- export default ( { input = defaultInput , plugins = [ ] } = { } ) => [
44
+ export default ( {
45
+ input = defaultInput ,
46
+ plugins = [ ] ,
47
+ externalsOptions,
48
+ cjsOutputOptions,
49
+ } = { } ) => [
39
50
{
40
51
input,
41
52
output,
42
- plugins : [ ...defaultPlugins , ...plugins , esbuild ( ) ] ,
53
+ plugins : [ ...defaultPlugins ( externalsOptions ) , ...plugins , esbuild ( ) ] ,
43
54
} ,
44
55
{
45
56
input,
46
57
output : {
47
58
...output ,
59
+ ...cjsOutputOptions ,
48
60
format : 'cjs' ,
49
61
entryFileNames : '[name].cjs' ,
50
62
} ,
51
- plugins : [ ...defaultPlugins , ...plugins , esbuild ( ) ] ,
63
+ plugins : [ ...defaultPlugins ( externalsOptions ) , ...plugins , esbuild ( ) ] ,
52
64
} ,
53
65
{
54
66
input,
55
67
output,
56
- plugins : [ ...defaultPlugins , ...plugins , dts ( ) ] ,
68
+ plugins : [ ...defaultPlugins ( externalsOptions ) , ...plugins , dts ( ) ] ,
57
69
} ,
58
70
] ;
0 commit comments