-
-
Notifications
You must be signed in to change notification settings - Fork 421
Expand file tree
/
Copy pathtsup.config.ts
More file actions
41 lines (40 loc) · 1.21 KB
/
Copy pathtsup.config.ts
File metadata and controls
41 lines (40 loc) · 1.21 KB
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
import { defineConfig } from 'tsup';
export default defineConfig([
// Main bundle — CSS is injected at runtime. Regular users need no CSS import.
// onSuccess prepends "use client" so Next.js App Router can import <DataTable>
// directly from a Server Component file.
{
entry: ['src/index.ts'],
format: ['esm', 'cjs'],
dts: true,
sourcemap: true,
clean: true,
external: ['react', 'react-dom'],
injectStyle: true,
treeshake: true,
minify: true,
onSuccess: 'node scripts/use-client-banner.mjs',
},
// Locales bundle — pure data, no React, no CSS.
{
entry: { 'locales/index': 'src/locales/index.ts' },
format: ['esm', 'cjs'],
dts: true,
sourcemap: true,
external: ['react', 'react-dom'],
treeshake: true,
minify: true,
},
// CSS-only build — emits dist/DataTable.css for SSR consumers (e.g. Next.js App Router)
// that need to import the stylesheet explicitly in a layout to avoid FOUC.
{
entry: { DataTable: 'src/index.ts' },
format: ['esm'],
external: ['react', 'react-dom'],
injectStyle: false,
treeshake: true,
minify: true,
// Only keep the emitted CSS file — the duplicate JS is not published.
onSuccess: 'rm -f dist/DataTable.mjs dist/DataTable.mjs.map',
},
]);