-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.ts
More file actions
48 lines (45 loc) · 1.37 KB
/
Copy pathrollup.config.ts
File metadata and controls
48 lines (45 loc) · 1.37 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
import commonjs from '@rollup/plugin-commonjs'
import typescript from '@rollup/plugin-typescript'
import { isAbsolute } from 'node:path'
import type { RollupOptions } from 'rollup'
const isBareModuleImport = (id: string, importer: string | undefined) =>
importer !== undefined && !id.startsWith('.') && !isAbsolute(id)
const config: RollupOptions = {
input: ['src/index.ts'],
output: [
{
dir: 'dist',
format: 'cjs',
entryFileNames: '[name].js',
exports: 'named',
// 'auto' emits a runtime `__esModule` check for each external default-import,
// unwrapping `.default` from ESM-shaped CJS modules (yamlify-object's CJS build,
// emitted by tsc, exposes the function as `exports.default` with `__esModule: true`
// and no `module.exports = fn` shim — without interop, `require()` returns the
// namespace object and calling it throws TypeError).
interop: 'auto',
preserveModules: true,
sourcemap: true,
},
{
dir: 'dist',
format: 'es',
exports: 'named',
entryFileNames: '[name].mjs',
preserveModules: true,
sourcemap: true,
},
],
treeshake: {
moduleSideEffects: false,
propertyReadSideEffects: false,
},
external: isBareModuleImport,
plugins: [
typescript({
tsconfig: 'tsconfig.build.json',
}),
commonjs(),
],
}
export default config