Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[compiler] Todo for fbt with multiple pronoun/plural #30437

Merged
merged 4 commits into from
Jul 29, 2024

Conversation

mofeiZ
Copy link
Contributor

@mofeiZ mofeiZ commented Jul 23, 2024

Stack from ghstack (oldest at bottom):


(pasted from fixture comment)
The root issue here is that fbt:plural/enum/pronoun read .start and .end from babel nodes to slice into source strings for some complex dedupe logic (see _getStringVariationCombinations)

Since Forget does not add .start and .end for babel nodes it synthesizes, getRawSource simply returns the whole source code string. As a result, all fbt nodes dedupe together and _getStringVariationCombinations ends up early exiting (before adding valid candidate values).

For fbt:plural tags specifically, the count node require that a .start/.end be attached (see code in FbtPluralNode).


For now, let's just bail out :-)

Copy link

vercel bot commented Jul 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 26, 2024 9:45pm

mofeiZ added a commit that referenced this pull request Jul 23, 2024
ghstack-source-id: 2be0fa3784b9a7623118520deef07d669d975665
Pull Request resolved: #30437
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Jul 23, 2024
Comment on lines +2134 to +2138
const fbtLocations = {
enum: new Array<SourceLocation>(),
plural: new Array<SourceLocation>(),
pronoun: new Array<SourceLocation>(),
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These can be tracked separately as fbt does not dedupe across enum/plural/pronouns

@mofeiZ mofeiZ marked this pull request as ready for review July 23, 2024 21:55
---

(pasted from fixture comment)
The root issue here is that fbt:plural/enum/pronoun read `.start` and `.end` from babel nodes to slice into source strings for some complex dedupe logic (see [_getStringVariationCombinations](https://github.com/facebook/fbt/blob/main/packages/babel-plugin-fbt/src/JSFbtBuilder.js#L297))

Since Forget does not add `.start` and `.end` for babel nodes it synthesizes, [getRawSource](https://github.com/facebook/fbt/blob/main/packages/babel-plugin-fbt/src/FbtUtil.js#L666-L673) simply returns the whole source code string. As a result, all fbt nodes dedupe together and _getStringVariationCombinations ends up early exiting (before adding valid candidate values).

For fbt:plural tags specifically, the `count` node require that a `.start/.end` be attached (see [code in FbtPluralNode](https://github.com/facebook/fbt/blob/main/packages/babel-plugin-fbt/src/fbt-nodes/FbtPluralNode.js#L87-L90)).


---
For now, let's just bail out :-)

[ghstack-poisoned]
---

(pasted from fixture comment)
The root issue here is that fbt:plural/enum/pronoun read `.start` and `.end` from babel nodes to slice into source strings for some complex dedupe logic (see [_getStringVariationCombinations](https://github.com/facebook/fbt/blob/main/packages/babel-plugin-fbt/src/JSFbtBuilder.js#L297))

Since Forget does not add `.start` and `.end` for babel nodes it synthesizes, [getRawSource](https://github.com/facebook/fbt/blob/main/packages/babel-plugin-fbt/src/FbtUtil.js#L666-L673) simply returns the whole source code string. As a result, all fbt nodes dedupe together and _getStringVariationCombinations ends up early exiting (before adding valid candidate values).

For fbt:plural tags specifically, the `count` node require that a `.start/.end` be attached (see [code in FbtPluralNode](https://github.com/facebook/fbt/blob/main/packages/babel-plugin-fbt/src/fbt-nodes/FbtPluralNode.js#L87-L90)).


---
For now, let's just bail out :-)

[ghstack-poisoned]
---

(pasted from fixture comment)
The root issue here is that fbt:plural/enum/pronoun read `.start` and `.end` from babel nodes to slice into source strings for some complex dedupe logic (see [_getStringVariationCombinations](https://github.com/facebook/fbt/blob/main/packages/babel-plugin-fbt/src/JSFbtBuilder.js#L297))

Since Forget does not add `.start` and `.end` for babel nodes it synthesizes, [getRawSource](https://github.com/facebook/fbt/blob/main/packages/babel-plugin-fbt/src/FbtUtil.js#L666-L673) simply returns the whole source code string. As a result, all fbt nodes dedupe together and _getStringVariationCombinations ends up early exiting (before adding valid candidate values).

For fbt:plural tags specifically, the `count` node require that a `.start/.end` be attached (see [code in FbtPluralNode](https://github.com/facebook/fbt/blob/main/packages/babel-plugin-fbt/src/fbt-nodes/FbtPluralNode.js#L87-L90)).


---
For now, let's just bail out :-)

[ghstack-poisoned]
@mofeiZ mofeiZ merged commit 4e69352 into gh/mofeiZ/15/base Jul 29, 2024
19 checks passed
mofeiZ added a commit that referenced this pull request Jul 29, 2024
ghstack-source-id: 77b6980c2b080771d18aa275c3b3258884bd463c
Pull Request resolved: #30437
@mofeiZ mofeiZ deleted the gh/mofeiZ/15/head branch July 29, 2024 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants