Skip to content

Commit 90c8b8d

Browse files
edits
Former-commit-id: f3c0113 Former-commit-id: 6c3fab20a3a38106e29e1d2588b5414f9aed51f8
1 parent 3b489cd commit 90c8b8d

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

docs/blog/2022-07-20-bun-is-the-future.mdx renamed to docs/blog/2022-07-20-bun-first-look.mdx

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: "Bun: A Complete Overhaul of the JavaScript Ecosystem"
3-
description: A security expert's analysis of the malicious code added to ctx and Phpass, Python and PHP dependencies, that turned them into malware by sending environment variables and credentials to a third party attacker.
3+
description: A first look at Bun, the new framework trying to replace node and just about everything else too.
44
slug: bun-first-look
55
date: 2022-07-20
6-
keywords: [bun, JavaScript, package-manager]
6+
keywords: [bun, JavaScript, package-manager, npm, node, deno]
77
tags: [malware, dependencies]
88
authors: [forrest]
99
---
@@ -41,7 +41,8 @@ rewrite of the JavaScript ecosystem.
4141
In order of things I'm desperate for, Bun is a:
4242
* JavaScript/TypeScript runtime that claims to be faster than Node or Deno
4343
* Package manager that's about a bajillion times faster than NPM or Yarn
44-
* Browser Bundler - complete with tsx, jsx, css, svg..etc support. Replacement for everything from `webpack` to `react-scripts`, and, you guessed it, extremely fast
44+
* Browser Bundler - complete with tsx, jsx, css, svg, .etc support. Replacement for everything from `webpack` to
45+
`react-scripts`, and, you guessed it, extremely fast
4546
* Really fast web server (express replacement)
4647
* Sqlite client
4748
* Bread
@@ -124,7 +125,9 @@ This isn't the first time someone has tried to speed up NPM. You might be famili
124125
faster installs. It does *work* but in practice,
125126
it's really hard to get working, and requires a lot of polyfilling and escape-hatches. We bit-the-bullet to use it, but I probably wouldn't recommend it or use it again.
126127

127-
Bun works the way NPM does, just faster. It uses its own lockfile format, but node_modules and the package.json look normal.
128+
Bun works the way NPM does, just faster. It uses its own lockfile format, but node_modules and the package.json look
129+
normal. A developer with a good understanding of filesystem calls combined with low-level access and a
130+
fast language makes for a really quick solution, without any fancy tricks.
128131

129132
Now, Bun [doesn't have](https://github.com/oven-sh/bun/issues/533) workspace support yet, meaning it won't work for a lot of the big monorepos
130133
that could really benefit from it (ahem, us). That said, Bun development seems to be moving at a lightning pace. Workspace support is mentioned on the roadmap as of a couple of weeks ago.
@@ -140,7 +143,8 @@ Perhaps some more people will learn about the project that way.
140143
Bun includes a transpiler for web browsers, to compete with webpack and esbuild. By the way, the parser in Bun is a Zig port
141144
of esbuild's parser. Neat.
142145

143-
It already supports quite an impressive array of file types. Css, SVG, tsx, jsx, ts. They're all supported. Advanced options like CSS in JS appear to work fine.
146+
It already supports quite an impressive array of file types. Css, Svg, Tsx, Jsx, Ts. They're all supported. Advanced
147+
options like CSS in JS appear to work fine.
144148

145149
Since Bun includes a project scaffolder with a few built in templates, I simply called:
146150

@@ -156,14 +160,19 @@ which has become a must-have for frontend devs coming from webpack.
156160
### What's missing from the transpiler?
157161
A lot of things you probably need for production, unfortunately. Minification is the biggest one I see still on the roadmap that real-world users will need.
158162
Having a large plugin ecosystem is kind of critical for a bundler to support different file formats. For instance, .vue files and .scss are still on the roadmap.
159-
Just about everyone and their grandma uses .scss, so that's a deal-breaker.
163+
Just about everyone and their grandma uses .scss, so that's a deal-breaker. I'm not sure how pluggable Bun's
164+
bundler is at the moment, but it seems that the focus is mainly on building solutions directing into the framework,
165+
rather than
166+
relying on a lot of other Open Source packages for solutions.
160167

161168
## Other features - Web server and sqlite client
162169

163170
Bun also adds some things you'd usually think of as frameworks to the standard library. Personally, I'm less excited about these more library type features. There are a lot of very good options available in Node for http servers.
164171

165172
Bun's webserver looks pretty bare-bones. Express still works fine for most of the community, even if it is a bit behind the times. (They just added promise support this year).
166173
Bun's server appears to be very similar to a Cloudflare Worker. Maybe Bun's creator will circle back around to more work on the webserver once every other problem in the entire JavaScript world is fixed.
174+
It's worth noting that clever system calls can make Bun's webserver [twice as fast in some cases](https://twitter.
175+
com/jarredsumner/status/1506182333459693571), particularly when working with files.
167176

168177
As for the new SQLite adapter, I guess the normal way to do sqlite in Node is a bit confusing. Most people combine the older `sqlite3` package with the `sqlite` wrapper to add promise support,
169178
but it's not that bad. Bun's solution looks a bit cleaner, and I won't even bother checking if it's faster.
@@ -182,15 +191,23 @@ You can probably skip this part if you don't know what Deno is or don't care. Pe
182191

183192
[Deno](https://deno.land/), written by the original creator of Node, does claim to resolve some outstanding issues.
184193
It makes es-modules the default, adds first-party TypeScript support (no need to transpile NPM modules before publishing), and so on. In my opinion
185-
it introduces other serious shortcomings along the way. The elephant in the room is that Deno has made enough breaking changes to package resolution and syntax that **it isn't
194+
it introduces other serious shortcomings along the way.
195+
196+
The elephant in the room is that Deno has made enough breaking changes to package resolution and syntax that **it isn't
186197
compatible with the existing NPM ecosystem.** This means that Deno needs to be a completely new ecosystem of libraries. There has been a bit of development with some early library support,
187-
but I'd say that clout can only get you so much buy-in, especially when so much momentum is involved. There are a few other things in Deno that strike me as half-baked, like the [lack of a package.json](https://deno.land/manual/examples/manage_dependencies),
188-
both from a module resolution perspective, and also because without a manifest file, there is nowhere to write extensible metadata about your package. Even GoLang has added `pom.xml` for this reason.
198+
but I'd say that clout can only get you so much buy-in, especially when so much momentum is involved. There are also
199+
some workarounds, like [CDNs that transpile NPM packages into Deno packages](https://deno.land/[email protected]/npm_nodejs/cdns#esmsh), but that doesn't smell very good to me.
200+
201+
There are a
202+
few other things in Deno that strike me as half-baked, like the [lack of a package.json](https://deno.land/manual/examples/manage_dependencies),
203+
both from a module resolution perspective, and also because without a manifest file, there is nowhere to write
204+
extensible metadata about your package. Even GoLang has added `go.mod` for this reason.
189205

190-
Also, I just want to point at that the sandboxing / permission system in Deno is the right idea but isn't fine-grained enough. It lives at the top level of the entire project, not at the package level, meaning a big app ends up needing all permissions and you're back to square one.
206+
Also, I just want to point at that the [sandboxing / permission system](https://deno.land/manual/getting_started/permissions#:~:text=Deno%20is%20secure%20by%20default,or%20a%20runtime%20permission%20prompt.) in Deno is the right idea but isn't
207+
fine-grained enough. It lives at the top level of the entire project, not at the package level, meaning a big app ends up needing all permissions and you're back to square one.
191208
As a security company, we were disappointed in its potential to protect large, real world apps from supply-chain attacks. Bun isn't claiming to solve this problem either (yet), I just wanted to vent.
192209

193-
I should probably write a whole post about this, but the short answer is:
210+
I should probably write a whole post about my problems with Deno, but the short answer is:
194211

195212
### Bun has way more potential to take-off
196213

lunatrace/bsl/backend/src/workers/queue/activities/snapshot-repository-activity.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export async function snapshotRepositoryActivity(req: SnapshotForRepositoryReque
6060
},
6161
})
6262
);
63+
6364
if (threwError(insertBuildResponse)) {
6465
const msg = 'failed to insert a new build';
6566
logger.error(msg, {

0 commit comments

Comments
 (0)