UNPKG

633 BJavaScriptView Raw
1import { transform } from 'buble';
2import { createFilter } from 'rollup-pluginutils';
3
4function buble(options = {}) {
5 const filter = createFilter(options.include, options.exclude);
6 const transformOptions = { ...options, transforms: { ...options.transforms, modules: false } };
7
8 return {
9 name: 'buble',
10
11 transform(code, id) {
12 if (!filter(id)) return null;
13
14 try {
15 return transform(code, transformOptions);
16 } catch (e) {
17 e.plugin = 'buble';
18 if (!e.loc) e.loc = {};
19 e.loc.file = id;
20 e.frame = e.snippet;
21 throw e;
22 }
23 }
24 };
25}
26
27export default buble;