Open History to see the last commit
1// @ts-check
2β
3/**
4 * @param {Object} opts - Options for building configurations.
5 * @param {string[]} opts.entry - The entry array.
6 * @returns {import('tsup').Options}
7 */
8export function modernConfig(opts) {
9 return {
10 entry: opts.entry,
11 format: ['cjs', 'esm'],
12 target: ['chrome91', 'firefox90', 'edge91', 'safari15', 'ios15', 'opera77'],
13 outDir: 'build/modern',
14 dts: true,
15 sourcemap: true,
16 clean: true,
17 external: ['typescript'],
18 footer: ({ format }) => {
19 if (format === 'cjs') {
20 // workaround for CJS default export
21 // @see https://github.com/evanw/esbuild/issues/1182#issuecomment-1011414271
22 return { js: `module.exports = module.exports.default` }
23 }
24β
25 return
26 },
27 }
28}
29β
30/**
31 * @param {Object} opts - Options for building configurations.
32 * @param {string[]} opts.entry - The entry array.
33 * @returns {import('tsup').Options}
34 */
35export function legacyConfig(opts) {
36 return {
37 entry: opts.entry,
38 format: ['cjs', 'esm'],
39 target: ['es2020', 'node16'],
40 outDir: 'build/legacy',
41 dts: true,
42 sourcemap: true,
43 clean: true,
44 external: ['typescript'],
45 }
46}