Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/MithrilJS/mopt
Babel plugin to optimize Mithril m() calls into simple JS objects for speed
https://github.com/MithrilJS/mopt
babel build mithril optimization
Last synced: 3 months ago
JSON representation
Babel plugin to optimize Mithril m() calls into simple JS objects for speed
- Host: GitHub
- URL: https://github.com/MithrilJS/mopt
- Owner: MithrilJS
- License: mit
- Created: 2015-09-30T00:18:41.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-04T20:18:48.000Z (over 7 years ago)
- Last Synced: 2024-07-03T00:37:55.764Z (4 months ago)
- Topics: babel, build, mithril, optimization
- Language: JavaScript
- Homepage:
- Size: 251 KB
- Stars: 43
- Watchers: 5
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
- awesome-mithril - mopt - Optimize `m()` calls to javascript objects. (Uncategorized / Uncategorized)
README
mopt [![NPM Version](https://img.shields.io/npm/v/mopt.svg)](https://www.npmjs.com/package/mopt) [![NPM License](https://img.shields.io/npm/l/mopt.svg)](https://www.npmjs.com/package/mopt)
=================A [babel](babeljs.io) plugin to statically optimize [mithril](http://mithril.js.org) hyperscript function invocations.
```js
// 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](https://npmjs.com/mithril-objectify).
## Installation
Install with npm
`npm i mopt`
## Usage with Babel
### `.babelrc`
```js
// .babelrc
{
"plugins": [ "mopt" ]
}
```### CLI
`$ babel --plugins mopt script.js`
### API
```js
require("babel-core").transform("", {
plugins: [ "mopt" ]
});
```## Usage with a bundler
### Rollup - [`rollup-plugin-babel`](https://www.npmjs.com/package/rollup-plugin-babel)
### Browserify - [`babelify`](https://www.npmjs.com/package/babelify)
### WebPack - [`babel-loader`](https://www.npmjs.com/package/babel-loader)