- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
# 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.
This project has `.tool-versions` file.
Use of a tool that supports reading `.tool-versions` is recommended.
## Commands
### Generate bundle files
```sh
bun scripts/bundle.ts
```
This command bundles `src/ef.js` then writes to `dist/` and `bundle.zip`.
### Check module imports
```sh
bun scripts/check-impots.ts
```
This command checks every `import`s in `src/**/*.ts`.
This command exit with non-zero code when any of import rule violations found.
### Build the website
```sh
bun scripts/website/build.ts
```
This command builds the website files then writes them to `website/dist/`.
### Build and Serve the website
```sh
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
```sh
bun run build
```
This command starts TypeScript Compiler then creates `esm/es2019/*.js` and `esm/es2019/*.d.ts`.
### Run unit tests
```sh
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
```sh
bun examples
# or
bun run examples
```
This starts Vite dev server.
### Run benchmarks
```sh
# 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
```sh
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
```sh
npm publish
```