fix: workspace-relative openInEditor paths resolve against cwd and double the package prefix in monorepos
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- nuxtjs, typescript
- Lĩnh vực
- developer-experience, tooling
Hướng nghiên cứu
Start at the openInEditor entry point described in the issue and inspect how process.cwd(), nuxt.options.workspaceDir, and the existsSync check are used before openInEditorHooks. Reproduce with a pnpm workspace app under apps/web on Windows, then verify that the workspace-relative path opens the expected file and hooks are not blocked by an early failure.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
🐛 The bug
In a pnpm monorepo, Component Inspector → Open in Editor fails with a doubled package path:
File not found: <repo>/apps/web/apps/web/app/features/.../SomeComponent.vue
Expected file:
<repo>/apps/web/app/features/.../SomeComponent.vue
(Same pattern for any package under apps/<name>/, e.g. previously apps/app → apps/app/apps/app/....)
Why
openInEditor resolves non-absolute paths with process.cwd() (the Nuxt package root, e.g. apps/web):
if (input.startsWith("./") || !ABSOLUTE_PATH_RE.test(input))
input = resolve(process.cwd(), input)
The inspector often sends a workspace-relative path like:
apps/web/app/features/.../SomeComponent.vue
So:
cwd (= …/apps/web) + apps/web/app/... → …/apps/web/apps/web/app/...
existsSync then fails and returns before openInEditorHooks run, so hooks cannot fix the path.
Nuxt already exposes nuxt.options.workspaceDir for monorepos, but it is not used here.
🛠️ To reproduce
pnpm monorepo with Nuxt at apps/web → pnpm --filter dev (cwd=apps/web) → Component Inspector → Open in Editor → File not found with doubled apps/web/apps/web/...
🌈 Expected behavior
Resolve relative open-in-editor paths against nuxt.options.workspaceDir (and/or try cwd → rootDir → workspaceDir and pick the first path that exists), then open the file.
Ideally openInEditorHooks should also run (or path normalization should happen) before the hard existsSync failure, so consumers can fix monorepo paths.
ℹ️ Additional context
Detailed reproduction
- pnpm workspace with Nuxt app at
apps/web(not repo root). - Run
pnpm --filter <app> devsoprocess.cwd()isapps/web. - Enable Component Inspector, click a component, Open in Editor.
- Observe
File not found: …/apps/web/apps/web/app/....
Minimal layout:
repo/
pnpm-workspace.yaml # packages: ['apps/*']
apps/
web/ # Nuxt app (cwd when running nuxt dev)
app/
components/
Foo.vue
Environment
- Nuxt:
4.5.x @nuxt/devtools:3.4.x(via Nuxt)- Package manager: pnpm workspace
- OS: Windows 10/11
Workaround
Local Nuxt module wrapping the DevTools RPC openInEditor to rewrite the path (try cwd / rootDir / workspaceDir + undouble apps/<pkg>/apps/<pkg>/…) before calling the original handler.
Also set:
// nuxt.config.ts
workspaceDir: fileURLToPath(new URL('../..', import.meta.url)), // monorepo root
Related
- Possibly related UX issues with inspector → editor: https://github.com/nuxt/devtools/issues/862
- Vite DevTools direction: resolve against
workspaceRootfor open-in-editor
- Ngôn ngữ chính
- TypeScript
- Star
- 3.3k
- Fork
- 214
- Merge trung bình
- 19 giờ 45 phút
- Pull request đã merge (30 ngày)
- 12
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của nuxt/devtools
-
fix: Inspect panel styles break when host page sets a custom html font-size (rem-based units) Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
feat: Nuxt devtools for AI Đang mởenhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
bug needs reproduction
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
Tất cả issue của nuxt/devtools
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
bcgov/bc-wallet-mobile#4761 · 1 bình luận ·
-
external-issue to-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
area-deployment area-integrations triage:bot-seen
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 86/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100