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

Detect Vitest for in-source testing #9

Open
ayuhito opened this issue Jun 26, 2022 · 1 comment
Open

Detect Vitest for in-source testing #9

ayuhito opened this issue Jun 26, 2022 · 1 comment
Labels
enhancement New feature or request pr welcome

Comments

@ayuhito
Copy link
Contributor

ayuhito commented Jun 26, 2022

Love this bundler and I appreciate the peace of mind having not to configure anything for things to just work.

Vitest does support in-source testing which I think is great when writing unit tests, however, since this bundler isn't extensible, it isn't possible for us to modify the Rollup config to tree-shake the testing code out as specified in their docs.

Would it be possible to merge the following replace config into the default Rollup config of this project? Whilst the addition of this shouldn't affect non-Vitest users, we can still include a check just incase to only include it if Vitest is present in the package.json.

// rollup.config.js
+ import replace from '@rollup/plugin-replace'

export default {
  plugins: [
+   replace({
+     'import.meta.vitest': 'undefined',
+   })
  ],
  // other options
}
@privatenumber
Copy link
Owner

That looks safe but I would rather not build in specific support for other tooling, or also make assumptions about how they need to be used.

I think I would prefer to add a --define CLI flag like the --env flag.

@privatenumber privatenumber added enhancement New feature or request pr welcome labels Jun 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pr welcome
Projects
None yet
Development

No branches or pull requests

2 participants