Skip to content

fix: mark prism-extend as side-effectful to fix CJS language registration#5148

Merged
traefiker merged 1 commit intotraefik:masterfrom
mdeliatf:fix/prism-cjs-build
Apr 30, 2026
Merged

fix: mark prism-extend as side-effectful to fix CJS language registration#5148
traefiker merged 1 commit intotraefik:masterfrom
mdeliatf:fix/prism-cjs-build

Conversation

@mdeliatf
Copy link
Copy Markdown
Contributor

Description

Additional Prism languages registered in prism-extend.ts worked locally and in Storybook but were silently dropped when hub-ui was built via Docker CI.

Root cause

package.json had "sideEffects": false, which tells bundlers they can safely tree-shake any module that only re-exports values from externals. Rolldown exploited this when generating the CJS build: since prism-extend.ts re-exports Prism from prism-react-renderer (an external dependency), it inlined the import directly and never generated prism-extend.cjs, losing all the language registration side effects in the process.

The ESM build was unaffected because ESM preserves module identity more strictly. Local development was also unaffected because webpack skips tree-shaking in dev mode.

The combination that triggered the bug: CJS resolution (Next.js production build) + tree-shaking enabled (webpack production mode) + sideEffects: false (told rolldown the module was pure).

How to test

  1. Pull the updated Faency package into hub-ui
  2. Run next build (or trigger a Docker CI build) this exercises the CJS path with tree-shaking enabled
  3. Open a page that renders a CodeBlock with one of the previously broken languages (e.g. hcl, toml, docker, bash) and verify syntax highlighting is applied correctly
  4. Confirm the same page works in the deployed Docker image

Good PR checkboxes

  • Change has been tested
  • Added/Updated tests
  • Added/Updated stories
  • PR follows conventions
  • Labels are set
  • Project is linked

Good Review checkboxes

ℹ️ Copy the snippet and paste in the review field to fill it
- [ ] I've tested the changes
- [ ] I've agreed on the unit tests (soon to come)
- [ ] I've checked the stories
- [ ] I've read the code and understood it
- [ ] I don't have any more questions
- [ ] I've described any optional improvements
- [ ] I checked PR follows [conventions](https://github.com/traefik/faency#how-to-contribute)

@mdeliatf mdeliatf force-pushed the fix/prism-cjs-build branch from f7ad391 to 5e50225 Compare April 29, 2026 10:02
@traefiker traefiker merged commit a939899 into traefik:master Apr 30, 2026
4 checks passed
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 12.3.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants