Skip to content

perf: add depTreeCache to walkDependencyTree #364

Draft
usualoma wants to merge 5 commits intomainfrom
perf-import-islands
Draft

perf: add depTreeCache to walkDependencyTree #364
usualoma wants to merge 5 commits intomainfrom
perf-import-islands

Conversation

@usualoma
Copy link
Copy Markdown
Member

Based on the patch created by @adrianani at #208, I made improvements, including addressing the issue of insufficient cache invalidation.

Cache dependency tree walk results to avoid re-walking the same
subtrees across multiple `transform` calls.

Thank you @adrianani for the suggestion!
Add configureServer hook to clear all caches (resolvedCache, file
content cache, depTreeCache) when files change, fixing a pre-existing
staleness bug where edited files would not be re-analyzed.
Use `${importee}\0${importer}` as the cache key instead of just the
importee string, preventing cross-file collisions where the same
relative import (e.g., "./Counter") from different files could resolve
to different modules.
Allow users to exclude specific directories (e.g., `node_modules`)
from the dependency tree walk via the `exclude` option. This is
opt-in since walking `node_modules` is by design for detecting
island components in npm packages.
@adrianani
Copy link
Copy Markdown

adrianani commented Apr 15, 2026

If I may add some more feedback from a DX point of view based on the vision described in your comment from #208

Even though islands are supposed to come from node_modules an opt-in pattern would be better.

Maybe I'm going the wrong way about using honox here but in a project with just a few dependencies, all fairly sensible like better-auth, drizzle, pg, @aws-sdk/client-s3, etc...
This adds up to about 65K files (if this terminal script is right), which is quite a lot to scan

find ./node_modules -type f | wc -l
   65226

Currently you can either exclude node_modules and IF you have any islands in there you don't seem to have an option to include them or exclude all that don't have islands but the few that might. Ie. going back to my current project, i have 47 dependencies and none are for islands.

With an opt-in pattern where the whole node_modules is excluded by default you could add in a includeNodeModules: ['some-package-name']

The exclude option would be nice if it's like a monorepo and you want to exclude other folders beyond node_modules.

Hope it makes sense?

@usualoma
Copy link
Copy Markdown
Member Author

Hi @adrianani,

Thank you for your feedback!
I’ll take some time to think it over.

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.

2 participants