Skip to content
This repository was archived by the owner on Sep 2, 2024. It is now read-only.
/ mopt Public archive

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

License

Notifications You must be signed in to change notification settings

MithrilJS/mopt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

e74d635 · Jun 4, 2017
Jun 4, 2017
Jun 4, 2017
Dec 5, 2015
Sep 30, 2015
May 5, 2016
Jun 1, 2016
Jun 1, 2016
Jun 4, 2017
Jun 4, 2017
Sep 11, 2016
May 12, 2016
Jun 4, 2017
Jun 4, 2017
May 2, 2017

Repository files navigation

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

Browserify - babelify

WebPack - babel-loader