Skip to content

add prebuild script to collect peerdeps #765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

arlyon
Copy link

@arlyon arlyon commented Apr 9, 2025

This adds a simple js script that is run before builds and commits that collects all peerDependencies from all subfolders together and inserts them into the root package.json. This closes #762

@arlyon arlyon force-pushed the arlyon/peerdeps branch from 81c9e0d to bc6eb55 Compare April 9, 2025 13:22
@arlyon
Copy link
Author

arlyon commented Apr 9, 2025

The question of #747 pops to mind here. If the official stance of this library is that there is a hard dependency on standard schemas with the view of eventually making it the only option once ecosystem adoption grows then great, we keep it in. We should probably also add @standardschema/spec as well just to be on the safe side. If not, I propose we revert it and use only peerdeps for now.

@jorisre jorisre requested review from bluebill1049 and jorisre April 9, 2025 15:22
@arlyon arlyon force-pushed the arlyon/peerdeps branch from bc6eb55 to 0a6e362 Compare May 12, 2025 16:10
@@ -317,9 +318,91 @@
"zod": "^3.24.2"
},
"peerDependencies": {
"react-hook-form": "^7.55.0"
"react-hook-form": "^7.55.0",
"@hookform/resolvers": "^2.0.0",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you depending on the package itself?

Copy link

@aqeelat aqeelat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how we can make sure we're not depending on ourselves.

Comment on lines +13 to +15
const peerDependencies = Object.fromEntries(
packageJsons.flatMap((pj) => Object.entries(pj?.peerDependencies ?? {})),
);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const peerDependencies = Object.fromEntries(
packageJsons.flatMap((pj) => Object.entries(pj?.peerDependencies ?? {})),
);
const topLevelPackageJson = JSON.parse(await fs.readFile('package.json'))
const peerDependencies = Object.fromEntries(
packageJsons
.flatMap((pj) => Object.entries(pj?.peerDependencies ?? {}))
.filter(([name]) => name !== topLevelPackageJson.name),
)

);

const packageJson = {
...JSON.parse(await fs.readFile('package.json')),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
...JSON.parse(await fs.readFile('package.json')),
...topLevelPackageJson,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

issue: Peer dependencies not picked up by package managers
2 participants