Skip to content

Commit

Permalink
refactor(babel-plugin-fbt)!: Use default collection script as a peer …
Browse files Browse the repository at this point in the history
…dependency

Reviewed By: mingshi-yang

Differential Revision: D26955843

fbshipit-source-id: 1333445f2871e15fbe431098ac2d2d1aacbd6c81
  • Loading branch information
John Watson authored and facebook-github-bot committed Mar 17, 2021
1 parent 00df1c3 commit 1ce9a76
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 23 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ List of changes for each released npm package version.
</summary>
</details>

- 0.16.4:
- [chore] Update babel-plugin-fbt dependency version to `^0.19.x`

- 0.16.3:
- [chore] Update babel-plugin-fbt dependency version to `^0.18.x`

Expand Down Expand Up @@ -128,6 +131,9 @@ List of changes for each released npm package version.

</details>

- 0.19.0:
- [refactor]! Move to @fbtjs/default-collection-transform and avoid fb-babel-plugin-utils/SyntaxPlugins

- 0.18.0:
- [fix] Ignore __private JSX attributes when parsing
- [feat] Add ability to collect strings from a custom `FbtCollector` module for collection script
Expand Down Expand Up @@ -230,6 +236,9 @@ List of changes for each released npm package version.

### babel-plugin-fbt-runtime versions

- 0.9.16:
- [chore] Updated peer dependency on babel-plugin-fbt

- 0.9.15:
- [chore] Updated peer dependency on babel-plugin-fbt

Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-fbt-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"fbjs": "^1.0.0"
},
"peerDependencies": {
"babel-plugin-fbt": "^0.18.x"
"babel-plugin-fbt": "^0.19.x"
},
"repository": {
"type": "git",
Expand Down
5 changes: 4 additions & 1 deletion packages/babel-plugin-fbt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "babel-plugin-fbt",
"description": "The FBT Babel localization transform",
"//version": "Follow SemVer specs at https://semver.org/",
"version": "0.18.0",
"version": "0.19.0",
"bin": {
"fbt-collect": "dist/bin/collectFbt.bin.js",
"fbt-manifest": "dist/bin/manifest.bin.js",
Expand Down Expand Up @@ -41,5 +41,8 @@
"scripts": {
"prepack": "gulp --series clean build",
"publish_to_npm_latest": "yarn publish . && git push --tags && git push"
},
"peerDependencies": {
"@fbtjs/default-collection-transform": "^0.0.x"

This comment has been minimized.

Copy link
@mrtnzlml

mrtnzlml Mar 18, 2021

Contributor

@jrwats Should installation instructions for FBT be updated to not only install fbt, babel-plugin-fbt and babel-plugin-fbt-runtime but also @fbtjs/default-collection-transform? FBT doesn't work without it after this change out of the box.

Or is the idea to push more towards the new --transform option of a collector? In which case the installation info should probably be updated as well. 🤔

This comment has been minimized.

Copy link
@jrwats

jrwats Mar 18, 2021

Contributor

Yes that's correct, we need to update installation instructions to include @fbtjs/default-collection-transform.

Down the road, it'd be ideal if we were more seamless about the project's Babel stack. I've touched on that slightly here: #95, but the custom --transform option is the next closest alternative

This comment has been minimized.

Copy link
@mrtnzlml

mrtnzlml Mar 18, 2021

Contributor

#203 - nothing extra, just mentioning it in the docs 🙂

}
}
21 changes: 1 addition & 20 deletions packages/babel-plugin-fbt/src/bin/FbtCollector.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
const {extractEnumsAndFlattenPhrases} = require('../FbtShiftEnums');
// eslint-disable-next-line fb-www/no-module-aliasing
const fbt = require('../index');
const babel = require('@babel/core');
const {SyntaxPlugins} = require('fb-babel-plugin-utils');
const fs = require('graceful-fs');
const path = require('path');

Expand Down Expand Up @@ -55,24 +53,6 @@ export type TransformOptions = {|
|}
*/

function transform(
code /*: string*/,
options /*: TransformOptions*/,
plugins /*: BabelPluginList */,
presets /*: BabelPresetList */
)/*: void*/ {
const opts = {
ast: false,
code: false,
filename: options.filename,
plugins: SyntaxPlugins.list.concat(plugins, [[fbt, options]]),
presets,
sourceType: 'unambiguous',
};
babel.transformSync(code, opts);
}


export interface IFbtCollector {
constructor(config : CollectorConfig, extraOptions : ExtraOptions): void;
collectFromOneFile(
Expand Down Expand Up @@ -129,6 +109,7 @@ class FbtCollector implements IFbtCollector {
options.fbtBabelPluginPath = path.join(__dirname, '../..');
externalTransform(source, options, filename);
} else {
const transform = require('@fbtjs/default-collection-transform');
transform(source, options, this._config.plugins || [], this._config.presets || []);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/fbt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"invariant": "^2.2.4"
},
"peerDependencies": {
"babel-plugin-fbt": "^0.18.x",
"babel-plugin-fbt": "^0.19.x",
"babel-plugin-fbt-runtime": "^0.9.x",
"react": "0.12.0 - 17.x.x"
},
Expand Down

0 comments on commit 1ce9a76

Please sign in to comment.