1
1
const path = require ( 'path' )
2
2
const alias = require ( '@rollup/plugin-alias' )
3
- const babelPlugin = require ( '@rollup/plugin-babel' )
4
3
const resolve = require ( '@rollup/plugin-node-resolve' )
5
4
const replace = require ( '@rollup/plugin-replace' )
6
5
const typescript = require ( '@rollup/plugin-typescript' )
@@ -19,24 +18,9 @@ function external(id) {
19
18
return ! id . startsWith ( '.' ) && ! id . startsWith ( root )
20
19
}
21
20
22
- function getBabelOptions ( targets ) {
23
- return {
24
- babelrc : false ,
25
- ignore : [ './node_modules' ] ,
26
- presets : [ [ '@babel/preset-env' , { loose : true , modules : false , targets } ] ] ,
27
- plugins : [
28
- [ '@babel/plugin-transform-react-jsx' , { runtime : 'automatic' } ] ,
29
- [ '@babel/plugin-transform-typescript' , { isTSX : true } ] ,
30
- ] ,
31
- extensions,
32
- comments : false ,
33
- babelHelpers : 'bundled' ,
34
- }
35
- }
36
-
37
- function getEsbuild ( env = 'development' ) {
21
+ function getEsbuild ( format ) {
38
22
return esbuild ( {
39
- minify : env === 'production' ,
23
+ format ,
40
24
target : 'es2018' ,
41
25
supported : { 'import-meta' : true } ,
42
26
tsconfig : path . resolve ( './tsconfig.json' ) ,
@@ -80,15 +64,15 @@ function createESMConfig(input, output) {
80
64
delimiters : [ '\\b' , '\\b(?!(\\.|/))' ] ,
81
65
preventAssignment : true ,
82
66
} ) ,
83
- getEsbuild ( ) ,
67
+ getEsbuild ( 'esm' ) ,
84
68
] ,
85
69
}
86
70
}
87
71
88
72
function createCommonJSConfig ( input , output ) {
89
73
return {
90
74
input,
91
- output : { file : ` ${ output } .js` , format : 'cjs' } ,
75
+ output : { file : output , format : 'cjs' } ,
92
76
external,
93
77
plugins : [
94
78
alias ( { entries : entries . filter ( ( e ) => ! e . find . test ( input ) ) } ) ,
@@ -98,7 +82,7 @@ function createCommonJSConfig(input, output) {
98
82
delimiters : [ '\\b' , '\\b(?!(\\.|/))' ] ,
99
83
preventAssignment : true ,
100
84
} ) ,
101
- babelPlugin ( getBabelOptions ( { ie : 11 } ) ) ,
85
+ getEsbuild ( 'cjs' ) ,
102
86
] ,
103
87
}
104
88
}
@@ -112,7 +96,7 @@ module.exports = function (args) {
112
96
}
113
97
return [
114
98
...( c === 'index' ? [ createDeclarationConfig ( `src/${ c } .ts` , 'dist' ) ] : [ ] ) ,
115
- createCommonJSConfig ( `src/${ c } .ts` , `dist/${ c } ` ) ,
99
+ createCommonJSConfig ( `src/${ c } .ts` , `dist/${ c } .js ` ) ,
116
100
createESMConfig ( `src/${ c } .ts` , `dist/esm/${ c } .mjs` ) ,
117
101
]
118
102
}
0 commit comments