Skip to content

fix: resolve bundle.onlyLocales from the first layer that specifies it#4012

Open
cernymatej wants to merge 1 commit into
nuxt-modules:mainfrom
cernymatej:fix/only-locales-layers
Open

fix: resolve bundle.onlyLocales from the first layer that specifies it#4012
cernymatej wants to merge 1 commit into
nuxt-modules:mainfrom
cernymatej:fix/only-locales-layers

Conversation

@cernymatej

@cernymatej cernymatej commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

📚 Description

previously, filterLocales only read bundle.onlyLocales from the running project (_layers[0]) and ignored it entirely when a downstream layer set it

this pr makes it walk layers starting from the running project and use the first one that specifies it, which IMO is the expected behaviour

Summary by CodeRabbit

  • Bug Fixes

    • Improved locale selection logic to intelligently scan through configuration layers for the appropriate locale settings, rather than only checking the initial layer.
  • Tests

    • Added comprehensive test coverage for locale selection behavior, including edge cases and fallback scenarios.

@cernymatej cernymatej requested a review from BobbieGoede as a code owner June 22, 2026 07:48
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ceb0b4ec-cf87-4315-a901-e9580e335b9a

📥 Commits

Reviewing files that changed from the base of the PR and between bd54cb9 and 1063b58.

📒 Files selected for processing (2)
  • src/utils.ts
  • test/utils.test.ts

Walkthrough

filterLocales in src/utils.ts is updated to loop over all entries in nuxt.options._layers and select the first layer that defines a bundle.onlyLocales value, replacing the previous hardcoded read from _layers[0]. The derived include list is then used to filter ctx.options.locales as before. test/utils.test.ts adds a new filterLocales describe block with typed helper factories (createLayer, createContext, createNuxt) and multiple Vitest cases asserting layer-precedence behavior, fallback when no layer sets onlyLocales, and the edge case where an explicit empty onlyLocales array stops the search and produces no filtering.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing the resolution of bundle.onlyLocales to use the first layer that specifies it, which is the core objective of the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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