This repository has been archived by the owner on Jul 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
58 lines (53 loc) · 1.68 KB
/
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import type { TransformOptions as BubleOptions } from "buble";
/** Options supported by buble-config-rhino */
export interface Options extends Omit<BubleOptions, "target"> {
/**
* `targets` is unsupported since we are specifically targeting Rhino.
*/
target?: never;
}
/** Transform options supported by buble-config-rhino */
// For now, we support everything
export type Transforms = Exclude<Options["transforms"], undefined>;
/**
* Generates an options object for Bublé.
* @param opts Bublé options. This will override options provided by
* `buble-config-rhino`.
* @return Options object that can be passed to `buble.transform()`
*/
export default function createPreset(opts?: Options): BubleOptions {
if (opts) {
if (opts.target !== undefined) {
throw new Error(`opts.targets is unsupported by buble-config-rhino`);
}
}
const { transforms: transformOverrides, ...configOverrides } = opts || {};
return {
transforms: {
// Disable transforms that are already supported by Rhino
arrow: false,
classes: true,
computedProperty: true,
conciseMethodProperty: true,
dangerousForOf: false,
dangerousTaggedTemplateString: true, // Dangerous but useful
defaultParameter: true,
destructuring: true,
exponentiation: true,
forOf: false,
generator: false,
letConst: true,
numericLiteral: false,
objectRestSpread: true,
parameterDestructuring: true,
reservedProperties: false,
spreadRest: true,
templateString: true,
trailingFunctionCommas: true,
unicodeRegExp: true,
...transformOverrides,
},
objectAssign: true,
...configOverrides,
};
}