Skip to content

Commit

Permalink
Switch to bun for almost everything.
Browse files Browse the repository at this point in the history
Addresses a significant part of #294, thanks to oven-sh/bun#2492 .
  • Loading branch information
lgarron committed Jan 14, 2024
1 parent c824977 commit 13d4e62
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 6,401 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
@@ -1,5 +1,5 @@
{
"postCreateCommand": "npm install --global bun && npm ci",
"postCreateCommand": "npm install --global bun && make setup",
"features": {
"ghcr.io/devcontainers/features/node:1": {
"version": "19"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/CI.yml
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: make setup
- run: make test-spec-bun-with-coverage
- run: make test-spec-dom-with-coverage
- run: make lint-ci
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: make setup
- run: make build-lib-js
- run: make build-bin
- run: make build-lib-types
Expand All @@ -75,10 +75,10 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: make setup
- run: make build-lib-js
- run: make test-dist-lib-node-import
- run: make test-dist-lib-node-scramble-all-events
- run: make test-dist-lib-bun-scramble-all-events
- run: make test-dist-lib-perf
- run: make test-dist-lib-plain-esbuild-compat
- run: make test-dist-lib-build-size
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/pages.yml
Expand Up @@ -24,7 +24,10 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- run: make setup
- run: make build-site-docs
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Expand Up @@ -3,8 +3,8 @@
/dist
/node_modules

# Stick with `package-lock.json` for now.
/bun.lockb
# Replaced with `bun.lockb`
/package-lock.json

# Created by `npm pack` by default.
/*.tgz
Expand Down
42 changes: 21 additions & 21 deletions Makefile
@@ -1,10 +1,10 @@
NODE=node
NPX=npx
BUN=bun
BUNX=${BUN} x
BUN_RUN=${BUN} run
BUN_BUN_RUN=${BUN} --bun run
BIOME=${BUN} x @biomejs/biome
WEB_TEST_RUNNER=./node_modules/.bin/wtr
NODE=node
NPM=npm
WEB_TEST_RUNNER=${BUNX} @web/test-runner

.PHONY: default
default:
Expand All @@ -14,12 +14,12 @@ default:
@echo ""
@echo "To build the project, run:"
@echo ""
@echo " npm install"
@echo " make setup"
@echo " make build"
@echo ""
@echo "To see available tests, run:"
@echo ""
@echo " npm install"
@echo " make setup"
@echo " make test-info"
@echo ""

Expand Down Expand Up @@ -54,14 +54,14 @@ build-site-experiments:
.PHONY: build-site-docs
build-site-docs:
rm -rf ./dist/sites/js.cubing.net/
${NPX} typedoc src/cubing/*/index.ts
${BUNX} typedoc src/cubing/*/index.ts
cp -R ./src/docs/js.cubing.net/* ./dist/sites/js.cubing.net/
@echo "\n\nNote: The js.cubing.net docs are deployed to GitHub Pages using GitHub Actions when a commit is pushed to the \`main\` branch:\nhttps://github.com/cubing/cubing.js/actions/workflows/pages.yml"
.PHONY: generate-js
generate-js: generate-js-parsers generate-js-svg
.PHONY: generate-js-parsers
generate-js-parsers:
${NPX} peggy --format es src/cubing/kpuzzle/parser/parser-peggy.peggy
${BUNX} peggy --format es src/cubing/kpuzzle/parser/parser-peggy.peggy
.PHONY: generate-js-svg
generate-js-svg:
@echo "TODO: Generating JS for SVGs is not implemented yet."
Expand All @@ -70,7 +70,7 @@ dev: quick-setup
${BUN_RUN} ./script/build/sites/dev.ts
.PHONY: link
link: build
npm link
${BUN} link
.PHONY: clean
clean:
rm -rf \
Expand Down Expand Up @@ -129,13 +129,13 @@ test-spec-dom-with-coverage: playwright-install
${WEB_TEST_RUNNER} --playwright --coverage
.PHONY: playwright-install
playwright-install:
npx playwright install
${BUNX} playwright install
.PHONY: test-src-import-restrictions
test-src-import-restrictions: build-lib-js
${BUN_RUN} ./script/test/src/import-restrictions/main.ts
.PHONY: test-src-tsc
test-src-tsc:
${NPX} tsc --project ./tsconfig.json
${BUNX} tsc --project ./tsconfig.json
.PHONY: test-src-scripts-consistency
test-src-scripts-consistency:
${BUN_RUN} ./script/test/src/scripts-consistency/main.ts
Expand All @@ -154,20 +154,20 @@ test-dist: test-dist-lib test-dist-bin
.PHONY: test-dist-lib
test-dist-lib: \
test-dist-lib-node-import \
test-dist-lib-node-scramble-all-events \
test-dist-lib-bun-scramble-all-events \
test-dist-lib-perf \
test-dist-lib-plain-esbuild-compat \
test-dist-lib-build-size \
test-dist-sites-experiments # keep CI.yml in sync with this
.PHONY: test-dist-lib-node-import
test-dist-lib-node-import: build-lib-js
${NODE} script/test/dist/lib/cubing/node/import/main.js
.PHONY: test-dist-lib-node-scramble-all-events
test-dist-lib-node-scramble-all-events: build-lib-js
${NODE} script/test/dist/lib/cubing/node/scramble-all-events/main.js
.PHONY: test-dist-lib-bun-scramble-all-events
test-dist-lib-bun-scramble-all-events: build-lib-js
${BUN} script/test/dist/lib/cubing/node/scramble-all-events/main.js
.PHONY: test-dist-lib-perf
test-dist-lib-perf: build-lib-js
${NODE} script/test/dist/lib/cubing/perf/*.js
${BUN} script/test/dist/lib/cubing/perf/*.js
.PHONY: test-dist-lib-plain-esbuild-compat
test-dist-lib-plain-esbuild-compat: build-lib-js
${BUN_RUN} script/test/dist/lib/cubing/plain-esbuild-compat/main.ts
Expand All @@ -176,7 +176,7 @@ test-dist-lib-build-size: build-lib-js
${BUN_RUN} ./script/test/dist/lib/cubing/build-size/main.ts
.PHONY: test-dist-sites-experiments
test-dist-sites-experiments: playwright-install build-sites
${NODE} ./script/test/dist/sites/experiments.cubing.net/main.js
${BUN} ./script/test/dist/sites/experiments.cubing.net/main.js
.PHONY: test-dist-bin
test-dist-bin: test-dist-bin-shebang test-dist-bin-npm-exec
.PHONY: test-dist-bin-shebang
Expand All @@ -187,13 +187,13 @@ test-dist-bin-shebang: build-bin
time dist/bin/scramble.js 222
.PHONY: test-dist-bin-npm-exec
test-dist-bin-npm-exec: build-bin
time npm exec scramble -- 222
time ${NPM} exec scramble -- 222
.PHONY: format
format:
${BIOME} format --write ./script ./src
.PHONY: setup
setup:
npm ci
${BUN} install # TOOD: was `npm ci`
.PHONY: quick-setup
quick-setup: | node_modules
.PHONY: lint
Expand Down Expand Up @@ -249,7 +249,7 @@ node_modules:
.PHONY: publish
.PHONY: publish
publish:
npm publish
${NPM} publish

.PHONY: pack
.PHONY: pack
Expand All @@ -260,4 +260,4 @@ pack:
# similarly, `./.temp/pack/` folder) that will stick around long enough for
# `npm pack` to use. The simplest is just to place the result directly in
# `./dist/`.
npm pack --pack-destination ./dist/
${NPM} pack --pack-destination ./dist/
Binary file added bun.lockb
Binary file not shown.

0 comments on commit 13d4e62

Please sign in to comment.