Skip to content

Commit

Permalink
fix(objects): 优化 load json5 在 cjs 模式下的逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
renxia committed Jan 8, 2024
1 parent 9224709 commit 5ba82f5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/common/objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ export async function tryLoadJSON5() {
// @ts-ignore
if (globalThis.JSON5) JSON5 = globalThis.JSON5;
else {
const t = await import('json5');
JSON5 = (t.default || t) as never;
if (typeof require === 'function') JSON5 = require('json5');
else {
const t = await import('json5');
JSON5 = (t.default || t) as never;
}
}
} catch {
// quit
Expand Down

0 comments on commit 5ba82f5

Please sign in to comment.