Skip to content
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

Merged
merged 3 commits into from May 6, 2024

Conversation

askoufis
Copy link
Contributor

@askoufis askoufis commented Apr 19, 2024

Replace fast-glob with fdir and picomatch

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 of fast-glob (or dependencies), but we do need globbing, which fdir supports via picomatch, 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 of node_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 modified node_modules to induce a peer dependency warning, the warning was output within a few seconds. On sku 11.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.

@askoufis askoufis requested a review from a team as a code owner April 19, 2024 04:39
Copy link

changeset-bot bot commented Apr 19, 2024

🦋 Changeset detected

Latest commit: 8b4b1a8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
sku Patch

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

@@ -104,6 +104,7 @@
"node-html-parser": "^6.1.1",
"open": "^7.3.1",
"path-to-regexp": "^6.2.0",
"picomatch": "^3.0.1",
Copy link
Contributor Author

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');
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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.

@askoufis askoufis enabled auto-merge (squash) May 6, 2024 03:54
@askoufis askoufis merged commit 2fa94c8 into master May 6, 2024
4 checks passed
@askoufis askoufis deleted the replace-fast-glob branch May 6, 2024 04:01
@seek-oss-ci seek-oss-ci mentioned this pull request May 6, 2024
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.

None yet

2 participants