belaustegui

belaustegui

Hi!

Bun is a new all-in-one toolkit for Javascript: bundler, test runner, package manager, dev. environment, etc. It can do what Esbuild does, and more.

I’ve just published a package heavily inspired in the Esbuild integration package made by Wojtek Mach and José Valim that is adapted to install and invoke Bun.

I am using it in a personal project of mine and the switch from Esbuild requires very minimal changes. Then, it allows you to install and the many node packages available without requiring NodeJS or NPM. It also supports TypeScript, JSX, CSS, WASM, and many more (even Rust!).

Anyway. If you want to check it out you can take a look at the GitHub Repo and the Hex.pm package.

Thanks again to @josevalim and @wojtekmach for creating the Esbuild packge :bowing_man: which I used as a base.

Showing Posts 1 to 10

D4no0

D4no0

It seems that you have some typos in readme:

def deps do
  [
    {:bun, "~> 0.1", runtime: Mix.env() == :dev}
  ]
end

While the name of the package is elixir_bun on hex.

belaustegui

belaustegui OP

Thanks for noticing this @D4no0 . I planned to name the project just bun bun when I was trying to push it to Hex.pm I found out that the name was already taken :cry:

I renamed it to elixir_bun but seems that I forgot to change it in a few places. Will do it right now.

EDIT: fixed just now. Thanks again.

belaustegui

belaustegui OP

I’ve just released elixir_bun 0.1.4 with the following changes:

  • A new logo
  • Updates in the README to use symlinks instead of copying the Phoenix dependencies
  • A fix for zombie Bun processes
  • An update to Bun 1.0.7 which is the latest stable version

Thanks to @pepicrft and @LostKobrakai who made their first contributions to the project :rocket:

For more information you can take a look at the Hex.pm package and the release notes.

belaustegui

belaustegui OP

Hi all again!

When I created this package I wanted to publish it as bun to follow the conventions set by the esbuild and tailwind packages. Unfortunately that package name was taken so I had to publish my project as elixir_bun instead.

After getting in touch with the hex.pm team they confirmed that having an empty package that is just squatting on a name goes against the hex.pm policies so it has been removed and made available again.

Long story short: the elixir_bun package is now retired on hex.pm and replaced by the bun package. If you are updating from elixir_bun you just have to replace :elixir_bun with :bun in your project.

Since this is a breaking change I’ve used the opportunity to release version 1.0 as bun can now be considered stable.

Greetings! :hibiscus:

13
Post #4
belaustegui

belaustegui OP

Hi all!

I’ve just released bun 1.1.0 which fixes an issue when running under elixir-slim Docker images. Thanks @Wigny for noticing and fixing the issue :bowing_man:

Additionally new installations will no use the latest bun version (1.0.26 at the moment of writing this). Remember that you can use the library configuration to pick the bun version that you want to use.

As usual you can check out the GitHub Repo and the Hex.pm package for the release notes and more information.

Happy coding! :hibiscus:

Wigny

Wigny

Hey, thanks for maintaining this nice tool.

Yesterday I was trying to achieve something similar to what the deno_ex library does, but using bun, which is providing the bun binary at runtime that later can be called with System.cmd/2 or using Port, allowing you to call JavaScript files from Elixir.

The problem I faced first was that the library by default downloads the binary in the _build/ directory and then when my project was compiled and released (mix release) the binary was not available anymore. To solve this issue I tried to imitate deno_ex and set the bun path to Application.app_dir(:bun, "priv/bin/bun"), but since this function was not meant to be used at compile time, I had to set this configuration in the runtime.exs file with config :bun, path: "..." and ensure to call mix bun.install --runtime-config in the mix assets.build task .

I know I could set the bun path to the application priv directory, but it’s an umbrella project and it doesn’t make sense for me to put the binary that will be used by a few child applications in a specific application. So for anyone reading this, any suggestions on a better approach to making bun available in the final release?

belaustegui

belaustegui OP

I think that each application that requires the bun executable should have bun as a dependency. This would allow you to set the required priv path per application, so each of them has its own bun executable.

Another approach that may work (but I don’t like as the first one) is to just save the bun executable in a well known path and access it directly from each application.
For example if you are using Docker for running the release you could download the bun executable in a particular path in the image and then access it directly in the applications.

belaustegui

belaustegui OP

Hi all!

I’ve just released bun 1.2.0 which improves the process wrapper. It now uses Bun to wrap itself in a way that automatically shuts down when the stdin closes. This removes the POSIX shell dependency on the development machine.
Thanks @hauleth for noticing and fixing this! :bowing_man:

Additionally I’ve updated the default Bun version that is downloaded to 1.0.33, which is the latest stable version released at the moment. As usual, you can override this setting in your configuration.

Check out the GitHub Repo and the Hex.pm package for the release notes and code.

Happy coding! :hibiscus:

hauleth

hauleth

Honestly, I have been using such script for some time now. I just finally decided to port my solution to bun library (I do not use this library in my project, I use my own wrapper instead).

znewbiez1001

znewbiez1001

@belaustegui Thank you for awesome installer!
But can you support me with this error:

I got that on a Macbook Pro M1. I tried to spot errors and it turned out there wasn’t a case to be matched with the MacBook

        [arch | _] = arch_str |> List.to_string() |> String.split("-")

inspecting result: [“arm”, “apple”, “darwin23.3.0”]

So can you please push fix codes for this? Thanks in advance!

Where Next? Top

Trending in Announcing Top

wojtekmach
Hey everyone! Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
handnot2
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application. This library uses Erlang esaml to provide plug enabl...
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
restlessronin
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub. Docs are at OpenaiEx User Gu...
152 11030 135
New
shahryarjb
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly. One of i...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
fuelen
Hi all! I want to present a small library which provides a mix task for generating an Entity-Relationship Diagram for Ecto schemas. You...
New

Other Trending Topics Top

mudasobwa
I am seeing a lot of aplications of Argumentum ad Vericundiam in software discussions. They do link some piece of writing and point us to...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
lawik
I was thinking since Goatmire Elixir turned out pretty good I should maybe do another one. 30th of Sep - 2nd of Oct this year./ The firs...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews