-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtsup.config.js
52 lines (49 loc) · 1.42 KB
/
tsup.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
import { defineConfig } from 'tsup'
import { esbuildPluginFilePathExtensions } from 'esbuild-plugin-file-path-extensions'
import packageJson from './package.json' assert { type: "json" };
export default defineConfig([
modernConfig({
entry: ["src/**/*.ts","src/**/*.tsx", "!src/**/__test__", "!**/*.test.ts"],
}),
legacyConfig({
entry: ["src/**/*.ts","src/**/*.tsx", "!src/**/__test__", "!**/*.test.ts"],
}),
])
function modernConfig(opts) {
return {
entry: opts.entry,
define: {
'process.env.PACKAGE_VERSION': `"${packageJson.version}"`,
},
esbuildOptions(options) {
options.jsxImportSource = 'preact';
options.jsx = 'automatic'
},
format: ['cjs', 'esm'],
target: ['chrome91', 'firefox90', 'edge91', 'safari15', 'ios15', 'opera77'],
outDir: 'dist/modern',
dts: true,
sourcemap: true,
clean: true,
esbuildPlugins: [esbuildPluginFilePathExtensions({ esmExtension: 'js' })]
}
}
function legacyConfig(opts) {
return {
entry: opts.entry,
define: {
'process.env.PACKAGE_VERSION': `"${packageJson.version}"`,
},
format: ['cjs', 'esm'],
target: ['es2020', 'node16'],
outDir: 'dist/legacy',
dts: true,
sourcemap: true,
clean: true,
esbuildPlugins: [esbuildPluginFilePathExtensions({ esmExtension: 'js' })],
esbuildOptions(options) {
options.jsxImportSource = 'preact';
options.jsx = 'automatic'
},
}
}