-
Notifications
You must be signed in to change notification settings - Fork 7
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
Testing out bun with NX/TSC/Vite #12
Conversation
apps/react-app/project.json
Outdated
} | ||
}, | ||
"build": { | ||
"options": { | ||
"commands": ["tsc", "vite build"] | ||
"commands": ["bunx tsc", "bunx vite build"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using bunx vite will basically run vite in node and not bun. Same with TSC here. You need force bun with --bun
`
``suggestion
"commands": ["bunx --bun tsc", "bunx --bun vite build"]
bun also has bulit in support for typescript compling so you dont need to run TSC. Whats the reasoning for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done! thx!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Jordan-Hall regarding:
"bun also has bulit in support for typescript compling so you dont need to run TSC. Whats the reasoning for it?"
I want to publish reusable libraries for others from some of my projects. Thus I want to transpire to *.js that is non-bundled, non-minified for easy reuse, tree shaking, etc.
I guess you'd recommend that I use https://bun.sh/docs/bundler? I guess that can be used for libraries and not just end user React apps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct working on getting this to work on nx-bun but you can use cli for it
bun build ./index.tsx --outdir ./out
apps/react-app/project.json
Outdated
@@ -4,12 +4,12 @@ | |||
"targets": { | |||
"watch": { | |||
"options": { | |||
"commands": ["vite"] | |||
"commands": ["bunx vite"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"commands": ["bunx vite"] | |
"commands": ["bunx --bun vite"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've adopted this! Thanks!
apps/koa-server/project.json
Outdated
@@ -4,7 +4,7 @@ | |||
"targets": { | |||
"watch": { | |||
"options": { | |||
"commands": ["tsc --watch", "nodemon dist/server.js"] | |||
"commands": ["bunx tsc --watch", "bunx nodemon dist/server.js"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read comment below i think you could change this to the following
"commands": ["bunx tsc --watch", "bunx nodemon dist/server.js"] | |
"commands": ["bun run --watch server.ts"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Thx!
Nife to change to force bun. Bun as a package manager is supper quick. But they also limit to approved postinstall via bun install. It can get 2 to 4x the speed. But this is what I was referring to on NX. You can use bun as PM people seeing instant result which is strange still |
Dockerfile
Outdated
@@ -1,13 +1,12 @@ | |||
FROM node:21-alpine | |||
FROM imbios/bun-node:latest-21-slim |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FROM imbios/bun-node:latest-21-slim | |
FROM oven/bun:1 |
Now you are running it in actual bun (vite etc) you shouldn't need node here anymore
Hacked in bun into the nx workflows and CI and docker build. Seems to produce a 30% speed increase.
Unfortunately the docker build is failing currently, probably because of nx incompatibility with bun.
I've mentioned the issue as well as proposing that NX support bun here: