Skip to content

fix(nitro): normalize module paths for windows virtual modules#348

Merged
HugoRCD merged 1 commit into
mainfrom
EVL-168
May 21, 2026
Merged

fix(nitro): normalize module paths for windows virtual modules#348
HugoRCD merged 1 commit into
mainfrom
EVL-168

Conversation

@HugoRCD
Copy link
Copy Markdown
Owner

@HugoRCD HugoRCD commented May 21, 2026

🔗 Linked issue

📚 Description

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Summary by CodeRabbit

  • Bug Fixes

    • Resolved Windows module resolution errors in Nitro integration that caused "Cannot find module" failures by normalizing internal path separators.
  • Tests

    • Added regression tests validating that Nitro module virtual import paths are properly generated on Windows for both v2 and v3 implementations.

Review Change Stack

@HugoRCD HugoRCD self-assigned this May 21, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
evlog-docs Ready Ready Preview, Comment, Open in v0 May 21, 2026 7:33pm
just-use-evlog Ready Ready Preview, Comment May 21, 2026 7:33pm

@github-actions github-actions Bot added the bug Something isn't working label May 21, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

Thank you for following the naming conventions! 🙏

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

📝 Walkthrough

Walkthrough

The PR fixes Windows module resolution failures in Nitro v2 and v3 integration by normalizing file paths to POSIX forward slashes before passing them to Nitro's options.plugins and options.errorHandler. This prevents Windows backslashes from being misinterpreted as escape sequences in Nitro's virtual module string literals. Regression tests validate both module versions, and a changeset documents the patch.

Changes

Windows Nitro Module Path Normalization

Layer / File(s) Summary
Nitro v3 module path normalization
packages/evlog/src/nitro-v3/module.ts
Introduces resolveModulePath() helper function that resolves paths relative to the module directory and replaces backslashes with forward slashes. The evlog() setup integrates this helper when registering plugin and errorHandler paths to prevent Nitro escape-sequence issues.
Nitro v2 module path normalization
packages/evlog/src/nitro/module.ts
Applies the same resolveModulePath() normalization approach to the Nitro v2 module, ensuring both plugin and errorHandler path registration use POSIX separators on Windows.
Path normalization regression test
packages/evlog/test/nitro/module-paths.test.ts
Vitest test suite stubs Nitro options and verifies that both v2 and v3 setup() methods produce virtual plugin and errorHandler paths using forward slashes, with no backslashes, accounting for shape differences between versions.
Release notes
.changeset/fix-windows-nitro-module-paths.md
Changeset entry documenting the Windows-specific path normalization fix for the evlog package.

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description only contains the template boilerplate with no actual content filled in—no linked issue, no detailed explanation of why the change was needed, and no checklist items checked. Add a detailed description explaining the Windows backslash issue with Nitro virtual modules, link any related issue (e.g., EVL-168), and check applicable checklist items.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main fix: normalizing module paths for Windows virtual modules in the Nitro plugin, which aligns perfectly with all file changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch EVL-168

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

@github-actions
Copy link
Copy Markdown
Contributor

Benchmark report

Bundle size

Threshold: 5% · 🔴 larger · 🟡 warning · 🟢 smaller · ⚪ unchanged · 🆕 new

Status Entry Base (gzip) Current (gzip) Change Raw delta
framework/express 727 B 739 B +1.7% +49 B
framework/nitro 7.16 kB 7.23 kB +0.9% +196 B
framework/nestjs 1.25 kB 1.26 kB +0.4% +41 B
toolkit 781 B 783 B +0.3% 0 B
adapter/better-stack 1.26 kB 1.26 kB +0.2% 0 B
framework/fastify 1.02 kB 1.02 kB +0.2% 0 B
framework/hono 615 B 616 B +0.2% 0 B
adapter/posthog 1.47 kB 1.47 kB +0.1% 0 B
adapter/axiom 1.50 kB 1.50 kB +0.1% 0 B
adapter/datadog 2.48 kB 2.48 kB +0.1% 0 B
adapter/otlp 2.14 kB 2.14 kB +0.1% 0 B
core (index) 2.15 kB 2.16 kB +0.1% 0 B
adapter/hyperdx 1.18 kB 1.18 kB +0.1% 0 B
workers 1.30 kB 1.31 kB +0.1% 0 B
framework/sveltekit 1.59 kB 1.59 kB +0.1% 0 B
framework/next 5.20 kB 5.20 kB +0.0% 0 B
framework/ai 4.67 kB 4.67 kB 0.0% 0 B
adapter/fs 3.35 kB 3.35 kB 0.0% 0 B
adapter/sentry 2.40 kB 2.40 kB 0.0% 0 B
framework/vite 2.40 kB 2.40 kB 0.0% 0 B
enrichers 1.99 kB 1.99 kB 0.0% 0 B
utils 1.58 kB 1.58 kB 0.0% 0 B
error 1.57 kB 1.57 kB 0.0% 0 B
pipeline 1.35 kB 1.35 kB 0.0% 0 B
framework/elysia 1.33 kB 1.33 kB 0.0% 0 B
http 1.24 kB 1.24 kB 0.0% 0 B
browser 289 B 289 B 0.0% 0 B
client 128 B 128 B 0.0% 0 B
types 31 B 31 B 0.0% 0 B
logger 229 B 225 B -1.7% 0 B
Total 54.33 kB 54.43 kB +0.2% +286 B

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/evlog/test/nitro/module-paths.test.ts`:
- Around line 13-22: The test currently reimplements the helper makeNitroStub;
move that helper into the shared test/helpers directory as a named export (e.g.,
export function makeNitroStub()) and update this test to import { makeNitroStub
} from the test/helpers module instead of defining it inline; ensure the
exported helper returns the same shape (options.plugins, options.errorHandler,
options.noExternals, options.runtimeConfig) so existing tests using
makeNitroStub() continue to work and update any other tests to import the shared
helper rather than reimplementing it.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 70f02a56-cac9-4ae8-8846-c5d7abccc8f9

📥 Commits

Reviewing files that changed from the base of the PR and between 39e4a29 and 7def622.

📒 Files selected for processing (4)
  • .changeset/fix-windows-nitro-module-paths.md
  • packages/evlog/src/nitro-v3/module.ts
  • packages/evlog/src/nitro/module.ts
  • packages/evlog/test/nitro/module-paths.test.ts

Comment on lines +13 to +22
function makeNitroStub() {
return {
options: {
plugins: [] as string[],
errorHandler: undefined as string | string[] | undefined,
noExternals: undefined as undefined | true | string[],
runtimeConfig: {} as Record<string, unknown>,
},
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Move makeNitroStub() into test/helpers/ and import it here.

This test re-implements a helper inline, which violates the test helper policy and makes reuse harder across Nitro tests.

As per coding guidelines, "Always import real source helpers in tests, never re-implement them in tests." and "Use the helpers in test/helpers/ (drain spies, fake timers, fetch mock, framework matrix) in tests."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/evlog/test/nitro/module-paths.test.ts` around lines 13 - 22, The
test currently reimplements the helper makeNitroStub; move that helper into the
shared test/helpers directory as a named export (e.g., export function
makeNitroStub()) and update this test to import { makeNitroStub } from the
test/helpers module instead of defining it inline; ensure the exported helper
returns the same shape (options.plugins, options.errorHandler,
options.noExternals, options.runtimeConfig) so existing tests using
makeNitroStub() continue to work and update any other tests to import the shared
helper rather than reimplementing it.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 21, 2026

npm i https://pkg.pr.new/evlog@348
npm i https://pkg.pr.new/@evlog/nuxthub@348

commit: 7def622

@HugoRCD HugoRCD merged commit 6d4d87c into main May 21, 2026
21 checks passed
@HugoRCD HugoRCD deleted the EVL-168 branch May 21, 2026 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant