fix(emcn): keep Prism grammar registrations in bundle, never throw on missing grammar#5293
Conversation
… missing grammar
Consumers import { highlight, languages } from the @sim/emcn barrel, which
re-exported Prism's highlight straight from prismjs. Bundlers resolved that
passthrough directly from prismjs and skipped prism.ts's module body, dropping
the side-effect grammar registrations so languages.json (etc.) were undefined at
runtime. Prism then threw 'The language "json" has no grammar.', crashing the
start-block file[] input format field and every other workflow-editor code
highlighter.
Own highlight as a local wrapper so the registrations stay in the dependency
graph, and degrade to escaped plaintext when a grammar is missing instead of
throwing.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryLow Risk Overview Instead of re-exporting Prism’s The wrapper also falls back to HTML-escaped plaintext when Reviewed by Cursor Bugbot for commit abc3c74. Configure here. |
Greptile SummaryThis PR centralizes Prism highlighting in the EMCN code helper.
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (1): Last reviewed commit: "fix(emcn): keep Prism grammar registrati..." | Re-trigger Greptile |
Summary
file[]field) crashed immediately withThe language "json" has no grammar.— and the same crash was latent in every other workflow-editor code highlighter (subflow editor, condition input, code blocks, tool-input editor, variables JSON editor).{ highlight, languages }from the@sim/emcnbarrel, which re-exported Prism'shighlightstraight fromprismjs. Bundlers resolved that passthrough directly fromprismjsand skippedprism.ts's module body — dropping the side-effect grammar registrations, solanguages.json(etc.) wereundefinedat runtime and Prism threw.prism.tsnow ownshighlightas a local wrapper, so the grammar registrations stay in the dependency graph, and the wrapper degrades to escaped plaintext when a grammar is missing instead of throwing.Type of Change
Testing
Tested manually — start-block
file[]field and other workflow-editor editors no longer crash;tscclean across@sim/emcnandapps/sim.Checklist