-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.react.js
More file actions
57 lines (55 loc) · 1.75 KB
/
Copy pathrollup.config.react.js
File metadata and controls
57 lines (55 loc) · 1.75 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
import typescript from '@rollup/plugin-typescript';
import alias from '@rollup/plugin-alias';
import path from 'path';
// Treat internal core/editor/etc modules as externals so they are not re-emitted under dist/react
function makeExternal(id) {
// Externalize peer deps only
if (id === 'react' || id === 'react-dom' || id === 'react/jsx-runtime') return true;
// Keep deep imports to the already-built core external so we don't duplicate core code
if (id === 'dv-rich-editor' || id.startsWith('dv-rich-editor/')) return true;
// Everything else (including relative/absolute paths inside src/react) should be bundled
return false;
}
export default [
{
input: 'src/react/index.ts',
output: {
file: 'dist/react/index.esm.js',
format: 'es',
sourcemap: true
},
plugins: [
// Rewrite local ../editor imports to package-root deep imports so consumers can resolve them
alias({
entries: [
{ find: '../editor/DhivehiRichEditor', replacement: 'dv-rich-editor/editor/DhivehiRichEditor' },
{ find: '../editor/ThemeManager', replacement: 'dv-rich-editor/editor/ThemeManager' }
]
}),
typescript({
tsconfig: './tsconfig.react.build.json',
// Do not emit declarations from Rollup plugin; let `tsc` emit them during the build step
declaration: false,
declarationMap: false
})
],
external: makeExternal
},
{
input: 'src/react/index.ts',
output: {
file: 'dist/react/index.js',
format: 'cjs',
sourcemap: true,
exports: 'named'
},
plugins: [
typescript({
tsconfig: './tsconfig.react.build.json',
declaration: false,
declarationMap: false
})
],
external: makeExternal
}
];