diff --git a/.playground/server/tsconfig.json b/.playground/server/tsconfig.json new file mode 100644 index 00000000..2413cb4d --- /dev/null +++ b/.playground/server/tsconfig.json @@ -0,0 +1,4 @@ +{ + // https://v3.nuxtjs.org/concepts/typescript + "extends": "../.nuxt/tsconfig.server.json" +} diff --git a/src/module.ts b/src/module.ts index 23259dab..d690b42e 100644 --- a/src/module.ts +++ b/src/module.ts @@ -1,6 +1,7 @@ import { addPrerenderRoutes, addServerHandler, + addServerImports, addServerPlugin, createResolver, defineNuxtModule, @@ -514,7 +515,7 @@ declare module 'nitropack' { if (!config.inferStaticPagesAsRoutes) config.excludeAppSources = true - const composable: typeof nuxt.options.imports.imports = [ + const imports: typeof nuxt.options.imports.imports = [ { from: resolve('./runtime/composables/defineSitemapEventHandler'), name: 'defineSitemapEventHandler', @@ -524,21 +525,13 @@ declare module 'nitropack' { name: 'defineSitemapUrls', }, ] - // technically this shouldn't be used in Nuxt but we may need the types here - nuxt.options.imports.imports = nuxt.options.imports.imports || [] - nuxt.options.imports.imports.push(...composable) + addServerImports(imports) // we may not have pages const pagesPromise = createPagesPromise() const nitroPromise = createNitroPromise() let resolvedConfigUrls = false nuxt.hooks.hook('nitro:config', (nitroConfig) => { - if (nitroConfig.imports !== false) { - nitroConfig.imports = nitroConfig.imports || {} - nitroConfig.imports.imports = nitroConfig.imports.imports || [] - nitroConfig.imports.imports.push(...composable) - } - nitroConfig.virtual!['#nuxt-simple-sitemap/global-sources.mjs'] = async () => { const { prerenderUrls, routeRules } = generateExtraRoutesFromNuxtConfig() const prerenderUrlsFinal = [ diff --git a/src/runtime/composables/defineSitemapEventHandler.ts b/src/runtime/composables/defineSitemapEventHandler.ts index 2d7299a4..c01039f2 100644 --- a/src/runtime/composables/defineSitemapEventHandler.ts +++ b/src/runtime/composables/defineSitemapEventHandler.ts @@ -2,12 +2,3 @@ import { type EventHandlerRequest, type EventHandlerResponse, defineEventHandler import type { SitemapUrlInput } from '../types' export const defineSitemapEventHandler: typeof defineEventHandler> = defineEventHandler - -export default defineSitemapEventHandler(() => { - return [ - { - broken: 'test', - loc: '/test', - }, - ] -})