1
1
import { uglify } from 'rollup-plugin-uglify'
2
- import pkg from './package.json'
3
2
import typescript from 'rollup-plugin-typescript2'
4
3
import replace from 'rollup-plugin-replace'
5
4
import versionInjector from 'rollup-plugin-version-injector'
5
+ import { createRequire } from 'module'
6
6
7
+ const pkg = createRequire ( import . meta. url ) ( './package.json' )
7
8
const version = process . env . VERSION || pkg . version
8
9
const sourcemap = true
9
10
const banner = `/*
@@ -14,16 +15,16 @@ const banner = `/*
14
15
const treeshake = {
15
16
propertyReadSideEffects : false
16
17
}
17
- const tsconfig = {
18
+ const tsconfig = ( target ) => ( {
18
19
tsconfigOverride : {
19
20
include : [ 'src' ] ,
20
21
exclude : [ 'test' , 'benchmark' ] ,
21
22
compilerOptions : {
22
- target : 'es5' ,
23
+ target,
23
24
module : 'ES2015'
24
25
}
25
26
}
26
- }
27
+ } )
27
28
const versionInjection = versionInjector ( {
28
29
injectInComments : false ,
29
30
injectInTags : {
@@ -60,7 +61,7 @@ const nodeCjs = {
60
61
banner
61
62
} ] ,
62
63
external : [ 'path' , 'fs' ] ,
63
- plugins : [ versionInjection , typescript ( tsconfig ) ] ,
64
+ plugins : [ versionInjection , typescript ( tsconfig ( 'es5' ) ) ] ,
64
65
treeshake,
65
66
input
66
67
}
@@ -75,7 +76,7 @@ const nodeEsm = {
75
76
plugins : [
76
77
versionInjection ,
77
78
replace ( esmRequire ) ,
78
- typescript ( tsconfig )
79
+ typescript ( tsconfig ( 'es6' ) )
79
80
] ,
80
81
treeshake,
81
82
input
@@ -92,7 +93,7 @@ const browserEsm = {
92
93
versionInjection ,
93
94
replace ( browserFS ) ,
94
95
replace ( browserStream ) ,
95
- typescript ( tsconfig )
96
+ typescript ( tsconfig ( 'es6' ) )
96
97
] ,
97
98
treeshake,
98
99
input
@@ -110,7 +111,7 @@ const browserUmd = {
110
111
versionInjection ,
111
112
replace ( browserFS ) ,
112
113
replace ( browserStream ) ,
113
- typescript ( tsconfig )
114
+ typescript ( tsconfig ( 'es5' ) )
114
115
] ,
115
116
treeshake,
116
117
input
@@ -128,7 +129,7 @@ const browserMin = {
128
129
versionInjection ,
129
130
replace ( browserFS ) ,
130
131
replace ( browserStream ) ,
131
- typescript ( tsconfig ) ,
132
+ typescript ( tsconfig ( 'es5' ) ) ,
132
133
uglify ( )
133
134
] ,
134
135
treeshake,
0 commit comments