fix: honour excludeAppSources added after setup - #660
Merged
Conversation
`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.
commit: |
📦 Package Size
All tracked output (11)
Runtime dependencies (13)
Baseline: main_@_e37a2ca___2026-08-10 · gzip is the comparison metric · changes below 16 B gzip are ignored |
Collaborator
Author
🤖 READY · 90/100
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Linked issue
❓ Type of change
📚 Description
excludeAppSourcesis silently ignored for any module that loads after this one.defineNuxtModuleresolves each module's options withdefu(inlineOptions, nuxtConfigOptions, optionsDefaults)and never writes the result back tonuxt.options[configKey], so theconfigwe get insetupis a detached copy. A module loading later can only reachnuxt.options.sitemap, and by then we have already captured our own object. Its entries never reach the filter ingenerateGlobalSources.Hit this with
@harlan-zw/comark-content, which replaces@nuxt/contentand so wants the@nuxt/content@v3:urlssource gone. It does the documented thing and adds the exclusion in itssetup(), but the site lists@nuxtjs/seobefore it, so the source stayed. That source has afetchto/__sitemap__/nuxt-content-urls.json, which no longer had a handler once@nuxt/contentwas uninstalled, and the 404 took the whole prerendered/sitemap.xmldown:generateGlobalSourcesis 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/sitemapthat appendsnuxt:pagestonuxt.options.sitemap.excludeAppSources, and asserts a static page file is gone from the output. It fails onmainwithexpected '<?xml version="1.0"...' not to contain '/about'.📚 Additional context
Worth deciding whether the
@nuxt/contentintegration should register itsfetchsource at all when the package is not installed. On the site that hit this,@nuxt/contentis removed frompackage.jsonand 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.