Skip to content

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Jan 9, 2025

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

Node.js 23.6 has native support for .ts/.mts/.cts files. However, they don't work in Babel because we wrongly try to parse them as JSON.

With this PR:

  • When running in Node.js 23.6 or higher, we rely on the native Node.js support for TypeScript
  • When running in older versions, if there is already ts-node or another ts hook installed we rely on it
  • When running in older versions with no TS hook installed, we only support transpiling .cts files

I'd consider this PR to be a bugfix, since it only changes the behavior in Node.js 23.6 to not respect what Node.js already supports by itself. It's a new Node.js feature, and not a new Babel feature.

Ref #17051

@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: core labels Jan 9, 2025
@babel-bot
Copy link
Collaborator

babel-bot commented Jan 9, 2025

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

if (ext !== ".cts") {
throw new ConfigError(
`\
You are using a ${ext} config file, but Babel only supports transpiling .cts configs. Either:
Copy link
Member Author

Choose a reason for hiding this comment

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

This error is "new", but before we would try to parse the files as JSON and thus just give a worse error.

@nicolo-ribaudo
Copy link
Member Author

Note that this PR does not add automatic support for automatically finding .ts config files. We can consider doing that in a minor.

@nicolo-ribaudo nicolo-ribaudo merged commit d9fa47d into babel:main Jan 17, 2025
55 checks passed
@nicolo-ribaudo nicolo-ribaudo deleted the ts-config-file branch January 17, 2025 15:35
Tobbe added a commit to Tobbe/redwood that referenced this pull request Mar 14, 2025
Tobbe added a commit to redwoodjs/graphql that referenced this pull request Mar 15, 2025
Tobbe added a commit to redwoodjs/graphql that referenced this pull request Mar 25, 2025
@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 Apr 19, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: core PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants