forked from babel/babel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (31 loc) · 1.09 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
import { declare } from "@babel/helper-plugin-utils";
import presetStage1 from "@babel/preset-stage-1";
import transformFunctionBind from "@babel/plugin-proposal-function-bind";
export default declare((api, opts = {}) => {
api.assertVersion(7);
const { loose = false, useBuiltIns = false, decoratorsLegacy = false } = opts;
if (typeof loose !== "boolean") {
throw new Error("@babel/preset-stage-0 'loose' option must be a boolean.");
}
if (typeof useBuiltIns !== "boolean") {
throw new Error(
"@babel/preset-stage-0 'useBuiltIns' option must be a boolean.",
);
}
if (typeof decoratorsLegacy !== "boolean") {
throw new Error(
"@babel/preset-stage-0 'decoratorsLegacy' option must be a boolean.",
);
}
if (decoratorsLegacy !== true) {
throw new Error(
"The new decorators proposal is not supported yet." +
' You must pass the `"decoratorsLegacy": true` option to' +
" @babel/preset-stage-0",
);
}
return {
presets: [[presetStage1, { loose, useBuiltIns, decoratorsLegacy }]],
plugins: [transformFunctionBind],
};
});