1import commonjs from '@rollup/plugin-commonjs';
2import resolve from '@rollup/plugin-node-resolve';
3import buble from '@rollup/plugin-buble';
4import compiler from '@ampproject/rollup-plugin-closure-compiler';
5
6import simplifyJSTags from './scripts/simplify-jstags-plugin.js';
7
8const plugins = [
9 commonjs({
10 ignoreGlobal: true,
11 include: ['*', '**'],
12 extensions: ['.js', '.ts', '.tsx'],
13 }),
14 resolve({
15 mainFields: ['module', 'jsnext', 'main'],
16 extensions: ['.js', '.ts', '.tsx'],
17 browser: true,
18 }),
19 buble({
20 transforms: {
21 unicodeRegExp: false,
22 dangerousForOf: true,
23 templateString: false,
24 },
25 exclude: 'node_modules/**',
26 }),
27];
28
29const output = (format = 'cjs', ext = '.js') => ({
30 chunkFileNames: '[hash]' + ext,
31 entryFileNames: 'reghex-[name]' + ext,
32 dir: './dist',
33 exports: 'named',
34 externalLiveBindings: false,
35 sourcemap: true,
36 esModule: false,
37 indent: false,
38 freeze: false,
39 strict: false,
40 format,
41 plugins: [
42 simplifyJSTags(),
43 compiler({
44 formatting: 'PRETTY_PRINT',
45 compilation_level: 'SIMPLE_OPTIMIZATIONS',
46 }),
47 ],
48});
49
50const base = {
51 onwarn: () => {},
52 external: () => false,
53 treeshake: {
54 propertyReadSideEffects: false,
55 },
56 plugins,
57 output: [output('cjs', '.js'), output('esm', '.mjs')],
58};
59
60export default [
61 {
62 ...base,
63 input: {
64 core: './src/core.js',
65 },
66 },
67 {
68 ...base,
69 output: {
70 ...output('cjs', '.js'),
71 exports: 'default',
72 },
73 input: {
74 babel: './src/babel/plugin.js',
75 macro: './src/babel/macro.js',
76 },
77 },
78];