Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polish: recommend preset for js extensions #11421

Merged
merged 1 commit into from Apr 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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