-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
73 lines (56 loc) · 1.69 KB
/
rollup.config.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
import resolve from '@rollup/plugin-node-resolve';
import babel from '@rollup/plugin-babel';
import {terser} from 'rollup-plugin-terser';
import fs from 'fs';
import path from 'path';
import rootpkg from './package.json';
let globals = {
'@activewidgets/experimental': 'ActiveWidgets.Experimental',
'@activewidgets/options': 'ActiveWidgets.Options'
};
let getBanner = name => `/**
* ${name} ${rootpkg.version}
* Copyright (C) 2023 ActiveWidgets SARL. All Rights Reserved.
* This code is licensed under the MIT license found in the
* LICENSE file in the root directory of this package.
*/
`;
function keepBanner(node, comment){
if (comment.type == "comment2") {
return /2023 ActiveWidgets/.test(comment.value);
}
}
let plugins = [
resolve(),
babel({
babelrc: false,
babelHelpers: 'bundled',
exclude: 'node_modules/**',
presets: [["@babel/env", {modules: false}]]
}),
terser({
output: {comments: keepBanner}
})
];
function read(filename){
return String(fs.readFileSync(filename, {encoding:'utf8'}));
}
function config(name, input){
let dir = path.dirname(input),
pkg = JSON.parse(read(path.join(dir, 'package.json'))),
main = path.join(dir, pkg.main),
module = path.join(dir, pkg.module),
sourcemap = true,
banner = getBanner(pkg.name),
extend = true;
return {
input,
output: [
{file: main, format: 'umd', sourcemap, banner, globals, name, extend},
{file: module, format: 'esm', sourcemap, banner}
],
external: Object.keys(globals),
plugins
};
}
export default config('ActiveWidgets.Relay', 'index.js');