question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Disallow plugin/preset shorthand names from babel@7 onwards

See original GitHub issue

Feature Request

Currently you can drop the babel-preset and babel-plugin prefixes. https://babeljs.io/docs/plugins/#pluginpreset-shorthand

"presets": ["@org/babel-preset-name"]

shorthand

"presets": ["@org/name"]

I propose for babel@7 we prevent this and only allow full names to be used.

Why?

  • It makes it more difficult when refactoring because you have to search for two names instead of one.

    • This makes removing all instances of a plugin in a monorepo harder than it should be.

    • There is the potential for clashes such as @babel/foo and @babel/babel-preset-foo.

    • Say you develop your own plugin, and want to rename it, and its used in every package in a monorepo. This because very difficult when you cannot rely on every usage being named the same.

  • It adds complexity to parsing babel plugin/preset names. Other tooling has to parse these names such as ava, and they need to implement this complicated logic.

  • The way it works with package @scopes makes it awkward, because its no longer dropping a prefix, its dropping from the middle.

Teachability, Documentation, Adoption, Migration Strategy

babel@7 would be a great time to do this because everyone is already renaming everything to be @babel prefixed anyway.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
loganfsmythcommented, May 6, 2018

Say I have a tool to check if a package specified in my package.json is used in my codebase. Babel will always be a special case, and makes a simple checker quite complicated.

I think no matter what that will require linting guidelines. If we changed to requiring the prefix, users could just as easily turn around and do

presets: [
  'env',
  'react',
  'flow'
].map(n => `@babel/preset-${n}`)

and you’d have the same issue, and it’s now more painful for users.

Ignoring that usecase and the edge cases though, I do understand where you’re coming from. I just think you’ll encounter this issue with any package that implements a plugin system. ESLint for example also does not reference the prefix in their config.

0reactions
hzoocommented, May 14, 2018

seeing as the usage is already very widespread and people are starting to adopt babel@7 already in a big way.

Yeah I think we don’t get much but we can definetely try to lint either in a tool like https://github.com/sonarwhal/sonarwhal or if we introduce our own type of thing

Read more comments on GitHub >

github_iconTop Results From Across the Web

Presets - Babel.js
Babel presets can act as sharable set of Babel plugins and/or config options . Official Presets. We've assembled a few presets for common...
Read more >
Options - Babel.js
Note: The format of presets is identical to plugins, except for the fact that name normalization expects "preset-" instead of "plugin-", and presets...
Read more >
babel/plugin-transform-shorthand-properties
NOTE: This plugin is included in @babel/preset-env ... npm install --save-dev @babel/plugin-transform-shorthand-properties.
Read more >
Upgrade to Babel 7
You can still use the shorthand version of a package name (remove the preset- or plugin- ) in the config, but I'm choosing...
Read more >
babel/plugin-transform-parameters
Default parameters desugar into let declarations to retain proper semantics. If this is not supported in your environment then you'll need the @babel/plugin- ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found