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

fix: allow slots in vitest-browser-vue #7120

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions packages/browser/src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,10 @@ export default (parentServer: ParentBrowserProject, base = '/'): Plugin[] => {

// since we override the resolution in the esbuild plugin, Vite can no longer optimizer it
// have ?. until Vitest 3.0 for backwards compatibility
const vueTestUtils = isPackageExists('@vue/test-utils', fileRoot)
if (vueTestUtils) {
include.push('@vue/test-utils')
const vue = isPackageExists('vitest-browser-vue', fileRoot)
if (vue) {
// we override them in the esbuild plugin so optimizer can no longer intercept it
include.push('@vue/test-utils', '@vue/compiler-core')
}

return {
Expand Down Expand Up @@ -520,10 +521,10 @@ body {
{
name: 'test-utils-rewrite',
setup(build) {
build.onResolve({ filter: /^@vue\/test-utils$/ }, (args) => {
const _require = getRequire()
// resolve to CJS instead of the browser because the browser version expects a global Vue object
const resolved = _require.resolve(args.path, {
// test-utils: resolve to CJS instead of the browser because the browser version expects a global Vue object
// compiler-core: only CJS version allows slots as strings
build.onResolve({ filter: /^@vue\/(test-utils|compiler-core)$/ }, (args) => {
const resolved = getRequire().resolve(args.path, {
paths: [args.importer],
})
return { path: resolved }
Expand Down
Loading