Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from PNPM to Bun, incl. dropping Jest & esbuild #1021

Merged
merged 6 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 8 additions & 17 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,20 @@ jobs:
steps:
- uses: actions/checkout@v4

# TODO Remove pnpm/action-setup after switching to using https://github.com/aspect-build/rules_ts (?)
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10 # Keep pnpm version in sync with web/README.md
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
cache-dependency-path: web/pnpm-lock.yaml
- name: Install bun
uses: oven-sh/setup-bun@v2
- name: Install Web dependencies
working-directory: web
run: pnpm install
run: bun install
- name: Test Web
working-directory: web
run: pnpm test
- name: Run TSC
working-directory: web
run: pnpm run tsc
run: bun test
# - name: Run Typescript Compiler (TSC)
# working-directory: web
# run: bun tsc
- name: Build Web
working-directory: web
run: pnpm run build
run: ./build

- uses: actions/setup-java@v4
with:
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ docs/BUILT/**
node_modules/
web/web-out/
# TODO This is ugly... how to better separate, to avoid?
web/public/bundle.js
web/public/bundle.js.map
web/public/bundles/

# Be
.be/
Expand Down
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"redhat.vscode-yaml",
"gruntfuggly.todo-tree",
"jbangdev.jbang-vscode",
"Orta.vscode-jest"
"oven.bun-vscode"
],
"unwantedRecommendations": [
// https://github.com/kshetline/ligatures-limited/issues/39
Expand Down
2 changes: 1 addition & 1 deletion docs/use/rosetta/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ $ ./enola rosetta --in test/picasso.ttl --out docs/BUILT/picasso.gexf
...
```

produces [`picasso.gexf`](../../BUILT/picasso.gexf) in [GEXF format](https://gexf.net), which can be opened e.g. in [Gephi Lite](https://gephi.org/gephi-lite/).
produces [`picasso.gexf`](../../BUILT/picasso.gexf) in [GEXF format](https://gexf.net) (see also [GEXF examples](https://github.com/graphology/graphology/tree/master/src/gexf/test/resources)), which can be opened e.g. in [Gephi Lite](https://gephi.org/gephi-lite/) or [Retina](https://ouestware.gitlab.io/retina/).

## Tika

Expand Down
6 changes: 6 additions & 0 deletions update.bash
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,9 @@ pre-commit run --all-files
bazelisk run @enola_maven//:outdated
echo "PLEASE READ ^^^ TO SEE IF YOU CAN UPDATE ANYTHING IN MODULE.bazel?"
echo "Don't forget to run 'REPIN=1 bazelisk run @enola_maven//:pin' after changes!"

# Web
cd web
bun outdated
bun update
cd ..
15 changes: 5 additions & 10 deletions web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,19 @@

## Usage

1. `cd web/`

1. One time `npm install -g pnpm@latest-10` <!-- NB: Keep pnpm version in-sync with pnpm/action-setup in ci.yaml -->
1. Install [🧅 Bun](https://bun.sh/docs/installation)

1. One time `pnpm install` (TODO: Replace with Bazel...)

1. Regularly `pnpm test`
1. `cd web/`

1. Often `pnpm run tsc && pnpm run build` (TODO: Integrate better... e.g. using concurrently or npm-run-all?)
1. Regularly `bun test`, and often `bun tsc && ./build` (TODO: Integrate better... e.g. using `concurrently` or `npm-run-all`?)

1. Start `../enola server --load "../models/enola.dev/**.ttl" --httpPort=9090`

1. Open <http://0.0.0.0:9090/wui/index.html>

TODO Resolve CORS in `npm run serve` to work with Enola JSON API server on another port.
TODO Resolve CORS in `bun serve` to work with Enola JSON API server on another port.

TODO Support a _Dev_ mode where `npm run dev` launches `build.mjs` (TBD `.ts`) with
a `--watch` for _both_ `tsc` and `esbuild` and then does a `npm run serve` equivalent.
TODO Support a _Dev_ for _both_ `tsc` and Bun's build watch mode... which also does a `bun serve` equivalent.

## NeXT

Expand Down
33 changes: 20 additions & 13 deletions web/ToDo.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@

# Enola `enola/web` TODO

## Tech

1. Try https://bun.sh/docs/bundler/html
1. Apply https://bun.sh/docs/typescript#suggested-compileroptions
1. Fix `bun tsc`

## Functional

* ~~Use Enola Server `/gexf` instead of `arctic.gexf` (and delete that)~~
Expand Down Expand Up @@ -50,31 +56,32 @@
### Clean

* Make pre-commit add License Header to `*.ts`
* Caching problems... how can I make it never cache bundle.js? I guess live edit will solve that..
* mv script.ts src/web/
* mv build.mjs src/dev/ (?)
* Needing `web/public/bundle.js` in `.gitignore` is ugly; how to better separate, to avoid?
* Caching problems... how can I make it never cache bundle.js? Will Watch Mode solve that? Else [hash] in JS filename...
* Needing `web/public/bundles/` in `.gitignore` is a bit ugly; how is this normally better separated?

### Productivity

* Does adopting https://eslint.org still make sense with TS? What does it add? See https://typescript-eslint.io!
* Does adopting https://eslint.org still make sense with TS? What does it add? See https://typescript-eslint.io
* How to auto rebuild & reload in browser on file change?

### TypeScript

* ~~Convert `script.js` to `script.[m?]ts`~~

### Bazel

* Use https://github.com/aspect-build/rules_js
* Use https://github.com/aspect-build/rules_js ... would have worked for `pnpm`, but won't for `bun`...
but perhaps a simple GenRule, with some https://github.com/bazel-contrib/bazel-lib/blob/main/docs/write_source_files.md magic?

### Testing

* ~~Introduce Jest for `npm run test` TS Unit Testing~~
* Split Graphology & Sigma related code in x2 separate .ts; and test Graphology GEXF initial coordinates in Node, without Browser?
* Try https://playwright.dev for web UI testing? With https://github.com/GoogleChromeLabs/chrome-for-testing?
* Web Test would be nice... at least just DOM, at first? Then, or directly, Browser?
* Split Graphology & Sigma related code in x2 separate .ts; and test Graphology GEXF initial coordinates in Node, without Browser?
* Try https://playwright.dev for web UI testing? With https://github.com/GoogleChromeLabs/chrome-for-testing?
* Make `bazel test //web` run web tests

### Performance

* #LATER

### Maintainability

* Include `VERSION` (with Git rev) into front-end, probably using https://bun.sh/docs/bundler#env ?
* Enable https://github.com/dependabot/dependabot-core/issues/6528, once that's released
* Recheck if https://github.com/oven-sh/bun/issues/1760 got implemented, to avoid "seeing" transitive (only) dependencies in `import`
1 change: 1 addition & 0 deletions web/build
34 changes: 0 additions & 34 deletions web/build.mjs

This file was deleted.

Binary file added web/bun.lockb
Binary file not shown.
8 changes: 0 additions & 8 deletions web/jest.config.ts

This file was deleted.

13 changes: 4 additions & 9 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
"name": "enola.dev",
"version": "0.0.1",
"main": "index.js",
"TODOtype": "module",
"type": "module",
"scripts": {
"tsc": "tsc",
"build": "node build.mjs",
"serve": "http-server -p 8080",
"test": "jest"
"clean": "rm -f web/public/bundle.js* && rm -rf web-out && mkdir web-out",
"serve": "http-server -p 9090"
},
"author": "The Enola <https://enola.dev> Authors",
"license": "Apache-2.0",
Expand All @@ -22,14 +20,11 @@
"devDependencies": {
"@jest/globals": "^29.7.0",
"@jest/types": "^29.6.3",
"@types/bun": "^1.1.17",
"@types/jest": "^29.5.14",
"@types/sigmajs": "^1.0.32",
"esbuild": "^0.24.0",
"graphology-types": "^0.24.8",
"http-server": "^14.1.1",
"jest": "^29.7.0",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"typescript": "^5.7.3"
}
}
Loading
Loading