-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrollup.config.common.js
87 lines (78 loc) · 3.28 KB
/
rollup.config.common.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
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
79
80
81
82
83
84
85
86
87
import typescript from '@rollup/plugin-typescript';
import externals from 'rollup-plugin-node-externals';
import copy from 'rollup-plugin-copy';
/** @type {import('rollup').RollupOptions} */
const config =
// ES module build (replaces broken basic TypeScript compilation)
// * ref: <https://github.com/microsoft/TypeScript/issues/18442> , <https://github.com/alshdavid/rxjs/blob/main/rollup.config.js#L10>
// * ref: <https://github.com/microsoft/TypeScript/pull/35148>
// * ref: <https://github.com/microsoft/TypeScript/issues/37582>
{
output: [
{
dir: 'lib',
format: 'esm',
entryFileNames: '[name].js',
sourcemap: true,
preserveModules: true, // or `false` to bundle as a single file
},
{
dir: 'lib',
format: 'cjs',
entryFileNames: '[name].cjs',
sourcemap: true,
preserveModules: true, // or `false` to bundle as a single file
},
],
plugins: [
externals(),
typescript({
exclude: ['**/tests/**', '**/*.test.*'],
compilerOptions: {
incremental: false,
},
}),
copy({
targets: [
{src: 'README.md', dest: 'lib'},
{src: 'CHANGELOG.md', dest: 'lib'},
{
src: 'package.json',
dest: 'lib',
transform: (contents) => {
const packageJson = JSON.parse(contents.toString());
return JSON.stringify({
...packageJson,
main: 'index.cjs',
module: 'index.js',
exports: {
...packageJson.exports,
...(packageJson.name ===
'@taddy/babel-plugin' && {
'./lib/': './',
'./cache/': './cache/',
'./macro': {
import: './macro.js',
require: './macro.cjs',
},
}),
...(packageJson.name === 'taddy' && {
'./vue': {
import: './vue/index.js',
require: './vue/index.cjs',
},
}),
'.': {
import: './index.js',
require: './index.cjs',
},
'./package.json': './package.json',
},
});
},
},
],
}),
],
};
export default config;