-
-
Notifications
You must be signed in to change notification settings - Fork 635
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a tool to measure memory allocations
- Loading branch information
Showing
11 changed files
with
1,895 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,5 +20,4 @@ packages/*/package-lock.json | |
.rpt2_cache_development | ||
.rpt2_cache_production | ||
|
||
scripts/fakedom/* | ||
.swc |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import {rollup} from "rollup"; | ||
import { existsSync, readdirSync, statSync } from "fs"; | ||
import commonjsPlugin from "rollup-plugin-commonjs"; | ||
import nodeResolvePlugin from "rollup-plugin-node-resolve"; | ||
import { dirname, join, resolve } from "path"; | ||
import replace from "rollup-plugin-replace"; | ||
import terser from '@rollup/plugin-terser'; | ||
import alias from "@rollup/plugin-alias"; | ||
import { fileURLToPath } from "url"; | ||
import babel from "@rollup/plugin-babel"; | ||
import jsonPlugin from "@rollup/plugin-json" | ||
|
||
const isProduction = process.env.NODE_ENV === 'production'; | ||
|
||
const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
const benchmarks = readdirSync(__dirname).filter(file => statSync(join(__dirname, file)).isDirectory()); | ||
const resolvePkg = pkg => resolve(__dirname, '../../packages', pkg, 'dist', 'index.esnext.js'); | ||
|
||
|
||
console.log(resolvePkg('inferno')); | ||
|
||
// see below for details on the options | ||
const plugins = [ | ||
replace({ | ||
'process.env.NODE_ENV': '"production"', | ||
sourcemap: false | ||
}), | ||
nodeResolvePlugin({ | ||
preferBuiltins: false | ||
}), | ||
babel({ | ||
exclude: 'node_modules/**', | ||
sourceMaps: false, | ||
babelrc: false, | ||
plugins: [ | ||
['babel-plugin-inferno', {imports: true, defineAllArguments: true}], | ||
] | ||
}), | ||
commonjsPlugin({ | ||
sourceMap: false | ||
}), | ||
jsonPlugin(), | ||
alias({ | ||
resolve: ['.js'], | ||
entries: [ | ||
{find: 'inferno', replacement: resolvePkg('inferno')}, | ||
{find: 'inferno-animation', replacement: resolvePkg('inferno-animation')}, | ||
{find: 'inferno-compat', replacement: resolvePkg('inferno-compat')}, | ||
{find: 'inferno-create-element', replacement: resolvePkg('inferno-create-element')}, | ||
{find: 'inferno-hydrate', replacement: resolvePkg('inferno-hydrate')}, | ||
{find: 'inferno-extras', replacement: resolvePkg('inferno-extras')}, | ||
{find: 'inferno-hyperscript', replacement: resolvePkg('inferno-hyperscript')}, | ||
{find: 'inferno-mobx', replacement: resolvePkg('inferno-mobx')}, | ||
{find: 'inferno-redux', replacement: resolvePkg('inferno-redux')}, | ||
{find: 'inferno-router', replacement: resolvePkg('inferno-router')}, | ||
{find: 'inferno-server', replacement: resolvePkg('inferno-server')}, | ||
{find: 'inferno-shared', replacement: resolvePkg('inferno-shared')}, | ||
{find: 'inferno-test-utils', replacement: resolvePkg('inferno-test-utils')}, | ||
{find: 'inferno-vnode-flags', replacement: resolvePkg('inferno-vnode-flags')}, | ||
{find: 'inferno-clone-vnode', replacement: resolvePkg('inferno-clone-vnode')}, | ||
{find: 'mobx', replacement: join(__dirname, '../../node_modules/mobx/dist/mobx.esm.js')} | ||
] | ||
}) | ||
]; | ||
|
||
if (isProduction) { | ||
plugins.push( | ||
terser({ | ||
compress: { | ||
ecma: 5, | ||
inline: true, | ||
if_return: false, | ||
reduce_funcs: false, | ||
passes: 5, | ||
comparisons: false, | ||
}, | ||
ie8: false, | ||
mangle: { | ||
toplevel: true | ||
}, | ||
parse: { | ||
html5_comments: false, | ||
shebang: false | ||
}, | ||
toplevel: false, | ||
warnings: false | ||
}) | ||
); | ||
} | ||
|
||
for (const dir of benchmarks) { | ||
const benchmarkPath = join(__dirname, dir); | ||
const appJsPath = resolve(benchmarkPath, 'app.js') | ||
|
||
// Don't build examples that don't have app.js | ||
if (!existsSync(appJsPath)) continue; | ||
|
||
const inputOptions = { | ||
input: appJsPath, | ||
external: ['os', 'fs', 'path', 'vm', 'url'], | ||
plugins: plugins | ||
}; | ||
|
||
const start = new Date(); | ||
|
||
console.log(`Build started -- ${start}`); | ||
|
||
rollup(inputOptions).then(function (opts) { | ||
return opts.write({ | ||
format: 'esm', | ||
file: join(benchmarkPath, 'dist', 'bundle.js'), | ||
sourcemap: false, | ||
name: 'inferno' | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {JSDOM} from 'jsdom'; | ||
const dom = new JSDOM(`<!DOCTYPE html><html><body><div id="app"></div></body></html>`); | ||
|
||
const rafMock = Promise.resolve().then.bind(Promise.resolve()); | ||
|
||
global.window = dom.window; | ||
global.document = dom.window.document; | ||
global.Node = dom.window.Node; | ||
global.window.requestAnimationFrame = rafMock | ||
global.requestAnimationFrame = rafMock; | ||
|
||
export const container = dom.window.document.querySelector("#app"); |
Oops, something went wrong.