This repository has been archived by the owner on Nov 18, 2024. It is now read-only.
Need to share some common JS code between clientside fbt.js and Babel transform node modules #158
Labels
enhancement
New feature or request
🚀 Feature Proposal
Currently, we have some JS constants that are defined twice on the clientside and Babel transform modules.
E.g. The Gender constant object that defines all the supported types of genders is defined in two places that need to be kept up to date manually.
fbt/runtime/nonfb/GenderConst.js
Lines 16 to 32 in a61a13b
fbt/packages/babel-plugin-fbt/Gender.js
Lines 12 to 29 in a61a13b
Motivation
Going forward, it'd make sense to avoid having to write duplicate JS constants.
Some JS functions might even be shared in the future.
How to do it?
We should figure out a way to share some common constants between the node.js and client-side modules.
Maybe by having the
fbt
npm module become a peerDependency ofbabel-plugin-fbt
?Or by defining the shared JS code into a special folder that'd be accessible to both
babel-plugin-fbt
andfbt
in Flow checks, and also bundled in these respective npm modules using some Gulp magic?The text was updated successfully, but these errors were encountered: