Skip to content

luwes/wesc

Repository files navigation

WeSC — We are the Superlative Components

Build web components from any backend.

WeSC is a streaming HTML/web-component bundler written in Rust (via lol-html for HTML and rolldown for the JS bundle). It compiles single-file .html components into Declarative-Shadow-DOM-ready output.

Goals

  • HTML first — lean on the platform (The Rule of Least Power).
  • Standards-aligned — Declarative Shadow DOM, slots, and <template>, not a custom dialect.
  • Single-file components — author markup, styles, and script in one .html file.
  • Backend-agnostic — a standalone CLI, plus native bindings (more welcome):

What WeSC is

WeSC is an HTML component bundler. It lets developers author web components as single-file components (SFCs), then compiles those components into final HTML plus optional CSS and JS bundles.

WeSC is not meant to replace full-featured template engines. It does not try to own variables, conditionals, loops, layouts, partials, or application data flow. Use Liquid, Handlebars, Nunjucks, Jinja, Twig, ERB, Mustache, your backend framework, or plain string output for that layer. WeSC sits beside them: it turns component definitions into reusable HTML building blocks that can be stamped by whatever renders your data.

Repository layout

Path What
packages/wesc The wesc npm package: CLI + Node bindings for the bundler.
packages/dom The @wesc/dom npm package: DOM SSR via Linkedom.
crates/wesc The Rust bundler core (lol-html).
crates/wesc-node napi-rs Node bindings.
crates/wesc-py PyO3 Python bindings.
crates/wesc-php ext-php-rs PHP bindings.
crates/wesc-go cgo Go bindings (C ABI).
crates/wesc-rb Magnus (rb-sys) Ruby bindings.
examples Bundler examples (departures-board, node-server, python-server, php-server, go-server, ruby-server).

Develop

This is an npm-workspaces monorepo. From the repo root:

npm install                 # installs every workspace
npm test                    # runs each package's tests
npm run lint                # lints each package
npm run build               # builds each package (esbuild for @wesc/dom)
npm run build:native        # builds the native Node bundler addon (Rust toolchain)
npm run build:php           # builds the native PHP extension (Rust + PHP headers + libclang)

The Go and Ruby bindings build with their own toolchains (cargo build -p wesc-go --release; bundle exec rake compile in crates/wesc-rb); see each crate's README.

Related

Built on

  • lol-html — streaming HTML rewriter powering the bundler.
  • rolldown — Rust bundler for the component JavaScript.
  • napi-rs — Rust ↔ Node bindings.
  • PyO3 — Rust ↔ Python bindings.
  • ext-php-rs — Rust ↔ PHP bindings.
  • cgo — Rust ↔ Go bindings (over a small C ABI).
  • Magnus — Rust ↔ Ruby bindings (on rb-sys).

Related projects

  • WebC — single-file web-component format from the 11ty team.