Skip to content

fix(vite): handle resolving string vite input #32527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2025
Merged

Conversation

danielroe
Copy link
Member

🔗 Linked issue

📚 Description

when used with storybook, the entry is a string (and this might also be true with other vite-based integrations which reuse part of the nuxt vite config, e.g. test-utils, histoire, etc.)

spotted by @yannbf ❤️

@danielroe danielroe self-assigned this Jul 2, 2025
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@danielroe danielroe marked this pull request as ready for review July 2, 2025 15:38
Copy link

coderabbitai bot commented Jul 2, 2025

Walkthrough

The functions resolveClientEntry and resolveServerEntry in packages/vite/src/utils/config.ts were updated to improve how the input variable is handled. The new logic first checks if input is a string and returns it immediately if so. If input is not a string and not an array, the functions then check for and return the relevant property (entry or server) if present. The error handling for missing entries remains unchanged. No changes were made to the function signatures or exported declarations.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3e0408b and 20e8fe8.

📒 Files selected for processing (1)
  • packages/vite/src/utils/config.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.{ts,tsx}`: Follow standard TypeScript conventions and best practices

**/*.{ts,tsx}: Follow standard TypeScript conventions and best practices

📄 Source: CodeRabbit Inference Engine (.github/copilot-instructions.md)

List of files the instruction was applied to:

  • packages/vite/src/utils/config.ts
`**/*.{ts,tsx,vue}`: Use clear, descriptive variable and function names Add comm...

**/*.{ts,tsx,vue}: Use clear, descriptive variable and function names
Add comments only to explain complex logic or non-obvious implementations
Keep functions focused and manageable (generally under 50 lines), and extract complex logic into separate domain-specific files
Remove code that is not used or needed
Use error handling patterns consistently

📄 Source: CodeRabbit Inference Engine (.github/copilot-instructions.md)

List of files the instruction was applied to:

  • packages/vite/src/utils/config.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: TheAlexLichter
PR: nuxt/nuxt#31812
File: packages/nuxt/src/components/plugins/islands-transform.ts:202-202
Timestamp: 2025-04-18T18:33:41.753Z
Learning: In Nuxt, using `rolldownVersion` (not `rollupVersion`) is intentional when detecting if rolldown-vite is being used, even though TypeScript may show an error because the property isn't in standard type definitions yet.
Learnt from: GalacticHypernova
PR: nuxt/nuxt#26468
File: packages/nuxt/src/components/plugins/loader.ts:24-24
Timestamp: 2024-11-05T15:22:54.759Z
Learning: In `packages/nuxt/src/components/plugins/loader.ts`, the references to `resolve` and `distDir` are legacy code from before Nuxt used the new unplugin VFS and will be removed.
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T13:48:28.109Z
Learning: Applies to **/*.{ts,tsx,vue} : Use error handling patterns consistently
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T13:48:28.108Z
Learning: Applies to **/*.{ts,tsx,vue} : Use clear, descriptive variable and function names
Learnt from: GalacticHypernova
PR: nuxt/nuxt#29661
File: packages/kit/src/template.ts:227-229
Timestamp: 2024-11-28T21:22:40.496Z
Learning: In `packages/kit/src/template.ts`, when updating the `EXTENSION_RE` regular expression for TypeScript configuration, avoid using patterns like `(\.\w+)+$` as they can result in catastrophic backtracking.
packages/vite/src/utils/config.ts (5)
Learnt from: GalacticHypernova
PR: nuxt/nuxt#26468
File: packages/nuxt/src/components/plugins/loader.ts:24-24
Timestamp: 2024-11-05T15:22:54.759Z
Learning: In `packages/nuxt/src/components/plugins/loader.ts`, the references to `resolve` and `distDir` are legacy code from before Nuxt used the new unplugin VFS and will be removed.
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T13:48:28.108Z
Learning: Applies to **/*.{ts,tsx,vue} : Use clear, descriptive variable and function names
Learnt from: GalacticHypernova
PR: nuxt/nuxt#29661
File: packages/kit/src/template.ts:227-229
Timestamp: 2024-11-28T21:22:40.496Z
Learning: In `packages/kit/src/template.ts`, when updating the `EXTENSION_RE` regular expression for TypeScript configuration, avoid using patterns like `(\.\w+)+$` as they can result in catastrophic backtracking.
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T13:48:28.109Z
Learning: Applies to **/*.{ts,tsx,vue} : Use error handling patterns consistently
Learnt from: TheAlexLichter
PR: nuxt/nuxt#31812
File: packages/nuxt/src/components/plugins/islands-transform.ts:202-202
Timestamp: 2025-04-18T18:33:41.753Z
Learning: In Nuxt, using `rolldownVersion` (not `rollupVersion`) is intentional when detecting if rolldown-vite is being used, even though TypeScript may show an error because the property isn't in standard type definitions yet.
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: test-fixtures (windows-latest, dev, vite, default, manifest-on, json, 20)
  • GitHub Check: test-fixtures (ubuntu-latest, built, vite, default, manifest-on, json, 20)
  • GitHub Check: test-fixtures (ubuntu-latest, built, vite, async, manifest-on, json, 20)
  • GitHub Check: test-fixtures (ubuntu-latest, dev, vite, default, manifest-off, json, 20)
  • GitHub Check: test-fixtures (ubuntu-latest, dev, vite, async, manifest-off, json, 20)
  • GitHub Check: test-benchmark
  • GitHub Check: release-pr
  • GitHub Check: typecheck (windows-latest, bundler)
  • GitHub Check: typecheck (ubuntu-latest, bundler)
🔇 Additional comments (2)
packages/vite/src/utils/config.ts (2)

5-11: LGTM! String input handling correctly implemented.

The addition of explicit string type checking before the existing object property logic is well-implemented. This change correctly addresses the Storybook integration issue whilst maintaining backwards compatibility with existing object-based inputs.


19-25: LGTM! Consistent implementation across both functions.

The resolveServerEntry function mirrors the same string handling logic as resolveClientEntry, ensuring consistent behaviour across both client and server entry resolution. The implementation correctly prioritises string inputs before checking for object properties.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in a Comment
  • Commit Unit Tests in branch fix/entry-resolution

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

pkg-pr-new bot commented Jul 2, 2025

Open in StackBlitz

@nuxt/kit

npm i https://pkg.pr.new/@nuxt/kit@32527

nuxt

npm i https://pkg.pr.new/nuxt@32527

@nuxt/rspack-builder

npm i https://pkg.pr.new/@nuxt/rspack-builder@32527

@nuxt/schema

npm i https://pkg.pr.new/@nuxt/schema@32527

@nuxt/vite-builder

npm i https://pkg.pr.new/@nuxt/vite-builder@32527

@nuxt/webpack-builder

npm i https://pkg.pr.new/@nuxt/webpack-builder@32527

commit: 20e8fe8

@yannbf
Copy link

yannbf commented Jul 2, 2025

Thank you so much for this <3

For extra context, the issue happened in Storybook's CI and can be seen here:
https://app.circleci.com/pipelines/github/storybookjs/storybook/100902/workflows/f0c81316-7cc2-4846-bad2-4ade3a2e0077/jobs/854251

with the following error message:

=> Failed to build the preview
Error: No entry found in rollupOptions.input
    at resolveClientEntry (file://./node_modules/@nuxt/vite-builder/dist/shared/vite-builder.BcQqDUYS.mjs:124:9)
    at configResolved (file://./node_modules/@nuxt/vite-builder/dist/shared/vite-builder.BcQqDUYS.mjs:173:15)
    at file://./node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:49086:67
    at Array.map (<anonymous>)
    at resolveConfig (file://./node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:49086:53)
    at async createBuilder (file://./node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:46707:18)
    at async build (file://./node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:45981:19)
    at async build (./node_modules/@storybook/builder-vite/dist/index.js:84:230)
    at async Promise.all (index 0)
    at async buildStaticStandalone (./node_modules/storybook/dist/core-server/index.cjs:35885:3)

and that's because Storybook's vite builder uses rollupOptions.input as a string and not and object containing the entry field.

Copy link

codspeed-hq bot commented Jul 2, 2025

CodSpeed Performance Report

Merging #32527 will not alter performance

Comparing fix/entry-resolution (20e8fe8) with main (3e0408b)

Summary

✅ 10 untouched benchmarks

@danielroe danielroe merged commit 404cf55 into main Jul 2, 2025
47 checks passed
@danielroe danielroe deleted the fix/entry-resolution branch July 2, 2025 16:11
@github-actions github-actions bot mentioned this pull request Jul 2, 2025
@github-actions github-actions bot mentioned this pull request Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants