Better file extension handling for TypeScript and Flow presets#11316
Merged
nicolo-ribaudo merged 4 commits intobabel:next-8-devfrom Jun 20, 2020
Merged
Conversation
hzoo
approved these changes
Apr 20, 2020
Member
hzoo
left a comment
There was a problem hiding this comment.
👍 , good to fix issues if they somehow have flow/ts presets both enabled or if no filename
1 task
JLHwung
approved these changes
Jun 19, 2020
Contributor
|
@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
7330948 to
83a632b
Compare
Collaborator
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/24239/ |
|
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:
|
existentialism
approved these changes
Jun 19, 2020
Co-authored-by: Brian Ng <[email protected]>
nicolo-ribaudo
commented
Jun 20, 2020
| 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, " + |
Member
Author
There was a problem hiding this comment.
English needs parentheses, here the fact that between "file" and "extension" has a higher precedence than - feels... weird 😛
nicolo-ribaudo
added a commit
that referenced
this pull request
Jun 21, 2020
Co-authored-by: Brian Ng <[email protected]> Co-authored-by: Huáng Jùnliàng <[email protected]>
nicolo-ribaudo
added a commit
that referenced
this pull request
Jul 5, 2020
Co-authored-by: Brian Ng <[email protected]> Co-authored-by: Huáng Jùnliàng <[email protected]>
nicolo-ribaudo
added a commit
that referenced
this pull request
Aug 28, 2020
Co-authored-by: Brian Ng <[email protected]> Co-authored-by: Huáng Jùnliàng <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
Don't require a filename for test/include/exclude _functions_Better file extension handling for TS/Flow/JSXThe 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: