Skip to content

Commit

Permalink
revert: use importModule to load env, revert #1667
Browse files Browse the repository at this point in the history
* fix: don't resolve test env import when transforming files

* chore: add happy-dom to dependencies to coverage test

* revert: use importModule to load env, revert #1667
  • Loading branch information
sheremet-va committed Jul 25, 2022
1 parent 8247ed9 commit 06090cc
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -8,7 +8,7 @@
"scripts": {
"ci": "ni && nr typecheck && nr lint && nr build && nr test:all",
"build": "pnpm -r --filter=./packages/** run build",
"dev": "pnpm -r --parallel --filter=./packages/** run dev",
"dev": "NODE_OPTIONS=\"--max-old-space-size=8192\" pnpm -r --parallel --filter=./packages/** run dev",
"docs": "pnpm -C docs run dev",
"docs:build": "pnpm -C docs run build",
"docs:serve": "pnpm -C docs run serve",
Expand Down
2 changes: 0 additions & 2 deletions packages/vitest/rollup.config.js
Expand Up @@ -38,8 +38,6 @@ const external = [
...Object.keys(pkg.peerDependencies),
'worker_threads',
'inspector',
'c8',
'@vitest/browser',
]

const plugins = [
Expand Down
3 changes: 2 additions & 1 deletion packages/vitest/src/integrations/env/edge-runtime.ts
@@ -1,10 +1,11 @@
import { importModule } from 'local-pkg'
import type { Environment } from '../../types'
import { populateGlobal } from './utils'

export default <Environment>({
name: 'edge-runtime',
async setup(global) {
const { EdgeVM } = await import('@edge-runtime/vm')
const { EdgeVM } = await importModule('@edge-runtime/vm') as typeof import('@edge-runtime/vm')
const vm = new EdgeVM({
extend: (context) => {
context.global = context
Expand Down
3 changes: 2 additions & 1 deletion packages/vitest/src/integrations/env/happy-dom.ts
@@ -1,3 +1,4 @@
import { importModule } from 'local-pkg'
import type { Environment } from '../../types'
import { populateGlobal } from './utils'

Expand All @@ -6,7 +7,7 @@ export default <Environment>({
async setup(global) {
// happy-dom v3 introduced a breaking change to Window, but
// provides GlobalWindow as a way to use previous behaviour
const { Window, GlobalWindow } = await import('happy-dom')
const { Window, GlobalWindow } = await importModule('happy-dom') as typeof import('happy-dom')
const win = new (GlobalWindow || Window)()

const { keys, originals } = populateGlobal(global, win, { bindFunctions: true })
Expand Down
3 changes: 2 additions & 1 deletion packages/vitest/src/integrations/env/jsdom.ts
@@ -1,3 +1,4 @@
import { importModule } from 'local-pkg'
import type { Environment } from '../../types'
import { populateGlobal } from './utils'

Expand All @@ -9,7 +10,7 @@ export default <Environment>({
JSDOM,
ResourceLoader,
VirtualConsole,
} = await import('jsdom')
} = await importModule('jsdom') as typeof import('jsdom')
const {
html = '<!DOCTYPE html>',
userAgent,
Expand Down
19 changes: 18 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/coverage-test/package.json
Expand Up @@ -12,6 +12,7 @@
"devDependencies": {
"@vitejs/plugin-vue": "^2.3.3",
"@vue/test-utils": "^2.0.0",
"happy-dom": "^6.0.4",
"vitest": "workspace:*"
}
}

0 comments on commit 06090cc

Please sign in to comment.