-
Notifications
You must be signed in to change notification settings - Fork 186
Expand file tree
/
Copy pathrollup.config.js
More file actions
89 lines (84 loc) · 2.56 KB
/
Copy pathrollup.config.js
File metadata and controls
89 lines (84 loc) · 2.56 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
import terser from '@rollup/plugin-terser';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import babel from '@rollup/plugin-babel';
import replace from '@rollup/plugin-replace';
export const plugins = [resolve({ browser: true }), babel({ babelHelpers: 'bundled' })];
// For interfaces in their dedicated packages
export function linkifyInterface(name, opts = {}) {
const iifeOpts = { name };
const globals = { linkifyjs: 'linkify' };
const external = ['linkifyjs'];
if ('globalName' in opts) {
iifeOpts.name = opts.globalName;
}
if ('globals' in opts) {
Object.assign(globals, opts.globals);
}
if ('external' in opts) {
external.push(...opts.external);
}
return {
input: `src/linkify-${name}.mjs`,
external,
output: [
{ file: `dist/linkify-${name}.js`, format: 'iife', globals, ...iifeOpts },
{ file: `dist/linkify-${name}.min.js`, format: 'iife', globals, ...iifeOpts, plugins: [terser()] },
{ file: `dist/linkify-${name}.cjs`, format: 'cjs', exports: 'auto' },
{ file: `dist/linkify-${name}.mjs`, format: 'es' },
],
plugins,
};
}
// Includes plugins from main linkifyjs package because those have not yet been
// fully migrated to their own packages to maintain backward compatibility with
// v2. Will change in v4
export function linkifyPlugin(plugin, opts = {}) {
const name = opts.globalName || false; // Most plugins don't export anything
const globals = { linkifyjs: 'linkify' };
return {
input: 'src/index.mjs',
external: ['linkifyjs'],
output: [
{ file: `dist/linkify-plugin-${plugin}.js`, format: 'iife', globals, name },
{ file: `dist/linkify-plugin-${plugin}.min.js`, format: 'iife', globals, name, plugins: [terser()] },
{ file: `dist/linkify-plugin-${plugin}.cjs`, format: 'cjs', exports: 'auto' },
{ file: `dist/linkify-plugin-${plugin}.mjs`, format: 'es' },
],
plugins,
};
}
// Build react globals for qunit tests
export default [
{
input: 'test/react.mjs',
output: [
{
file: 'test/qunit/vendor/react.min.js',
name: 'React',
format: 'iife',
plugins: [terser()],
},
],
plugins: plugins.concat([
replace({ 'process.env.NODE_ENV': '"production"', preventAssignment: true }),
commonjs(),
]),
},
{
input: 'test/react-dom.mjs',
output: [
{
file: 'test/qunit/vendor/react-dom.min.js',
name: 'ReactDOM',
globals: { react: 'React' },
format: 'iife',
plugins: [terser()],
},
],
plugins: plugins.concat([
replace({ 'process.env.NODE_ENV': '"production"', preventAssignment: true }),
commonjs(),
]),
},
];