Improve error messages around pipeline option (#8279)
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
import { declare } from "@babel/helper-plugin-utils";
|
||||
|
||||
const proposals = ["minimal"];
|
||||
export const proposals = ["minimal"];
|
||||
|
||||
export default declare((api, { proposal }) => {
|
||||
api.assertVersion(7);
|
||||
|
||||
if (typeof proposal !== "string" || !proposals.includes(proposal)) {
|
||||
throw new Error("'proposal' must be one of: " + proposals.join(", "));
|
||||
throw new Error(
|
||||
"The pipeline operator plugin requires a 'proposal' option." +
|
||||
"'proposal' must be one of: " +
|
||||
proposals.join(", ") +
|
||||
". More details: https://babeljs.io/docs/en/next/babel-plugin-proposal-pipeline-operator",
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -2,6 +2,7 @@ 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);
|
||||
@@ -38,8 +39,9 @@ export default declare((api, opts = {}) => {
|
||||
if (typeof pipelineProposal !== "string") {
|
||||
throw new Error(
|
||||
"The pipeline operator requires a proposal set." +
|
||||
" You must pass the 'pipelineProposal' option to" +
|
||||
" @babel/preset-stage-0",
|
||||
" You must pass 'pipelineProposal' option to" +
|
||||
" @babel/preset-stage-0 whose value must be one of: " +
|
||||
proposals.join(", "),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@ 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 from "@babel/plugin-proposal-pipeline-operator";
|
||||
import transformPipelineOperator, {
|
||||
proposals,
|
||||
} from "@babel/plugin-proposal-pipeline-operator";
|
||||
import transformNullishCoalescingOperator from "@babel/plugin-proposal-nullish-coalescing-operator";
|
||||
import transformDoExpressions from "@babel/plugin-proposal-do-expressions";
|
||||
|
||||
@@ -44,7 +46,8 @@ export default declare((api, opts = {}) => {
|
||||
throw new Error(
|
||||
"The pipeline operator requires a proposal set." +
|
||||
" You must pass 'pipelineProposal' option to" +
|
||||
" @babel/preset-stage-1",
|
||||
" @babel/preset-stage-1 whose value must be one of: " +
|
||||
proposals.join(", "),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user