Skip to content

Commit 60decb0

Browse files
authored
fix: delay module setup until modules:done (#3501)
1 parent 9c0be23 commit 60decb0

1 file changed

Lines changed: 72 additions & 71 deletions

File tree

src/module.ts

Lines changed: 72 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -39,82 +39,83 @@ export default defineNuxtModule<NuxtI18nOptions>({
3939
await initParser()
4040

4141
/**
42-
* Prepare options
42+
* prepare options
4343
*/
4444
prepareOptions(ctx, nuxt)
4545

4646
/**
47-
* nuxt layers handling ...
47+
* allow other modules to setup first in case these use i18n hooks
4848
*/
49-
await prepareLayers(ctx, nuxt)
50-
51-
/**
52-
* setup runtime config
53-
*/
54-
// for public
55-
prepareRuntimeConfig(ctx, nuxt)
56-
57-
/**
58-
* resolve locale info and vue-i18n config path
59-
*/
60-
await resolveLocaleInfo(ctx, nuxt)
61-
62-
/**
63-
* setup nuxt/pages
64-
*/
65-
await setupPages(ctx, nuxt)
66-
67-
/**
68-
* ignore `/` during prerender when using prefixed routing
69-
*/
70-
prepareStrategy(ctx, nuxt)
71-
72-
/**
73-
* setup module alias
74-
*/
75-
setupAlias(ctx, nuxt)
76-
77-
/**
78-
* add plugin and templates
79-
*/
80-
prepareRuntime(ctx, nuxt)
81-
82-
/**
83-
* generate vue-i18n and messages types using runtime server endpoint
84-
*/
85-
await prepareTypeGeneration(ctx, nuxt)
86-
87-
/**
88-
* disable preloading/prefetching lazy loaded locales
89-
*/
90-
prepareBuildManifest(ctx, nuxt)
91-
92-
/**
93-
* extend bundler
94-
*/
95-
96-
await extendBundler(ctx, nuxt)
97-
98-
/**
99-
* setup nitro
100-
*/
101-
102-
await setupNitro(ctx, nuxt)
103-
104-
/**
105-
* auto imports
106-
*/
107-
prepareAutoImports(ctx, nuxt)
108-
109-
/**
110-
* transpile @nuxtjs/i18n
111-
*/
112-
prepareTranspile(nuxt)
113-
114-
/**
115-
* Optimize deps
116-
*/
117-
prepareVite(nuxt)
49+
nuxt.hook('modules:done', async () => {
50+
/**
51+
* nuxt layers handling ...
52+
*/
53+
await prepareLayers(ctx, nuxt)
54+
/**
55+
* setup runtime config
56+
*/
57+
prepareRuntimeConfig(ctx, nuxt)
58+
59+
/**
60+
* resolve locale info and vue-i18n config path
61+
*/
62+
await resolveLocaleInfo(ctx, nuxt)
63+
64+
/**
65+
* setup nuxt/pages
66+
*/
67+
await setupPages(ctx, nuxt)
68+
69+
/**
70+
* ignore `/` during prerender when using prefixed routing
71+
*/
72+
prepareStrategy(ctx, nuxt)
73+
74+
/**
75+
* setup module alias
76+
*/
77+
setupAlias(ctx, nuxt)
78+
79+
/**
80+
* add plugin and templates
81+
*/
82+
prepareRuntime(ctx, nuxt)
83+
84+
/**
85+
* generate vue-i18n and messages types using runtime server endpoint
86+
*/
87+
await prepareTypeGeneration(ctx, nuxt)
88+
89+
/**
90+
* disable preloading/prefetching lazy loaded locales
91+
*/
92+
prepareBuildManifest(ctx, nuxt)
93+
94+
/**
95+
* extend bundler
96+
*/
97+
await extendBundler(ctx, nuxt)
98+
99+
/**
100+
* setup nitro
101+
*/
102+
await setupNitro(ctx, nuxt)
103+
104+
/**
105+
* auto imports
106+
*/
107+
prepareAutoImports(ctx, nuxt)
108+
109+
/**
110+
* transpile @nuxtjs/i18n
111+
*/
112+
prepareTranspile(nuxt)
113+
114+
/**
115+
* optimize deps
116+
*/
117+
prepareVite(nuxt)
118+
})
118119
}
119120
})
120121

0 commit comments

Comments
 (0)