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
Replace fast-glob
with fdir
and picomatch
, optimize peer dep validation crawler
#952
Conversation
🦋 Changeset detectedLatest commit: 8b4b1a8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
738358c
to
a69f627
Compare
@@ -104,6 +104,7 @@ | |||
"node-html-parser": "^6.1.1", | |||
"open": "^7.3.1", | |||
"path-to-regexp": "^6.2.0", | |||
"picomatch": "^3.0.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
picomatch
v4 is the latest, but fdir
's peer dependency hasn't been updated to support it. We're not really missing anything by staying on v3 for now.
@@ -1,57 +1,83 @@ | |||
const { posix: path } = require('node:path'); | |||
const chalk = require('chalk'); | |||
const glob = require('fast-glob'); | |||
const { fdir: Fdir } = require('fdir'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rename the import to prevent https://eslint.org/docs/latest/rules/new-cap at the call site.
pnpmVirtualStoreRelativePath, | ||
'@seek*/node_modules/@seek/*/package.json', | ||
); | ||
if (isPnpm) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to how fdir
handles symlinks, I had to special-case some code for pnpm, in addition to the pnpm-related block below.
Replace
fast-glob
withfdir
andpicomatch
fdir
is a 0 dependency directory crawler with optional glob support via a peer dependency. For our use cases, we don't need most of the features offast-glob
(or dependencies), but we do need globbing, whichfdir
supports viapicomatch
, a 0 dependency glob matcher.Replacing globs with simple filters
Due to API differences and some changes in how we crawl in certain cases, I've replaced some globs with simple filters.
Optimize peer dep validation crawler
validatePeerDeps
was crawling all ofnode_modules
(and.pnpm
if present) many times. We now crawl these places just once, and process the results appropriately. This results in a much faster output of the warning messages.Running
sku build
in a moderately sized app where I modifiednode_modules
to induce a peer dependency warning, the warning was output within a few seconds. On sku11.5.0
this took >1 minute.Disable peer dependency validation for pnpm
Our current method of peer dep validation doesn't work for pnpm. This is because it relies on crawling through nested
node_modules
directories, which pnpm only uses to store binaries.If we really want this functionality for pnpm, we'll need to implement it some other way.
Note
Not marking this change as breaking as it wasn't doing anything in the first place.