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

Testing out bun with NX/TSC/Vite #12

Merged
merged 12 commits into from
Feb 26, 2024
Merged

Testing out bun with NX/TSC/Vite #12

merged 12 commits into from
Feb 26, 2024

Conversation

bhouston
Copy link
Owner

@bhouston bhouston commented Jan 10, 2024

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:

}
},
"build": {
"options": {
"commands": ["tsc", "vite build"]
"commands": ["bunx tsc", "bunx vite build"]

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?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done! thx!

Copy link
Owner Author

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?

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

@@ -4,12 +4,12 @@
"targets": {
"watch": {
"options": {
"commands": ["vite"]
"commands": ["bunx vite"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"commands": ["bunx vite"]
"commands": ["bunx --bun vite"]

Copy link
Owner Author

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!

@@ -4,7 +4,7 @@
"targets": {
"watch": {
"options": {
"commands": ["tsc --watch", "nodemon dist/server.js"]
"commands": ["bunx tsc --watch", "bunx nodemon dist/server.js"]

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

Suggested change
"commands": ["bunx tsc --watch", "bunx nodemon dist/server.js"]
"commands": ["bun run --watch server.ts"]

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Thx!

@Jordan-Hall
Copy link

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

@bhouston bhouston merged commit f0ec054 into main Feb 26, 2024
5 checks passed
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.

2 participants