Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Expose FbtCommonConstants as a babel-plugin-fbt option
Summary: Enable providing common strings in babel-plugin-fbt as an option Reviewed By: fantazic Differential Revision: D18672440 fbshipit-source-id: 160a489d5207ed8e907fb50c61dfe47499caaf23
- Loading branch information
1 parent
0f68f7f
commit 26c5cd8
Showing
10 changed files
with
74 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Copyright 2004-present Facebook. All Rights Reserved. | ||
* | ||
* @flow | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/*:: | ||
type FbtCommonMap = { | ||
[text: string]: string | ||
} | ||
*/ | ||
|
||
const textToDesc /*: FbtCommonMap*/ = {}; | ||
|
||
const FbtCommon = { | ||
init( | ||
opts /*: {fbtCommon?: FbtCommonMap, fbtCommonPath?: string} */ = {}, | ||
) /*: void */ { | ||
if (opts.fbtCommon) { | ||
Object.assign(textToDesc, opts.fbtCommon); | ||
} | ||
if (opts.fbtCommonPath != null) { | ||
// $FlowFixMe - dynamic require | ||
Object.assign(textToDesc, require(opts.fbtCommonPath)); | ||
} | ||
}, | ||
|
||
getDesc(text /*: string */) /*: ?string */ { | ||
return textToDesc[text]; | ||
} | ||
}; | ||
|
||
module.exports = FbtCommon; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/babel-plugin-fbt/bin/__tests__/FbtCommonForTests.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"Required": "Indicates an editor field is required." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.