-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrollup.config.js
More file actions
112 lines (109 loc) · 3 KB
/
rollup.config.js
File metadata and controls
112 lines (109 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import { babel } from '@rollup/plugin-babel'
import terser from '@rollup/plugin-terser'
import typescript from "@rollup/plugin-typescript";
import sizes from "rollup-plugin-sizes"
import json from "@rollup/plugin-json";
import {dts} from "rollup-plugin-dts";
const extensions = ['.js', '.ts']
const babelPresetsBrowser = [
'@babel/preset-typescript',
['@babel/preset-env', {
useBuiltIns: false,
debug: true
}]
]
const _babelPresetsNode = [
'@babel/preset-typescript',
['@babel/preset-env', {
targets: {
node: '14'
},
useBuiltIns: false,
debug: true
}]
]
const babelPlugins = [
['@babel/plugin-transform-runtime', {
corejs: {
version: 3,
proposals: true
},
helpers: true,
absoluteRuntime: false,
useESModules: true,
version: "^7.26.0"
}]
]
export default [
{
input: 'src/index.ts',
output: [
{
format: 'iife',
name: 'Metapatcher',
file: 'dist/metapatcher.iife.js',
sourcemap: true,
globals: {
Metapatcher: 'Metapatcher'
}
}
],
plugins: [
json(),
typescript({ noForceEmit: true }),
nodeResolve({ preferBuiltins: false, browser: true, extensions }),
commonjs({ sourceMap: true }),
babel({
extensions,
//include: ['src/**/*.ts'],
//exclude: ['node_modules/**'],
exclude: [/core-js/],
babelHelpers: 'runtime',
babelrc: false,
presets: babelPresetsBrowser,
plugins: babelPlugins
}),
terser({sourceMap: true}),
sizes()
]
},
{
input: 'src/index.ts',
external: [/@babel\/runtime/],
output: [
{
format: 'es',
file: 'dist/metapatcher.es.js',
sourcemap: true
},
{
format: 'cjs',
file: 'dist/metapatcher.cjs.js',
sourcemap: true
}
],
plugins: [
json(),
typescript({ noForceEmit: true }),
nodeResolve({ preferBuiltins: false, browser: true, extensions }),
commonjs({ sourceMap: true }),
babel({
extensions,
include: ['src/**/*.ts'],
babelHelpers: 'runtime',
babelrc: false,
presets: babelPresetsBrowser,
plugins: babelPlugins
}),
terser({sourceMap: true}),
sizes()
]
},
{
input: "./dist/index.d.ts",
output: [{ file: "dist/index.d.cts", format: "cjs" }],
plugins: [dts()],
}
]