Skip to content

fix: fix runtime path in typescript config#750

Open
dword-design wants to merge 4 commits into
nuxt:mainfrom
dword-design:fix-runtime-path-typescript-config
Open

fix: fix runtime path in typescript config#750
dword-design wants to merge 4 commits into
nuxt:mainfrom
dword-design:fix-runtime-path-typescript-config

Conversation

@dword-design
Copy link
Copy Markdown

@dword-design dword-design commented Jun 4, 2026

🔗 Linked issue

resolves #749

📚 Description

Looks like this is fixing the path in TypeScript and the build command still works. Tests are failing but they are also failing for me without the change. I added a test for that use case that runs through.

I'm not sure if we need to convert slashes when matching the path in the test since I'm usually using node:path, which uses OS-specific slashes.

@dword-design dword-design requested a review from danielroe as a code owner June 4, 2026 03:37
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 4, 2026

Open in StackBlitz

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

commit: 20eeca7

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a53e74a7-f79b-4c9d-9e97-6847dbb0e26d

📥 Commits

Reviewing files that changed from the base of the PR and between 839e401 and 20eeca7.

📒 Files selected for processing (2)
  • example/src/runtime/server/plugins/plugin.ts
  • test/prepare.spec.ts
✅ Files skipped from review due to trivial changes (1)
  • example/src/runtime/server/plugins/plugin.ts

📝 Walkthrough

Walkthrough

This PR changes the Nuxt module override in the prepare command to resolve the module path from ./src (was ./src/module) and adds a Vitest integration that runs pnpm nuxt-module-build prepare in a temp workspace and asserts the generated .nuxt/tsconfig.server.json includes a ../src/runtime include entry.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: fix runtime path in typescript config' directly addresses the main change in the PR, which fixes the runtime path resolution from './src/module' to './src' in the TypeScript configuration.
Description check ✅ Passed The description is related to the changeset, mentioning the path fix works and including a test case. It references the linked issue (#749) and explains the author's uncertainty about path normalization.
Linked Issues check ✅ Passed The PR addresses issue #749 by fixing the path in the TypeScript configuration from 'src/module/runtime' to 'src/runtime', resolving the documented conflict between the README and TypeScript config folder structure references.
Out of Scope Changes check ✅ Passed All changes are in scope: the path fix in prepare.ts, the test for the use case in prepare.spec.ts, and the example plugin file creation directly support resolving issue #749.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

Copy link
Copy Markdown

@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: 2

🤖 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 `@test/prepare.spec.ts`:
- Around line 17-19: Indentation in test/prepare.spec.ts is inconsistent around
the await exec(...) call and the nested options/object and test blocks; fix by
aligning the nested object properties and nested blocks to the project's lint
style (e.g., two-space indentation) so the await exec('pnpm',
['nuxt-module-build', 'prepare', prepareRootDir], { nodeOptions: { cwd:
workspaceDir }, }) call and surrounding test/describe/it blocks (the code
referencing exec, nodeOptions, cwd, workspaceDir) have consistent indentation
for each nested level; update lines around the exec call and the nearby lines
27–31 so nested braces and array elements line up with the same indent depth.
- Around line 9-10: The prepareRootDir calculation is using string replace on
exampleDir which can alter unrelated parts of the path; change it to derive the
temp workspace from the parent directory instead: compute the parent dir (e.g.
via path.dirname(exampleDir) or new URL('../', exampleDir) semantics) and then
build prepareRootDir by joining that parent with '.temp-example-prepare'
(referencing the existing exampleDir and prepareRootDir identifiers so you
replace the replace(...) expression with a dirname + path.join/URL-based sibling
path).
🪄 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: CHILL

Plan: Pro

Run ID: 1c03822f-e5ed-490b-bda4-0904cd2bc9b9

📥 Commits

Reviewing files that changed from the base of the PR and between 677fa40 and 839e401.

📒 Files selected for processing (1)
  • test/prepare.spec.ts

Comment thread test/prepare.spec.ts
Comment on lines +9 to +10
const exampleDir = fileURLToPath(new URL('../example', import.meta.url))
const prepareRootDir = exampleDir.replace('example', '.temp-example-prepare')
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Derive the temp workspace from the parent directory, not a string replace.

exampleDir.replace('example', '.temp-example-prepare') rewrites the first example anywhere in the absolute path. On a checkout path like /tmp/example-repos/module-builder/example, this points to /tmp/.temp-example-prepare-repos/module-builder/example, so the test copies and prepares the wrong directory. Build the sibling path from dirname(exampleDir) instead.

Proposed fix
 const workspaceDir = fileURLToPath(new URL('..', import.meta.url))
 const exampleDir = fileURLToPath(new URL('../example', import.meta.url))
-const prepareRootDir = exampleDir.replace('example', '.temp-example-prepare')
+const prepareRootDir = join(dirname(exampleDir), '.temp-example-prepare')
🤖 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 `@test/prepare.spec.ts` around lines 9 - 10, The prepareRootDir calculation is
using string replace on exampleDir which can alter unrelated parts of the path;
change it to derive the temp workspace from the parent directory instead:
compute the parent dir (e.g. via path.dirname(exampleDir) or new URL('../',
exampleDir) semantics) and then build prepareRootDir by joining that parent with
'.temp-example-prepare' (referencing the existing exampleDir and prepareRootDir
identifiers so you replace the replace(...) expression with a dirname +
path.join/URL-based sibling path).

Comment thread test/prepare.spec.ts
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.

Conflict between folder structure in readme (src/runtime) and TypeScript config (src/module/runtime)

1 participant