Fix stage-0/1 import of pipeline/decorators proposals (#8317)

Just default to pipeline "minimal" and true for decorators for ease of use. We are going to remove the stage presets next so it's fine since it will error when using the plugin individually later.
This commit is contained in:
James DiGioia
2018-07-16 13:02:54 -04:00
committed by Henry Zhu
parent 935533cff3
commit 8817fcf03e
2 changed files with 5 additions and 42 deletions

View File

@@ -2,7 +2,6 @@ import { declare } from "@babel/helper-plugin-utils";
import presetStage1 from "@babel/preset-stage-1";
import transformFunctionBind from "@babel/plugin-proposal-function-bind";
import { proposals } from "@babel/plugin-proposal-pipeline-operator";
export default declare((api, opts = {}) => {
api.assertVersion(7);
@@ -10,8 +9,8 @@ export default declare((api, opts = {}) => {
const {
loose = false,
useBuiltIns = false,
decoratorsLegacy = false,
pipelineProposal,
decoratorsLegacy = true,
pipelineProposal = "minimal",
} = opts;
if (typeof loose !== "boolean") {
@@ -28,23 +27,6 @@ export default declare((api, opts = {}) => {
);
}
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",
);
}
if (typeof pipelineProposal !== "string") {
throw new Error(
"The pipeline operator requires a proposal set." +
" You must pass 'pipelineProposal' option to" +
" @babel/preset-stage-0 whose value must be one of: " +
proposals.join(", "),
);
}
return {
presets: [
[

View File

@@ -4,9 +4,7 @@ import presetStage2 from "@babel/preset-stage-2";
import transformExportDefaultFrom from "@babel/plugin-proposal-export-default-from";
import transformLogicalAssignmentOperators from "@babel/plugin-proposal-logical-assignment-operators";
import transformOptionalChaining from "@babel/plugin-proposal-optional-chaining";
import transformPipelineOperator, {
proposals,
} from "@babel/plugin-proposal-pipeline-operator";
import transformPipelineOperator from "@babel/plugin-proposal-pipeline-operator";
import transformNullishCoalescingOperator from "@babel/plugin-proposal-nullish-coalescing-operator";
import transformDoExpressions from "@babel/plugin-proposal-do-expressions";
@@ -16,8 +14,8 @@ export default declare((api, opts = {}) => {
const {
loose = false,
useBuiltIns = false,
decoratorsLegacy = false,
pipelineProposal,
decoratorsLegacy = true,
pipelineProposal = "minimal",
} = opts;
if (typeof loose !== "boolean") {
@@ -34,23 +32,6 @@ export default declare((api, opts = {}) => {
);
}
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-1",
);
}
if (typeof pipelineProposal !== "string") {
throw new Error(
"The pipeline operator requires a proposal set." +
" You must pass 'pipelineProposal' option to" +
" @babel/preset-stage-1 whose value must be one of: " +
proposals.join(", "),
);
}
return {
presets: [[presetStage2, { loose, useBuiltIns, decoratorsLegacy }]],
plugins: [