Add "decoratorsLegacy" to presets
This commit is contained in:
parent
96316dcf88
commit
2679d6775c
@ -47,3 +47,9 @@ Enable "loose" transformations for any plugins in this preset that allow them.
|
|||||||
`boolean`, defaults to `false`.
|
`boolean`, defaults to `false`.
|
||||||
|
|
||||||
Will use the native built-in instead of trying to polyfill behavior for any plugins that require one.
|
Will use the native built-in instead of trying to polyfill behavior for any plugins that require one.
|
||||||
|
|
||||||
|
### `decoratorsLegacy`
|
||||||
|
|
||||||
|
`boolean`, defaults to `false`.
|
||||||
|
|
||||||
|
Use the legacy (stage 1) decorators syntax and behavior.
|
||||||
|
|||||||
@ -3,16 +3,10 @@ import presetStage1 from "@babel/preset-stage-1";
|
|||||||
|
|
||||||
import transformFunctionBind from "@babel/plugin-proposal-function-bind";
|
import transformFunctionBind from "@babel/plugin-proposal-function-bind";
|
||||||
|
|
||||||
export default declare((api, opts) => {
|
export default declare((api, opts = {}) => {
|
||||||
api.assertVersion(7);
|
api.assertVersion(7);
|
||||||
|
|
||||||
let loose = false;
|
const { loose = false, useBuiltIns = false, decoratorsLegacy = false } = opts;
|
||||||
let useBuiltIns = false;
|
|
||||||
|
|
||||||
if (opts !== undefined) {
|
|
||||||
if (opts.loose !== undefined) loose = opts.loose;
|
|
||||||
if (opts.useBuiltIns !== undefined) useBuiltIns = opts.useBuiltIns;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof loose !== "boolean") {
|
if (typeof loose !== "boolean") {
|
||||||
throw new Error("@babel/preset-stage-0 'loose' option must be a boolean.");
|
throw new Error("@babel/preset-stage-0 'loose' option must be a boolean.");
|
||||||
@ -22,9 +16,22 @@ export default declare((api, opts) => {
|
|||||||
"@babel/preset-stage-0 'useBuiltIns' option must be a boolean.",
|
"@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 muse pass the `"decoratorsLegacy": true` option to' +
|
||||||
|
" @babel/preset-stage-0",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
presets: [[presetStage1, { loose, useBuiltIns }]],
|
presets: [[presetStage1, { loose, useBuiltIns, decoratorsLegacy }]],
|
||||||
plugins: [transformFunctionBind],
|
plugins: [transformFunctionBind],
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@ -58,6 +58,12 @@ Enable "loose" transformations for any plugins in this preset that allow them.
|
|||||||
|
|
||||||
Will use the native built-in instead of trying to polyfill behavior for any plugins that require one.
|
Will use the native built-in instead of trying to polyfill behavior for any plugins that require one.
|
||||||
|
|
||||||
|
### `decoratorsLegacy`
|
||||||
|
|
||||||
|
`boolean`, defaults to `false`.
|
||||||
|
|
||||||
|
Use the legacy (stage 1) decorators syntax and behavior.
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
- Chapter "[The TC39 process for ECMAScript features](http://exploringjs.com/es2016-es2017/ch_tc39-process.html)" in "Exploring ES2016 and ES2017" by Axel Rauschmayer
|
- Chapter "[The TC39 process for ECMAScript features](http://exploringjs.com/es2016-es2017/ch_tc39-process.html)" in "Exploring ES2016 and ES2017" by Axel Rauschmayer
|
||||||
|
|||||||
@ -9,7 +9,6 @@
|
|||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/helper-plugin-utils": "7.0.0-beta.44",
|
"@babel/helper-plugin-utils": "7.0.0-beta.44",
|
||||||
"@babel/plugin-proposal-decorators": "7.0.0-beta.44",
|
|
||||||
"@babel/plugin-proposal-do-expressions": "7.0.0-beta.44",
|
"@babel/plugin-proposal-do-expressions": "7.0.0-beta.44",
|
||||||
"@babel/plugin-proposal-export-default-from": "7.0.0-beta.44",
|
"@babel/plugin-proposal-export-default-from": "7.0.0-beta.44",
|
||||||
"@babel/plugin-proposal-logical-assignment-operators": "7.0.0-beta.44",
|
"@babel/plugin-proposal-logical-assignment-operators": "7.0.0-beta.44",
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import { declare } from "@babel/helper-plugin-utils";
|
import { declare } from "@babel/helper-plugin-utils";
|
||||||
import presetStage2 from "@babel/preset-stage-2";
|
import presetStage2 from "@babel/preset-stage-2";
|
||||||
|
|
||||||
import transformDecorators from "@babel/plugin-proposal-decorators";
|
|
||||||
import transformExportDefaultFrom from "@babel/plugin-proposal-export-default-from";
|
import transformExportDefaultFrom from "@babel/plugin-proposal-export-default-from";
|
||||||
import transformLogicalAssignmentOperators from "@babel/plugin-proposal-logical-assignment-operators";
|
import transformLogicalAssignmentOperators from "@babel/plugin-proposal-logical-assignment-operators";
|
||||||
import transformOptionalChaining from "@babel/plugin-proposal-optional-chaining";
|
import transformOptionalChaining from "@babel/plugin-proposal-optional-chaining";
|
||||||
@ -9,16 +8,10 @@ import transformPipelineOperator from "@babel/plugin-proposal-pipeline-operator"
|
|||||||
import transformNullishCoalescingOperator from "@babel/plugin-proposal-nullish-coalescing-operator";
|
import transformNullishCoalescingOperator from "@babel/plugin-proposal-nullish-coalescing-operator";
|
||||||
import transformDoExpressions from "@babel/plugin-proposal-do-expressions";
|
import transformDoExpressions from "@babel/plugin-proposal-do-expressions";
|
||||||
|
|
||||||
export default declare((api, opts) => {
|
export default declare((api, opts = {}) => {
|
||||||
api.assertVersion(7);
|
api.assertVersion(7);
|
||||||
|
|
||||||
let loose = false;
|
const { loose = false, useBuiltIns = false, decoratorsLegacy = false } = opts;
|
||||||
let useBuiltIns = false;
|
|
||||||
|
|
||||||
if (opts !== undefined) {
|
|
||||||
if (opts.loose !== undefined) loose = opts.loose;
|
|
||||||
if (opts.useBuiltIns !== undefined) useBuiltIns = opts.useBuiltIns;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof loose !== "boolean") {
|
if (typeof loose !== "boolean") {
|
||||||
throw new Error("@babel/preset-stage-1 'loose' option must be a boolean.");
|
throw new Error("@babel/preset-stage-1 'loose' option must be a boolean.");
|
||||||
@ -28,11 +21,23 @@ export default declare((api, opts) => {
|
|||||||
"@babel/preset-stage-1 'useBuiltIns' option must be a boolean.",
|
"@babel/preset-stage-1 'useBuiltIns' option must be a boolean.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (typeof decoratorsLegacy !== "boolean") {
|
||||||
|
throw new Error(
|
||||||
|
"@babel/preset-stage-1 'decoratorsLegacy' option must be a boolean.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (decoratorsLegacy !== true) {
|
||||||
|
throw new Error(
|
||||||
|
"The new decorators proposal is not supported yet." +
|
||||||
|
' You muse pass the `"decoratorsLegacy": true` option to' +
|
||||||
|
" @babel/preset-stage-1",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
presets: [[presetStage2, { loose, useBuiltIns }]],
|
presets: [[presetStage2, { loose, useBuiltIns, decoratorsLegacy }]],
|
||||||
plugins: [
|
plugins: [
|
||||||
[transformDecorators, { legacy: true }],
|
|
||||||
transformExportDefaultFrom,
|
transformExportDefaultFrom,
|
||||||
transformLogicalAssignmentOperators,
|
transformLogicalAssignmentOperators,
|
||||||
[transformOptionalChaining, { loose }],
|
[transformOptionalChaining, { loose }],
|
||||||
|
|||||||
@ -58,6 +58,12 @@ Enable "loose" transformations for any plugins in this preset that allow them.
|
|||||||
|
|
||||||
Will use the native built-in instead of trying to polyfill behavior for any plugins that require one.
|
Will use the native built-in instead of trying to polyfill behavior for any plugins that require one.
|
||||||
|
|
||||||
|
### `decoratorsLegacy`
|
||||||
|
|
||||||
|
`boolean`, defaults to `false`.
|
||||||
|
|
||||||
|
Use the legacy (stage 1) decorators syntax and behavior.
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
- Chapter "[The TC39 process for ECMAScript features](http://exploringjs.com/es2016-es2017/ch_tc39-process.html)" in "Exploring ES2016 and ES2017" by Axel Rauschmayer
|
- Chapter "[The TC39 process for ECMAScript features](http://exploringjs.com/es2016-es2017/ch_tc39-process.html)" in "Exploring ES2016 and ES2017" by Axel Rauschmayer
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/helper-plugin-utils": "7.0.0-beta.44",
|
"@babel/helper-plugin-utils": "7.0.0-beta.44",
|
||||||
|
"@babel/plugin-proposal-decorators": "7.0.0-beta.44",
|
||||||
"@babel/plugin-proposal-export-namespace-from": "7.0.0-beta.44",
|
"@babel/plugin-proposal-export-namespace-from": "7.0.0-beta.44",
|
||||||
"@babel/plugin-proposal-function-sent": "7.0.0-beta.44",
|
"@babel/plugin-proposal-function-sent": "7.0.0-beta.44",
|
||||||
"@babel/plugin-proposal-numeric-separator": "7.0.0-beta.44",
|
"@babel/plugin-proposal-numeric-separator": "7.0.0-beta.44",
|
||||||
|
|||||||
@ -1,21 +1,16 @@
|
|||||||
import { declare } from "@babel/helper-plugin-utils";
|
import { declare } from "@babel/helper-plugin-utils";
|
||||||
import presetStage3 from "@babel/preset-stage-3";
|
import presetStage3 from "@babel/preset-stage-3";
|
||||||
|
|
||||||
|
import transformDecorators from "@babel/plugin-proposal-decorators";
|
||||||
import transformFunctionSent from "@babel/plugin-proposal-function-sent";
|
import transformFunctionSent from "@babel/plugin-proposal-function-sent";
|
||||||
import transformExportNamespaceFrom from "@babel/plugin-proposal-export-namespace-from";
|
import transformExportNamespaceFrom from "@babel/plugin-proposal-export-namespace-from";
|
||||||
import transformNumericSeparator from "@babel/plugin-proposal-numeric-separator";
|
import transformNumericSeparator from "@babel/plugin-proposal-numeric-separator";
|
||||||
import transformThrowExpressions from "@babel/plugin-proposal-throw-expressions";
|
import transformThrowExpressions from "@babel/plugin-proposal-throw-expressions";
|
||||||
|
|
||||||
export default declare((api, opts) => {
|
export default declare((api, opts = {}) => {
|
||||||
api.assertVersion(7);
|
api.assertVersion(7);
|
||||||
|
|
||||||
let loose = false;
|
const { loose = false, useBuiltIns = false, decoratorsLegacy = false } = opts;
|
||||||
let useBuiltIns = false;
|
|
||||||
|
|
||||||
if (opts !== undefined) {
|
|
||||||
if (opts.loose !== undefined) loose = opts.loose;
|
|
||||||
if (opts.useBuiltIns !== undefined) useBuiltIns = opts.useBuiltIns;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof loose !== "boolean") {
|
if (typeof loose !== "boolean") {
|
||||||
throw new Error("@babel/preset-stage-2 'loose' option must be a boolean.");
|
throw new Error("@babel/preset-stage-2 'loose' option must be a boolean.");
|
||||||
@ -25,10 +20,24 @@ export default declare((api, opts) => {
|
|||||||
"@babel/preset-stage-2 'useBuiltIns' option must be a boolean.",
|
"@babel/preset-stage-2 'useBuiltIns' option must be a boolean.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (typeof decoratorsLegacy !== "boolean") {
|
||||||
|
throw new Error(
|
||||||
|
"@babel/preset-stage-2 'decoratorsLegacy' option must be a boolean.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (decoratorsLegacy !== true) {
|
||||||
|
throw new Error(
|
||||||
|
"The new decorators proposal is not supported yet." +
|
||||||
|
' You muse pass the `"decoratorsLegacy": true` option to' +
|
||||||
|
" @babel/preset-stage-2",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
presets: [[presetStage3, { loose, useBuiltIns }]],
|
presets: [[presetStage3, { loose, useBuiltIns }]],
|
||||||
plugins: [
|
plugins: [
|
||||||
|
[transformDecorators, { legacy: decoratorsLegacy }],
|
||||||
transformFunctionSent,
|
transformFunctionSent,
|
||||||
transformExportNamespaceFrom,
|
transformExportNamespaceFrom,
|
||||||
transformNumericSeparator,
|
transformNumericSeparator,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user