Skip to content

Conversation

@nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Mar 22, 2020

Q                       A
Fixed Issues?
Patch: Bug Fix?
Major: Breaking Change? Yes
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

This PR includes two different commits, conceptually separated, but the second one relies on the first one. The first one could be backported to Babel 7 if needed, but the second one is a breaking change.

  1. Don't require a filename for test/include/exclude _functions_
  2. Better file extension handling for TS/Flow/JSX

The first commit removes the requirement to provide a filename to Babel when a preset specifies a function in test/include/exclude. By doing so, it's possible for presets to provide a fallback behavior in case of a missing file name.
I didn't remove the restriction for strings or regular expressions, since it's not clear what the default fallback should be.

The second commit provides a better UX when using Flow, TypeScript or JSX. The two main changes are that the plugins/presets don't opaquely disable other plugins, and that a filename isn't required anymore. I also changed the options they take regarding file names:

  • When using the TS preset, the filename is not required anymore
  • When both the TS and Flow plugins are enabled on the same file, an error is thrown rather then giving the precedence to TS
  • The TypeScript plugin doesn't disable JSX anymore
  • By default, the Flow preset only enables the plugin when applied to a non-ts file
  • The .isTSX option has been removed from the TS pluginsand preset, since users can directly enable the JSX plugin.
  • The .allExtensions option has been removed from the TS plugin, since it was used to replace the extension test with the removed .isTSX option
  • A new option, .ignoreExtensions, has been added to both the TS and Flow plugins, to make it possible to run them on JS and TS files respectively

@nicolo-ribaudo nicolo-ribaudo added PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release PR: New Feature 🚀 A type of pull request used for our changelog categories area: flow area: typescript labels Mar 22, 2020
@nicolo-ribaudo nicolo-ribaudo added this to the Babel 8.0 milestone Mar 22, 2020
@nicolo-ribaudo nicolo-ribaudo mentioned this pull request Mar 22, 2020
34 tasks
Copy link
Member

@hzoo hzoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 , good to fix issues if they somehow have flow/ts presets both enabled or if no filename

@JLHwung
Copy link
Contributor

JLHwung commented Jun 19, 2020

@nicolo-ribaudo Can you rebase?

This PR introduces multiple changes:
- When using the TS preset, the filename is not required anymore
- When both the TS and Flow plugins are enabled on the same file, an error is thrown rather then giving the precedence to TS
- The TypeScript plugin doesn't disable JSX anymore
- By default, the Flow preset only enables the plugin when applied to a non-ts file
- The .isTSX option has been removed from the TS pluginsand preset, since users can directly enable the JSX plugin.
- The .allExtensions option has been removed from the TS plugin, since it was used to replace the extension test with the removed .isTSX option
- A new option, .ignoreExtensions, has been added to both the TS and Flow plugins, to make it possible to run them on JS and TS files respectively
@nicolo-ribaudo nicolo-ribaudo force-pushed the ts-flow-jsx-better-extension-handling branch from 7330948 to 83a632b Compare June 19, 2020 10:03
@babel-bot
Copy link
Collaborator

babel-bot commented Jun 19, 2020

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/24239/

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 19, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 5f3520d:

Sandbox Source
silly-kirch-emh43 Configuration
small-pond-94w7r Configuration

throw new Error(
"The .allExtensions and .isTSX options have been removed.\n" +
"If you want to disable JSX detection based on the file extension, " +
"If you want to disable file extension-based JSX detection, " +
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English needs parentheses, here the fact that between "file" and "extension" has a higher precedence than - feels... weird 😛

@nicolo-ribaudo nicolo-ribaudo merged commit 11d4913 into babel:next-8-dev Jun 20, 2020
@nicolo-ribaudo nicolo-ribaudo deleted the ts-flow-jsx-better-extension-handling branch June 20, 2020 10:56
nicolo-ribaudo added a commit that referenced this pull request Jun 21, 2020
nicolo-ribaudo added a commit that referenced this pull request Jul 5, 2020
nicolo-ribaudo added a commit that referenced this pull request Aug 28, 2020
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Sep 20, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2020
@JLHwung JLHwung removed this from the v8.0.0 milestone Aug 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: flow area: typescript outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release PR: New Feature 🚀 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants