Repository navigation
feat(nuxt): make file names clickable π±οΈ - #35898
Conversation
@nuxt/kit
@nuxt/nitro-server
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Actionable comments posted: 1
π§Ή Nitpick comments (1)
packages/nuxt/test/utils.test.ts (1)
85-93: π Maintainability & Code Quality | π΅ Trivial | β‘ Quick winCover the Nuxt alias formatter.
Both cases pass
null, so thenuxt ? formatter : undefinedbranch is untested. Add a minimal Nuxt options fixture asserting an absolute file is displayed as~/...(including the optional position).π€ 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/nuxt/test/utils.test.ts` around lines 85 - 93, Add a minimal Nuxt options fixture in the linkToAlias tests and pass it to linkToAlias so the nuxt formatter branch is exercised. Assert that an absolute file path is rendered with the ~/ prefix, including the expected line and column when a position is provided.
π€ 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/nuxt/src/components/scan.ts`:
- Line 9: Update the NUXT_B3008 diagnostic path handling to use linkToAlias for
both scannedPath and expectedPath instead of resolveToAlias, matching the
clickable-path conversion already applied to NUXT_B3009, NUXT_B3010, and
NUXT_B3011.
---
Nitpick comments:
In `@packages/nuxt/test/utils.test.ts`:
- Around line 85-93: Add a minimal Nuxt options fixture in the linkToAlias tests
and pass it to linkToAlias so the nuxt formatter branch is exercised. Assert
that an absolute file path is rendered with the ~/ prefix, including the
expected line and column when a position is provided.
πͺ 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: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e3924158-a6c7-405f-9f68-535c96b967c8
β Files ignored due to path filters (3)
packages/nuxt/package.jsonis excluded by!**/package.jsonpackages/vite/package.jsonis excluded by!**/package.jsonpnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!pnpm-lock.yaml
π Files selected for processing (23)
packages/nuxt/src/compiler/module.tspackages/nuxt/src/compiler/plugins/keyed-function-factories.tspackages/nuxt/src/components/module.tspackages/nuxt/src/components/plugins/islands-transform.tspackages/nuxt/src/components/plugins/lazy-hydration-transform.tspackages/nuxt/src/components/plugins/loader.tspackages/nuxt/src/components/scan.tspackages/nuxt/src/core/app.tspackages/nuxt/src/core/external-config-files.tspackages/nuxt/src/core/nuxt.tspackages/nuxt/src/core/perf.tspackages/nuxt/src/core/plugins/plugin-metadata.tspackages/nuxt/src/core/schema.tspackages/nuxt/src/head/plugins/unhead-imports.tspackages/nuxt/src/imports/module.tspackages/nuxt/src/pages/module.tspackages/nuxt/src/pages/plugins/page-meta.tspackages/nuxt/src/pages/utils.tspackages/nuxt/src/utils.tspackages/nuxt/test/page-metadata.test.tspackages/nuxt/test/utils.test.tspackages/vite/src/plugins/optimize-deps-hint.tspnpm-workspace.yaml
|
|
||
| import { QUOTE_RE, resolveComponentNameSegments } from '../core/utils/index.ts' | ||
| import { resolveToAlias } from '../utils.ts' | ||
| import { linkToAlias, resolveToAlias } from '../utils.ts' |
There was a problem hiding this comment.
π― Functional Correctness | π‘ Minor | β‘ Quick win
Also link the NUXT_B3008 paths.
The new conversion covers NUXT_B3009, NUXT_B3010, and NUXT_B3011, but NUXT_B3008 still builds scannedPath and expectedPath with resolveToAlias at Lines 51β53. That warning will continue to emit plain paths instead of clickable ones.
Proposed fix
- const original = resolveToAlias(dir.path, nuxt)
- const corrected = resolveToAlias(join(dirname(dir.path), sibling), nuxt)
+ const original = linkToAlias(dir.path, nuxt)
+ const corrected = linkToAlias(join(dirname(dir.path), sibling), nuxt)This follows the PR objective that component diagnostics should render clickable file paths.
π€ 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/nuxt/src/components/scan.ts` at line 9, Update the NUXT_B3008
diagnostic path handling to use linkToAlias for both scannedPath and
expectedPath instead of resolveToAlias, matching the clickable-path conversion
already applied to NUXT_B3009, NUXT_B3010, and NUXT_B3011.
Merging this PR will not alter performance
Comparing Footnotes
|
933d703 to
90fd212
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and canβt be posted inline due to platform limitations.
β οΈ Outside diff range comments (2)
packages/nuxt/src/pages/module.ts (1)
785-795: π― Functional Correctness | π Major | β‘ Quick winPropagate parent aliases when evaluating child pages.
markPageschecks a pageβs aliases, but line 794 recurses into children using only the canonicalpath. If a parent page also has an alias, Vue Router will render the child under that aliased path too, andmarkPagesdoes not evaluate the child against that route. This can mark an aliased scripted child as_noScriptsand strip its client chunk incorrectly; recurse against every resolved parent prefix, including canonical and aliased paths, and add a regression test with differingnoScriptsrules for the canonical and aliased child routes.π€ 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/nuxt/src/pages/module.ts` around lines 785 - 795, Update markPages so child pages are recursively evaluated under every resolved parent prefix: the canonical path and each resolved alias, rather than only path. Combine the recursive results with the current pageβs noScripts status so a scripted child under any parent route prevents incorrect _noScripts marking, and add a regression test covering differing noScripts rules for canonical and aliased child routes.packages/nuxt/src/pages/utils.ts (1)
551-565: π― Functional Correctness | π Major | ποΈ Heavy liftKeep page-meta imports server-only for
_noScriptsroutes.This guard only prevents component loading.
metaRoutestill referencesmetaImportName(Lines 583-589), so Line 651 adds the pageβs?macro=truemodule to the client route table. That module can retain imports and declarations required for dynamic metadata, allowing page code to execute client-side despitenoScripts. Omit or server-guard macro metadata imports for these routes too.π€ 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/nuxt/src/pages/utils.ts` around lines 551 - 565, The `_noScripts` guard currently limits only component loading while page-meta macro imports still enter the client route table. Update the metadata import handling around `metaRoute` and `metaImportName` so `?macro=true` imports are omitted or server-guarded whenever `page._noScripts` is true, while preserving normal metadata behavior for other routes.
π€ 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.
Outside diff comments:
In `@packages/nuxt/src/pages/module.ts`:
- Around line 785-795: Update markPages so child pages are recursively evaluated
under every resolved parent prefix: the canonical path and each resolved alias,
rather than only path. Combine the recursive results with the current pageβs
noScripts status so a scripted child under any parent route prevents incorrect
_noScripts marking, and add a regression test covering differing noScripts rules
for canonical and aliased child routes.
In `@packages/nuxt/src/pages/utils.ts`:
- Around line 551-565: The `_noScripts` guard currently limits only component
loading while page-meta macro imports still enter the client route table. Update
the metadata import handling around `metaRoute` and `metaImportName` so
`?macro=true` imports are omitted or server-guarded whenever `page._noScripts`
is true, while preserving normal metadata behavior for other routes.
βΉοΈ Review info
βοΈ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 91bf008f-d7a8-4a58-bd90-a7f48d36a3c6
β Files ignored due to path filters (3)
packages/nuxt/package.jsonis excluded by!**/package.jsonpackages/vite/package.jsonis excluded by!**/package.jsonpnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!pnpm-lock.yaml
π Files selected for processing (23)
packages/nuxt/src/compiler/module.tspackages/nuxt/src/compiler/plugins/keyed-function-factories.tspackages/nuxt/src/components/module.tspackages/nuxt/src/components/plugins/islands-transform.tspackages/nuxt/src/components/plugins/lazy-hydration-transform.tspackages/nuxt/src/components/plugins/loader.tspackages/nuxt/src/components/scan.tspackages/nuxt/src/core/app.tspackages/nuxt/src/core/external-config-files.tspackages/nuxt/src/core/nuxt.tspackages/nuxt/src/core/perf.tspackages/nuxt/src/core/plugins/plugin-metadata.tspackages/nuxt/src/core/schema.tspackages/nuxt/src/head/plugins/unhead-imports.tspackages/nuxt/src/imports/module.tspackages/nuxt/src/pages/module.tspackages/nuxt/src/pages/plugins/page-meta.tspackages/nuxt/src/pages/utils.tspackages/nuxt/src/utils.tspackages/nuxt/test/page-metadata.test.tspackages/nuxt/test/utils.test.tspackages/vite/src/plugins/optimize-deps-hint.tspnpm-workspace.yaml
π§ Files skipped from review as they are similar to previous changes (7)
- packages/nuxt/src/compiler/plugins/keyed-function-factories.ts
- packages/nuxt/src/components/scan.ts
- packages/nuxt/src/head/plugins/unhead-imports.ts
- packages/nuxt/src/core/app.ts
- packages/nuxt/src/core/perf.ts
- packages/nuxt/src/components/plugins/loader.ts
- packages/nuxt/src/core/nuxt.ts
π Linked issue
π Description
this uses clickable-path to add links to open files in an editor. (files are printed using nuxt aliases which means they often wouldn't have opened previously.
example:
we also now track line/column in the page meta plugin so we can't link directly to the line responsible for the warning...