Skip to content

Allow visitors to add dependencies#1170

Merged
devongovett merged 2 commits intomasterfrom
visitor-deps
Mar 5, 2026
Merged

Allow visitors to add dependencies#1170
devongovett merged 2 commits intomasterfrom
visitor-deps

Conversation

@devongovett
Copy link
Member

Closes #877

Visitors can now be functions that receive an addDependency function. When called, this adds either a file or glob dependency that is returned to the caller (e.g. a bundler). Lightning CSS doesn't do anything with these dependencies by default: the caller is responsible for implementing file watching or cache invalidation based on these dependencies. composeVisitors also has support for visitors that are functions, passing the options to each visitor.

This is implemented entirely in the JavaScript layer. Dependencies do not cross the Rust boundary. They are appended to the list of other dependencies such as imports and urls returned by Rust when analyzeDependencies is true.

Copy link
Contributor

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

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

Thank you! I've tested this PR at vitejs/vite#21748 and it worked for my use case

@devongovett devongovett merged commit 96c5c6d into master Mar 5, 2026
3 checks passed
@devongovett devongovett deleted the visitor-deps branch March 5, 2026 01:32
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.

Feature Request: add a way to register dependencies by plugins

2 participants