forked from visjs/vis-timeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.build.js
172 lines (162 loc) · 4.29 KB
/
rollup.build.js
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import commonjs from "rollup-plugin-commonjs";
import nodeResolve from "rollup-plugin-node-resolve";
import nodeBuiltins from "rollup-plugin-node-builtins";
import babel from "rollup-plugin-babel";
import { terser } from "rollup-plugin-terser";
import { generateHeader } from "vis-dev-utils";
import css from "rollup-plugin-css-porter";
import copy from "rollup-plugin-copy";
import packageJSON from "./package.json";
const banner = generateHeader({ name: "vis-timeline and vis-graph2d" });
const globals = {
"@egjs/hammerjs": "Hammer",
"emitter-component": "Emitter",
"propagating-hammerjs": "propagating",
"vis-data": "vis",
"vis-util": "vis",
keycharm: "keycharm",
moment: "moment"
};
// These are used in the public API and if there are different versions imported
// by the user compatibility issues may arise.
const externalPeer = ["moment", "vis-data"];
// These have big potential to cause bundle bloat.
const externalESNext = [].concat.call(
[],
Object.keys(packageJSON.dependencies),
Object.keys(packageJSON.peerDependencies),
// This will show a warning if any of them is used. The idea behind it is that
// if someone accidentaly imports a dev dependency they won't accidentaly add
// it to globals and Rollup will warn them about their error.
Object.keys(packageJSON.devDependencies)
);
const commonOutputESM = {
banner,
format: "esm",
globals,
sourcemap: true
};
const commonOutputUMD = {
banner,
exports: "named",
extend: true,
format: "umd",
globals,
name: "vis",
sourcemap: true
};
const commonPlugins = [
copy({
targets: [
{
src: "dev-lib/bundle-esm.js",
dest: ["esnext", "peer", "standalone"],
rename: "index.js"
},
{
src: "dev-lib/bundle-index.js",
dest: [
"esnext/esm",
"esnext/umd",
"peer/esm",
"peer/umd",
"standalone/esm",
"standalone/umd"
],
rename: "index.js"
}
]
}),
css({
dest: "styles/vis-timeline-graph2d.css"
}),
commonjs(),
nodeBuiltins(),
nodeResolve({ browser: true })
];
const babelPlugin = babel({
runtimeHelpers: true
});
const terserPlugin = terser({
output: {
comments: "some"
}
});
export default [
{
input: "lib/bundle-standalone.js",
output: [
Object.assign({}, commonOutputESM, {
file: "standalone/esm/vis-timeline-graph2d.js"
}),
Object.assign({}, commonOutputUMD, {
file: "standalone/umd/vis-timeline-graph2d.js"
})
],
plugins: [].concat.call([], commonPlugins, [babelPlugin])
},
{
input: "lib/bundle-standalone.js",
output: [
Object.assign({}, commonOutputESM, {
file: "standalone/esm/vis-timeline-graph2d.min.js"
}),
Object.assign({}, commonOutputUMD, {
file: "standalone/umd/vis-timeline-graph2d.min.js"
})
],
plugins: [].concat(commonPlugins, [babelPlugin, terserPlugin])
},
{
external: externalPeer,
input: "lib/bundle-peer.js",
output: [
Object.assign({}, commonOutputESM, {
file: "peer/esm/vis-timeline-graph2d.js"
}),
Object.assign({}, commonOutputUMD, {
file: "peer/umd/vis-timeline-graph2d.js"
})
],
plugins: [].concat.call([], commonPlugins, [babelPlugin])
},
{
external: externalPeer,
input: "lib/bundle-peer.js",
output: [
Object.assign({}, commonOutputESM, {
file: "peer/esm/vis-timeline-graph2d.min.js"
}),
Object.assign({}, commonOutputUMD, {
file: "peer/umd/vis-timeline-graph2d.min.js"
})
],
plugins: [].concat(commonPlugins, [babelPlugin, terserPlugin])
},
{
external: externalESNext,
input: "lib/bundle-peer.js",
output: [
Object.assign({}, commonOutputESM, {
file: "esnext/esm/vis-timeline-graph2d.js"
}),
Object.assign({}, commonOutputUMD, {
file: "esnext/umd/vis-timeline-graph2d.js"
})
],
plugins: commonPlugins
},
{
external: externalESNext,
input: "lib/bundle-peer.js",
output: [
Object.assign({}, commonOutputESM, {
file: "esnext/esm/vis-timeline-graph2d.min.js"
}),
Object.assign({}, commonOutputUMD, {
file: "esnext/umd/vis-timeline-graph2d.min.js"
})
],
plugins: [].concat(commonPlugins, [terserPlugin])
}
];