8000 fix(kit): normalize layer directory paths with trailing slashes to support dotted folder names by rywils · Pull Request #33858 · nuxt/nuxt · GitHub
[go: up one dir, main page]

Skip to content

fix(kit): normalize layer directory paths with trailing slashes to support dotted folder names#33858

Merged
danielroe merged 1 commit intonuxt:mainfrom
rywils:dotted-layer-directories
Dec 12, 2025
Merged

fix(kit): normalize layer directory paths with trailing slashes to support dotted folder names#33858
danielroe merged 1 commit intonuxt:mainfrom
rywils:dotted-layer-directories

Conversation

@rywils
Copy link
Contributor
@rywils rywils commented Dec 12, 2025

🔗 Linked issue

resolves #33855

🐞 Can't import variables from ordered layers in nuxt config #33855

Nuxt’s auto layer discovery strips the trailing slash from layers/* results.
When a layer folder contains a dot (e.g. 01.base), the resolver interprets it as a file extension instead of a directory and throws:

Cannot find module 'layers/01.base'

The change makes Nuxt always keep a trailing slash on auto-detected layer paths, so dotted folders are consistently handled as directories. Fairly simple, straight forward fix.

Cheers!

@rywils rywils requested a review from danielroe as a code owner December 12, 2025 05:17
@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@pkg-pr-new
Copy link
pkg-pr-new bot commented Dec 12, 2025

Open in StackBlitz

@nuxt/kit

npm i https://pkg.pr.new/@nuxt/kit@33858

@nuxt/nitro-server

npm i https://pkg.pr.new/@nuxt/nitro-server@33858

nuxt

npm i https://pkg.pr.new/nuxt@33858

@nuxt/rspack-builder

npm i https://pkg.pr.new/@nuxt/rspack-builder@33858

@nuxt/schema

npm i https://pkg.pr.new/@nuxt/schema@33858

@nuxt/vite-builder

npm i https://pkg.pr.new/@nuxt/vite-builder@33858

@nuxt/webpack-builder

npm i https://pkg.pr.new/@nuxt/webpack-builder@33858

commit: 21a5c0c

@coderabbitai
Copy link
Contributor
coderabbitai bot commented Dec 12, 2025

Walkthrough

This pull request modifies the loader configuration in packages/kit/src/loader/config.ts to adjust trailing slash handling for local layers. The change replaces a single import from ufo with both withTrailingSlash and withoutTrailingSlash utilities. The normalisation of localLayers switches from removing trailing slashes to explicitly enforcing them via withTrailingSlash. Conversely, the construction of localRelativePaths now removes trailing slashes from localLayers using withoutTrailingSlash, reversing the previous path comparison logic. No public API signatures are a 8000 ffected.

Possibly related PRs

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: normalizing layer directory paths with trailing slashes to support dotted folder names, which directly matches the changeset's core objective.
Description check ✅ Passed The pull request description clearly relates to the changeset, explaining the fix for layer directory path normalization with trailing slashes to support dotted folder names.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

✨ Issue Enrichment is now available for GitHub issues!

CodeRabbit can now help you manage issues more effectively:

  • Duplicate Detection — Identify similar or duplicate issues
  • Related Issues & PRs — Find relevant issues and PR's from your repository
  • Suggested Assignees — Find the best person to work on the issue
  • Implementation Planning — Generate detailed coding plans for engineers and agents
Disable automatic issue enrichment

To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

issue_enrichment:
  auto_enrich:
    enabled: false

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.

@codspeed-hq
Copy link
codspeed-hq bot commented Dec 12, 2025

CodSpeed Performance Report

Merging #33858 will improve performances by 12.17%

Comparing rywils:dotted-layer-directories (21a5c0c) with main (c1b3590)1

Summary

⚡ 1 improvement
✅ 9 untouched

Benchmarks breakdown

Benchmark BASE HEAD Change
writeTypes in the basic-types fixture 90.5 ms 80.7 ms +12.17%

Footnotes

  1. No successful run was found on main (672880b) during the generation of this report, so c1b3590 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@jd-solanki
Copy link
Contributor

I'm not sure about tests but is it possible to have test case for numbered layers directories?

Copy link
Member
@danielroe danielroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! thank you ❤️

@danielroe danielroe merged commit 7d50229 into nuxt:main Dec 12, 2025
57 checks passed
@github-actions github-actions bot mentioned this pull request Dec 12, 2025
@jd-solanki
Copy link
Contributor

Hey @danielroe

Is it possible to change order of layers via extends so we don't have to rename directories when we want to add new layer which required to be placed between existing layers.

Benefits:

  • When using template repo it doesn't break pull updates
  • When checking repo history it doesn't confuse

I would love to have this feature, Should I raise a feature request for this?

@danielroe
Copy link
Member

unfortunately that's not possible with local layers.

if you want that, move them out of the layers directory and register them with extends instead. we can't mix + match.

@rywils rywils deleted the dotted-layer-directories branch December 13, 2025 23:36
This was referenced Dec 15, 2025
@github-actions github-actions bot mentioned this pull request Jan 21, 2026
@rywils rywils restored the dotted-layer-directories branch March 14, 2026 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐞 Can't import variables from ordered layers in nuxt config

3 participants

0