-
Notifications
You must be signed in to change notification settings - Fork 23
/
index.js
41 lines (40 loc) · 1.08 KB
/
index.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
const rollup = require('./dist');
// old API just module.exports = class BroccoliRollup
// this proxies export to it, but catches default and BroccoliRollup keys
// and also, call redirects to default().
module.exports = new Proxy(rollup.BroccoliRollup, {
// support default interop with require
apply(_, thisArg, args) {
return Reflect.apply(rollup.default, thisArg, args);
},
get(target, prop) {
switch (prop) {
case 'default':
case 'BroccoliRollup':
return rollup[prop];
default:
return target[prop];
}
},
has(target, prop) {
switch (prop) {
case 'default':
case 'BroccoliRollup':
return true;
default:
return prop in target;
}
},
ownKeys(target) {
return ['default', 'BroccoliRollup'].concat(Reflect.ownKeys(target));
},
getOwnPropertyDescriptor(target, prop) {
switch (prop) {
case 'default':
case 'BroccoliRollup':
return Reflect.getOwnPropertyDescriptor(rollup, prop);
default:
return Reflect.getOwnPropertyDescriptor(target, prop);
}
},
});