Babel plugin to optimize Mithril m() calls into simple JS objects for speed
New patterns optimized since 2.0.0
m("div", [].join(...))
m("div", "string".replace(...))
and other String.prototype
methods that return a stringm("div", JSON.stringify(...))
m("div", fooga ? "wooga" : "booga")
m("div", m.trust("<div></div>"))
m("div", m.component(component))
(New in 2.2.0)The only new feature in v2.0.0
is the addition of a rollup plugin to simplify usage w/ that bundler.
rollup.rollup({
entry : "./entry.js",
plugins : [
require("mithril-objectify/rollup")()
]
})
.then(function(bundle) {
return bundle.write({
dest : "./out/source.js"
});
})
Exports have changed. To access the browserify transform now requires:
require("mithril-objectify/browserify");
The JS API is now available as the default export:
require("mithril-objectify");
All other usage remains the same, and documentation in the README has been updated.
mithril-objectify
now understands the following signature:
m(".foo", [ 1, 2, 3 ].map(function(val) { return m("p", val); }));
Which is another step towards optimizing every little thing that is safe to statically optimize! Right now it's limited to the subset of Array.prototype
methods that return an array, so concat
, filter
, map
, reverse
, slice
, sort
, splice
will all be optimized. Let me know if I missed one!
npm i mithril-objectify
will get you the latest release!
v1.1.1
is a patched version of v1.1.0
, which actually included all the above array fun but also included Issue #6, so v.1.1.1
is the clearly superior version!