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

Generate a Rails app with esbuild and no importmap

Creates a new Rails application configured with esbuild, an extremely fast JavaScript bundler written in Go that provides TypeScript and JSX support with minimal configuration.

Creating Rails applications with esbuild bundling

How do you create a Rails app with esbuild? Use rails new myapp --javascript=esbuild to generate a new Rails application with esbuild configured as the JavaScript bundler, providing extremely fast compilation with built-in TypeScript and JSX support.

The rails new --javascript=esbuild command creates Rails applications optimized for modern JavaScript development through esbuild's revolutionary performance. esbuild is 10-100x faster than traditional JavaScript bundlers, making it the recommended choice for most Rails applications requiring JavaScript transpilation.

Why esbuild excels for Rails development

esbuild is written in Go and compiles to native code, while most other bundlers are written in JavaScript. This fundamental difference means instant feedback loops with sub-second compilation times that maintain developer flow.

Zero-configuration TypeScript and JSX support eliminates complex setup traditionally required for modern JavaScript features. esbuild handles TypeScript transpilation and JSX transformation out of the box, enabling React development without configuration overhead.

What the Rails generator configures

The generator automatically adds jsbundling-rails to your Gemfile, configures package.json with build scripts, and sets up ./bin/dev for concurrent Rails server and esbuild watch mode. Node.js and Yarn must be installed when using esbuild.

Performance advantages

esbuild uses Go's shared memory between threads and parallel garbage collection, while JavaScript has separate heaps per thread. This architecture enables parallel processing that leverages multi-core systems effectively.

Benchmark tests show esbuild bundling 10 copies of three.js in under a second, compared to webpack's 41+ seconds.

When to choose esbuild

Choose esbuild for applications requiring TypeScript, JSX, or npm packages with fast development cycles. It provides the best balance of modern JavaScript capabilities and build speed for most Rails applications.

Try Avo for free