Skip to content

Commit 36e38c3

Browse files
committedNov 14, 2024··
fix: avoid using consola in runtime, close #295
1 parent a216b73 commit 36e38c3

File tree

4 files changed

+5
-11
lines changed

4 files changed

+5
-11
lines changed
 

‎package.json

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"@iconify/vue": "^4.2.0-dev.1",
4646
"@nuxt/devtools-kit": "^1.6.0",
4747
"@nuxt/kit": "^3.14.159",
48-
"consola": "^3.2.3",
4948
"local-pkg": "^0.5.0",
5049
"mlly": "^1.7.2",
5150
"ohash": "^1.1.4",

‎pnpm-lock.yaml

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/runtime/components/shared.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { computed } from 'vue'
22
import { getIcon as _getIcon, addIcon as _addIcon, loadIcon as _loadIcon } from '@iconify/vue'
3-
import { consola } from 'consola'
43
import type { IconifyIcon } from '@iconify/types'
54
import type { NuxtIconRuntimeOptions } from '../../types'
65
import { useAppConfig } from '#imports'
@@ -19,7 +18,7 @@ export async function loadIcon(name: string, timeout: number): Promise<Required<
1918
let timeoutWarn: ReturnType<typeof setTimeout>
2019
const load = _loadIcon(name)
2120
.catch(() => {
22-
consola.warn(`[Icon] failed to load icon \`${name}\``)
21+
console.warn(`[Icon] failed to load icon \`${name}\``)
2322
return null
2423
})
2524

@@ -28,7 +27,7 @@ export async function loadIcon(name: string, timeout: number): Promise<Required<
2827
load,
2928
new Promise<void>((resolve) => {
3029
timeoutWarn = setTimeout(() => {
31-
consola.warn(`[Icon] loading icon \`${name}\` timed out after ${timeout}ms`)
30+
console.warn(`[Icon] loading icon \`${name}\` timed out after ${timeout}ms`)
3231
resolve()
3332
}, timeout)
3433
})])

‎src/runtime/server/api.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { basename } from 'pathe'
22
import { getIcons } from '@iconify/utils'
3-
import { consola } from 'consola'
43
import { hash } from 'ohash'
54
import { createError, getQuery, type H3Event } from 'h3'
65
import type { NuxtIconRuntimeOptions } from '../../schema-types'
@@ -32,14 +31,14 @@ export default defineCachedEventHandler(async (event: H3Event) => {
3231
collection,
3332
icons,
3433
)
35-
consola.debug(`[Icon] serving ${(icons || []).map(i => '`' + collectionName + ':' + i + '`').join(',')} from bundled collection`)
34+
console.debug(`[Icon] serving ${(icons || []).map(i => '`' + collectionName + ':' + i + '`').join(',')} from bundled collection`)
3635
return data
3736
}
3837
}
3938
else if (import.meta.dev) {
4039
// Warn only once per collection, and only with the default endpoint
4140
if (collectionName && !warnOnceSet.has(collectionName) && apiEndPoint === DEFAULT_ENDPOINT) {
42-
consola.warn([
41+
console.warn([
4342
`[Icon] Collection \`${collectionName}\` is not found locally`,
4443
`We suggest to install it via \`npm i -D @iconify-json/${collectionName}\` to provide the best end-user experience.`,
4544
].join('\n'))
@@ -49,7 +48,7 @@ export default defineCachedEventHandler(async (event: H3Event) => {
4948

5049
if (options.fallbackToApi === true || options.fallbackToApi === 'server-only') {
5150
const apiUrl = new URL('./' + basename(url.pathname) + url.search, apiEndPoint)
52-
consola.debug(`[Icon] fetching ${(icons || []).map(i => '`' + collectionName + ':' + i + '`').join(',')} from iconify api`)
51+
console.debug(`[Icon] fetching ${(icons || []).map(i => '`' + collectionName + ':' + i + '`').join(',')} from iconify api`)
5352
if (apiUrl.host !== new URL(apiEndPoint).host) {
5453
return createError({ status: 400, message: 'Invalid icon request' })
5554
}

0 commit comments

Comments
 (0)
Please sign in to comment.