-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrollup.config.js
More file actions
78 lines (74 loc) · 1.88 KB
/
Copy pathrollup.config.js
File metadata and controls
78 lines (74 loc) · 1.88 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import typescript from '@rollup/plugin-typescript';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import { writeFileSync, mkdirSync } from 'fs';
import { dirname } from 'path';
const external = ['@deck.gl/core', 'zod', 'zod-to-json-schema']; // dependencies should not be bundled
// Plugin to create package.json in dist/cjs
const createCjsPackageJson = () => ({
name: 'create-cjs-package-json',
generateBundle() {
const pkgJsonPath = 'dist/cjs/package.json';
mkdirSync(dirname(pkgJsonPath), { recursive: true });
writeFileSync(pkgJsonPath, JSON.stringify({ type: 'commonjs' }, null, 2));
}
});
// Entry points for main and subpath exports
const entryPoints = {
'index': 'src/index.ts',
'definitions/index': 'src/definitions/index.ts',
'executors/index': 'src/executors/index.ts',
'schemas/index': 'src/schemas/index.ts',
'converters/index': 'src/converters/index.ts',
'prompts/index': 'src/prompts/index.ts',
};
export default [
// ESM build
{
input: entryPoints,
output: {
dir: 'dist/esm',
format: 'esm',
preserveModules: true,
preserveModulesRoot: 'src',
sourcemap: true
},
plugins: [
resolve(),
commonjs(),
json(),
typescript({
declaration: true,
outDir: 'dist/esm',
rootDir: 'src'
})
],
external
},
// CJS build
{
input: entryPoints,
output: {
dir: 'dist/cjs',
format: 'cjs',
preserveModules: true,
preserveModulesRoot: 'src',
sourcemap: true,
exports: 'named'
},
plugins: [
resolve(),
commonjs(),
json(),
typescript({
declaration: false,
declarationMap: false,
outDir: 'dist/cjs',
rootDir: 'src'
}),
createCjsPackageJson()
],
external
}
];