Registry / devops / vite-plugin-mithril-jsx

vite-plugin-mithril-jsx

JSON →
library1.0.4jsnpmunverified

Vite plugin that configures JSX for Mithril.js — works with all Vite versions (5, 6, 7+), automatically adapting to the underlying transformer (esbuild or rolldown/OXC). Ships TypeScript types. Peer dependency: vite >=5.0.0. Current stable version: 1.0.4. Release cadence: low, maintenance-driven. Key differentiator: zero-config JSX setup for Mithril across Vite versions, handles esbuild, rolldown, and OXC configs automatically.

npm install vite-plugin-mithril-jsx
INSTALL
IMPORT
SIG · VITE-PLUGIN-MITHRI
V
vite-plugin-mithril-jsx
devopsjavascriptv1.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
import mithrilJsx from 'vite-plugin-mithril-jsx'
const mithrilJsx = require('vite-plugin-mithril-jsx')
ESM-only; no CommonJS export supplied
mithrilJsx
import mithrilJsx from 'vite-plugin-mithril-jsx'
import { mithrilJsx } from 'vite-plugin-mithril-jsx'
The package uses a default export only. Named export does not exist.
MithrilJsxOptions
import type { MithrilJsxOptions } from 'vite-plugin-mithril-jsx'
Type import is available for TypeScript users; not needed at runtime.

Shows minimal Vite config with plugin, then a JSX component using Mithril.

// install: npm install -D vite-plugin-mithril-jsx // vite.config.ts import { defineConfig } from 'vite'; import mithrilJsx from 'vite-plugin-mithril-jsx'; export default defineConfig({ plugins: [mithrilJsx()], }); // Then in your App.jsx: import m from 'mithril'; export default function App() { return ( <> <h1>Hello, Mithril!</h1> <p>JSX works with no React in sight.</p> </> ); }
Debug
Known issues
gotchaThe JSX factory `m` must be available in every file using JSX. Either import `m` from 'mithril' in each file or set `globalThis.m = m` once in your entry point.
fix
Add `import m from 'mithril'` at the top of each JSX file, or set `globalThis.m = m` in your entry file before any JSX usage.
affects: >=1.0.0
gotchaThe `jsExtensions` option enables JSX parsing in .js and .ts files, which may affect build performance and cause unexpected parsing errors in non-JSX files.
fix
Only enable `jsExtensions` if you have JSX in .js/.ts files; keep default false otherwise.
affects: >=1.0.0
deprecatedVite 5 uses esbuild only; Vite 6 adds rolldown experimental; Vite 7+ uses OXC. Plugin handles this automatically, but users should be aware of the underlying transformer changes.
fix
No action needed; plugin auto-adapts.
affects: >=1.0.0
gotchaThe `pragmaFrag` default is 'mFrag', which is automatically defined via `define` to be '['. Do NOT use `mFrag` as a variable name in your code — it will be replaced at compile time.
fix
Avoid naming any variable or import `mFrag`; rely on the plugin's define.
affects: >=1.0.0
Errors
Common errors & fixes
Uncaught ReferenceError: m is not defined
JSX factory `m` is not imported or globally available in the file.
fix
Add `import m from 'mithril'` to the file using JSX.
Failed to resolve import "mithril" from "src/App.jsx". Does the file exist?
Mithril is not installed as a dependency.
fix
Run `npm install mithril` and ensure it's in your package.json.
[vite] The CJS build of Vite's Node API is deprecated.
Plugin is ESM-only; using require() to load the plugin triggers the deprecation warning.
fix
Use `import mithrilJsx from 'vite-plugin-mithril-jsx'` in an ESM context.
TypeError: mithrilJsx is not a function
Importing a named export instead of the default export.
fix
Use `import mithrilJsx from 'vite-plugin-mithril-jsx'` (no curly braces).
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies
viterequiredPeer dependency; plugin requires Vite >=5.0.0
Agent activity
4 hits · last 30 days
node
4
Resources
vite-plugin-mithril-jsx — npm install vite-plugin-mithril-jsx · libregistry