Repository navigation
Conversation
🦋 Changeset detectedLatest commit: 308b44a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
marsian83
marked this pull request as ready for review
November 27, 2026 15:51
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In a Vite dev server that renders on the server through Vite's module runner, such as Waku, every page that imports from
@clickhouse/click-uifails to server render (#1020):The page responds with a 500 and an empty
<body>, and the browser renders it from the RSC payload. Production builds (waku build) are not affected.In the ESM build,
CodeBlockimportsLightfromreact-syntax-highlighter, which bundlers resolve to its ESM build, but its six languages fromreact-syntax-highlighter/dist/cjs/.... When Vite's module runner evaluates one of those CJS files, itsrequire('@babel/runtime/helpers/interopRequireDefault')returns an ES module instead of the function.CodeBlockimports the languages fromreact-syntax-highlighter/dist/esm/....dist/cjs/...with Rollup'soutput.paths, so the CJS build keeps requiring CJS files. Pointing it at the ESM files would break Jest setups that don't transformnode_modules..default || xfallbacks from theregisterLanguagecalls.Links and tickets
Closes #1020
Good to know
Tested with packed builds (
yarn pack) ofmainand this branch:mainwaku dev, page importing onlyButtonwaku dev, SQLCodeBlockwaku build+waku startnext buildwith webpack and with Turbopackreact-dom/server, CSS stubbed as Jest wouldCodeBlockfrom source through Vite, which loads either formatFollow-ups I noticed and kept out of this PR:
CodeBlockregisters its languages at module top level, so importing anything from the package root runs it. Registering on first render would keep imports stabl.languageis typed asstring, so an unsupported language silently renders as plain text. tightening the type, or letting consumers register more languages, is a public API change, so Ig i should propose that in an issue first?Checklist
Contribution
buildandbuild-storybookwork locallyAccessibility
No markup, behavior or style changes.
Screenshots
Network tab,
waku dev, page importing onlyButton:Note
Medium Risk
Touches dual-format packaging and dependency resolution for CodeBlock, but scope is narrow and backed by new build guards plus manual Waku/Next/Jest verification.
Overview
Fixes server-side failures (
_interopRequireDefault is not a function) in Vite SSR consumers (e.g. Waku) when anything from the package root loads CodeBlock, which previously pulledreact-syntax-highlighterlanguage modules fromdist/cjsin the ESM output.CodeBlock now imports languages from
dist/esm/...and registers them without CJS interop fallbacks. The CJS bundle rewrites those paths back todist/cjsvia Rollupoutput.pathsinvite.config.ts, so Jest-style CJS consumers stay on CommonJS deps.The build health check script now fails the build if ESM artifacts import another package’s CJS build, or CJS artifacts require ESM builds — guarding against this class of SSR/Jest breakage going forward. Highlighting behavior is unchanged; patch release noted in the changeset.
Reviewed by Cursor Bugbot for commit 308b44a. Bugbot is set up for automated code reviews on this repo. Configure here.