Mopt Save

Babel plugin to optimize Mithril m() calls into simple JS objects for speed

Project README

mopt NPM Version NPM License

A babel plugin to statically optimize mithril hyperscript function invocations.

// This hyperscript function invocation
m(".fooga");

// Gets optimized into
m.vnode("div",undefined,{className:"fooga"},undefined,undefined,undefined);

Please file an issue if you come across any cases that this doesn't handle, I'd love to improve the number of structures I can rewrite!

Mithril Version Warning

mopt only works with [email protected].

For optimizing [email protected] see mithril-objectify.

Installation

Install with npm

npm i mopt

Usage with Babel

.babelrc

// .babelrc
{
    "plugins": [ "mopt" ]
}

CLI

$ babel --plugins mopt script.js

API

require("babel-core").transform("<code>", {
  plugins: [ "mopt" ]
});

Usage with a bundler

Rollup - rollup-plugin-babel

Browserify - babelify

WebPack - babel-loader

Open Source Agenda is not affiliated with "Mopt" Project. README Source: MithrilJS/mopt
Stars
44
Open Issues
2
Last Commit
6 years ago
Repository
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating