|
1 | | -import typescript from "@rollup/plugin-typescript"; |
2 | | -import pkg from './package.json'; |
3 | | -import { terser } from "rollup-plugin-terser"; |
4 | | -import bundleSize from 'rollup-plugin-bundle-size'; |
5 | | - |
6 | | -const banner = ` |
7 | | -/*! ================================ |
8 | | -${pkg.name} v${pkg.version} |
9 | | -(c) 2020-present ${pkg.author} |
10 | | -Released under ${pkg.license} License |
11 | | -================================== */ |
12 | | -`; |
13 | | - |
14 | | -/** |
15 | | - * @type {import('rollup/dist/rollup').InputOptions} |
16 | | - */ |
17 | | -const commonConfig = { |
18 | | - external: [ |
19 | | - ...Object.keys(pkg.dependencies ?? {}), |
20 | | - ...Object.keys(pkg.optionalDependencies ?? {}), |
21 | | - ...Object.keys(pkg.peerDependencies ?? {}) |
22 | | - ], |
23 | | - plugins: [ |
24 | | - // it doesn't find the config by default and doesn't emit interface files |
25 | | - // todo - https://github.com/rollup/plugins/pull/791/files#diff-77ceb76f06466d761730b952567396e6b5c292cc4044441cdfdf048b4614881dR83 check those tests |
26 | | - typescript({ tsconfig: './tsconfig.json' }), |
27 | | - terser({ |
28 | | - format: { |
29 | | - comments: (node, comment) => { |
30 | | - if (comment.type === "comment2") { |
31 | | - return /@upfront/.test(comment.value); |
32 | | - } |
33 | | - } |
34 | | - } |
35 | | - }), |
36 | | - bundleSize() |
37 | | - ] |
38 | | -}; |
39 | | - |
40 | | -/** |
41 | | - * @type {import('rollup/dist/rollup').RollupOptions[]} |
42 | | - */ |
43 | | -const rollupConfig = [ |
44 | | - { |
45 | | - input: 'src/index.ts', |
46 | | - output: [ |
47 | | - { |
48 | | - file: pkg.main, |
49 | | - format: 'cjs', |
50 | | - sourcemap: true, |
51 | | - banner |
52 | | - }, |
53 | | - { |
54 | | - file: pkg.module, |
55 | | - format: 'es', |
56 | | - sourcemap: true, |
57 | | - banner |
58 | | - } |
59 | | - ], |
60 | | - ...commonConfig |
61 | | - }, |
62 | | - |
63 | | - { |
64 | | - input: 'src/array.ts', |
65 | | - output: [ |
66 | | - { |
67 | | - file: 'array.min.js', |
68 | | - format: 'cjs', |
69 | | - sourcemap: true, |
70 | | - banner |
71 | | - }, |
72 | | - { |
73 | | - file: 'array.es.min.js', |
74 | | - format: 'es', |
75 | | - sourcemap: true, |
76 | | - banner |
77 | | - } |
78 | | - ], |
79 | | - ...commonConfig |
80 | | - }, |
81 | | - |
82 | | - { |
83 | | - input: 'src/string.ts', |
84 | | - output: [ |
85 | | - { |
86 | | - file: 'string.min.js', |
87 | | - format: 'cjs', |
88 | | - sourcemap: true, |
89 | | - banner |
90 | | - }, |
91 | | - { |
92 | | - file: 'string.es.min.js', |
93 | | - format: 'es', |
94 | | - sourcemap: true, |
95 | | - banner |
96 | | - } |
97 | | - ], |
98 | | - ...commonConfig |
99 | | - } |
100 | | -]; |
101 | | - |
102 | | -export default rollupConfig; |
| 1 | +import typescript from '@rollup/plugin-typescript'; |
| 2 | +import pkg from './package.json' assert { type: 'json' }; |
| 3 | +import terser from '@rollup/plugin-terser'; |
| 4 | +import bundleSize from 'rollup-plugin-bundle-size'; |
| 5 | + |
| 6 | +const banner = ` |
| 7 | +/*! ================================ |
| 8 | +${pkg.name} v${pkg.version} |
| 9 | +(c) 2020-present ${pkg.author} |
| 10 | +Released under ${pkg.license} License |
| 11 | +================================== */ |
| 12 | +`; |
| 13 | + |
| 14 | +/** |
| 15 | + * @type {import('rollup/dist/rollup').InputOptions} |
| 16 | + */ |
| 17 | +const commonConfig = { |
| 18 | + external: [ |
| 19 | + ...Object.keys(pkg.dependencies ?? {}), |
| 20 | + ...Object.keys(pkg.optionalDependencies ?? {}), |
| 21 | + ...Object.keys(pkg.peerDependencies ?? {}) |
| 22 | + ], |
| 23 | + plugins: [ |
| 24 | + // it doesn't find the config by default and doesn't emit interface files |
| 25 | + // todo - https://github.com/rollup/plugins/pull/791/files#diff-77ceb76f06466d761730b952567396e6b5c292cc4044441cdfdf048b4614881dR83 check those tests |
| 26 | + typescript({ tsconfig: './tsconfig.json' }), |
| 27 | + terser({ |
| 28 | + format: { |
| 29 | + comments: (node, comment) => { |
| 30 | + if (comment.type === "comment2") { |
| 31 | + return /@upfront/.test(comment.value); |
| 32 | + } |
| 33 | + } |
| 34 | + } |
| 35 | + }), |
| 36 | + bundleSize() |
| 37 | + ] |
| 38 | +}; |
| 39 | + |
| 40 | +/** |
| 41 | + * @type {import('rollup/dist/rollup').RollupOptions[]} |
| 42 | + */ |
| 43 | +const rollupConfig = [ |
| 44 | + { |
| 45 | + input: 'src/index.ts', |
| 46 | + output: [ |
| 47 | + { |
| 48 | + file: pkg.main, |
| 49 | + format: 'cjs', |
| 50 | + sourcemap: true, |
| 51 | + banner |
| 52 | + }, |
| 53 | + { |
| 54 | + file: pkg.module, |
| 55 | + format: 'es', |
| 56 | + sourcemap: true, |
| 57 | + banner |
| 58 | + } |
| 59 | + ], |
| 60 | + ...commonConfig |
| 61 | + }, |
| 62 | + |
| 63 | + { |
| 64 | + input: 'src/array.ts', |
| 65 | + output: [ |
| 66 | + { |
| 67 | + file: 'array.min.js', |
| 68 | + format: 'cjs', |
| 69 | + sourcemap: true, |
| 70 | + banner |
| 71 | + }, |
| 72 | + { |
| 73 | + file: 'array.es.min.js', |
| 74 | + format: 'es', |
| 75 | + sourcemap: true, |
| 76 | + banner |
| 77 | + } |
| 78 | + ], |
| 79 | + ...commonConfig |
| 80 | + }, |
| 81 | + |
| 82 | + { |
| 83 | + input: 'src/string.ts', |
| 84 | + output: [ |
| 85 | + { |
| 86 | + file: 'string.min.js', |
| 87 | + format: 'cjs', |
| 88 | + sourcemap: true, |
| 89 | + banner |
| 90 | + }, |
| 91 | + { |
| 92 | + file: 'string.es.min.js', |
| 93 | + format: 'es', |
| 94 | + sourcemap: true, |
| 95 | + banner |
| 96 | + } |
| 97 | + ], |
| 98 | + ...commonConfig |
| 99 | + } |
| 100 | +]; |
| 101 | + |
| 102 | +export default rollupConfig; |
0 commit comments