-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathrollup.config.js
More file actions
60 lines (58 loc) · 1.84 KB
/
Copy pathrollup.config.js
File metadata and controls
60 lines (58 loc) · 1.84 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import scss from 'rollup-plugin-scss';
import postcss from 'postcss';
import autoprefixer from 'autoprefixer';
import typescript from 'rollup-plugin-typescript2';
import terser from '@rollup/plugin-terser';
// Dual CJS + ESM (so existing require() consumers keep working — this is a non-breaking minor).
// react / react-dom / zod / the core are external (peer or dependency), resolved at the
// consumer rather than bundled in.
const isExternal = (id) =>
id === 'react' ||
id === 'react-dom' ||
id === 'zod' ||
id === '@tanstack/ai' ||
id === '@simplepdf/embed' ||
id.startsWith('@simplepdf/embed/');
export default {
// Three entries mirroring the core: the zod-free root, plus the opt-in agentic /ai-sdk
// (pulls zod) and /tanstack-ai (pulls zod + @tanstack/ai). The root loads neither.
input: { index: 'src/index.tsx', 'ai-sdk': 'src/ai-sdk.tsx', 'tanstack-ai': 'src/tanstack-ai.tsx' },
output: [
{
dir: 'dist',
format: 'cjs',
exports: 'named',
sourcemap: true,
entryFileNames: '[name].cjs',
chunkFileNames: 'chunks/[name]-[hash].cjs',
},
{
dir: 'dist',
format: 'es',
exports: 'named',
sourcemap: true,
entryFileNames: '[name].esm.js',
chunkFileNames: 'chunks/[name]-[hash].esm.js',
},
],
plugins: [
scss({
processor: () => postcss([autoprefixer()]),
outputStyle: 'compressed',
insert: true,
}),
// Build excludes test files so type-only `*.test-d.ts` assertions (still type-checked by
// test:types) never emit declarations into dist / ship to npm.
typescript({
tsconfigOverride: {
exclude: ['node_modules', 'src/**/*.test.ts', 'src/**/*.test.tsx', 'src/**/*.test-d.ts', 'vitest.setup.ts'],
},
}),
terser({
format: {
comments: false,
},
}),
],
external: isExternal,
};