Skip to content

[Babel 8]: Remove record and tuple syntax support - #17242

Merged
JLHwung merged 6 commits into
babel:mainfrom
JLHwung:remove-record-and-tuple-syntax-support
Apr 17, 2025
Merged

JLHwung merged 6 commits into
babel:mainfrom
JLHwung:remove-record-and-tuple-syntax-support

Conversation

@JLHwung

@JLHwung JLHwung commented Apr 15, 2025 •

Copy link
Copy Markdown
Contributor
Q 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 A
Fixed Issues? Fixes #17241
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link babel/website#3080
Any Dependency Changes?
License MIT

In this PR we remove the record&tuple (R&T) syntax support since the ES proposal has been withdrawn on Apr 14, 2025. We removed most Babel 8 only R&T tests: Babel 7 will still support R&T. but we urge users to migrate to the composites proposal.

@JLHwung JLHwung added PR: Breaking Change 馃挜 A type of pull request used for our changelog categories for next major release PR: Needs Docs labels Apr 15, 2025
@babel-bot

babel-bot commented Apr 15, 2025 •

Copy link
Copy Markdown
Collaborator

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

@JLHwung

JLHwung commented Apr 16, 2025

Copy link
Copy Markdown
Contributor Author

Currently pending prettier removal of the recordAndTuple plugin usage

/cc @fisker Thank you.

@nicolo-ribaudo

Copy link
Copy Markdown
Member

Fyi, quoting @acutmore (champion of composites, co-champion of R&T):

"we urge users to migrate to the composites proposal."

There is nothing to migrate to just yet
Users could keep using the bloomberg/report-tuple-polyfill and replace the syntax with direct factory calls
(assuming they are not in a position to do a larger migration)

I think in the migration guide we should direct people to that polyfill, that they are already using anyway because Babel's transpiled code relies on it.

@JLHwung

JLHwung commented Apr 16, 2025

Copy link
Copy Markdown
Contributor Author

Fyi, quoting @acutmore (champion of composites, co-champion of R&T):

"we urge users to migrate to the composites proposal."

There is nothing to migrate to just yet
Users could keep using the bloomberg/report-tuple-polyfill and replace the syntax with direct factory calls
(assuming they are not in a position to do a larger migration)

I think in the migration guide we should direct people to that polyfill, that they are already using anyway because Babel's transpiled code relies on it.

Thank you, I drafted a migration guide on babel/website#3080, PTAL.

@fisker

fisker commented Apr 16, 2025

Copy link
Copy Markdown
Contributor

Prettier PR merged.

export const tt = {
// Punctuation token types.
bracketL: createToken("[", { beforeExpr, startsExpr }),
// TODO: Remove this in Babel 8

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These are all not user-exposed, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately it is exposed via the tokens parser option. And Babel eslint parser depends on token labels so that it can transform Babel tokens to espree tokens. Although espree does not support R&T, we do have to convert it to a punctuator token type.

@@ -1,3 +1,7 @@
import runner from "@babel/helper-plugin-test-runner";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we just remove and deprecate this plugin? I can add it to the babel/babel-archive repo.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it'd better to be removed after we published Babel 8. This plugin can function as a codemod to help people migrate to the factory calls, in babel/website#3080 I provided an example Babel config for such purpose. For this reason, we have to keep it in the monorepo otherwise it might be broken unexpectedly by any internal changes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@JLHwung Sorry I don't fully understand what you mean, can't we just remove this plugin and keep the parser tests? This plugin doesn't seem to use private APIs or have relevant code in traverse.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Most archived libraries are either trivial syntax plugins or helpers deemed no longer used by us. Like I said although this plugin can be archived now, it can be repurposed to a codemod that potentially helps people migrate from the novel syntax to the Record/Tuple factory calls, we should guarantee that this plugin works for every @babel/* 7 versions, as long as the parser supported R&T.

This plugin depends on @babel/helper-module-imports and @babel/helper-validator-option. It is not a very trivial plugin like those archived syntax plugins. Staying in the monorepo gives us the assurance that it won't break when users are migrating from Babel 7 to Babel 8.

@JLHwung
JLHwung merged commit 9a40d85 into babel:main Apr 17, 2025
@JLHwung
JLHwung deleted the remove-record-and-tuple-syntax-support branch April 17, 2025 17:54
@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 Jul 18, 2025
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 18, 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 PR: Breaking Change 馃挜 A type of pull request used for our changelog categories for next major release Spec: Record Tuple

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove record-and-tuple syntax support in Babel 8

5 participants