From bf2576ba41b994b22f7ccb2b571cca0892ca85c7 Mon Sep 17 00:00:00 2001 From: natew Date: Fri, 27 Dec 2024 08:20:30 -1000 Subject: [PATCH] fix(vite-flow): use internal resolve to avoid issues in babel resolution in external monorepos --- packages/vite-flow/package.json | 1 + packages/vite-flow/src/transformFlowBabel.ts | 3 ++- packages/vite-flow/tsconfig.json | 4 +++- yarn.lock | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/vite-flow/package.json b/packages/vite-flow/package.json index c232a3f69..a0402fc4c 100644 --- a/packages/vite-flow/package.json +++ b/packages/vite-flow/package.json @@ -30,6 +30,7 @@ "@babel/core": "^7.26.0", "@babel/plugin-transform-private-methods": "^7.25.9", "@react-native/babel-plugin-codegen": "^0.76.5", + "@vxrn/resolve": "workspace:^", "babel-plugin-syntax-hermes-parser": "^0.25.1", "flow-remove-types": "^2.247.1", "metro-react-native-babel-preset": "^0.77.0", diff --git a/packages/vite-flow/src/transformFlowBabel.ts b/packages/vite-flow/src/transformFlowBabel.ts index aeb28441f..aa3d94039 100644 --- a/packages/vite-flow/src/transformFlowBabel.ts +++ b/packages/vite-flow/src/transformFlowBabel.ts @@ -1,4 +1,5 @@ import babel from '@babel/core' +import { resolvePath } from '@vxrn/resolve' export async function transformFlowBabel( input: string, @@ -11,7 +12,7 @@ export async function transformFlowBabel( filename: 'file.js', // this is required for @react-native/babel-plugin-codegen to work. presets: [ [ - 'module:metro-react-native-babel-preset', + resolvePath('metro-react-native-babel-preset'), { // To use the `@babel/plugin-transform-react-jsx` plugin for JSX. useTransformReactJSXExperimental: true, diff --git a/packages/vite-flow/tsconfig.json b/packages/vite-flow/tsconfig.json index c44752f97..6fa56efa9 100644 --- a/packages/vite-flow/tsconfig.json +++ b/packages/vite-flow/tsconfig.json @@ -4,6 +4,8 @@ "composite": true }, "references": [ - + { + "path": "../resolve" + }, ] } diff --git a/yarn.lock b/yarn.lock index 6e1eae92c..e9a518491 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12526,6 +12526,7 @@ __metadata: "@biomejs/biome": "npm:^1.8.3" "@react-native/babel-plugin-codegen": "npm:^0.76.5" "@tamagui/build": "npm:^1.121.2" + "@vxrn/resolve": "workspace:^" babel-plugin-syntax-hermes-parser: "npm:^0.25.1" flow-remove-types: "npm:^2.247.1" metro-react-native-babel-preset: "npm:^0.77.0"