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 committed Oct 2, 2024
1 parent 5a41154 commit 56763ba
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion packages/expo/src/executors/build/build.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,20 @@ function copyPackageJsonAndLock(
const projectPackageJsonDevDependencies = {
...projectPackageJson.devDependencies,
};

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 56763ba

Please sign in to comment.