This repository has been archived by the owner on Feb 5, 2022. It is now read-only.
forked from nfrasser/linkifyjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
95 lines (86 loc) · 2.91 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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';
export const plugins = [
resolve(),
commonjs(),
babel({ babelHelpers: 'bundled' })
];
// For interfaces in their dedicated packages
export function linkifyInterface(name, opts = {}) {
const iifeOpts = { name };
const globals = { linkifyjs: 'linkify' };
const external = ['@matrix-org/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}.js`,
external,
output: [
{ file: 'index.js', format: 'cjs', exports: 'auto' },
{ 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}.module.js`, format: 'es' },
],
plugins
};
}
// Interfaces embedded in the main linkifyjs package, not yet fully migrated
// over to their own packages. This should be removed in v3.1 or v4
export function linkifyClassicInterface(name, opts = {}) {
const iifeOpts = { name };
const globals = { linkifyjs: 'linkify' };
if ('globalName' in opts) { iifeOpts.name = opts.globalName; }
const 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}.module.js`, format: 'es' }
];
if (opts.commonjs) {
output.push({ file: `lib/linkify-${name}.js`, format: 'cjs', exports: 'auto' });
}
return {
input: `../linkifyjs/src/linkify-${name}.js`,
external: ['@matrix-org/linkifyjs'], // add other dependent packages here
output,
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(name, opts = {}) {
const globals = { linkifyjs: 'linkify' };
const output = [
{ file: `dist/linkify-plugin-${name}.js`, format: 'iife', globals, name: false },
{ file: `dist/linkify-plugin-${name}.min.js`, format: 'iife', globals, name: false, plugins: [terser()] },
{ file: `dist/linkify-plugin-${name}.module.js`, format: 'es' }
];
if (opts.commonjs) {
output.push({ file: `lib/plugins/${name}.js`, format: 'cjs', exports: 'auto' });
}
return {
input: `../linkifyjs/src/plugins/${name}.js`,
external: ['@matrix-org/linkifyjs'],
output,
plugins
};
}
export default [
/*
{
input: 'src/linkify/core/generated/state-machine.js',
output: [
{
file: 'dist/state-machine.min.js',
name: 'linkifyScannerStart',
format: 'iife',
plugins: [terser()]
}
],
plugins
},
*/
];