Skip to content

Conversation

@SutuSebastian
Copy link
Collaborator

@SutuSebastian SutuSebastian commented Aug 5, 2025

Fix nextjs plugin to work on all environments

Changes

  • fix(ui): nextjs plugin to run properly on NODE_ENV environments: production, development and test
  • log file writes in dev

Breaking changes

withFlowbiteReact now always returns async configuration (see: Async Configuration) so make sure to wrap any other HOC (higher-order-functions) such as withContentlayer because most of them do not forward pass async config arguments (eg: phase, options)

// ❌ not working
export default withContentlayer(withFlowbiteReact(nextConfig));

// ✅ working
export default withFlowbiteReact(withContentlayer(nextConfig));

Summary by CodeRabbit

  • Bug Fixes

    • Ensured the Next.js plugin for Flowbite React works correctly in all environments (production, development, and test).
  • New Features

    • Added logging for file writes during development to aid in debugging.
  • Refactor

    • Updated the Flowbite React Next.js plugin to always use an asynchronous configuration, requiring it to be the outermost wrapper when combined with other plugins.
    • Changed the order of plugin composition in the Next.js configuration for improved compatibility.

@SutuSebastian SutuSebastian requested a review from rluders August 5, 2025 08:32
@SutuSebastian SutuSebastian self-assigned this Aug 5, 2025
@SutuSebastian SutuSebastian added the 🐛 bug Something isn't working label Aug 5, 2025
@SutuSebastian SutuSebastian linked an issue Aug 5, 2025 that may be closed by this pull request
2 tasks
@SutuSebastian SutuSebastian added the confirmed This bug was confirmed label Aug 5, 2025
@changeset-bot
Copy link

changeset-bot bot commented Aug 5, 2025

🦋 Changeset detected

Latest commit: ea1354f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
flowbite-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Aug 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
flowbite-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 5, 2025 8:32am
flowbite-react-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 5, 2025 8:32am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 5, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This change refactors the withFlowbiteReact Next.js plugin to always return an asynchronous configuration callback, updates its usage order with withContentlayer in the Next.js config, and adds logging for class list file writes during development. The changes ensure compatibility with Next.js async config requirements and improve plugin behavior tracking.

Changes

Cohort / File(s) Change Summary
Next.js Plugin Refactor
packages/ui/src/plugin/nextjs.ts
Refactored withFlowbiteReact to always return an async configuration callback, using Next.js build phases for environment detection. Ensures single invocation of dev()/build() per process and updates signature for compatibility with Next.js async config requirements.
Next.js Config Composition Order
apps/web/next.config.mjs
Reversed the composition order: withFlowbiteReact is now the outermost wrapper, followed by withContentlayer. This aligns with the new async requirements of withFlowbiteReact and ensures correct plugin behavior.
Development Logging
packages/ui/src/cli/commands/dev.ts
Added console logging before writing the class list JSON file during development, both after initial generation and on file changes. No other logic or control flow changes.
Changelog
.changeset/short-candies-warn.md
Added a changeset documenting the patch, plugin refactor, new logging, and the breaking change in plugin composition order.

Sequence Diagram(s)

sequenceDiagram
    participant NextJS as Next.js
    participant Flowbite as withFlowbiteReact
    participant Contentlayer as withContentlayer
    participant Dev as dev()/build()

    NextJS->>Flowbite: Load config (phase, options)
    Flowbite->>Dev: Run dev() or build() (once per process)
    Flowbite->>Contentlayer: Pass config to withContentlayer
    Contentlayer->>NextJS: Return final config
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Suggested labels

:rocket: enhancement

Suggested reviewers

  • rluders

Poem

A plugin refactored, async and bright,
Wrapped just so, to make configs right.
With logs that now chatter,
When class lists do scatter,
Next.js and Flowbite—what a delight!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 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 5fdb439 and ea1354f.

📒 Files selected for processing (4)
  • .changeset/short-candies-warn.md (1 hunks)
  • apps/web/next.config.mjs (1 hunks)
  • packages/ui/src/cli/commands/dev.ts (2 hunks)
  • packages/ui/src/plugin/nextjs.ts (2 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 1611-class-listjson-is-not-generated-in-production-environment

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.
  • 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.

Support

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

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

@SutuSebastian SutuSebastian merged commit 941a075 into main Aug 5, 2025
8 checks passed
@SutuSebastian SutuSebastian deleted the 1611-class-listjson-is-not-generated-in-production-environment branch August 5, 2025 08:35
@github-actions github-actions bot mentioned this pull request Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working confirmed This bug was confirmed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

class-list.json is not generated in production environment

2 participants