@@ -246,28 +246,31 @@ export default defineNuxtModule<ModuleOptions>({
246
246
}
247
247
}
248
248
249
- let needsRobotsPolyfill = true
250
- const robotsModuleName = [ 'nuxt-simple-robots' , '@nuxtjs/robots' ] . find ( s => hasNuxtModule ( s ) )
251
- if ( robotsModuleName ) {
252
- const robotsVersion = await getNuxtModuleVersion ( robotsModuleName )
253
- // we want to keep versions in sync
254
- if ( ! await hasNuxtModuleCompatibility ( robotsModuleName , '>=4' ) )
255
- logger . warn ( `You are using ${ robotsModuleName } v${ robotsVersion } . For the best compatibility, please upgrade to ${ robotsModuleName } v4.0.0 or higher.` )
256
- else
257
- needsRobotsPolyfill = false
258
- // @ts -expect-error untyped
259
- nuxt . hooks . hook ( 'robots:config' , ( robotsConfig ) => {
260
- robotsConfig . sitemap . push ( usingMultiSitemaps ? '/sitemap_index.xml' : `/${ config . sitemapName } ` )
261
- } )
262
- }
263
- // this is added in v4 of Nuxt Robots
264
- if ( needsRobotsPolyfill ) {
265
- addServerImports ( [ {
266
- name : 'getPathRobotConfigPolyfill' ,
267
- as : 'getPathRobotConfig' ,
268
- from : resolve ( './runtime/nitro/composables/getPathRobotConfigPolyfill' ) ,
269
- } ] )
270
- }
249
+ // @ts -expect-error untyped
250
+ nuxt . hooks . hook ( 'robots:config' , ( robotsConfig ) => {
251
+ robotsConfig . sitemap . push ( usingMultiSitemaps ? '/sitemap_index.xml' : `/${ config . sitemapName } ` )
252
+ } )
253
+ // avoid issues with module order
254
+ nuxt . hooks . hook ( 'modules:done' , async ( ) => {
255
+ const robotsModuleName = [ 'nuxt-simple-robots' , '@nuxtjs/robots' ] . find ( s => hasNuxtModule ( s ) )
256
+ let needsRobotsPolyfill = true
257
+ if ( robotsModuleName ) {
258
+ const robotsVersion = await getNuxtModuleVersion ( robotsModuleName )
259
+ // we want to keep versions in sync
260
+ if ( ! await hasNuxtModuleCompatibility ( robotsModuleName , '>=4' ) )
261
+ logger . warn ( `You are using ${ robotsModuleName } v${ robotsVersion } . For the best compatibility, please upgrade to ${ robotsModuleName } v4.0.0 or higher.` )
262
+ else
263
+ needsRobotsPolyfill = false
264
+ }
265
+ // this is added in v4 of Nuxt Robots
266
+ if ( needsRobotsPolyfill ) {
267
+ addServerImports ( [ {
268
+ name : 'getPathRobotConfigPolyfill' ,
269
+ as : 'getPathRobotConfig' ,
270
+ from : resolve ( './runtime/nitro/composables/getPathRobotConfigPolyfill' ) ,
271
+ } ] )
272
+ }
273
+ } )
271
274
272
275
extendTypes ( name ! , async ( { typesPath } ) => {
273
276
return `
0 commit comments