Skip to content

fix: resolve runtime imports in projects under a path with spaces or non-ASCII characters - #806

Merged
danielroe merged 1 commit into
nuxt:mainfrom
smotim:fix/runtime-externals-encoded-path
Nov 10, 2026
Merged

danielroe merged 1 commit into
nuxt:mainfrom
smotim:fix/runtime-externals-encoded-path

Conversation

@smotim

@smotim smotim commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Description

nuxt-module-build build fails when the module lives under a path with a space or a non-ASCII character (~/My Modules/…, ~/Документы/…): rollup cannot resolve the runtime imports of module.ts and the type build stops with Cannot find module …/src/runtime/…, so module.d.mts and types.d.mts are never written.

The runtime-externals plugin swaps the source directory for the output directory on a file URL:

pathToFileURL(normalizedId).href.replace(entry.input, entry.outDir)

href percent-encodes spaces and non-ASCII characters while entry.input is a plain path, so nothing is replaced, and the import keeps pointing at src/runtime/… without an extension. The fix swaps the directories on the path first and converts to a URL afterwards.

The new test builds a copy of the example under .temp-example with spaces ü. It fails without the change and passes with it; the existing tests already fail before the change when the repository itself is checked out under such a path.

@smotim
smotim requested a review from danielroe as a code owner October 27, 2026 18:15
@pkg-pr-new

pkg-pr-new Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/module-builder@806

commit: 5b8931d

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 07d5ba11-5847-41e2-ad54-548acb75662c
Commits

Reviewing files that changed from the base of the PR and between 11d2b8e and 5b8931d.

Files selected for processing: 1
  • src/commands/build.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

Walkthrough

The runtime external resolver now substitutes entry.input with entry.outDir in the filesystem path before converting it to a file URL. The build tests add an example path containing spaces and a non-ASCII character, prepare and pre-pack it, and check that its generated declaration includes the .js runtime import extension.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~8 minutes

Merge Risk: Minimal · up to 5b893

No actionable correctness or availability risk remains in this change.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title names the main change: runtime import resolution fails under paths with spaces or non-ASCII characters, and the fix addresses that. It is a conventional fix-prefixed, single-sentence title t…
Description check Passed The description explains the failure (nuxt-module-build build under paths with spaces or non-ASCII characters), gives the cause (the runtime-externals plugin replaces the directory after URL percent-e…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within survi…
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.
Full details: Title check

Explanation

The title names the main change: runtime import resolution fails under paths with spaces or non-ASCII characters, and the fix addresses that. It is a conventional fix-prefixed, single-sentence title that a teammate scanning history can understand. It is slightly long at 89 characters, but it stays specific.

Full details: Description check

Explanation

The description explains the failure (nuxt-module-build build under paths with spaces or non-ASCII characters), gives the cause (the runtime-externals plugin replaces the directory after URL percent-encoding), describes the fix (swap directories on the path before converting to a URL), and mentions the new test. It is directly related to the changeset.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/commands/build.ts

Parsing error: Unexpected token {

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.

@smotim
smotim force-pushed the fix/runtime-externals-encoded-path branch from 11d2b8e to 5b8931d Compare October 27, 2026 18:36
@danielroe
danielroe merged commit 40f18bc into nuxt:main Nov 10, 2026
9 checks passed
This was referenced Nov 10, 2026
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.

2 participants