Skip to content

Commit

Permalink
chore: use /@id/ for importing
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Mar 21, 2023
1 parent ab6fdd5 commit a0838a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
10 changes: 5 additions & 5 deletions packages/browser/src/client/main.ts
Expand Up @@ -23,8 +23,8 @@ const browserHashMap = new Map<string, string>()
const url = new URL(location.href)
const testId = url.searchParams.get('id') || 'unknown'

const plainImport = (id: string) => {
const name = `/@plain/${id}`
const importId = (id: string) => {
const name = `/@id/${id}`
return import(name)
}

Expand Down Expand Up @@ -85,14 +85,14 @@ async function runTests(paths: string[], config: any, client: VitestClient) {
takeCoverageInsideWorker,
stopCoverageInsideWorker,
startCoverageInsideWorker,
} = await plainImport('vitest/browser') as typeof import('vitest/browser')
} = await importId('vitest/browser') as typeof import('vitest/browser')

const executor = {
executeId: (id: string) => plainImport(id),
executeId: (id: string) => importId(id),
}

if (!runner) {
const { VitestTestRunner } = await plainImport('vitest/runners') as typeof import('vitest/runners')
const { VitestTestRunner } = await importId('vitest/runners') as typeof import('vitest/runners')
const BrowserRunner = createBrowserRunner(VitestTestRunner, { takeCoverage: () => takeCoverageInsideWorker(config.coverage, executor) })
runner = new BrowserRunner({ config, client, browserHashMap })
}
Expand Down
3 changes: 0 additions & 3 deletions packages/browser/src/node/index.ts
Expand Up @@ -19,9 +19,6 @@ export default (base = '/'): Plugin[] => {
enforce: 'pre',
name: 'vitest:browser',
async resolveId(id) {
if (id.startsWith('/@plain/'))
return this.resolve(id.slice('/@plain/'.length))

if (id.startsWith('node:'))
id = id.slice(5)

Expand Down

0 comments on commit a0838a0

Please sign in to comment.