forked from rollup/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
28 lines (23 loc) · 750 Bytes
/
index.ts
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
import { transform } from 'buble';
import type { Plugin } from 'rollup';
import { createFilter } from '@rollup/pluginutils';
import type { RollupBubleOptions } from '../types';
export default function buble(options: RollupBubleOptions = {}): Plugin {
const filter = createFilter(options.include, options.exclude);
const transformOptions = { ...options, transforms: { ...options.transforms, modules: false } };
return {
name: 'buble',
transform(code, id) {
if (!filter(id)) return null;
try {
return transform(code, transformOptions);
} catch (e: any) {
e.plugin = 'buble';
if (!e.loc) e.loc = {};
e.loc.file = id;
e.frame = e.snippet;
throw e;
}
}
};
}