Babel plugin to optimize Mithril m() calls into simple JS objects for speed
JavaScript
Latest commit fbbc966 Dec 26, 2016 @tivac v5.0.1
Permalink
Failed to load latest commit information.
src
test fix: Properly transform array children Dec 25, 2016
.eslintignore Fix eslint complaint Dec 5, 2015
.gitattributes 👾 Added .gitattributes & .gitignore files Sep 30, 2015
.gitignore
.npmignore Publish w/ publish-please Jun 1, 2016
.publishrc
.travis.yml build: new repo location Dec 25, 2016
CHANGES.md
LICENSE
jsconfig.json Convert to Babel plugin (#33) May 12, 2016
package.json v5.0.1 Dec 27, 2016
readme.md docs: readme formatting and more badge oddities Dec 27, 2016

readme.md

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 mithril@1.x.

For optimizing mithril@0.2.x 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