Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions bake-node.gemspec

This file was deleted.

24 changes: 0 additions & 24 deletions bake/node.rb

This file was deleted.

24 changes: 0 additions & 24 deletions bake/node/packages.rb

This file was deleted.

38 changes: 38 additions & 0 deletions bake/web/packages.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2026, by Samuel Williams.

def initialize(context)
super

require "web/packages/controller"
end

# Install packages using the configured package manager.
# @parameter root [String] The directory containing package.json.
# @parameter frozen [Boolean] Require the lock file to remain unchanged.
def install(root: context.root, frozen: false)
Web::Packages::Controller.new(root).install(frozen: frozen)
end

# Run a package script using the configured package manager.
# @parameter script [String] The package script to run.
# @parameter root [String] The directory containing package.json.
def test(script: "test", root: context.root)
Web::Packages::Controller.new(root).run(script)
end

# Materialize configured web packages as static files.
# @parameter root [String] The directory containing package.json.
# @parameter output [String | Nil] Override the configured output directory.
def update(root: context.root, output: nil)
Web::Packages::Controller.new(root).update(output: output)
end

# Check that the materialized web packages are current.
# @parameter root [String] The directory containing package.json.
# @parameter output [String | Nil] Override the configured output directory.
def check(root: context.root, output: nil)
Web::Packages::Controller.new(root).check(output: output)
end
4 changes: 2 additions & 2 deletions bake/node/importmap.rb → bake/web/packages/import_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
def initialize(context)
super

require "bake/node/controller"
require "web/packages/controller"
end

# Print the import map for the materialized static packages.
# @parameter root [String] The directory containing package.json.
# @parameter output [String | Nil] Override the configured output directory.
def show(root: context.root, output: nil)
puts Bake::Node::Controller.new(root).import_map(output: output)
puts Web::Packages::Controller.new(root).import_map(output: output)
end
28 changes: 14 additions & 14 deletions context/getting-started.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Getting Started

This guide explains how to use `bake-node` to install an external JavaScript dependency and expose it as static assets from a Ruby project.
This guide explains how to use `web-packages` to install an external JavaScript dependency and expose it as static assets from a Ruby project.

## Installation

Add the gem to your project:

~~~ bash
$ bundle add bake-node
$ bundle add web-packages
~~~

Your project also needs Node.js and one supported package manager: npm, pnpm, Yarn or Bun. Bake Node delegates dependency resolution and script execution to that package manager.
Your project also needs Node.js and one supported package manager: npm, pnpm, Yarn or Bun. Web Packages delegates dependency resolution and script execution to that package manager.

## Add a JavaScript Dependency

Expand All @@ -29,18 +29,18 @@ Ruby applications commonly need browser libraries without needing a JavaScript b
Install the dependencies using the detected package manager:

~~~ bash
$ bundle exec bake node:install
$ bundle exec bake web:packages:install
~~~

The package manager remains responsible for its lock file and `node_modules`. Use immutable installation in CI:

~~~ bash
$ bundle exec bake node:install frozen=true
$ bundle exec bake web:packages:install frozen=true
~~~

## Select Browser Files

Packages often contain development sources, tests and metadata that should not be deployed. Add a `bake-node` section which selects the browser-facing files:
Packages often contain development sources, tests and metadata that should not be deployed. Add a `web-packages` section which selects the browser-facing files:

~~~ json
{
Expand All @@ -49,7 +49,7 @@ Packages often contain development sources, tests and metadata that should not b
"dependencies": {
"morphdom": "^2.7"
},
"bake-node": {
"web-packages": {
"packages": {
"morphdom": {
"include": ["morphdom-esm.js"],
Expand All @@ -69,15 +69,15 @@ Direct production dependencies are selected by default. The package-specific obj
Materialize the configured packages:

~~~ bash
$ bundle exec bake node:packages:static
$ bundle exec bake web:packages:update
~~~

The default output is `public/_components`. Bake Node builds the complete output in a temporary directory and replaces the existing projection only after every package has been validated.
The default output is `public/_components`. Web Packages builds the complete output in a temporary directory and replaces the existing projection only after every package has been validated.

Print the generated browser import map:

~~~ bash
$ bundle exec bake node:importmap:show
$ bundle exec bake web:packages:import_map:show
~~~

For the example above, the result includes:
Expand All @@ -94,7 +94,7 @@ Your application can embed this JSON in a `<script type="importmap">` element an

## Run JavaScript Tests

Bake Node runs scripts from the root `package.json` without imposing a test framework:
Web Packages runs scripts from the root `package.json` without imposing a test framework:

~~~ json
{
Expand All @@ -105,21 +105,21 @@ Bake Node runs scripts from the root `package.json` without imposing a test fram
~~~

~~~ bash
$ bundle exec bake node:test
$ bundle exec bake web:packages:test
~~~

Pass another script name when a project has multiple JavaScript test suites:

~~~ bash
$ bundle exec bake node:test script=test:browser
$ bundle exec bake web:packages:test script=test:browser
~~~

## Verify Generated Files

Projects which commit or deploy the static projection can verify that it matches the current dependencies and configuration:

~~~ bash
$ bundle exec bake node:packages:check
$ bundle exec bake web:packages:check
~~~

See the [Static Packages](../static-packages/index) guide for detailed selection, manifest and import-map configuration. See [Internal Packages](../internal-packages/index) when JavaScript is developed alongside the Ruby code.
18 changes: 9 additions & 9 deletions context/index.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# Automatically generated context index for Utopia::Project guides.
# Do not edit then files in this directory directly, instead edit the guides and then run `bake utopia:project:agent:context:update`.
---
description: Integrate Node.js packages into Bake projects.
description: Integrate JavaScript packages into Ruby web applications.
metadata:
bug_tracker_uri: https://github.com/socketry/bake-node/issues
changelog_uri: https://github.com/socketry/bake-node/blob/main/releases.md
documentation_uri: https://socketry.github.io/bake-node/
bug_tracker_uri: https://github.com/socketry/web-packages/issues
changelog_uri: https://github.com/socketry/web-packages/blob/main/releases.md
documentation_uri: https://socketry.github.io/web-packages/
funding_uri: https://github.com/sponsors/ioquatix/
source_code_uri: https://github.com/socketry/bake-node.git
source_code_uri: https://github.com/socketry/web-packages.git
files:
- path: getting-started.md
title: Getting Started
description: This guide explains how to use `bake-node` to install an external JavaScript
dependency and expose it as static assets from a Ruby project.
description: This guide explains how to use `web-packages` to install an external
JavaScript dependency and expose it as static assets from a Ruby project.
- path: internal-packages.md
title: Internal Packages
description: This guide explains how to organize JavaScript developed inside a Ruby
project as independent workspace packages while using Bake Node for testing and
static deployment.
project as independent workspace packages while using Web Packages for testing
and static deployment.
- path: static-packages.md
title: Static Packages
description: This guide explains how to control which installed package files are
Expand Down
18 changes: 9 additions & 9 deletions context/internal-packages.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Internal Packages

This guide explains how to organize JavaScript developed inside a Ruby project as independent workspace packages while using Bake Node for testing and static deployment.
This guide explains how to organize JavaScript developed inside a Ruby project as independent workspace packages while using Web Packages for testing and static deployment.

## Why Use Workspace Packages?

Internal JavaScript often has its own module boundaries, tests and release concerns. Mixing it into the Ruby `lib/` hierarchy makes both languages harder to navigate, while placing authored code directly in `node_modules` makes it disposable.

Bake Node recommends three distinct layers:
Web Packages recommends three distinct layers:

~~~ text
components/ # Authored internal JavaScript packages.
node_modules/ # Disposable package-manager projection.
public/_components/ # Generated static deployment projection.
package.json # Workspace and Bake Node configuration.
package.json # Workspace and Web Packages configuration.
~~~

`components/` describes the role of the code without requiring a second language-level hierarchy. A single directory can contain one or many packages.
Expand Down Expand Up @@ -54,7 +54,7 @@ Expose internal packages through the root workspace configuration:
{
"private": true,
"workspaces": ["components/*"],
"bake-node": {
"web-packages": {
"packages": {
"@example/live": {
"include": ["Live.js"],
Expand All @@ -67,13 +67,13 @@ Expose internal packages through the root workspace configuration:
}
~~~

The package manager projects the workspace package into `node_modules/@example/live`, usually using a link. Bake Node resolves that link, ensures selected files remain inside the package, and copies the resulting files into `public/_components/@example/live`.
The package manager projects the workspace package into `node_modules/@example/live`, usually using a link. Web Packages resolves that link, ensures selected files remain inside the package, and copies the resulting files into `public/_components/@example/live`.

The `components/` path is a convention rather than a requirement. Any workspace or local-package layout supported by the selected package manager can be used.

## Test Internal Packages

Each package can keep its own test command. Define a root script which invokes the workspace tests according to the selected package manager, then let Bake Node run that script:
Each package can keep its own test command. Define a root script which invokes the workspace tests according to the selected package manager, then let Web Packages run that script:

~~~ json
{
Expand All @@ -84,10 +84,10 @@ Each package can keep its own test command. Define a root script which invokes t
~~~

~~~ bash
$ bundle exec bake node:test
$ bundle exec bake web:packages:test
~~~

pnpm, Yarn and Bun have their own workspace script syntax. Bake Node deliberately does not abstract those differences; the root script remains the project's explicit test entry point.
pnpm, Yarn and Bun have their own workspace script syntax. Web Packages deliberately does not abstract those differences; the root script remains the project's explicit test entry point.

## Multiple Internal Libraries

Expand All @@ -103,7 +103,7 @@ components/
package.json
~~~

Packages used only for development do not need to appear in `bake-node.packages`. Packages listed there can be deployed even when they are not direct root dependencies.
Packages used only for development do not need to appear in `web-packages.packages`. Packages listed there can be deployed even when they are not direct root dependencies.

## Avoid Authoring in `node_modules`

Expand Down
Loading