Skip to content

Commit 412a2a3

Browse files
author
Alexis Bouhet
committed
Reflex DOM benchmark
1 parent 3d5ed63 commit 412a2a3

File tree

6 files changed

+698
-0
lines changed

6 files changed

+698
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import esbuild from "esbuild";
2+
3+
// ----------------------------------------------------------------------------- BUILD MODE
4+
const buildMode = (process.argv[2] ?? "dev").toLowerCase();
5+
const isDev = buildMode === "dev"
6+
if ( buildMode !== 'prod' && buildMode !== 'dev' ) {
7+
console.error("Build mode need to be 'prod' or 'dev'.")
8+
process.exit(0)
9+
}
10+
11+
// ----------------------------------------------------------------------------- BUILD CONTEXT
12+
// Create build context
13+
const _buildContext = await esbuild.context({
14+
//target: [ 'chrome58', 'edge18', 'firefox57', 'safari11' ],
15+
platform: "browser",
16+
format: "iife",
17+
minify: !isDev,
18+
mangleProps: isDev ? undefined : /^_/,
19+
bundle: true,
20+
loader: {
21+
'.ts' : 'ts',
22+
'.tsx' : 'tsx'
23+
},
24+
metafile: true,
25+
write: true,
26+
plugins: [],
27+
define: {
28+
"process.env.NODE_ENV": isDev ? `"development"` : `"production"`
29+
},
30+
logLevel: "info",
31+
outbase: "./src/",
32+
entryPoints: ["./src/main.tsx"],
33+
outdir: "./dist/"
34+
})
35+
36+
// ----------------------------------------------------------------------------- DEV OR BUILD
37+
38+
// Dev mode
39+
if ( isDev ) {
40+
await _buildContext.watch()
41+
}
42+
// Build mode
43+
else {
44+
await _buildContext.rebuild()
45+
await _buildContext.dispose()
46+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>Reflex-DOM</title>
6+
<link href="/css/currentStyle.css" rel="stylesheet"/>
7+
</head>
8+
<body>
9+
<div id="main"></div>
10+
<script src="./dist/main.js" type="module"></script>
11+
</body>
12+
</html>

0 commit comments

Comments
 (0)