Skip to content

fix(emcn): keep Prism grammar registrations in bundle, never throw on missing grammar#5293

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/files-inpp
Jun 30, 2026
Merged

fix(emcn): keep Prism grammar registrations in bundle, never throw on missing grammar#5293
waleedlatif1 merged 1 commit into
stagingfrom
fix/files-inpp

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Selecting files in the start block's input format (file[] field) crashed immediately with The 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).
  • Root cause: 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 and Prism threw.
  • Fix is centralized at the source: prism.ts now owns highlight as 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.
  • No per-file imports or inline guards — one change covers all consumers.

Type of Change

  • Bug fix

Testing

Tested manually — start-block file[] field and other workflow-editor editors no longer crash; tsc clean across @sim/emcn and apps/sim.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)
… 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.
@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Jun 30, 2026 8:05pm

Request Review

@cursor

cursor Bot commented Jun 30, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Localized UI syntax-highlighting fix with a defensive fallback; no auth, data, or API surface changes beyond safer highlighting behavior.

Overview
Fixes workflow-editor crashes (The language "json" has no grammar.) by changing how highlight is exported from prism.ts.

Instead of re-exporting Prism’s highlight from prismjs, the module now defines a local highlight wrapper that calls prismHighlight internally. That keeps the side-effect grammar component imports in the bundle graph when consumers pull { highlight, languages } from the @sim/emcn barrel—bundlers no longer resolve highlight straight from prismjs and drop the registrations.

The wrapper also falls back to HTML-escaped plaintext when grammar is undefined, so a missing or unregistered language degrades safely instead of throwing. All barrel consumers get this behavior from one centralized change.

Reviewed by Cursor Bugbot for commit abc3c74. Configure here.

@greptile-apps

greptile-apps Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR centralizes Prism highlighting in the EMCN code helper.

  • Adds a local highlight wrapper around Prism.
  • Keeps grammar registration imports in the same module as the exported helper.
  • Falls back to escaped plaintext when a grammar is missing.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • The wrapper preserves the existing exported names.
  • The missing-grammar fallback returns escaped text in the inspected rendering path.

Important Files Changed

Filename Overview
packages/emcn/src/components/code/prism.ts Replaces the direct Prism highlight re-export with a local wrapper and missing-grammar plaintext fallback.

Reviews (1): Last reviewed commit: "fix(emcn): keep Prism grammar registrati..." | Re-trigger Greptile

@waleedlatif1 waleedlatif1 merged commit 84c22f1 into staging Jun 30, 2026
17 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/files-inpp branch June 30, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant