Skip to content

Commit 8b1d75c

Browse files
committedNov 10, 2024··
fix(vite): dedupe @iconify/vue by default
1 parent fd46c6e commit 8b1d75c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed
 

‎src/module.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,20 @@ export default defineNuxtModule<ModuleOptions>({
5454
throw new TypeError('`customize` callback can\'t not be set in module options, use `app.config.ts` or component props instead.')
5555
}
5656

57+
// Use `server` provider when SSR is disabled or generate mode
5758
if (!options.provider) {
58-
// Use `server` provider when SSR is disabled or generate mode
5959
options.provider = (!nuxt.options.ssr || nuxt.options._generate)
6060
? 'iconify'
6161
: 'server'
6262
}
6363

64+
// In some monorepo, `@iconify/vue` might be bundled twice which does not share the loaded data
65+
nuxt.options.vite ||= {}
66+
nuxt.options.vite.resolve ||= {}
67+
nuxt.options.vite.resolve.dedupe ||= []
68+
nuxt.options.vite.resolve.dedupe.push('@iconify/vue')
69+
70+
// Create context
6471
const ctx = new NuxtIconModuleContext(nuxt, options)
6572

6673
addPlugin(
@@ -90,7 +97,6 @@ export default defineNuxtModule<ModuleOptions>({
9097
nuxt.options.appConfig.icon || {},
9198
runtimeOptions,
9299
)
93-
94100
// Define types for the app.config compatible with Nuxt Studio
95101
nuxt.hook('schema:extend', (schemas) => {
96102
schemas.push({

0 commit comments

Comments
 (0)
Please sign in to comment.