Skip to content

Commit

Permalink
feat(expo): build w/package.json overrides/resolutions
Browse files Browse the repository at this point in the history
  • Loading branch information
franzmoro authored and xiongemi committed Oct 11, 2024
1 parent db10812 commit 3ed3e45
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/expo/src/executors/build/build.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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)
Expand Down

0 comments on commit 3ed3e45

Please sign in to comment.