@nkzw/eslint-plugin-fbtee 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +54 -22
  2. package/lib/index.mjs +1 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -10,14 +10,14 @@ const Greeting = ({ name }) => (
10
10
  );
11
11
  ```
12
12
 
13
- _fbtee_ is a modern continuation of Facebook's `fbt`, rebuilt for TypeScript, ESM, React 19, Vite, Next.js, Babel & SWC.
13
+ _fbtee_ is a modern continuation of Facebook's `fbt`, rebuilt for TypeScript, ESM, React 19, Vite, Babel, SWC, Next.js & Oxc.
14
14
 
15
15
  ## Features
16
16
 
17
17
  - **Inline translations for Better Developer Experience:** Embed translations directly into your code. No need to manage translation keys or wrap your code with `t()` functions. **fbtee** uses a compiler to extract strings from your code and prepare them for translation providers.
18
18
  - **Proven in Production:** Built on Facebook's `fbt`, with over a decade of production usage serving billions of users, plus years in production at [Athena Crisis](https://athenacrisis.com).
19
19
  - **Optimized Performance with IR:** Compiles translations into an Intermediate Representation (IR) for extracting strings, then optimizes the runtime output for performance.
20
- - **Easy Setup:** Quick integration with Babel, SWC, Vite, Next.js, and Expo.
20
+ - **Easy Setup:** Quick integration with Vite, Babel, SWC, Oxc, Next.js, and Expo.
21
21
 
22
22
  ## Getting Started
23
23
 
@@ -34,49 +34,51 @@ npm install fbtee
34
34
 
35
35
  _fbtee_ requires Node 22+. React apps should use React 19+.
36
36
 
37
- ### Babel, Vite and React
37
+ ### Vite
38
38
 
39
- Install the Babel preset and the Rolldown Babel plugin:
39
+ Most projects should install the ready-to-use Vite plugin and the CLI:
40
40
 
41
41
  ```bash
42
- npm install -D @nkzw/babel-preset-fbtee @rolldown/plugin-babel
42
+ npm install -D @nkzw/vite-plugin-fbtee @nkzw/fbtee-cli
43
43
  ```
44
44
 
45
- With Vite, `@rolldown/plugin-babel`, and `@vitejs/plugin-react`:
45
+ Add the fbtee plugin before the React plugin:
46
46
 
47
- ```ts
48
- import fbteePreset from '@nkzw/babel-preset-fbtee';
49
- import babel from '@rolldown/plugin-babel';
47
+ ```js
48
+ import fbtee from '@nkzw/vite-plugin-fbtee';
50
49
  import react from '@vitejs/plugin-react';
51
50
  import { defineConfig } from 'vite';
52
51
 
53
52
  export default defineConfig({
54
53
  plugins: [
55
- babel({
56
- presets: [fbteePreset],
54
+ fbtee({
55
+ fbtCommon: {
56
+ Accept: 'Button label for accepting terms',
57
+ },
58
+ fbtEnumManifest: {},
57
59
  }),
58
60
  react(),
59
61
  ],
60
62
  });
61
63
  ```
62
64
 
63
- With a direct Babel setup:
65
+ ### Babel
64
66
 
65
- ```js
66
- export default {
67
- presets: ['@nkzw/babel-preset-fbtee'],
68
- };
67
+ Install the Babel preset and the CLI:
68
+
69
+ ```bash
70
+ npm install -D @nkzw/babel-preset-fbtee @nkzw/fbtee-cli
69
71
  ```
70
72
 
71
- With Next.js and Babel:
73
+ Add the preset to your Babel configuration:
72
74
 
73
75
  ```js
74
76
  export default {
75
- presets: ['next/babel', '@nkzw/babel-preset-fbtee'],
77
+ presets: ['@nkzw/babel-preset-fbtee'],
76
78
  };
77
79
  ```
78
80
 
79
- ### SWC and Turbopack
81
+ ### SWC
80
82
 
81
83
  Install the SWC runtime compiler and the CLI:
82
84
 
@@ -87,24 +89,54 @@ npm install -D @nkzw/swc-plugin-fbtee @nkzw/fbtee-cli
87
89
  For Next.js SWC plugins:
88
90
 
89
91
  ```js
92
+ import { createFbteePluginOptions } from '@nkzw/swc-plugin-fbtee/index.js';
93
+
90
94
  export default {
91
95
  experimental: {
92
96
  swcPlugins: [
93
97
  [
94
98
  '@nkzw/swc-plugin-fbtee',
95
- {
99
+ createFbteePluginOptions({
96
100
  fbtCommon: {
97
101
  Accept: 'Button label for accepting terms',
98
102
  },
99
103
  fbtEnumManifest: {},
100
- },
104
+ }),
101
105
  ],
102
106
  ],
103
107
  },
104
108
  };
105
109
  ```
106
110
 
107
- Use the SWC plugin to compile app code. Use `fbtee collect` to extract phrases. Do not pass `collectFbt: true` to the SWC plugin.
111
+ ### Low-level Oxc Transform
112
+
113
+ For custom build-system integrations, install the native Oxc transform:
114
+
115
+ ```bash
116
+ npm install -D @nkzw/oxc-transform-fbtee @nkzw/fbtee-cli oxc-transform
117
+ ```
118
+
119
+ Apply the fbtee transform before the standard Oxc transform:
120
+
121
+ ```js
122
+ import { transformSync as transformFbtee } from '@nkzw/oxc-transform-fbtee';
123
+ import { transformSync as transformOxc } from 'oxc-transform';
124
+
125
+ const fbteeResult = transformFbtee(filename, sourceText, {
126
+ fbtCommon: {
127
+ Accept: 'Button label for accepting terms',
128
+ },
129
+ fbtEnumManifest: {},
130
+ });
131
+
132
+ if (fbteeResult.errors.length > 0) {
133
+ throw new Error(fbteeResult.errors.map(({ message }) => message).join('\n'));
134
+ }
135
+
136
+ const result = transformOxc(filename, fbteeResult.code, {
137
+ jsx: { runtime: 'automatic' },
138
+ });
139
+ ```
108
140
 
109
141
  ### TypeScript JSX Types
110
142
 
package/lib/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ESLintUtils } from "@typescript-eslint/utils";
2
2
  //#region package.json
3
3
  var name = "@nkzw/eslint-plugin-fbtee";
4
- var version = "3.0.0";
4
+ var version = "3.1.0";
5
5
  //#endregion
6
6
  //#region src/utils.tsx
7
7
  const createRule = ESLintUtils.RuleCreator((name) => `https://github.com/nkzw-tech/fbtee/blob/main/packages/eslint-plugin-fbtee/docs/rules/${name}.md`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nkzw/eslint-plugin-fbtee",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "repository": {