Skip to content

Commit

Permalink
fix: JSON5 exports parse under the default key in ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
goosewobbler committed Nov 19, 2024
1 parent cc89adf commit de398b4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/@wdio_electron-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ async function readConfig(configFile: string, projectDir: string) {
} else {
const data = await fs.readFile(configFilePath, 'utf8');
if (extRegex.json.test(ext)) {
result = (await import('json5')).parse(data);
const json5 = await import('json5');
// JSON5 exports parse as default in ESM, but as a named export in CJS
// https://github.com/json5/json5/issues/240
const parseJson = json5.parse || json5.default.parse;
result = parseJson(data);
} else if (extRegex.toml.test(ext)) {
result = (await import('smol-toml')).parse(data);
} else if (extRegex.yaml.test(ext)) {
Expand Down

0 comments on commit de398b4

Please sign in to comment.