-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(vitest): fix
optimizeDeps.disabled
warnings on Vite 5.1 (#5215)
- Loading branch information
Showing
8 changed files
with
132 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const importMetaUrl = import.meta.url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "@vitest/test-deps-url", | ||
"type": "module", | ||
"exports": "./index.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "@vitest/test-optimize-deps", | ||
"type": "module", | ||
"private": true, | ||
"scripts": { | ||
"test": "vitest" | ||
}, | ||
"devDependencies": { | ||
"@vitest/test-dep-url": "file:./dep-url", | ||
"vitest": "workspace:*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// @vitest-environment node | ||
|
||
import { expect, test } from 'vitest' | ||
|
||
// @ts-expect-error untyped | ||
import { importMetaUrl } from '@vitest/test-dep-url' | ||
|
||
// TODO: flaky on Windows | ||
// https://github.com/vitest-dev/vitest/pull/5215#discussion_r1492066033 | ||
test.skipIf(process.platform === 'win32')('import.meta.url', () => { | ||
expect(importMetaUrl).toContain('/node_modules/.vitest/deps_ssr/') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// @vitest-environment happy-dom | ||
|
||
import { expect, test } from 'vitest' | ||
|
||
// @ts-expect-error untyped | ||
import { importMetaUrl } from '@vitest/test-dep-url' | ||
|
||
test('import.meta.url', () => { | ||
expect(importMetaUrl).toContain('/node_modules/.vitest/deps/') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { defineConfig } from 'vitest/config' | ||
|
||
export default defineConfig({ | ||
optimizeDeps: { | ||
include: ['@vitest/test-dep-url'], | ||
}, | ||
ssr: { | ||
optimizeDeps: { | ||
include: ['@vitest/test-dep-url'], | ||
}, | ||
}, | ||
test: { | ||
chaiConfig: { | ||
truncateThreshold: 1000, | ||
}, | ||
deps: { | ||
optimizer: { | ||
web: { | ||
enabled: true, | ||
}, | ||
ssr: { | ||
enabled: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
// use dummy ssrLoadModule to trigger ssr.optimizeDeps. | ||
// this will be unnecessary from Vite 5.1 | ||
// cf. https://github.com/vitejs/vite/pull/15561 | ||
plugins: [ | ||
{ | ||
name: 'force-ssr-optimize-deps', | ||
configureServer(server) { | ||
return async () => { | ||
await server.ssrLoadModule('/package.json') | ||
} | ||
}, | ||
}, | ||
], | ||
}) |