Development Guide
This document describes how to develop the ef library itself.
Requirements
You need Bun v1, and Node.js v20 (optional). Node.js is required for publishing the package and running benchmark on V8.
AWS CLI is also required for website deployment.
This project has .tool-versions file.
Use of a tool that supports reading .tool-versions is recommended.
Commands
Generate bundle files
bun scripts/bundle.ts
This command bundles src/ef.js then writes to dist/ and bundle.zip.
Check module imports
bun scripts/check-impots.ts
This command checks every imports in src/**/*.ts.
This command exit with non-zero code when any of import rule violations found.
Build the website
bun scripts/website/build.ts
This command builds the website files then writes them to website/dist/.
Build and Serve the website
bun scripts/website/serve.ts
# Rebuild when the source files are changed. Currently does not work for non ".tsx?" files due
# to a bug in Bun. Also changes to client-only file does not trigger rebuild too.
bun --hot scripts/website/serve.ts
# Specify listen port and hostname
HOST=my.domain PORT=8080 bun scripts/website/serve.ts
This command starts a web server and builds the website files.
Build npm distribution files
bun run build
This command starts TypeScript Compiler then creates esm/es2019/*.js and esm/es2019/*.d.ts.
Run unit tests
bun test
This command runs unit tests.
Add --watch option in order to start in watch mode.
For more options, please run the command with --help option.
Test files are under tests/ directory, and have .test.ts extension.
Do not put test files under src/ because that makes build configuration way more complex.
Run example pages
bun examples
# or
bun run examples
This starts Vite dev server.
Run benchmarks
# JavaScriptCore
bun bench/[path/to/suite.js]
# V8
node bench/[path/to/suite.js]
These command runs benchmarks.
Benchmark suites are at bench/, written in plain JavaScript because Node.js can’t run TypeScript files directly.
Run in-browser benchmark
bun bench
# then open displayed URL in your browser
This command starts a Vite dev server, which serves a simple HTML page that runs in-browser benchmark JS. The script automatically starts once the page is loaded, and the result is displayed in browser console.
Publish package to NPM
npm publish
Deploy built website
bun scripts/website/deploy.ts --s3-bucket "S3 bucket name" --cf-dist-id "CloudFront distribution ID"
In order to authenticate, you need configure below environment variables:
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_DEFAULT_REGION
Each CLI options has corresponding environment variables.
--s3-bucket…S3_BUCKET--cf-dist-id…CF_DIST_ID