Rails Glossary > Generate a Rails app with bun and no importmap

Generate a Rails app with bun and no importmap

Creates a new Rails application configured with Bun, an all-in-one JavaScript runtime and bundler that provides extremely fast compilation without requiring Node.js, offering a simplified development environment.

Rails applications with Bun bundling

How do you create a Rails app with Bun? Use rails new myapp --javascript=bun to generate a new Rails application with Bun configured as the JavaScript runtime and bundler, providing extremely fast compilation and eliminating Node.js dependencies through Bun's all-in-one approach.

The rails new --javascript=bun command creates Rails applications equipped with the fastest all-in-one JavaScript toolkit available. Bun is 1.75x faster than esbuild, 150x faster than Parcel 2, 180x times faster than Rollup + Terser, and 220x times faster than Webpack.

Why Bun revolutionizes development

All-in-one architecture eliminates the complexity of managing separate tools. Instead of 1,000 node_modules for development, you only need bun. Bun is a new JavaScript runtime with a native bundler, transpiler, task runner, and npm client built-in.

Unlike other package managers, Bun doesn't execute postinstall scripts by default, providing additional security.

What the Rails generator configures

The generator adds jsbundling-rails to your Gemfile and configures ./bin/dev for Rails and Bun coordination. Unlike other bundlers, Bun requires only the Bun runtime - no Node.js or Yarn installation needed.

Performance advantages

Bun is written in Zig and powered by JavaScriptCore under the hood, dramatically reducing startup times and memory usage. Bun's fast native bundler establishes new benchmarks, bundling 10 copies of three.js from scratch with sourcemaps and minification.

Current limitations

Bun doesn't support some basic features like tree-shaking, minifier, and source maps, though these are being actively developed.

When to choose Bun

Choose Bun for simplified development requiring modern JavaScript capabilities without toolchain complexity. If you are using Bun, then you just need to install Bun as it is both a JavaScript runtime and a bundler.

Try Avo for free