Skip to content

1559: Can't resolve 'tailwindcss/version.js' #1566

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

Open
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

SutuSebastian
Copy link
Collaborator

@SutuSebastian SutuSebastian commented Apr 19, 2025

Breaking changes

  • removed flowbite-react patch CLI command

Changes

  • flowbite-react/.gitignore, flowbite-react/config.json self manages, regenerates and repairs
  • new generated file init.(jsx|tsx) in .flowbite-react/ directory that syncs up values from config.json that also are needed in React app runtime (similar to how a React context works)
    • synced on CLI commands: init, build, dev, register
  • If you have custom configuration in .flowbite-react/config.json (different dark/prefix/version values), you must render <ThemeInit /> at the root level of your app to sync runtime with node config values
    • notify users to include <ThemeInit /> at the root level if custom dark, prefix, or version values are detected in the configuration file
  • expose flowbite-react/store import path
  • check if flowbite-react is installed when npx flowbite-react@latest init
    • bump the version to latest if below 0.11.x
  • remove redundant { flag: "w" } in fs.writeFile
  • update dark-mode.md and prefix.md documentation to reflect the <ThemeInit /> changes

Migration Guide

  1. Remove flowbite-react patch from your package.json

    {
      "scripts": {
    -   "postinstall": "flowbite-react patch"
      }
    }
  2. Add <ThemeInit /> (import from .flowbite-react/init.(jsx|tsx)) at the root level of your app if you have custom configuration in .flowbite-react/config.json (different dark/prefix/version values).

Summary by CodeRabbit

  • New Features

    • Introduced a required version property in configuration files to specify Tailwind CSS version (3 or 4).
    • Added a new <ThemeInit /> React component for synchronizing runtime configuration with project settings; users with custom configurations must render this at the app root.
  • Breaking Changes

    • Removed the flowbite-react patch CLI command and related patching logic.
    • .gitignore and configuration files are now self-managed and auto-regenerating.
  • Documentation

    • Updated guides to reflect new configuration requirements and usage of <ThemeInit />.
    • Revised instructions for dark mode, prefix, and CLI usage.
  • Chores

    • Updated Bun version and improved CLI workflow and error handling.
  • Refactor

    • Streamlined CLI commands and configuration management, enhancing reliability and maintainability.
  • Bug Fixes

    • Improved handling and validation of configuration files and runtime synchronization.

- Add `version` field to configuration schema and documentation, specifying the Tailwind CSS version to use (default: 4)
@SutuSebastian SutuSebastian self-assigned this Apr 19, 2025
@SutuSebastian SutuSebastian linked an issue Apr 19, 2025 that may be closed by this pull request
2 tasks
Copy link

changeset-bot bot commented Apr 19, 2025

🦋 Changeset detected

Latest commit: 6dd6d1d

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 Minor

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

Copy link

vercel bot commented Apr 19, 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 Jul 21, 2025 6:51pm
flowbite-react-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 21, 2025 6:51pm

Copy link
Contributor

coderabbitai bot commented Apr 19, 2025

Walkthrough

This update removes the flowbite-react patch CLI command and all related patching logic, introducing a new self-managing configuration and initialization system for Flowbite React. The .flowbite-react/config.json and .gitignore files are now auto-managed, and a new init.(jsx|tsx) file is generated to synchronize configuration with the React runtime via a ThemeInit component. Documentation, CLI commands, and schema definitions are updated to require and describe the new version config property.

Changes

File(s) / Group Change Summary
.changeset/tricky-planes-shake.md, .github/actions/setup/action.yml, package.json Updated documentation, Bun version, and changeset for release.
apps/storybook/.flowbite-react/config.json, apps/web/.flowbite-react/config.json Added "version": 3 to config files.
apps/storybook/.flowbite-react/init.tsx, apps/web/.flowbite-react/init.tsx Auto-generated ThemeInit React component for config sync.
apps/storybook/.storybook/preview.tsx, apps/web/app/layout.tsx Imported and rendered ThemeInit at app root.
apps/storybook/tsconfig.json Broadened file inclusion, added excludes.
apps/web/content/docs/customize/config.mdx, apps/web/content/docs/customize/dark-mode.mdx, apps/web/content/docs/customize/prefix.mdx, apps/web/content/docs/customize/custom-components.mdx, apps/web/content/docs/getting-started/cli.mdx Updated documentation to require/use new version property and ThemeInit usage.
packages/ui/package.json Added exports for store and store/init, removed postinstall patch script.
packages/ui/rollup.config.js Removed Tailwind version file from externals.
packages/ui/schema.json, packages/ui/scripts/generate-metadata.ts Updated schema to require version and set prefix default.
packages/ui/src/cli/commands/build.ts, create.ts, dev.ts, init.ts, register.ts Refactored commands to remove patch logic, add setupInit, and improve config/component handling.
packages/ui/src/cli/commands/ensure-tailwind.ts, setup-class-list.ts, setup-gitignore.ts, setup-output-directory.ts, setup-plugin.ts, setup-register.ts, setup-tailwind.ts, setup-vscode.ts Added/updated JSDoc comments, minor refactorings.
packages/ui/src/cli/commands/setup-config.ts Major refactor: deep config validation, auto-fix, and migration to include version.
packages/ui/src/cli/commands/setup-init.ts New: Generates/updates `.flowbite-react/init.(tsx
packages/ui/src/cli/consts.ts Added constants for new init and gitignore files/paths.
packages/ui/src/cli/main.ts Removed patch command; updated install logic.
packages/ui/src/cli/utils/build-class-list.ts Now takes explicit version parameter.
packages/ui/src/cli/utils/get-config.ts Delegates to new setupConfig for robust config handling.
packages/ui/src/cli/utils/get-module-package-json.ts, get-tailwind-version.ts New: Utilities for reading package versions and Tailwind version.
packages/ui/src/helpers/get-tailwind-version.ts, packages/ui/src/cli/commands/generate-class-list.ts, patch.ts, setup-patch.ts Deleted: Patch and Tailwind version helpers, old class list generator.
packages/ui/src/helpers/resolve-theme.ts, tailwind-merge.ts Use runtime store for version instead of static helper.
packages/ui/src/helpers/resolve-theme.test.ts Updated test to set version in store.
packages/ui/src/store/index.ts Store now tracks version; added getVersion getter.
packages/ui/src/theme/config.tsx ThemeConfig now only uses mode prop, not full store.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant ConfigFile
    participant InitFile
    participant ReactApp

    User->>CLI: Run init/build/dev/register
    CLI->>ConfigFile: Read/validate config.json
    CLI->>InitFile: Generate/update init.tsx (ThemeInit)
    CLI->>ReactApp: User imports ThemeInit at root
    ReactApp->>ThemeInit: Render at runtime
    ThemeInit->>Store: Sync config (dark, prefix, version)
Loading

Estimated code review effort

4 (~100 minutes)

The changes are extensive, affecting CLI commands, configuration management, runtime initialization, documentation, and package exports. There are major refactors, new files, and deletions, but the changes are mostly focused on a specific feature set and are well-scoped.

Possibly related PRs

Suggested reviewers

  • rluders
  • tulup-conner

Poem

🐇
Goodbye to patch, hello to sync,
With ThemeInit, configs now link.
Versioned and tidy, our files self-heal,
Docs and schemas show the new deal.
Hop along, React, with runtime delight—
The rabbit ensures your theming is right!
🌱


📜 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 c443c90 and 6dd6d1d.

📒 Files selected for processing (1)
  • .changeset/tricky-planes-shake.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/tricky-planes-shake.md

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 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 added 🐛 bug Something isn't working confirmed This bug was confirmed labels Apr 19, 2025
@SutuSebastian SutuSebastian changed the title 1559 cant resolve tailwindcssversionjs 1559: Can't resolve 'tailwindcss/version.js' Apr 19, 2025
- add `ThemeConfig` in apps/[storybook, web]
- enforce schema `version` to [3,4]
@trzcina
Copy link

trzcina commented May 5, 2025

Hi @SutuSebastian,
I'm looking forward to this bugfix - currently, I have to manually override the missing version.js in my project by modifying the next.config.ts file. Thanks for working on the fix!

@SutuSebastian
Copy link
Collaborator Author

@trzcina just couple of migration scripts left and thats it, things looks pretty stable so far.

Btw, what does this have to do with next.config.ts? it's 100% related to patching the tailwindcss/package.json with the version.js file

@trzcina
Copy link

trzcina commented May 6, 2025

@trzcina just couple of migration scripts left and thats it, things looks pretty stable so far.

Btw, what does this have to do with next.config.ts? it's 100% related to patching the tailwindcss/package.json with the version.js file

Thanks for the info. What I meant is that in my project, I replaced this file by overriding the Webpack config — in my case, within the Next.js configuration.

const path = require("path");

module.exports = {
  webpack: (config) => {
    config.resolve.alias["tailwindcss/version.js"] = path.resolve(replacement );
    return config;
  },
};

- do not ignore `.flowbite-react/init.tsx` file
- remove typescript related content and make it portable (jsx/tsx)
- adjust init file path handling to support both .tsx and .jsx extensions
- compare AST nodes for content changes
- notify users to include <ThemeInit /> at the root level if custom dark, prefix, or version values are detected in the configuration file
- replace ThemeConfig with ThemeInit component for syncing runtime with custom configuration
- clarify steps for disabling dark mode and using custom prefixes
Copy link
Contributor

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

♻️ Duplicate comments (1)
packages/ui/src/cli/commands/setup-vscode.ts (1)

149-149: Duplicate of previous encoding remark
See above – apply identical change here for consistency.

🧹 Nitpick comments (13)
packages/ui/src/cli/commands/setup-vscode.ts (1)

101-101: Explicitly pass encoding when writing JSON

fs.writeFile defaults to UTF-8, but being explicit prevents accidental regression if Node ever changes defaults or if someone swaps this call for the synchronous variant.

-    await fs.writeFile(vscodeSettingsFilePath, cjson.stringify(settings, null, 2));
+    await fs.writeFile(
+      vscodeSettingsFilePath,
+      cjson.stringify(settings, null, 2),
+      { encoding: "utf-8" },
+    );

(Same comment applies to the extensions.json write on line 149.)

apps/web/app/layout.tsx (1)

6-6: Prefer path alias over brittle relative import

../.flowbite-react/init works today, but any directory shuffle (e.g. moving layout.tsx) will silently break the import. Adding a @flowbite-init alias in tsconfig.json (and the Next 13 alias section) keeps the path stable:

-import { ThemeInit } from "../.flowbite-react/init";
+import { ThemeInit } from "@flowbite-init";

This also avoids importing from a dot-prefixed directory which some tooling skips by default.

packages/ui/src/cli/commands/setup-output-directory.ts (1)

4-8: Good JSDoc—add return type for completeness

Nice touch documenting the helper. Consider stating the (implicit) Promise<void> return to help IDEs display richer hints:

- * This function checks if the `.flowbite-react` directory exists and creates it if it does not.
+ * This function checks if the `.flowbite-react` directory exists and creates it if it does not.
+ *
+ * @returns {Promise<void>}
apps/web/content/docs/customize/custom-components.mdx (1)

24-34: Update surrounding docs to list new fields

The JSON example now introduces dark, tsx, and version, but the bullet list above still enumerates only path, rsc, and tsx. Readers may miss that version is mandatory. Please adjust the description list accordingly.

packages/ui/src/helpers/resolve-theme.ts (1)

70-70: Guard against unsupported version values

getVersion() is expected to return 3 | 4, but nothing prevents downstream code from writing an arbitrary number/string into the store. A defensive check avoids silent mis-behaviour:

-const version = getVersion();
+const version = getVersion();
+if (version !== 3 && version !== 4) {
+  throw new Error(`Unsupported Tailwind version "${version}". Expected 3 or 4.`);
+}
packages/ui/src/cli/utils/get-tailwind-version.ts (1)

11-24: Solid implementation with good error handling.

The function properly handles package detection, version parsing, and validation. The error messages are clear and the typing is precise.

Consider making the version parsing more robust:

-  const major = parseInt(tailwindcssPackageJson.version.split(".")[0], 10);
+  const versionParts = tailwindcssPackageJson.version.split(".");
+  const major = versionParts.length > 0 ? parseInt(versionParts[0], 10) : NaN;

This would handle edge cases where the version string might not follow expected format.

packages/ui/src/cli/utils/get-module-package-json.ts (1)

16-21: Consider adding optional error logging for debugging.

The fallback mechanism and error handling approach are solid. However, the empty catch blocks might make troubleshooting difficult during development.

Consider adding optional debug logging:

  } catch {
    try {
      return (await import(`${packageName}/package.json`)).default;
-   } catch {
+   } catch (error) {
+     // Optional: Add debug logging
+     // console.debug(`Failed to resolve ${packageName}/package.json:`, error);
      return null;
    }
  }
packages/ui/src/cli/commands/setup-gitignore.ts (1)

21-24: Consider documenting the setTimeout delay reasoning.

The simplified content comparison and improved logging are excellent improvements. However, the 10ms delay in setTimeout might benefit from a comment explaining its purpose.

Consider adding a comment to explain the delay:

-      setTimeout(() => fs.writeFile(gitIgnoreFilePath, content), 10);
+      // Small delay to avoid potential file system race conditions
+      setTimeout(() => fs.writeFile(gitIgnoreFilePath, content), 10);
packages/ui/src/cli/utils/build-class-list.ts (1)

8-27: Update JSDoc to document the version parameter.

The function signature correctly adds the version parameter with proper type constraints, but the JSDoc comment should be updated to document this new parameter.

 * @param {Object} options - The options for building the class list.
 * @param {string[]} options.components - The components to include in the class list.
 * @param {boolean} options.dark - Whether to include dark mode classes.
 * @param {string} options.prefix - The prefix to apply to the class names.
+ * @param {3 | 4} options.version - The Tailwind CSS version to use for class generation.
 * @returns {string[]} The sorted list of CSS classes.
packages/ui/src/cli/commands/install.ts (1)

13-21: Improve error message clarity for package manager detection.

The fallback logic is sound, but the error message could be more informative about the fallback behavior.

-    if (!pm) {
-      console.error("Could not detect package manager");
-    }
+    if (!pm) {
+      console.warn("Could not detect package manager, falling back to npm");
+    }
packages/ui/src/cli/commands/setup-config.ts (2)

51-60: Consider optimizing component validation.

The component validation creates a new validator function on each invalid component check. Consider extracting it outside the condition:

-      const isValidComponent = (component: unknown) =>
-        typeof component === "string" &&
-        component.trim() !== "" &&
-        (component === "*" ||
-          COMPONENT_TO_CLASS_LIST_MAP[component as keyof typeof COMPONENT_TO_CLASS_LIST_MAP] !== undefined);
-
-      if (newConfig.components.some((component) => !isValidComponent(component))) {
+      if (newConfig.components.some((component) => !isValidComponent(component))) {

And define isValidComponent at the function scope or as a separate utility.


82-85: Version validation might be too strict.

The version validation always overwrites the user's version with the detected version. This might be intentional for consistency, but it prevents users from manually setting a different Tailwind version if needed (e.g., during migration).

Consider whether this strict enforcement is necessary or if a warning would suffice.

packages/ui/src/cli/commands/setup-init.ts (1)

13-40: Consider conditional TypeScript directives for JSX files.

The template includes TypeScript-specific directives (// @ts-nocheck) even when generating .jsx files. Consider making this conditional:

const content = `
/* eslint-disable */
-// @ts-nocheck
+${config.tsx ? "// @ts-nocheck" : ""}
// biome-ignore-all lint: auto-generated file
`.trim();

Otherwise, the template structure and path determination logic looks good.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 134b3eb and c443c90.

📒 Files selected for processing (52)
  • .changeset/tricky-planes-shake.md (1 hunks)
  • .github/actions/setup/action.yml (1 hunks)
  • apps/storybook/.flowbite-react/config.json (1 hunks)
  • apps/storybook/.flowbite-react/init.tsx (1 hunks)
  • apps/storybook/.storybook/preview.tsx (2 hunks)
  • apps/storybook/tsconfig.json (1 hunks)
  • apps/web/.flowbite-react/config.json (1 hunks)
  • apps/web/.flowbite-react/init.tsx (1 hunks)
  • apps/web/app/layout.tsx (2 hunks)
  • apps/web/content/docs/customize/config.mdx (5 hunks)
  • apps/web/content/docs/customize/custom-components.mdx (1 hunks)
  • apps/web/content/docs/customize/dark-mode.mdx (2 hunks)
  • apps/web/content/docs/customize/prefix.mdx (2 hunks)
  • apps/web/content/docs/getting-started/cli.mdx (2 hunks)
  • package.json (1 hunks)
  • packages/ui/package.json (1 hunks)
  • packages/ui/rollup.config.js (0 hunks)
  • packages/ui/schema.json (2 hunks)
  • packages/ui/scripts/generate-metadata.ts (2 hunks)
  • packages/ui/src/cli/commands/build.ts (1 hunks)
  • packages/ui/src/cli/commands/create.ts (2 hunks)
  • packages/ui/src/cli/commands/dev.ts (4 hunks)
  • packages/ui/src/cli/commands/ensure-tailwind.ts (1 hunks)
  • packages/ui/src/cli/commands/generate-class-list.ts (0 hunks)
  • packages/ui/src/cli/commands/help.ts (0 hunks)
  • packages/ui/src/cli/commands/init.ts (1 hunks)
  • packages/ui/src/cli/commands/install.ts (2 hunks)
  • packages/ui/src/cli/commands/patch.ts (0 hunks)
  • packages/ui/src/cli/commands/register.ts (2 hunks)
  • packages/ui/src/cli/commands/setup-class-list.ts (1 hunks)
  • packages/ui/src/cli/commands/setup-config.ts (1 hunks)
  • packages/ui/src/cli/commands/setup-gitignore.ts (1 hunks)
  • packages/ui/src/cli/commands/setup-init.ts (1 hunks)
  • packages/ui/src/cli/commands/setup-output-directory.ts (1 hunks)
  • packages/ui/src/cli/commands/setup-patch.ts (0 hunks)
  • packages/ui/src/cli/commands/setup-plugin.ts (1 hunks)
  • packages/ui/src/cli/commands/setup-register.ts (2 hunks)
  • packages/ui/src/cli/commands/setup-tailwind.ts (2 hunks)
  • packages/ui/src/cli/commands/setup-vscode.ts (4 hunks)
  • packages/ui/src/cli/consts.ts (1 hunks)
  • packages/ui/src/cli/main.ts (2 hunks)
  • packages/ui/src/cli/utils/build-class-list.ts (1 hunks)
  • packages/ui/src/cli/utils/get-config.ts (1 hunks)
  • packages/ui/src/cli/utils/get-module-package-json.ts (1 hunks)
  • packages/ui/src/cli/utils/get-package-json.ts (1 hunks)
  • packages/ui/src/cli/utils/get-tailwind-version.ts (1 hunks)
  • packages/ui/src/helpers/get-tailwind-version.ts (0 hunks)
  • packages/ui/src/helpers/resolve-theme.test.ts (1 hunks)
  • packages/ui/src/helpers/resolve-theme.ts (2 hunks)
  • packages/ui/src/helpers/tailwind-merge.ts (1 hunks)
  • packages/ui/src/store/index.ts (3 hunks)
  • packages/ui/src/theme/config.tsx (1 hunks)
💤 Files with no reviewable changes (6)
  • packages/ui/rollup.config.js
  • packages/ui/src/cli/commands/help.ts
  • packages/ui/src/helpers/get-tailwind-version.ts
  • packages/ui/src/cli/commands/setup-patch.ts
  • packages/ui/src/cli/commands/generate-class-list.ts
  • packages/ui/src/cli/commands/patch.ts
🧰 Additional context used
🧬 Code Graph Analysis (16)
packages/ui/src/helpers/resolve-theme.ts (1)
packages/ui/src/store/index.ts (1)
  • getVersion (75-77)
packages/ui/src/cli/commands/setup-class-list.ts (1)
packages/ui/src/cli/consts.ts (1)
  • classListFilePath (14-14)
packages/ui/src/cli/commands/setup-register.ts (1)
packages/ui/src/cli/consts.ts (1)
  • packageJsonFile (8-8)
packages/ui/src/helpers/resolve-theme.test.ts (1)
packages/ui/src/store/index.ts (1)
  • setStore (40-61)
packages/ui/src/cli/utils/get-tailwind-version.ts (1)
packages/ui/src/cli/utils/get-module-package-json.ts (1)
  • getModulePackageJson (9-22)
apps/storybook/.flowbite-react/init.tsx (1)
apps/web/.flowbite-react/init.tsx (1)
  • ThemeInit (18-20)
apps/web/.flowbite-react/init.tsx (1)
apps/storybook/.flowbite-react/init.tsx (1)
  • ThemeInit (18-20)
packages/ui/src/theme/config.tsx (1)
packages/ui/src/store/index.ts (1)
  • StoreProps (4-31)
packages/ui/src/helpers/tailwind-merge.ts (1)
packages/ui/src/store/index.ts (2)
  • getPrefix (71-73)
  • getVersion (75-77)
packages/ui/src/cli/commands/ensure-tailwind.ts (1)
packages/ui/src/cli/utils/get-package-json.ts (1)
  • getPackageJson (20-27)
packages/ui/src/cli/commands/setup-gitignore.ts (1)
packages/ui/src/cli/consts.ts (3)
  • classListFile (3-3)
  • processIdFile (11-11)
  • gitIgnoreFilePath (16-16)
packages/ui/src/cli/commands/register.ts (3)
packages/ui/src/cli/commands/setup-output-directory.ts (1)
  • setupOutputDirectory (9-16)
packages/ui/src/cli/utils/get-config.ts (1)
  • getConfig (13-15)
packages/ui/src/cli/commands/setup-init.ts (1)
  • setupInit (12-70)
packages/ui/src/cli/commands/install.ts (2)
packages/ui/src/cli/utils/get-package-json.ts (1)
  • getPackageJson (20-27)
packages/ui/src/cli/utils/get-module-package-json.ts (1)
  • getModulePackageJson (9-22)
packages/ui/src/cli/commands/setup-init.ts (2)
packages/ui/src/cli/commands/setup-config.ts (1)
  • Config (8-17)
packages/ui/src/cli/consts.ts (2)
  • initFilePath (17-17)
  • initJsxFilePath (18-18)
packages/ui/src/cli/commands/setup-config.ts (2)
packages/ui/src/cli/utils/get-tailwind-version.ts (1)
  • getTailwindVersion (11-24)
packages/ui/src/cli/consts.ts (1)
  • configFilePath (15-15)
packages/ui/src/cli/commands/dev.ts (7)
packages/ui/src/cli/commands/setup-output-directory.ts (1)
  • setupOutputDirectory (9-16)
packages/ui/src/cli/utils/get-config.ts (1)
  • getConfig (13-15)
packages/ui/src/cli/commands/setup-init.ts (1)
  • setupInit (12-70)
packages/ui/src/cli/utils/find-files.ts (1)
  • findFiles (26-94)
packages/ui/src/cli/consts.ts (6)
  • allowedExtensions (37-37)
  • classListFilePath (14-14)
  • configFilePath (15-15)
  • initFilePath (17-17)
  • initJsxFilePath (18-18)
  • gitIgnoreFilePath (16-16)
packages/ui/src/cli/utils/build-class-list.ts (1)
  • buildClassList (17-84)
packages/ui/src/cli/commands/setup-gitignore.ts (1)
  • setupGitIgnore (10-28)
🪛 Biome (1.9.4)
apps/storybook/.flowbite-react/init.tsx

[error] 3-3: failed to parse category "-all"

(suppressions/parse)

apps/web/.flowbite-react/init.tsx

[error] 3-3: failed to parse category "-all"

(suppressions/parse)

🔇 Additional comments (82)
packages/ui/src/cli/commands/setup-vscode.ts (1)

6-11: Nice docs – thanks for the clarity!
The added JSDoc noticeably improves discoverability for CLI contributors.

.github/actions/setup/action.yml (1)

10-10: 👍 Bun bumped to 1.2.18 – remember to keep @types/bun in sync
CI and local environments will now run Bun 1.2.18. package.json still pins @types/bun at 1.2.4; consider upgrading to avoid type mismatches.

apps/web/.flowbite-react/config.json (1)

8-9: Verify that version matches the Tailwind CSS major actually installed

"version": 3 drives runtime/theme behaviour. If the project upgrades Tailwind 4 later, forgetting to bump this field will lead to mismatched class maps.

Request: double-check the Tailwind dependency across all workspaces and update this field (and others) consistently.

apps/web/app/layout.tsx (1)

63-66: Validate that ThemeInit is a client component

RootLayout is a server component. Rendering a client component (ThemeInit) inside it is valid, but only if ThemeInit’s file begins with "use client". If that pragma is missing the build will fail with

You're importing a component that needs `use client`…

Please double-check the generated init.(tsx|jsx) file or add the directive.

apps/storybook/.flowbite-react/config.json (1)

8-9: Ensure Tailwind version matches the rest of the workspace

The store default is 4, whereas Storybook config sets "version": 3. If Storybook consumes components built for v4 utilities, class names may be transformed incorrectly (see convertUtilitiesToV4). Confirm Storybook really uses Tailwind v3 or bump the value to 4.

packages/ui/src/helpers/resolve-theme.ts (1)

4-4: 👍 Centralising version retrieval

Switching to getVersion removes redundant heuristics and keeps all state in the store.

apps/storybook/tsconfig.json (1)

24-25: LGTM! TypeScript configuration properly updated for new file structure.

The changes correctly broaden the compilation scope to include all TypeScript files recursively, which is necessary for the new .flowbite-react/init.tsx file, while properly excluding build artifacts and dependencies.

packages/ui/src/helpers/resolve-theme.test.ts (1)

21-21: Good addition of version property to test the new version-aware theme system.

The addition of version: 3 to the store setup correctly tests the version-specific prefix application behavior, ensuring the new version-aware theme resolution system works as expected.

packages/ui/src/cli/commands/setup-plugin.ts (1)

3-8: Excellent documentation addition.

The JSDoc comment clearly describes the function's purpose and behavior, improving code maintainability without altering the implementation.

packages/ui/src/cli/main.ts (2)

53-53: Command list correctly updated to remove patch command.

The removal of "patch" from the valid commands list is consistent with the elimination of the patching mechanism described in the PR objectives.


26-27: installPackage function export verified

  • Confirmed that installPackage is exported from packages/ui/src/cli/commands/install.ts.
  • Renaming in packages/ui/src/cli/main.ts (lines 26–27) and removal of the patch command align with the intended refactoring.

All changes look good—approving.

packages/ui/src/cli/commands/create.ts (2)

168-168: Simplification of writeFile call is acceptable.

Removing the explicit { flag: "w" } option is fine since the default behavior of fs.writeFile is to overwrite existing files, which matches the intended behavior.


5-5: setupInit export verified and integration approved.

  • Confirmed that setupInit is correctly exported from packages/ui/src/cli/commands/setup-init.ts.
  • The call to setupInit(config) in create.ts aligns with the new initialization pattern.
  • Removing the explicit { flag: "w" } from fs.writeFile relies on the default overwrite behavior and is acceptable.
packages/ui/src/cli/commands/setup-tailwind.ts (2)

9-14: Well-documented function purpose.

The JSDoc clearly describes the function's behavior and aligns with the implementation.


27-32: Clear and accurate documentation.

The JSDoc properly explains the v4-specific setup process including file search and directive addition.

packages/ui/src/cli/commands/setup-register.ts (2)

6-12: Comprehensive function documentation.

The JSDoc thoroughly explains the postinstall script setup logic including both new and existing script scenarios.


29-29: Good simplification by relying on default behavior.

Removing the explicit write flag is appropriate since fs.writeFile defaults to overwriting files.

packages/ui/src/cli/commands/setup-class-list.ts (2)

4-8: Clear documentation of file management logic.

The JSDoc accurately describes the function's file existence checking and creation behavior.


14-14: Consistent simplification across the codebase.

Removing the explicit write flag aligns with the cleanup pattern seen in other files.

packages/ui/src/helpers/tailwind-merge.ts (2)

3-3: Good centralization of version access.

Moving to store-based version retrieval improves performance by avoiding repeated file system access.


9-9: Consistent with the new store-based architecture.

The function call change aligns with the centralized version management approach.

apps/web/.flowbite-react/init.tsx (2)

12-16: Configuration values look correct.

The hardcoded config values align with the migration from patch-based to runtime initialization approach. The version: 3 indicates Tailwind CSS v3 usage, which is appropriate for addressing the 'tailwindcss/version.js' resolution issue.


18-22: Component implementation follows the expected pattern.

The ThemeInit component correctly spreads the config to StoreInit and includes the proper display name, consistent with the pattern shown in the storybook example.

apps/storybook/.storybook/preview.tsx (2)

2-4: Good TypeScript typing and import additions.

The explicit Decorator[] typing and necessary imports for React and ThemeInit are properly added.


22-28: Decorator implementation and ordering look correct.

The ThemeInit decorator is properly placed first to establish the base configuration before the existing withThemeByClassName decorator applies theme switching logic. This ensures consistent theme initialization across all Storybook stories.

packages/ui/src/cli/commands/register.ts (2)

10-12: Proper setup sequence for initialization system.

Moving setupOutputDirectory() to the beginning and adding setupInit(config) correctly implements the new initialization flow. This ensures the output directory exists before generating the init file.


38-38: Simplified writeFile call is appropriate.

Removing the { flag: "w" } option is fine since "w" (write/overwrite) is the default behavior for fs.writeFile.

packages/ui/scripts/generate-metadata.ts (3)

238-238: Good explicit default for prefix property.

Making the empty string default explicit improves schema clarity and consistency.


252-258: Appropriate version property definition.

The version property correctly restricts values to Tailwind CSS versions 3 and 4, with a sensible default of 4. This directly addresses the tailwindcss/version.js resolution issue by making version management explicit.


260-260: Version correctly added to required properties.

Including version in the required array ensures all configurations explicitly specify their Tailwind CSS version, which is essential for the new initialization system.

packages/ui/src/theme/config.tsx (2)

4-4: Good interface narrowing for focused responsibility.

Restricting ThemeConfigProps to only the mode property clarifies that ThemeConfig is now focused solely on theme mode management, while broader configuration is handled by the new ThemeInit component.


6-7: Implementation correctly reflects the narrowed interface.

The component now properly accepts only the mode parameter and explicitly passes it to StoreInit, maintaining clear separation of concerns in the new architecture.

apps/web/content/docs/getting-started/cli.mdx (2)

225-227: LGTM! Configuration example updated correctly.

The addition of the version property with a default value of 4 aligns perfectly with the new explicit Tailwind CSS version configuration approach, replacing the previous patching mechanism.


254-257: Documentation for new version property is clear and helpful.

The explanation of the version property is concise and accurately describes its purpose in specifying which Tailwind CSS version to use.

packages/ui/src/cli/commands/ensure-tailwind.ts (3)

3-5: Good addition of JSDoc documentation.

The JSDoc comment clearly describes the function's purpose.


8-8: Good refactoring with packageName constant.

Using a constant instead of repeating string literals improves maintainability and reduces the risk of typos.


10-10: Simplified check is cleaner and more readable.

The direct boolean check is more concise than the previous approach and maintains the same functionality.

packages/ui/schema.json (3)

131-133: Good addition of default value for prefix property.

Adding the default empty string value improves the schema completeness and user experience.


144-149: Well-designed version property definition.

The version property correctly:

  • Uses appropriate data type (number)
  • Restricts values to supported Tailwind CSS versions (3, 4)
  • Sets a sensible default (4 for latest version)
  • Includes helpful description with documentation link

151-151: Appropriate to make version a required property.

Making version required ensures all configurations explicitly specify which Tailwind CSS version to use, which is essential for the new approach replacing the patch mechanism.

packages/ui/src/store/index.ts (4)

25-31: Well-documented version property type definition.

The JSDoc documentation clearly explains the property's purpose and default value. The union type 3 | 4 correctly restricts to supported Tailwind CSS versions.


37-37: Consistent initialization pattern.

The version property follows the same initialization pattern as other store properties.


54-61: Robust validation logic with helpful error messaging.

The validation correctly:

  • Checks for valid values (3 or 4)
  • Provides clear warning message with available options
  • Follows the same pattern as the mode property validation

75-77: Consistent getter function implementation.

The getVersion function follows the same pattern as other getter functions in the store.

apps/web/content/docs/customize/prefix.mdx (3)

22-24: Config example correctly updated with version property.

The addition of "version": 4 in the configuration example is consistent with the schema changes and new explicit versioning approach.


53-53: Clear explanation of when ThemeInit is required.

The documentation clearly explains that ThemeInit is needed when using custom configuration, which helps users understand when this component is necessary.


55-67: Updated example correctly demonstrates new ThemeInit usage.

The code example properly shows:

  • Correct import path from the auto-generated init file
  • Proper placement at the root level
  • Simple usage without props (configuration comes from the config file)
apps/storybook/.flowbite-react/init.tsx (3)

9-10: LGTM!

The imports are correct and necessary for the component implementation.


12-16: LGTM!

The configuration object follows the established pattern and contains appropriate values for the Storybook environment.


18-22: LGTM!

The component implementation is clean and follows React best practices. The displayName assignment is helpful for debugging.

packages/ui/src/cli/utils/get-module-package-json.ts (2)

1-11: LGTM!

The function signature and generic type constraint are well-designed, ensuring type safety while allowing flexibility for different package.json structures.


12-15: LGTM!

The primary resolution method using createRequire is well-implemented and should handle most cases reliably.

packages/ui/src/cli/commands/init.ts (3)

2-2: LGTM!

The new imports for installPackage and setupInit are appropriate and align with the refactored initialization flow.

Also applies to: 6-6


16-16: LGTM!

The refactored initialization sequence is logical and well-structured. Storing the config result and passing it to setupInit enables proper runtime configuration synchronization.

Also applies to: 20-21


22-23: LGTM!

The reordering of setup calls maintains logical flow and the new sequence is appropriate for the refactored initialization process.

apps/web/content/docs/customize/config.mdx (4)

43-44: LGTM!

The schema updates are well-structured. The version property with enum constraints and the explicit default for prefix improve configuration clarity and validation.

Also applies to: 56-63


111-117: LGTM!

The documentation for the version property is clear, informative, and follows the established format for other configuration properties.


137-144: LGTM!

The configuration examples are properly updated to include the version property and maintain consistency with the schema definition.

Also applies to: 160-167


56-167: Excellent documentation update supporting the new version configuration.

The documentation comprehensively covers the new version property with clear schema definition, detailed explanations, and consistent examples. This supports the broader refactoring and new runtime initialization approach.

packages/ui/src/cli/commands/setup-gitignore.ts (3)

2-2: LGTM!

Using imported constants improves maintainability and consistency. The centralized approach eliminates hardcoded strings and path construction.

Also applies to: 11-11


4-9: LGTM!

The updated JSDoc documentation is comprehensive and clearly explains the function's purpose and behavior.


14-19: LGTM!

The refactored file reading logic using try-catch is cleaner and more readable than the previous promise-based approach.

packages/ui/src/cli/consts.ts (3)

5-6: LGTM: New file constants are well-defined.

The new gitIgnoreFile and initFile constants follow the existing pattern and correctly define the base filenames for the new initialization system.


16-18: LGTM: Path constants are properly constructed.

The new path constants follow the established pattern and correctly support both TypeScript (.tsx) and JavaScript (.jsx) versions of the initialization file.


9-10: LGTM: Constants reorganization is harmless.

The moved pluginName and pluginPath constants retain their correct values and this appears to be a simple reorganization for better logical grouping.

packages/ui/src/cli/commands/build.ts (2)

1-7: LGTM: Imports align with new build functionality.

The new imports support the refactored build process including configuration loading, initialization setup, and component extraction logic.


13-48: Component extraction logic is well-covered by tests
The extractComponentImports utility includes comprehensive tests for:
• Single, multiple, aliased, and star imports
• Subpath imports (e.g. flowbite-react/lib/components)
• Filtering invalid names
No further changes are needed.

packages/ui/src/cli/utils/build-class-list.ts (1)

74-81: LGTM: Version parameter usage is correct.

The explicit version parameter is properly used in both the utility conversion logic and prefix application, maintaining the same conditional behavior as the previous implementation.

packages/ui/src/cli/commands/install.ts (2)

22-35: LGTM: Version checking logic is well-implemented.

The logic correctly checks package dependencies, performs proper semantic version comparison, and efficiently handles the update-or-skip decision. The 0.11 version threshold aligns with the introduction of the new CLI system.


37-44: LGTM: Installation flow follows best practices.

The installation logic properly resolves package manager commands, provides user feedback, handles async operations correctly, and includes appropriate error handling with consistent messaging.

.changeset/tricky-planes-shake.md (1)

1-29: LGTM: Comprehensive and clear changeset documentation.

The changeset properly documents the breaking changes, explains the new system clearly, and provides actionable migration steps with specific code examples. The documentation aligns well with the implemented changes.

packages/ui/src/cli/utils/get-config.ts (1)

1-15: LGTM! Clean delegation pattern.

The refactoring to delegate all configuration management to setupConfig simplifies the code and creates a clear separation of concerns. The documentation accurately reflects the new behavior.

packages/ui/package.json (1)

165-184: New store exports properly configured.

The addition of ./store and ./store/init exports follows the established pattern with proper TypeScript declarations for both ESM and CommonJS environments. This supports the new ThemeInit component initialization system.

packages/ui/src/cli/commands/dev.ts (4)

25-27: Proper initialization sequence established.

The addition of setupOutputDirectory() ensures the output directory exists before proceeding, and setupInit(config) generates the initialization file based on the loaded configuration. This establishes a clear initialization flow.


37-62: Well-structured initial file scanning.

The initial scan properly:

  • Uses findFiles utility to discover all relevant files
  • Extracts component imports from each file
  • Builds the class list based on discovered or configured components
  • Only writes the class list file if it differs from the existing one

82-88: Smart configuration hot-reloading implemented.

The watcher now properly handles changes to configuration-related files by:

  • Reloading config when config.json or init files change
  • Re-running setupInit to regenerate the initialization file
  • Updating .gitignore when needed

This enables a smooth development experience with automatic synchronization.


115-115: Good optimization with ignoreInitial: true.

Setting ignoreInitial: true prevents the watcher from firing events for all existing files on startup, avoiding duplicate processing since the initial scan already handles existing files.

apps/web/content/docs/customize/dark-mode.mdx (1)

58-96: Documentation accurately reflects the new configuration approach.

The updated documentation:

  • Clearly explains the two-step process for disabling dark mode
  • Shows the required version property in the config example
  • Provides proper usage example for the ThemeInit component
  • Includes an important note explaining the distinction between build-time and runtime configuration

The changes align perfectly with the new architecture that removes the patch mechanism in favor of explicit configuration.

packages/ui/src/cli/commands/setup-config.ts (2)

105-116: Excellent user guidance for custom configurations.

The informative messages clearly explain:

  • When ThemeInit is required (custom values detected)
  • Why it's necessary (runtime sync with build config)
  • What happens without it (default values used)
  • Concrete example of the impact (incorrect class names)

This proactive guidance will help prevent configuration issues.


19-129: Robust configuration management implementation.

The setupConfig function provides comprehensive configuration handling:

  • ✅ Deep validation of all properties with type checking
  • ✅ Sanitization of invalid values with defaults
  • ✅ Removal of unknown properties
  • ✅ Key ordering for consistency
  • ✅ Clear error messages and user guidance
  • ✅ Proper error handling for missing/invalid files

This implementation successfully replaces the previous patch-based approach with a more maintainable configuration system.

packages/ui/src/cli/commands/setup-init.ts (2)

1-11: LGTM: Clean imports and good documentation.

The imports are appropriate and the JSDoc documentation clearly explains the function's purpose.


72-104: LGTM: Well-implemented AST comparison function.

The compareNodes function is thoughtfully designed to compare AST nodes while ignoring irrelevant metadata like location information and comments. The recursive approach handles all data types correctly, and the filtered properties list is comprehensive for typical AST structures.

@@ -0,0 +1,22 @@
/* eslint-disable */
// @ts-nocheck
// biome-ignore-all lint: auto-generated file
Copy link
Contributor

@coderabbitai coderabbitai bot Jul 21, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix the biome-ignore comment syntax.

The static analysis tool correctly identified a syntax error in the biome-ignore comment.

Apply this fix:

-// biome-ignore-all lint: auto-generated file
+// biome-ignore lint/all: auto-generated file
🧰 Tools
🪛 Biome (1.9.4)

[error] 3-3: failed to parse category "-all"

(suppressions/parse)

🤖 Prompt for AI Agents
In apps/web/.flowbite-react/init.tsx at line 3, the biome-ignore comment syntax
is incorrect and causing a syntax error. Correct the comment syntax to properly
disable biome linting for the file, ensuring it follows the expected format for
biome-ignore comments.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

are u sure this is the latest syntax?

Copy link
Contributor

Choose a reason for hiding this comment

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

🧩 Analysis chain

@SutuSebastian Let me verify the current biome-ignore syntax for you.


🌐 Web query:

biome-ignore comment syntax latest documentation 2024

💡 Result:

The Biome ignore comment syntax as of the latest available 2024 documentation (Biome 2.0+) is as follows:

Comment Syntax

  • Inline suppression (next line only):

    • // biome-ignore <category/group/rule>: <optional reason>
      • Example: // biome-ignore lint/suspicious/noDebugger: legacy code, intentional
      • Disables the specified rule for the next line only[1][4].
  • File-wide suppression (entire file):

    • // biome-ignore-all <category/group/rule>: <optional reason>
      • Must appear at the very top of the file.
      • Example: // biome-ignore-all lint/suspicious/noDebugger: generated file
      • Disables the specified rule for the entire file[4][1].
  • Range suppression:

    • // biome-ignore-start <category/group/rule>: <optional reason>
      • Starts a suppression range. Disables the rule for all lines following, until ended.
    • // biome-ignore-end
      • Ends the suppression range. This is optional; if omitted, the suppression continues to the end of the file[1][4].

Syntax Details

  • Category: lint, assist, or syntax.
  • Group/rule: e.g. /suspicious or /suspicious/noDebugger.
  • You can specify only the group, or be more specific by targeting an individual rule.
  • An explanation or reason for suppression is optional but recommended (after a colon).

Usage Examples

Use case Example
Ignore next line // biome-ignore lint/style/noUnusedVars: this is a polyfill
File-wide ignore // biome-ignore-all lint/suspicious/noDebugger: intentional debugger in devbuild
Ignore block/range // biome-ignore-start lint/suspicious/noDebugger
...
// biome-ignore-end
  • Note: If a suppression comment (like biome-ignore-all) is not at the very top of the file, Biome will flag it as unused[1].
  • Suppressions work for both lint rules and assist actions due to a shared engine[1][4].

Biome 2.0 (released 2024–2025) significantly improved suppression options, adding both // biome-ignore-all for full-file suppression and range-based // biome-ignore-start / // biome-ignore-end support. For full details, see the suppressions documentation[4][1][7].

If you need exact syntactic examples or further explanation, consult Biome’s suppressions documentation[1] and the release notes for v2.0[4].

Citations:


@SutuSebastian You're absolutely right to question my suggestion! I apologize for the confusion.

After checking the latest Biome documentation, the original syntax in your file is actually correct:

// biome-ignore-all lint: auto-generated file

According to Biome's current documentation, the proper syntax for file-wide suppression is:

  • // biome-ignore-all <category/group/rule>: <optional reason>

Where:

  • lint is the category (to disable all lint rules)
  • The colon is followed by an optional explanation

My previous suggestion of // biome-ignore lint/all: auto-generated file was incorrect. The file is already using the correct syntax for disabling all linting rules across the entire file.

The static analysis tool error might be from an older version of Biome or a configuration issue, but your syntax follows the current standard. No changes are needed to this line.


✏️ Learnings added
Learnt from: SutuSebastian
PR: themesberg/flowbite-react#1566
File: apps/web/.flowbite-react/init.tsx:0-0
Timestamp: 2025-07-21T18:59:04.117Z
Learning: The correct Biome ignore syntax for disabling all lint rules in a file is `// biome-ignore-all lint: <optional reason>`, not `// biome-ignore lint/all:` as I previously suggested.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

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
Status: In Progress
Development

Successfully merging this pull request may close these issues.

Can't resolve 'tailwindcss/version.js'
2 participants