Skip to content

Commit 7fda328

Browse files
committed
fix: only use consola when debugging
1 parent bf828c1 commit 7fda328

File tree

1 file changed

+14
-11
lines changed
  • packages/schema-org/createSchemaOrg

1 file changed

+14
-11
lines changed

packages/schema-org/createSchemaOrg/index.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,21 @@ export const createSchemaOrg = (options: CreateSchemaOrgInput) => {
2929
// eslint-disable-next-line no-console
3030
let warn: ConsolaFn | ((...arg: any) => void) = (...arg: any) => { console.warn(...arg) }
3131
// opt-in to consola if available
32-
try {
33-
import('consola').then((consola) => {
34-
const logger = consola.default.withScope('@vueuse/schema-org')
35-
if (options.debug) {
36-
logger.level = 4
37-
debug = logger.debug
38-
}
39-
warn = logger.warn
40-
}).catch()
32+
if (options.debug) {
33+
try {
34+
import('consola').then((consola) => {
35+
const logger = consola.default.withScope('@vueuse/schema-org')
36+
if (options.debug) {
37+
logger.level = 4
38+
debug = logger.debug
39+
}
40+
warn = logger.warn
41+
}).catch()
42+
}
43+
// if consola is missing it's not a problem
44+
catch (e) {
45+
}
4146
}
42-
// if consola is missing it's not a problem
43-
catch (e) {}
4447

4548
if (!options.provider?.useRoute)
4649
warn('Missing useRoute implementation. Provide a `useRoute` handler, usually from `vue-router`.')

0 commit comments

Comments
 (0)