An extensible library for highlighting JSX syntax in the Monaco Editor using Babel. Current stable version: 2.77.77. Released on npm with active maintenance. Key differentiators: directly uses Babel for parsing (not jscodeshift), exposes AST for custom highlighting, supports JSX commenting, and provides debounced highlight updates. Requires peer dependencies: @babel/parser, @babel/traverse, and monaco-editor (>=0.21). Suitable for React JSX and TSX projects using Monaco Editor.
npm install monaco-jsx-highlighterVerified import paths — ran on the pinned version, not inferred.
Set up Monaco Editor, parse JSX with Babel, and activate JSX highlighting and commenting.
Replace jscodeshift with @babel/parser and @babel/traverse; update constructor arguments.
Update call: highlightOnDidChangeModelContent(debounceTime, afterHighlight) instead of highlightOnDidChangeModelContent(afterHighlight).
Ensure cleanup logic is reliable; consider recreating the highlighter instead of reusing.
Install peer deps explicitly: npm install @babel/parser @babel/traverse monaco-editor
Run npm install monaco-jsx-highlighter @babel/parser @babel/traverse monaco-editor
Use import MonacoJSXHighlighter from 'monaco-jsx-highlighter' and instantiate correctly.
Install @babel/traverse: npm install @babel/traverse
Use import MonacoJSXHighlighter from 'monaco-jsx-highlighter' for ESM, or const MonacoJSXHighlighter = require('monaco-jsx-highlighter').default for CJS.