mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Added lib for size benchmark
This commit is contained in:
parent
def5a52815
commit
41b2c0878a
6
benchmark/size/inferno/client.jsx
Normal file
6
benchmark/size/inferno/client.jsx
Normal file
@ -0,0 +1,6 @@
|
||||
import Inferno, { render } from 'inferno';
|
||||
import App from './components/App';
|
||||
|
||||
render(
|
||||
<App name='Frank' colors={['red', 'green', 'blue']}/>,
|
||||
document.body);
|
||||
57
benchmark/size/inferno/components/App/index.jsx
Normal file
57
benchmark/size/inferno/components/App/index.jsx
Normal file
@ -0,0 +1,57 @@
|
||||
'use strict';
|
||||
import Inferno from 'inferno';
|
||||
import Component from 'inferno-component';
|
||||
|
||||
function renderColor(color) {
|
||||
var style = {
|
||||
backgroundColor: color
|
||||
};
|
||||
|
||||
return <li className="color" style={style}>
|
||||
{color}
|
||||
</li>
|
||||
}
|
||||
|
||||
function renderColors(colors) {
|
||||
if (colors.length) {
|
||||
return (<ul>{colors.map(renderColor)}</ul>);
|
||||
} else {
|
||||
return <div>No colors!</div>
|
||||
}
|
||||
}
|
||||
|
||||
export default class extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
name: props.name,
|
||||
colors: props.colors,
|
||||
clickCount: 0
|
||||
}
|
||||
|
||||
this.handleButtonClick = function() {
|
||||
this.setState({
|
||||
clickCount: this.state.clickCount + 1
|
||||
});
|
||||
}.bind(this);
|
||||
}
|
||||
|
||||
render() {
|
||||
var colors = this.state.colors;
|
||||
var name = this.state.name;
|
||||
var clickCount = this.state.clickCount;
|
||||
var handleButtonClick = this.handleButtonClick;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>Hello {name}!</h1>
|
||||
<div className="colors">
|
||||
{renderColors(colors)}
|
||||
</div>
|
||||
<button type="button" onClick={handleButtonClick}>
|
||||
You clicked the button {clickCount} time(s)
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
37
benchmark/size/inferno/rollup.config.js
Normal file
37
benchmark/size/inferno/rollup.config.js
Normal file
@ -0,0 +1,37 @@
|
||||
import commonjsPlugin from 'rollup-plugin-commonjs';
|
||||
import browserifyPlugin from 'rollup-plugin-browserify-transform';
|
||||
import nodeResolvePlugin from 'rollup-plugin-node-resolve';
|
||||
import babelPlugin from 'rollup-plugin-babel';
|
||||
import envify from 'envify';
|
||||
import path from 'path';
|
||||
|
||||
process.env.NODE_ENV = 'production';
|
||||
|
||||
// NODE_ENV=production browserify -t envify -t markoify --extension='.marko' --global-transform minprops/browserify -o build/bundles/marko.js marko/client.js
|
||||
|
||||
|
||||
export default {
|
||||
entry: path.join(__dirname, 'client.jsx'),
|
||||
format: 'iife',
|
||||
moduleName: 'app',
|
||||
plugins: [
|
||||
babelPlugin({
|
||||
include: ['node_modules/**', '**/*.js', '**/*.jsx'],
|
||||
babelrc: false,
|
||||
"presets": [
|
||||
["es2015", { "loose": true, "modules": false }],
|
||||
"stage-0"
|
||||
],
|
||||
"plugins": ["inferno"]
|
||||
}),
|
||||
browserifyPlugin(envify),
|
||||
nodeResolvePlugin({
|
||||
jsnext: false, // Default: false
|
||||
main: true, // Default: true
|
||||
browser: true, // Default: false
|
||||
preferBuiltins: false,
|
||||
extensions: [ '.js', '.jsx' ]
|
||||
})
|
||||
],
|
||||
dest: path.join(__dirname, '../build/bundles/inferno.js')
|
||||
};
|
||||
@ -7,17 +7,20 @@
|
||||
"setup": "npm install --silent && npm link ../../",
|
||||
"build": "npm run bundle --silent && npm run minify --silent",
|
||||
"build-marko": "npm run bundle-marko --silent && node minify.js marko",
|
||||
"bundle": "mkdir -p build/bundles && npm run bundle-marko && npm run bundle-react && npm run bundle-vue && npm run bundle-preact",
|
||||
"build-inferno": "npm run bundle-inferno --silent && node minify.js inferno",
|
||||
"bundle": "mkdir -p build/bundles && npm run bundle-marko && npm run bundle-react && npm run bundle-vue && npm run bundle-preact && npm run bundle-inferno",
|
||||
"bundle-marko": "NODE_ENV=production rollup -c marko/rollup.config.js",
|
||||
"bundle-react": "NODE_ENV=production rollup -c react/rollup.config.js",
|
||||
"bundle-preact": "NODE_ENV=production rollup -c preact/rollup.config.js",
|
||||
"bundle-vue": "NODE_ENV=production rollup -c vue/rollup.config.js",
|
||||
"bundle-inferno": "NODE_ENV=production rollup -c inferno/rollup.config.js",
|
||||
"minify": "node minify.js",
|
||||
"http-server": "http-server"
|
||||
},
|
||||
"author": "Patrick Steele-Idem <pnidem@gmail.com>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"babel-plugin-inferno": "^1.8.0",
|
||||
"babel-plugin-transform-es2015-block-scoping": "^6.21.0",
|
||||
"babel-plugin-transform-react-constant-elements": "^6.9.1",
|
||||
"babel-plugin-transform-react-jsx": "^6.8.0",
|
||||
@ -31,6 +34,9 @@
|
||||
"format-number": "^2.0.1",
|
||||
"google-closure-compiler-js": "^20161201.0.0",
|
||||
"http-server": "^0.9.0",
|
||||
"inferno": "^1.3.0-rc.1",
|
||||
"inferno-component": "^1.3.0-rc.1",
|
||||
"inferno-server": "^1.3.0-rc.1",
|
||||
"markoify": "^2.1.1",
|
||||
"minprops": "^1.0.0",
|
||||
"preact": "^7.1.0",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user