@@ -6,16 +6,15 @@ import replace from "@rollup/plugin-replace";
6
6
7
7
// eslint-disable-next-line @typescript-eslint/no-var-requires
8
8
const pkg = require ( "./package.json" ) ;
9
-
10
- export default [ {
11
- input : "lib-es6/index" ,
9
+ const browserTpl = ( input , umdOutput , esOutput ) => ( {
10
+ input : input ,
12
11
output : [ {
13
- file : pkg . browser ,
12
+ file : umdOutput ,
14
13
format : "umd" ,
15
14
sourcemap : true ,
16
15
name : pkg . name
17
16
} , {
18
- file : pkg . module + ".js" ,
17
+ file : esOutput ,
19
18
format : "es" ,
20
19
sourcemap : true
21
20
} ] ,
@@ -27,16 +26,17 @@ export default [{
27
26
commonjs ( { } ) ,
28
27
sourcemaps ( )
29
28
]
30
- } , {
31
- input : "lib-es6/index" ,
29
+ } ) ;
30
+ const nodeTpl = ( input , cjsOutput , esOutput ) => ( {
31
+ input : input ,
32
32
external : [ "fs" , "crypto" , "path" ] ,
33
33
output : [ {
34
- file : pkg . main ,
34
+ file : cjsOutput ,
35
35
format : "cjs" ,
36
36
sourcemap : true ,
37
37
name : pkg . name
38
38
} , {
39
- file : pkg [ "module-node" ] + ".js" ,
39
+ file : esOutput ,
40
40
format : "es" ,
41
41
sourcemap : true
42
42
} ] ,
@@ -56,45 +56,15 @@ export default [{
56
56
commonjs ( { } ) ,
57
57
sourcemaps ( )
58
58
]
59
- } , {
60
- input : "lib-es6/__tests__/index" ,
61
- output : {
62
- file : "dist/test.js" ,
63
- format : "umd" ,
64
- sourcemap : true ,
65
- name : pkg . name
66
- } ,
67
- plugins : [
68
- alias ( { } ) ,
69
- nodeResolve ( {
70
- preferBuiltins : true
71
- } ) ,
72
- commonjs ( { } ) ,
73
- sourcemaps ( )
74
- ]
75
- } , {
76
- input : "lib-es6/__tests__/index" ,
77
- external : [ "fs" , "crypto" , "path" ] ,
78
- output : {
79
- file : "dist/test.node.js" ,
80
- format : "commonjs" ,
81
- sourcemap : true ,
82
- name : pkg . name
83
- } ,
84
- plugins : [
85
- alias ( {
86
- entries : [
87
- { find : "../build/graphviz/graphvizlib/graphvizlib" , replacement : "../build/graphviz/graphvizlib/graphvizlib.node" } ,
88
- { find : "../build/expat/expatlib/expatlib" , replacement : "../build/expat/expatlib/expatlib.node" }
89
- ]
90
- } ) ,
91
- replace ( {
92
- ".node.wasm" : ".wasm"
93
- } ) ,
94
- nodeResolve ( {
95
- preferBuiltins : true
96
- } ) ,
97
- commonjs ( { } ) ,
98
- sourcemaps ( )
99
- ]
100
- } ] ;
59
+ } ) ;
60
+
61
+ export default [
62
+ browserTpl ( "lib-es6/index" , pkg . browser , pkg . module + ".js" ) ,
63
+ browserTpl ( "lib-es6/graphviz" , "dist/graphviz.js" , "dist/graphviz.es6.js" ) ,
64
+ browserTpl ( "lib-es6/expat" , "dist/expat.js" , "dist/expat.es6.js" ) ,
65
+ nodeTpl ( "lib-es6/index" , pkg . main , pkg [ "module-node" ] + ".js" ) ,
66
+ nodeTpl ( "lib-es6/graphviz" , "dist/graphviz.node.js" , "dist/graphviz.node.es6.js" ) ,
67
+ nodeTpl ( "lib-es6/expat" , "dist/expat.node.js" , "dist/expat.node.es6.js" ) ,
68
+ browserTpl ( "lib-es6/__tests__/index" , "dist/test.js" , "dist/test.es6.js" ) ,
69
+ nodeTpl ( "lib-es6/__tests__/index" , "dist/test.node.js" , "dist/test.node.es6.js" )
70
+ ] ;
0 commit comments