Skip to content

fix: honour excludeAppSources added after setup - #660

Merged
harlan-zw merged 1 commit into
mainfrom
fix/late-exclude-app-sources
Aug 16, 2026
Merged

fix: honour excludeAppSources added after setup#660
harlan-zw merged 1 commit into
mainfrom
fix/late-exclude-app-sources

Conversation

@harlan-zw

Copy link
Copy Markdown
Collaborator

🔗 Linked issue

❓ Type of change

  • 🐞 Bug fix (a non-breaking change that fixes an issue)

📚 Description

excludeAppSources is silently ignored for any module that loads after this one.

defineNuxtModule resolves each module's options with defu(inlineOptions, nuxtConfigOptions, optionsDefaults) and never writes the result back to nuxt.options[configKey], so the config we get in setup is a detached copy. A module loading later can only reach nuxt.options.sitemap, and by then we have already captured our own object. Its entries never reach the filter in generateGlobalSources.

Hit this with @harlan-zw/comark-content, which replaces @nuxt/content and so wants the @nuxt/content@v3:urls source gone. It does the documented thing and adds the exclusion in its setup(), but the site lists @nuxtjs/seo before it, so the source stayed. That source has a fetch to /__sitemap__/nuxt-content-urls.json, which no longer had a handler once @nuxt/content was uninstalled, and the 404 took the whole prerendered /sitemap.xml down:

[error] [request error] [fatal] [GET] http://localhost/__sitemap__/nuxt-content-urls.json
Page not found: /__sitemap__/nuxt-content-urls.json
[error] [@nuxt/sitemap] Failed to fetch source. { url: '/__sitemap__/nuxt-content-urls.json' }

Errors prerendering:
  ├─ /sitemap.xml (2936ms)
  │ └── [500] Server Error

generateGlobalSources is a closure invoked lazily, well after every module has set up, so it can just read the authored list again at that point and union it with the resolved one. Order stops mattering.

Kept narrow on purpose: only ever adds exclusions, and a non-array authored value is ignored rather than replacing what we resolved.

The e2e covers it end to end. It registers a module after @nuxtjs/sitemap that appends nuxt:pages to nuxt.options.sitemap.excludeAppSources, and asserts a static page file is gone from the output. It fails on main with expected '<?xml version="1.0"...' not to contain '/about'.

📚 Additional context

Worth deciding whether the @nuxt/content integration should register its fetch source at all when the package is not installed. On the site that hit this, @nuxt/content is removed from package.json and the Vercel install log shows it being pruned, yet the source is still registered there. I could not reproduce that half locally, so I have not touched the detection.

🤖 AI disclosure: Harlan Agent Kit modified this description. My AI open-source policy.

`defineNuxtModule` builds each module's options with `defu(...)` and never
writes the result back to `nuxt.options`, so the config this module resolves
during setup is detached from `nuxt.options.sitemap`. A module that loads
later can only reach `nuxt.options.sitemap`, and its `excludeAppSources`
entries were silently dropped.

App sources are generated lazily, long after every module has set up, so
read the authored list again at that point and union it with the resolved
one. Excluding an app source now works regardless of module order.
@pkg-pr-new

pkg-pr-new Bot commented Aug 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nuxtjs/sitemap@660

commit: 5cf2a0f

@github-actions

Copy link
Copy Markdown

📦 Package Size

⚠️ 2 size metrics grew

Package output Gzipped Δ
@nuxtjs/sitemap · export . 13 kB → 13 kB 🔴 +154 B (+1.2%)
@nuxtjs/sitemap · published payload 53 kB → 53 kB 🔴 +154 B (+0.3%)
All tracked output (11)
Package output Gzipped Raw
@nuxtjs/sitemap · dependency nuxt-site-config 9.8 kB 24 kB
@nuxtjs/sitemap · dependency nuxtseo-shared 20 kB 65 kB
@nuxtjs/sitemap · dependency radix3 4.3 kB 16 kB
@nuxtjs/sitemap · dependency sitemapd 13 kB 55 kB
@nuxtjs/sitemap · export . 13 kB 55 kB 🔴
@nuxtjs/sitemap · export ./content 1.3 kB 4.3 kB
@nuxtjs/sitemap · export ./utils 2.3 kB 8.4 kB
@nuxtjs/sitemap · published payload 53 kB 181 kB 🔴
@nuxtjs/sitemap · server runtime 31 kB 98 kB
sitemapd · dependency fast-xml-parser 122 kB 383 kB
sitemapd · published payload 13 kB 55 kB
Runtime dependencies (13)
Package Dependency Requested Resolved Cost
@nuxtjs/sitemap @nuxt/kit ^4.5.2 4.5.2 ♻️ free via Nuxt 4.5.2
@nuxtjs/sitemap consola ^3.4.2 3.4.2 ♻️ free via Nuxt 4.5.2
@nuxtjs/sitemap defu ^6.1.7 6.1.7 ♻️ free via Nuxt 4.5.2
@nuxtjs/sitemap nuxt-site-config ^4.2.0 4.2.0 📦 9.8 kB gzip
@nuxtjs/sitemap nuxtseo-shared ^5.3.11 5.3.11 📦 20 kB gzip
@nuxtjs/sitemap ofetch ^1.5.1 1.5.1 ♻️ free via Nuxt 4.5.2
@nuxtjs/sitemap pathe ^2.0.3 2.0.3 ♻️ free via Nuxt 4.5.2
@nuxtjs/sitemap pkg-types ^2.3.1 2.3.1 ♻️ free via Nuxt 4.5.2
@nuxtjs/sitemap radix3 ^1.1.2 1.1.2 📦 4.3 kB gzip
@nuxtjs/sitemap sitemapd workspace:^ 0.2.2 📦 13 kB gzip
@nuxtjs/sitemap ufo ^1.6.4 1.6.4 ♻️ free via Nuxt 4.5.2
@nuxtjs/sitemap ultrahtml ^1.7.0 1.7.0 ♻️ free via Nuxt 4.5.2
sitemapd fast-xml-parser ^5.10.1 5.10.1 📦 122 kB gzip

Baseline: main_@_e37a2ca___2026-08-10 · gzip is the comparison metric · changes below 16 B gzip are ignored

@harlan-zw

harlan-zw commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator Author

🤖 READY · 90/100

Harlan Agent Kit posted this automated review. It is not Harlan's personal review or approval. AI open source policy. Human merge decision still required.

▓▓▓▓▓ 100%

@harlan-zw
harlan-zw merged commit be9309d into main Aug 16, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant