From 3ed3e45981a6254063d797cbec44b4c1c6c4013c Mon Sep 17 00:00:00 2001 From: Franz Moro Date: Wed, 2 Oct 2024 19:43:32 +0100 Subject: [PATCH] feat(expo): build w/package.json overrides/resolutions (#28249) --- .../expo/src/executors/build/build.impl.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/packages/expo/src/executors/build/build.impl.ts b/packages/expo/src/executors/build/build.impl.ts index f93b5914a1f3c..0c57b34f7e101 100644 --- a/packages/expo/src/executors/build/build.impl.ts +++ b/packages/expo/src/executors/build/build.impl.ts @@ -143,6 +143,17 @@ function copyPackageJsonAndLock( projectPackageJson.dependencies = rootPackageJsonDependencies; projectPackageJson.devDependencies = rootPackageJsonDevDependencies; + const projectOverrides = projectPackageJson.overrides; + const projectResolutions = projectPackageJson.resolutions; + + if (rootPackageJson.overrides) { + projectPackageJson.overrides = rootPackageJson.overrides; + } + // if overrides exists, give precedence to it over resolutions + if (!rootPackageJson.overrides && rootPackageJson.resolutions) { + projectPackageJson.resolutions = rootPackageJson.resolutions; + } + // Copy dependencies from root package.json to project package.json writeJsonFile(packageJsonProject, projectPackageJson); @@ -153,6 +164,18 @@ function copyPackageJsonAndLock( // Reset project package.json to original state projectPackageJson.dependencies = projectPackageJsonDependencies; projectPackageJson.devDependencies = projectPackageJsonDevDependencies; + + if (projectOverrides) { + projectPackageJson.overrides = projectOverrides; + } else { + delete projectPackageJson.overrides; + } + if (projectResolutions) { + projectPackageJson.resolutions = projectResolutions; + } else { + delete projectPackageJson.resolutions; + } + writeFileSync( packageJsonProject, JSON.stringify(projectPackageJson, null, 2)