diff --git a/packages/babel-plugin-fbtee/package.json b/packages/babel-plugin-fbtee/package.json index 3a67fc6e..812fffcb 100644 --- a/packages/babel-plugin-fbtee/package.json +++ b/packages/babel-plugin-fbtee/package.json @@ -44,8 +44,5 @@ "@types/babel__core": "^7.20.5", "@types/babel__traverse": "^7.20.6", "@types/glob": "^8.1.0" - }, - "peerDependencies": { - "typescript": "^5.7.0" } } diff --git a/packages/babel-plugin-fbtee/src/bin/manifestUtils.tsx b/packages/babel-plugin-fbtee/src/bin/manifestUtils.tsx index 468cb4e7..03f296c8 100644 --- a/packages/babel-plugin-fbtee/src/bin/manifestUtils.tsx +++ b/packages/babel-plugin-fbtee/src/bin/manifestUtils.tsx @@ -1,8 +1,10 @@ import fs from 'node:fs'; import { parse, relative, resolve } from 'node:path'; +import { transformSync } from '@babel/core'; +import presetReact from '@babel/preset-react'; +import presetTypeScript from '@babel/preset-typescript'; import { globSync } from 'glob'; import invariant from 'invariant'; -import ts from 'typescript'; import { FBT_ENUM_MODULE_SUFFIX as ENUM_FILE, ModuleNameRegExp, @@ -34,18 +36,22 @@ export async function generateManifest( ); for (const filepath of enumFiles) { + const name = parse(filepath).name; const tsContent = fs.readFileSync(filepath, 'utf8'); - const jsContent = ts.transpile(tsContent, { - module: ts.ModuleKind.ESNext, - target: ts.ScriptTarget.ESNext, + const result = transformSync(tsContent, { + ast: false, + filename: filepath, + presets: [presetTypeScript, presetReact], + sourceType: 'module', }); - const jsDataUrl = `data:text/javascript;base64,${Buffer.from(jsContent).toString('base64')}`; + invariant(result?.code, 'Unable to transform `%s`', filepath); + + const jsDataUrl = `data:text/javascript;base64,${Buffer.from(result.code).toString('base64')}`; const module = await import(jsDataUrl); const enumValue: EnumModule = module.default; - const name = parse(filepath).name; invariant( enumValue != null, 'No valid enum found for `%s`, ensure you are exporting your enum ' + diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 73a8fcd3..a7b64bc0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -198,9 +198,6 @@ importers: nullthrows: specifier: ^1.1.1 version: 1.1.1 - typescript: - specifier: ^5.7.0 - version: 5.7.2 yargs: specifier: ^17.7.2 version: 17.7.2