Skip to content

Commit 9f35895

Browse files
committed
dx: suppress duplicate imports warning
1 parent fd3aaec commit 9f35895

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

playground/nuxt.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ export default defineNuxtConfig({
33
devtools: { enabled: true },
44
compatibilityDate: '2025-05-13',
55
nuxtifyPages: {
6+
// Logs
7+
verboseLogs: true,
8+
69
// Brand
710
brand: {
811
tagline: 'This is a sample tagline for the pages module.',

src/module.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ export default defineNuxtModule<ModuleOptions>({
7171
})
7272

7373
// Modules
74-
await installModule('@nuxtify/core')
74+
await installModule('@nuxtify/core', {
75+
verboseLogs: _options.verboseLogs,
76+
})
7577

7678
// Layouts
7779
addLayout({
@@ -105,5 +107,22 @@ export default defineNuxtModule<ModuleOptions>({
105107
file: resolver.resolve('./runtime/pages/DynamicSlug.vue'),
106108
})
107109
})
110+
111+
// Remove duplicate imports (to suppress Nuxt warnings)
112+
_nuxt.hook('imports:extend', (imports) => {
113+
// Find and remove the 'useNuxtifyConfig' import that comes from '@nuxtify/core'
114+
const coreImportIndex = imports.findIndex(
115+
(imp) => {
116+
// The 'name' property refers to the exported name of the composable.
117+
// The 'from' property is the path to the source file.
118+
return (imp.as || imp.name) === 'useNuxtifyConfig' && imp.from.includes('@nuxtify/core')
119+
},
120+
)
121+
122+
if (coreImportIndex > -1) {
123+
imports.splice(coreImportIndex, 1)
124+
if (_options.verboseLogs) console.log('[nuxtify-pages] Intentionally overriding useNuxtifyConfig from @nuxtify/core.')
125+
}
126+
})
108127
},
109128
})

0 commit comments

Comments
 (0)