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

feat: add alias option #1634

Merged
merged 3 commits into from Jul 19, 2022
Merged

feat: add alias option #1634

merged 3 commits into from Jul 19, 2022

Conversation

sheremet-va
Copy link
Member

Linked #1628

@netlify
Copy link

netlify bot commented Jul 12, 2022

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 12052a8
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/62cd335547e7d5000892d13e
😎 Deploy Preview https://deploy-preview-1634--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@antfu
Copy link
Member

antfu commented Jul 12, 2022

I am not so sure. I understand it could be easier for users to have env-specific alias, yet it might still be limited. I am concerned this would introduce some slippery slope effect that we might need to re-expose every vite option under test. Since we have vitest.config and process.env.VITEST on top of the fact that the config is js, I would prefer to reuse Vite's options as much as possible.

@sheremet-va
Copy link
Member Author

sheremet-va commented Jul 12, 2022

I am not so sure. I understand it could be easier for users to have env-specific alias, yet it might still be limited. I am concerned this would introduce some slippery slope effect that we might need to re-expose every vite option under test. Since we have vitest.config and process.env.VITEST on top of the fact that the config is js, I would prefer to reuse Vite's options as much as possible.

I think we should add plugins and alias support to test property, since they are highly requested, and it's easier to configure with a simple test.alias/test.plugins than go to the issues/discord and ask. Plugins are harder to implement right now, so I am waiting on multi repo support.

Anything else should stay on Vite config. What do you think, @patak-dev?

@antfu
Copy link
Member

antfu commented Jul 13, 2022

OK, I am ok to have alias and plugins for the DX.


- **Type:** `Record<string, string> | Array<{ find: string | RegExp, replacement: string, customResolver?: ResolverFunction | ResolverObject }>`

Define custom aliases when running inside tests. They will be merged with aliases from `resolve.alias`.

Choose a reason for hiding this comment

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

Could it be named something else than alias ?

Genuinely asking cause it's not immediately clear to me how they compare/plug into the vite ones (alias in vite 2 and resolve.alias in vite 3). Easy to be confused when quickly checking config or looking for an existing issue.

Could it be renamed ? (ie: extraAlias, moduleMapper, testAlias...)

Copy link
Member Author

Choose a reason for hiding this comment

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

It’s on test.alias, what is confusing here?

Choose a reason for hiding this comment

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

You're absolutely right, no confusion. My bad, I was confused :)

@sheremet-va sheremet-va merged commit 7c2138f into vitest-dev:main Jul 19, 2022
@sheremet-va sheremet-va deleted the feat/alias branch July 19, 2022 14:44
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

3 participants