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

build: add bun #173

Merged
merged 1 commit into from
Nov 9, 2023
Merged

build: add bun #173

merged 1 commit into from
Nov 9, 2023

Conversation

davidlj95
Copy link
Owner

@davidlj95 davidlj95 commented Nov 9, 2023

Includes many changes for this to work

Package manager replacement

  • Remove package-lock.json and add bun.lockb after installing
  • Configure Bun's lockfile diff to use bun given it's a binary file
  • Add run scripts to use bun instead of npm. Or instead ts-node (which uses node runtime). Prefix them with bun: so we can keep NPM / Node ones for some time in case we regret something

Scripting

Many changes, that include improvements to previous setup despite setting up Bun along the way

  • Use ts extensions by adding allowImportingTsExtensions to tsconfig.json
  • Remove allowSyntheticDefaultImports to avoid confusing magic to happen. If it's a default one, import it as it. Otherwise, don't.
  • Add ts-node config to import app files as ESM files. This allows us to mark those files as ESM without adding mts extension or type: module to package.json (that we can't as doing so makes the SSR tasks fail). Therefore the exports are as expected: what you export (with export) is what you can later import. Otherwise, Node.js for compatibility would add a non-existing default import. And then the imports got weird
    • When importing this way, without the Node.js magic default import, then we can run scripts with bun, yay! 🥳
  • Allow importing without extensions when running scripts via Node. By adding --experimental-specifier-resolution=node to Node run args when running ts-node. Otherwise, we would have to add .ts extensions when importing there. Which is a bit uglier.
    • Otherwise, we could run it with bun. But not with node, as requires the extension as per ES modules requirements.

CI/CD

  • Sets up bun using their action
  • Install dependencies using frozen lockfile option
  • Removes setting up Node.js
  • Adds cache for bun global cache
  • Update .ci/Makefile to use new bun run scripts and use bunx to run Lighthouse

Wins

  • Script runs way faster: from 28s to 10s in my machine
  • Awesome speed for installs 🚀
    • Seems build times in CI/CD haven't improved so much though

Copy link
Owner Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

includes many changes needed for this to work
@davidlj95 davidlj95 enabled auto-merge (squash) November 9, 2023 22:02
@davidlj95 davidlj95 merged commit cf91864 into main Nov 9, 2023
11 checks passed
@davidlj95 davidlj95 deleted the build-add-bun branch November 9, 2023 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant