Registry / web-framework / babel-plugin-mjsx

babel-plugin-mjsx

JSON →
library4.1.1jsnpmunverified

Babel plugin for Mithril JSX precompilation, converting JSX into Mithril virtual DOM nodes (e.g., {tag: 'div', attrs: {}, children: []}). Current stable version is 4.1.1. The plugin has evolved through major versions, with v4.0.0 changing whitespace trimming behavior and v4.1.0 adding jsxCompliant (attribute casing) and warnDeprecatedHtml options. It is the primary JSX compiler for Mithril v2+ and precompilation yields performance benefits over runtime interpretation.

npm install babel-plugin-mjsx
INSTALL
IMPORT
SIG · BABEL-PLUGIN-MJSX
B
babel-plugin-mjsx
web-frameworkjavascriptv4.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin
plugins: ['mjsx']
plugins: ['babel-plugin-mjsx']
Babel plugin names are automatic without 'babel-plugin-' prefix
jsxCompliant
plugins: [['mjsx', { jsxCompliant: true }]]
plugins: [['mjsx', { jsxCompliant: 'true' }]]
Option must be boolean, not string
warnDeprecatedHtml
plugins: [['mjsx', { warnDeprecatedHtml: true }]]
plugins: [['mjsx', { deprecated: true }]]
Explicit option name is 'warnDeprecatedHtml'

Demonstrates Babel configuration and JSX-to-Mithril precompilation output.

// .babelrc { "plugins": [ ["mjsx", { jsxCompliant: true, warnDeprecatedHtml: false }] ] } // Input: const view = () => ( <div className="container"> <Component foo="bar">Text</Component> </div> ); // Output (simplified): const view = () => ({ tag: 'div', attrs: { className: 'container' }, children: [ m.component(Component, { foo: 'bar' }, ['Text']) ] });
Debug
Known issues
breakingv4.0.0 changed whitespace trimming behavior to match v1.x; existing code may render differently if relying on whitespace.
fix
Update to v4.0.0+ and adjust templates if whitespace matters.
affects: <4.0.0
deprecatedv4.1.0 changed option name from 'deprecated' to 'warnDeprecatedHtml'. Using deprecated option name will be ignored.
fix
Use 'warnDeprecatedHtml' instead of 'deprecated'.
affects: >=4.1.0
gotchaPlugin name in Babel config must be 'mjsx', not 'babel-plugin-mjsx' or Babel will fail to find it.
fix
Use 'mjsx' as plugin name in .babelrc or programmatic config.
affects: >=3.0.0
gotchaThe plugin outputs Mithril v1-style m.component() for custom components; Mithril v2 uses m() directly. This may cause confusion.
fix
Ensure your Mithril version is compatible or manually adjust output.
affects: >=4.0.0
Errors
Common errors & fixes
Error: Cannot find module 'babel-plugin-mjsx'
Plugin name incorrectly prefixed with 'babel-plugin-' in config, but npm installed correctly.
fix
Use 'mjsx' in Babel config, not 'babel-plugin-mjsx'.
Unsupported option: deprecated
Using 'deprecated' option name after v4.1.0.
fix
Replace 'deprecated' with 'warnDeprecatedHtml'.
TypeError: Cannot read properties of null (reading 'tag')
JSX returning null or undefined, e.g., conditional rendering without fallback.
fix
Ensure JSX always returns a valid element or wrap conditionals with m() or fragment.
Upgrade
Version history
4.1.1latest on npm
Audit
Dependencies
@babel/corerequiredBabel plugin requires Babel core to function
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
babel-plugin-mjsx — npm install babel-plugin-mjsx · libregistry