Skip to content

Commit

Permalink
Rollup render function
Browse files Browse the repository at this point in the history
  • Loading branch information
platypii committed Jun 6, 2024
1 parent 541c746 commit 0b43615
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"no-useless-return": "error",
"no-var": "error",
"object-curly-spacing": ["error", "always"],
"prefer-const": "error",
"prefer-const": "warn",
"prefer-destructuring": ["warn", {"object": true, "array": false}],
"prefer-promise-reject-errors": "error",
"quotes": ["error", "single"],
Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@
"hyperparam": "./src/cli.js"
},
"scripts": {
"lint": "eslint .",
"build": "rollup -c",
"lint": "eslint src",
"serve": "node src/cli.js serve",
"test": "vitest run"
},
"devDependencies": {
"@rollup/plugin-commonjs": "26.0.1",
"@rollup/plugin-node-resolve": "15.2.3",
"@rollup/plugin-replace": "5.0.7",
"@rollup/plugin-terser": "0.4.4",
"@types/node": "20.14.2",
"@typescript-eslint/eslint-plugin": "7.11.0",
"eslint": "8.57.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-jsdoc": "48.2.7",
"rollup": "4.18.0",
"typescript": "5.4.5",
"vitest": "1.6.0"
}
Expand Down
2 changes: 2 additions & 0 deletions public/bundle.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions public/bundle.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 1 addition & 15 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,7 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Mulish:wght@400;600&display=swap"/>
</head>
<body>
<div id="dropzone">
<div id="overlay">
Drop .parquet file
</div>
<nav>
<h1>hyperparam</h1>
</nav>
<div id="content">
<div id="welcome">
Drop .parquet file here
</div>
</div>
</div>
<input id="file-input" type="file">

<div id="app"></div>
<script type="module" src="bundle.min.js"></script>
</body>
</html>
23 changes: 23 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import commonjs from '@rollup/plugin-commonjs'
import resolve from '@rollup/plugin-node-resolve'
import replace from '@rollup/plugin-replace'
import terser from '@rollup/plugin-terser'

export default {
input: 'src/render.js',
output: {
file: 'public/bundle.min.js',
name: 'hyperparam',
format: 'iife',
sourcemap: true,
},
plugins: [
commonjs(),
replace({
'process.env.NODE_ENV': JSON.stringify('production'), // or 'development' based on your build environment
preventAssignment: true,
}),
resolve({ browser: true }),
terser(),
],
}
9 changes: 9 additions & 0 deletions src/render.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function render() {
const app = document.getElementById('app')
if (!app) throw new Error('missing app element')
app.innerHTML = `
<h1>Hello, World!</h1>
<p>Current time: ${new Date()}</p>
`
}
render()
2 changes: 1 addition & 1 deletion src/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* Dependency-free http server for serving static files
*/

import http from 'http'
import fs from 'fs/promises'
import http from 'http'
import path from 'path'
import url from 'url'
import zlib from 'zlib'
Expand Down

0 comments on commit 0b43615

Please sign in to comment.