Skip to content

chore(css-modules): 🤖 Prevent duplicate CSS imports in build watcher#981

Merged
punkbit merged 2 commits intomainfrom
fix/tracked-imports-keeps-appending-causing-duplicate-css-imports-on-rebuild
Apr 10, 2026
Merged

chore(css-modules): 🤖 Prevent duplicate CSS imports in build watcher#981
punkbit merged 2 commits intomainfrom
fix/tracked-imports-keeps-appending-causing-duplicate-css-imports-on-rebuild

Conversation

@punkbit
Copy link
Copy Markdown
Contributor

@punkbit punkbit commented Apr 10, 2026

Why?

Prevent duplicate CSS imports in vite build --watch mode by clearing trackedImports between rebuilds.

How?

  • Reset on buildStart call

Preview?

N/A

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 10, 2026

🦋 Changeset detected

Latest commit: c31189c

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

This PR includes changesets to release 1 package
Name Type
@clickhouse/click-ui 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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 10, 2026

Claude finished @punkbit's task in 32s —— View job


Code Review

  • Gather context
  • Read changed files
  • Provide review

✅ Looks great! Clean, minimal, and correct fix.

The use of trackedImports.length = 0 (mutating in place rather than reassigning to []) is the right approach here — it preserves the array reference used across closures in the plugin. Resetting in buildStart is the correct hook for this since it fires at the beginning of each build cycle in watch mode, before transform populates the array again.

The changeset is correctly marked as patch.

💡 Suggestion (non-blocking)

  • plugins/css-colocate/index.ts:30–37: Since trackedImports.length = 0 and preprocessCssModules are both in buildStart, it's worth noting that if preprocessCssModules throws, the reset still happened — which is fine and actually desirable (stale imports from a failed prior build shouldn't carry over). No action needed, just confirming the ordering is intentional and correct.

Nice work! 🙌

@workflow-authentication-public
Copy link
Copy Markdown
Contributor

📚 Storybook Preview Deployed

✅ Preview URL: https://click-gky5lnta9-clickhouse.vercel.app

Built from commit: 0748b2f683b1e3b3e5f97b7e20a1d3ba01d485f4

@punkbit punkbit merged commit 12770c3 into main Apr 10, 2026
11 checks passed
@punkbit punkbit deleted the fix/tracked-imports-keeps-appending-causing-duplicate-css-imports-on-rebuild branch April 10, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants