Skip to content

feat(@formatjs/ts-transformer): flatten before id generation, fix #3537#5790

Closed
longlho wants to merge 1 commit intomainfrom
01-01-fix_formatjs_ts-transformer_flatten_before_id_generation_fix_3537
Closed

feat(@formatjs/ts-transformer): flatten before id generation, fix #3537#5790
longlho wants to merge 1 commit intomainfrom
01-01-fix_formatjs_ts-transformer_flatten_before_id_generation_fix_3537

Conversation

@longlho
Copy link
Member

@longlho longlho commented Jan 2, 2026

TL;DR

Fix issue #3537 by applying message flattening before ID generation in babel-plugin-formatjs.

What changed?

  • Added flatten option to babel-plugin-formatjs types
  • Modified evaluateMessageDescriptor to apply flattening before calling overrideIdFn
  • Passed the flatten option through the visitor functions
  • Updated the CLI to leverage the flattening done in the babel plugin instead of applying it afterward
  • Added tests to verify that flattened messages are correctly passed to overrideIdFn

How to test?

  1. Run the new test case: GH #3537: flatten with overrideIdFn
  2. Verify that when using both flatten and overrideIdFn options, the ID is generated based on the flattened message
  3. Check the CLI integration test for flattening with ID interpolation pattern

Why make this change?

Fixes issue #3537 where message IDs were being generated based on the original message format rather than the flattened version. This caused inconsistencies when using content-based IDs with flattened messages, as the ID was based on the pre-flattened content while the output contained the flattened message. By applying flattening before ID generation, we ensure that the ID is based on the same content that will be in the final output.

@longlho longlho marked this pull request as ready for review January 2, 2026 04:26
Copy link
Member Author

longlho commented Jan 2, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • main - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has required the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@longlho longlho changed the title fix(@formatjs/ts-transformer): flatten before id generation, fix #3537 feat(@formatjs/ts-transformer): flatten before id generation, fix #3537 Jan 2, 2026
@longlho longlho force-pushed the 01-01-fix_formatjs_ts-transformer_flatten_before_id_generation_fix_3537 branch from 458f3c5 to 24671a1 Compare January 2, 2026 04:31
@graphite-app
Copy link

graphite-app bot commented Jan 2, 2026

Merge activity

  • Jan 2, 4:33 AM UTC: longlho added this pull request to the Graphite merge queue.
  • Jan 2, 4:33 AM UTC: CI is running for this pull request on a draft pull request (#5791) due to your merge queue CI optimization settings.
  • Jan 2, 4:36 AM UTC: Merged by the Graphite merge queue via draft PR: #5791.

graphite-app bot pushed a commit that referenced this pull request Jan 2, 2026
… (#5790)

### TL;DR

Fix issue #3537 by applying message flattening before ID generation in babel-plugin-formatjs.

### What changed?

- Added `flatten` option to babel-plugin-formatjs types
- Modified `evaluateMessageDescriptor` to apply flattening before calling `overrideIdFn`
- Passed the flatten option through the visitor functions
- Updated the CLI to leverage the flattening done in the babel plugin instead of applying it afterward
- Added tests to verify that flattened messages are correctly passed to `overrideIdFn`

### How to test?

1. Run the new test case: `GH #3537: flatten with overrideIdFn`
2. Verify that when using both `flatten` and `overrideIdFn` options, the ID is generated based on the flattened message
3. Check the CLI integration test for flattening with ID interpolation pattern

### Why make this change?

Fixes issue #3537 where message IDs were being generated based on the original message format rather than the flattened version. This caused inconsistencies when using content-based IDs with flattened messages, as the ID was based on the pre-flattened content while the output contained the flattened message. By applying flattening before ID generation, we ensure that the ID is based on the same content that will be in the final output.
@graphite-app graphite-app bot closed this Jan 2, 2026
@graphite-app graphite-app bot deleted the 01-01-fix_formatjs_ts-transformer_flatten_before_id_generation_fix_3537 branch January 2, 2026 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant