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(browser): dedupe @vitest/browser/client #6081

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion packages/browser/src/client/orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ async function getContainer(config: ResolvedConfig): Promise<HTMLDivElement> {
return document.querySelector('#vitest-tester') as HTMLDivElement
}

client.ws.addEventListener('open', async () => {
client.waitForConnection().then(async () => {
const testFiles = getBrowserState().files

await orchestrator.init()
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/client/public/error-catcher.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { channel, client } from '/@id/@vitest/browser/client'
import { channel, client } from '@vitest/browser/client'

function on(event, listener) {
window.addEventListener(event, listener)
Expand Down
2 changes: 2 additions & 0 deletions packages/browser/src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ export default (browserServer: BrowserServer, base = '/'): Plugin[] => {
'vitest/utils',
'vitest/browser',
'vitest/runners',
'@vitest/browser',
'@vitest/browser/client',
'@vitest/utils',
'@vitest/utils/source-map',
'@vitest/runner',
Expand Down
7 changes: 2 additions & 5 deletions packages/browser/src/node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class BrowserServer implements IBrowserServer {
public testerHtml: Promise<string> | string
public orchestratorHtml: Promise<string> | string
public injectorJs: Promise<string> | string
public errorCatcherJs: Promise<string> | string
public errorCatcherPath: Promise<string> | string
public stateJs: Promise<string> | string

public state: BrowserServerState
Expand Down Expand Up @@ -87,10 +87,7 @@ export class BrowserServer implements IBrowserServer {
resolve(distRoot, 'client/esm-client-injector.js'),
'utf8',
).then(js => (this.injectorJs = js))
this.errorCatcherJs = readFile(
resolve(distRoot, 'client/error-catcher.js'),
'utf8',
).then(js => (this.errorCatcherJs = js))
this.errorCatcherPath = resolve(distRoot, 'client/error-catcher.js')
this.stateJs = readFile(
resolve(distRoot, 'state.js'),
'utf-8',
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/node/serverOrchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export async function resolveOrchestrator(
__VITEST_TITLE__: 'Vitest Browser Runner',
__VITEST_SCRIPTS__: server.orchestratorScripts,
__VITEST_INJECTOR__: `<script type="module">${injector}</script>`,
__VITEST_ERROR_CATCHER__: `<script type="module">${server.errorCatcherJs}</script>`,
__VITEST_ERROR_CATCHER__: `<script type="module" src="${server.errorCatcherPath}"></script>`,
__VITEST_CONTEXT_ID__: JSON.stringify(contextId),
})
}
2 changes: 1 addition & 1 deletion packages/browser/src/node/serverTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export async function resolveTester(
__VITEST_TITLE__: 'Vitest Browser Tester',
__VITEST_SCRIPTS__: server.testerScripts,
__VITEST_INJECTOR__: `<script type="module">${injector}</script>`,
__VITEST_ERROR_CATCHER__: `<script type="module">${server.errorCatcherJs}</script>`,
__VITEST_ERROR_CATCHER__: `<script type="module" src="${server.errorCatcherPath}"></script>`,
__VITEST_APPEND__:
`<script type="module">
__vitest_browser_runner__.runningFiles = ${tests}
Expand Down