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

Separate Vitest-dependent utils into a different entrypoint #173

Merged
merged 2 commits into from
Mar 6, 2025

Conversation

illright
Copy link
Member

@illright illright commented Feb 2, 2025

@steiger/toolkit has some utilities to help plugin writers write tests easier. We don't want to force people to use Vitest, so it's marked as an optional peer dependency. However, the file you import when you import @steiger/toolkit contains an import from vitest, which fails when you don't have Vitest installed.

This PR creates another entrypoint, @steiger/toolkit/test. Now this entrypoint has all the test utils, and you can only import it if you have Vitest installed. If you don't need test utils, you can import everything else from @steiger/toolkit, no Vitest required.

Copy link

changeset-bot bot commented Feb 2, 2025

🦋 Changeset detected

Latest commit: 5e9e18a

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

This PR includes changesets to release 1 package
Name Type
@steiger/toolkit Minor

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

@illright illright requested a review from daniilsapa February 3, 2025 09:15
Copy link
Collaborator

@daniilsapa daniilsapa left a comment

Choose a reason for hiding this comment

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

Yeah, that's a pretty subtle moment but makes perfect sense. Thanks!

I don't have any questions except one. Should we cover the fact that @steiger/toolkit/test requires Vitest to be installed (maybe a short note somewhere in README). Not a big deal, we can put this aside until we have full-fledged documentation for plugin creators.

@@ -4,5 +4,3 @@ export { findAllRecursively } from './find-all-recursively.js'
export { enableAllRules, createConfigs } from './create-configs.js'
Copy link
Collaborator

Choose a reason for hiding this comment

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

findAllRecursively still has some references to vitest (import.meta.vitest) and is still imported in @steiger/toolkit. But looks like it shouldn't cause any problems because import.meta.vitest will be "undefined"

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I think it should be fine

@illright
Copy link
Member Author

The point about docs is good, but I agree, it can wait until we have some kind of docs :D

@illright illright merged commit df5870b into master Mar 6, 2025
15 of 16 checks passed
@illright illright deleted the separate-test-utils branch March 6, 2025 17:22
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