UNPKG

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