Skip to content

Conversation

@stipsan
Copy link
Member

@stipsan stipsan commented Jun 19, 2025

Fixes #1397 but unsure if it can land since findPackageJSON isn't well supported yet. I initially tried with createRequire, but I couldn't get it to fail when running from within @sanity/pkg-utils, it has to detect resolution errors from cwd. Since @sanity/pkg-utils has a direct dependency on @sanity/browserslist-config there's always going to be ./node_modules/@sanity/pkg-utils/node_modules/@sanity/browserslist-config or ./node_modules/@sanity/browserslist-config.
It needs to detect the ./node_modules/@sanity/pkg-utils/node_modules/@sanity/browserslist-config case specifically, or rather, that ./node_modules/@sanity/browserslist-config is "missing" and thus "browserslist": "extends @sanity/browserslist-config" won't have an effect in other tooling than @sanity/pkg-utils itself.

I put "missing" in quotes, as it's not that simple. ./node_modules/@sanity/browserslist-config might be missing and its fine, if ../../node_modules/@sanity/browserslist-config does. That's why I'm trying to rely on core node resolution APIs so that we can know for a fact wether it's failing to resolve or not.

@stipsan stipsan requested a review from a team as a code owner June 19, 2025 21:26
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.

Doesn't error if missing @sanity/browserlist-config dependency

2 participants