Skip to content

Commit d6bd797

Browse files
Copilotkobenguyent
andcommitted
Fix wdio.js: Use createRequire for synchronous module loading
Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com>
1 parent 775b059 commit d6bd797

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/plugin/wdio.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import mainConfig from '../config.js'
66
import recorder from '../recorder.js'
77
import event from '../event.js'
88
import output from '../output.js'
9+
import { createRequire } from 'module'
10+
const require = createRequire(import.meta.url)
911

1012
const defaultConfig = {
1113
services: [],
@@ -239,7 +241,7 @@ export default config => {
239241

240242
function safeRequire(name) {
241243
try {
242-
return import(name)
244+
return require(name)
243245
} catch (e) {
244246
if (!e.message.match(`Cannot find module '${name}'`)) {
245247
throw new Error(`Couldn't initialise "${name}".\n${e.stack}`)

0 commit comments

Comments
 (0)