|
1 | | -import alias from '@rollup/plugin-alias'; |
2 | 1 | import babel from '@rollup/plugin-babel'; |
3 | 2 | import nodeResolve from '@rollup/plugin-node-resolve'; |
4 | 3 | import typescript from '@rollup/plugin-typescript'; |
5 | | -import path from 'node:path'; |
6 | 4 |
|
7 | | -/** @type {import('rollup').RollupOptions[]} */ |
8 | | -export default [ |
9 | | - { |
10 | | - input: [ |
11 | | - 'src/index.ts', |
12 | | - 'src/enums/index.ts', |
13 | | - 'src/lib/index.ts', |
14 | | - 'src/types/index.ts', |
15 | | - 'src/utils/index.ts' |
16 | | - ], |
17 | | - output: { |
18 | | - dir: 'build/esm', |
| 5 | +/** @type {import('rollup').RollupOptions} */ |
| 6 | +export default { |
| 7 | + input: [ |
| 8 | + 'src/index.ts', |
| 9 | + 'src/enums/index.ts', |
| 10 | + 'src/lib/index.ts', |
| 11 | + 'src/types/index.ts', |
| 12 | + 'src/utils/index.ts' |
| 13 | + ], |
| 14 | + output: [ |
| 15 | + { |
| 16 | + dir: 'build', |
19 | 17 | format: 'esm', |
20 | 18 | preserveModules: true, |
21 | | - exports: 'named' |
| 19 | + exports: 'named', |
| 20 | + entryFileNames: '[name].mjs' |
22 | 21 | }, |
23 | | - preserveEntrySignatures: 'strict', |
24 | | - plugins: [ |
25 | | - typescript({ |
26 | | - outDir: 'build/esm/src' |
27 | | - }), |
28 | | - alias({ |
29 | | - customResolver: nodeResolve({ extensions: ['.ts', '.js', '.d.ts'] }), |
30 | | - entries: [{ find: 'src', replacement: path.resolve(__dirname, 'build/esm/src') }] |
31 | | - }), |
32 | | - babel({ |
33 | | - extensions: ['.js', '.ts', '.mjs', '.cjs', '.html'], |
34 | | - babelHelpers: 'runtime', |
35 | | - exclude: ['node_modules/@babel/**'], |
36 | | - presets: [ |
37 | | - [ |
38 | | - '@babel/preset-env', |
39 | | - { |
40 | | - targets: { firefox: '48' }, |
41 | | - exclude: ['@babel/plugin-transform-regenerator'] |
42 | | - } |
43 | | - ] |
44 | | - ], |
45 | | - plugins: [ |
46 | | - '@babel/plugin-syntax-dynamic-import', |
47 | | - [ |
48 | | - '@babel/plugin-transform-runtime', |
49 | | - { |
50 | | - useESModules: true, |
51 | | - regenerator: false |
52 | | - } |
53 | | - ] |
54 | | - ] |
55 | | - }), |
56 | | - nodeResolve() |
57 | | - ] |
58 | | - }, |
59 | | - { |
60 | | - input: [ |
61 | | - 'src/index.ts', |
62 | | - 'src/enums/index.ts', |
63 | | - 'src/lib/index.ts', |
64 | | - 'src/types/index.ts', |
65 | | - 'src/utils/index.ts' |
66 | | - ], |
67 | | - output: { |
68 | | - dir: 'build/cjs', |
| 22 | + { |
| 23 | + dir: 'build', |
69 | 24 | format: 'cjs', |
70 | 25 | preserveModules: true, |
71 | | - exports: 'named' |
72 | | - }, |
73 | | - preserveEntrySignatures: 'strict', |
74 | | - plugins: [ |
75 | | - alias({ |
76 | | - entries: [{ find: '$', replacement: path.resolve(__dirname, 'src') }] |
77 | | - }), |
78 | | - typescript({ |
79 | | - outDir: 'build/cjs/src' |
80 | | - }), |
81 | | - babel({ |
82 | | - extensions: ['.js', '.ts', '.mjs', '.cjs', '.html'], |
83 | | - babelHelpers: 'runtime', |
84 | | - exclude: ['node_modules/@babel/**'], |
85 | | - presets: [ |
86 | | - [ |
87 | | - '@babel/preset-env', |
88 | | - { |
89 | | - targets: { firefox: '48' }, |
90 | | - exclude: ['@babel/plugin-transform-regenerator'] |
91 | | - } |
92 | | - ] |
93 | | - ], |
94 | | - plugins: [ |
95 | | - '@babel/plugin-syntax-dynamic-import', |
96 | | - [ |
97 | | - '@babel/plugin-transform-runtime', |
98 | | - { |
99 | | - useESModules: true, |
100 | | - regenerator: false |
101 | | - } |
102 | | - ] |
| 26 | + exports: 'named', |
| 27 | + entryFileNames: '[name].cjs' |
| 28 | + } |
| 29 | + ], |
| 30 | + preserveEntrySignatures: 'strict', |
| 31 | + plugins: [ |
| 32 | + nodeResolve({}), |
| 33 | + typescript({ |
| 34 | + outDir: 'build/src' |
| 35 | + }), |
| 36 | + babel({ |
| 37 | + extensions: ['.js', '.ts', '.mjs', '.cjs', '.html'], |
| 38 | + babelHelpers: 'runtime', |
| 39 | + exclude: ['node_modules/@babel/**'], |
| 40 | + presets: [ |
| 41 | + [ |
| 42 | + '@babel/preset-env', |
| 43 | + { |
| 44 | + targets: { firefox: '48' }, |
| 45 | + exclude: ['@babel/plugin-transform-regenerator'] |
| 46 | + } |
| 47 | + ] |
| 48 | + ], |
| 49 | + plugins: [ |
| 50 | + '@babel/plugin-syntax-dynamic-import', |
| 51 | + [ |
| 52 | + '@babel/plugin-transform-runtime', |
| 53 | + { |
| 54 | + useESModules: true, |
| 55 | + regenerator: false |
| 56 | + } |
103 | 57 | ] |
104 | | - }), |
105 | | - nodeResolve() |
106 | | - ] |
107 | | - } |
108 | | -]; |
| 58 | + ] |
| 59 | + }) |
| 60 | + ] |
| 61 | +}; |
0 commit comments