Skip to content

Commit

Permalink
polish: recommend preset for js extensions (#11421)
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Apr 16, 2020
1 parent d9eb943 commit 1c09701
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/babel-core/src/parser/util/missing-plugin-helper.js
Expand Up @@ -83,8 +83,8 @@ const pluginNameMap = {
url: "https://git.io/vb4yb",
},
transform: {
name: "@babel/plugin-transform-flow-strip-types",
url: "https://git.io/vb49g",
name: "@babel/preset-flow",
url: "https://git.io/JfeDn",
},
},
functionBind: {
Expand Down Expand Up @@ -119,8 +119,8 @@ const pluginNameMap = {
url: "https://git.io/vb4yA",
},
transform: {
name: "@babel/plugin-transform-react-jsx",
url: "https://git.io/vb4yd",
name: "@babel/preset-react",
url: "https://git.io/JfeDR",
},
},
logicalAssignment: {
Expand Down Expand Up @@ -185,8 +185,8 @@ const pluginNameMap = {
url: "https://git.io/vb4SC",
},
transform: {
name: "@babel/plugin-transform-typescript",
url: "https://git.io/vb4Sm",
name: "@babel/preset-typescript",
url: "https://git.io/JfeDz",
},
},

Expand Down Expand Up @@ -260,13 +260,15 @@ export default function generateMissingPluginMessage(
if (pluginInfo) {
const { syntax: syntaxPlugin, transform: transformPlugin } = pluginInfo;
if (syntaxPlugin) {
const syntaxPluginInfo = getNameURLCombination(syntaxPlugin);
if (transformPlugin) {
const transformPluginInfo = getNameURLCombination(transformPlugin);
helpMessage +=
`\n\nAdd ${transformPluginInfo} to the 'plugins' section of your Babel config ` +
`to enable transformation.`;
const sectionType = transformPlugin.name.startsWith("@babel/plugin")
? "plugins"
: "presets";
helpMessage += `\n\nAdd ${transformPluginInfo} to the '${sectionType}' section of your Babel config to enable transformation.
If you want to leave it as-is, add ${syntaxPluginInfo} to the 'plugins' section to enable parsing.`;
} else {
const syntaxPluginInfo = getNameURLCombination(syntaxPlugin);
helpMessage +=
`\n\nAdd ${syntaxPluginInfo} to the 'plugins' section of your Babel config ` +
`to enable parsing.`;
Expand Down

0 comments on commit 1c09701

Please sign in to comment.