Module: Bundlebun

Defined in:
lib/bundlebun.rb,
lib/bundlebun/runner.rb,
lib/bundlebun/version.rb,
lib/bundlebun/env_path.rb,
lib/bundlebun/platform.rb,
lib/bundlebun/integrations.rb,
lib/bundlebun/integrations/execjs.rb,
lib/bundlebun/integrations/vite_ruby.rb,
lib/bundlebun/integrations/jsbundling.rb,
lib/bundlebun/integrations/cssbundling.rb,
sig/bundlebun.rbs,
sig/bundlebun/runner.rbs,
sig/bundlebun/version.rbs,
sig/bundlebun/env_path.rbs,
sig/bundlebun/platform.rbs,
sig/bundlebun/integrations.rbs,
sig/bundlebun/integrations/execjs.rbs,
sig/bundlebun/integrations/vite_ruby.rbs,
sig/bundlebun/integrations/jsbundling.rbs,
sig/bundlebun/integrations/cssbundling.rbs

Overview

bundlebun bundles Bun, a fast JavaScript runtime, package manager and builder, with your Ruby and Rails applications. No Docker, devcontainers, curl | sh, or brew needed.

bundlebun includes binary distributions of Bun for each of the supported platforms (macOS, Linux, Windows) and architectures.

bundlebun provides two ways to run Bun:

  • Bundlebun.call (also available as Bundlebun.exec): Replaces the current Ruby process with Bun. The default.

  • Bundlebun.system: Runs Bun as a subprocess and returns control to Ruby. Use this when you need to continue executing Ruby code after Bun finishes.

Examples:

Running Bun (replaces process, never returns)

Bundlebun.('install')                # .() shorthand syntax
Bundlebun.call('outdated')
Bundlebun.call(['add', 'postcss'])

Running Bun as subprocess (returns to Ruby)

if Bundlebun.system('install')
  puts 'Dependencies installed!'
end

See Also:

Defined Under Namespace

Modules: Integrations Classes: EnvPath, Platform, Runner

Constant Summary collapse

VERSION =

bundlebun uses the #{bundlebun.version}.#{bun.version} versioning scheme. gem bundlebun version 0.1.0.1.1.38 is a distribution that includes a gem with its own code version 0.1.0 and a Bun runtime with version 1.1.38.

This constant always points to the "own" version of the gem.

Returns:

  • (String)
'0.5.1'

Class Method Summary collapse

Class Method Details

.bun ⇒ Object Also known as: bun?, bun!



117
# File 'lib/bundlebun.rb', line 117

def bun = 'Bun'

.call ⇒ bot

Replaces the current Ruby process with Bun. This is the default way to run Bun. Never returns.

Parameters:

  • arguments (String, Array[String])

Returns:

  • (bot)


60
61
62
# File 'lib/bundlebun.rb', line 60

def call(...)
  Runner.call(...)
end

.exec ⇒ bot

Replaces the current Ruby process with Bun. Same as .call.

Parameters:

  • arguments (String, Array[String])

Returns:

  • (bot)


71
72
73
# File 'lib/bundlebun.rb', line 71

def exec(...)
  Runner.exec(...)
end

.load_integrations ⇒ Array[Module]

Detect and load all integrations (monkey-patches).

Returns:

  • (Array[Module])

See Also:



113
114
115
# File 'lib/bundlebun.rb', line 113

def load_integrations
  Integrations.bun!
end

.load_tasks ⇒ void

This method returns an undefined value.

Load included Rake tasks (like bun:install).



106
107
108
# File 'lib/bundlebun.rb', line 106

def load_tasks
  Dir[File.expand_path('tasks/*.rake', __dir__)].each { |task| Rake.load_rakefile(task) }
end

.prepend_to_path ⇒ String?

Prepend the path to the bundled Bun executable to PATH.

Returns:

  • (String, nil)

See Also:



101
102
103
# File 'lib/bundlebun.rb', line 101

def prepend_to_path
  EnvPath.prepend(Runner.full_directory)
end

.system ⇒ Boolean?

Runs Bun as a subprocess and returns control to Ruby. Returns true if Bun exited successfully, false if it failed, nil if execution failed.

Parameters:

  • arguments (String, Array[String])

Returns:

  • (Boolean, nil)


94
95
96
# File 'lib/bundlebun.rb', line 94

def system(...)
  Runner.system(...)
end