Skip to content

Commit

Permalink
feat(preset-icons): fallback on env does not support NodeLoader (#2693)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fatpandac authored Jun 4, 2023
1 parent 40a6291 commit 4cdac21
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/preset-icons/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ async function createNodeLoader() {
}
catch { }
try {
// eslint-disable-next-line @typescript-eslint/no-require-imports
return require('@iconify/utils/lib/loader/node-loader.cjs')
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
return require('@iconify/utils/lib/loader/node-loader.cjs').loadNodeIcon
}
catch { }
}
Expand All @@ -25,8 +25,11 @@ export const presetIcons = createPresetIcons(async (options) => {

const loaders: UniversalIconLoader[] = []

if (isNode && !isVSCode)
loaders.push(await createNodeLoader())
if (isNode && !isVSCode) {
const nodeLoader = await createNodeLoader()
if (nodeLoader !== undefined)
loaders.push(nodeLoader)
}

if (cdn)
loaders.push(createCDNLoader(cdn))
Expand Down

0 comments on commit 4cdac21

Please sign in to comment.