Skip to content

Commit

Permalink
revert: use importModule to load env, revert vitest-dev#1667
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jul 25, 2022
1 parent fbbbd51 commit 244feb8
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ const external = [
...Object.keys(pkg.peerDependencies),
'worker_threads',
'inspector',
'c8',
'@vitest/browser',
]

const plugins = [
Expand Down
4 changes: 2 additions & 2 deletions packages/vitest/src/integrations/env/edge-runtime.ts
Original file line number Diff line number Diff line change
@@ -1,11 +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 libName = '@edge-runtime/vm'
const { EdgeVM } = await import(libName) as typeof 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
4 changes: 2 additions & 2 deletions packages/vitest/src/integrations/env/happy-dom.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { importModule } from 'local-pkg'
import type { Environment } from '../../types'
import { populateGlobal } from './utils'

export default <Environment>({
name: 'happy-dom',
async setup(global) {
const libName = 'happy-dom'
// happy-dom v3 introduced a breaking change to Window, but
// provides GlobalWindow as a way to use previous behaviour
const { Window, GlobalWindow } = await import(libName) as typeof 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
4 changes: 2 additions & 2 deletions packages/vitest/src/integrations/env/jsdom.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { importModule } from 'local-pkg'
import type { Environment } from '../../types'
import { populateGlobal } from './utils'

export default <Environment>({
name: 'jsdom',
async setup(global, { jsdom = {} }) {
const libName = 'jsdom'
const {
CookieJar,
JSDOM,
ResourceLoader,
VirtualConsole,
} = await import(libName) as typeof import('jsdom')
} = await importModule('jsdom') as typeof import('jsdom')
const {
html = '<!DOCTYPE html>',
userAgent,
Expand Down

0 comments on commit 244feb8

Please sign in to comment.