tobogganSe connecter

library

Prebuilt pebble components: drop-in custom elements, no compiler needed

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

Dernier runAucun
0Étoiles
0Forks
2Issues
64 lignes · 2942 octetsBrut · Historique

Consuming a component

Each component builds a self-contained dist — dist/<name>.js (pebble bundled in, minified, internal properties mangled), dist/<name>.d.ts, and dist/<name>.css when the component ships a sheet. A consumer needs no JSX compiler and no pebble build step; the bundle's import side effect is the element's registration.

Two flows: vendor the dist (works today, works forever) or install from the forge's npm registry (once the library is published there).

Vendoring the dist

The precedent is toboggan's packages/pebble: copy the component's dist files into your repo and record where they came from.

vendor/pebble-library/
  toaster.js        # dist/toaster.js
  toaster.js.map    # optional, for debugging
  toaster.d.ts      # the types
  toaster.css       # optional: the raw sheet, for zero-JS <link> pages
  REVISION          # the library commit this copy was taken from

REVISION is one line — the library's commit sha (git -C library rev-parse HEAD at vendor time). Re-vendoring is copying the files again and updating REVISION; the diff in your repo shows exactly what changed. Pin deliberately, bump deliberately.

Then either a script tag:

<script type="module" src="/vendor/pebble-library/toaster.js"></script>
<pebble-toaster></pebble-toaster>

or an import from your own module graph (your bundler sees a plain ESM file):

import "./vendor/pebble-library/toaster.js";

Importing twice is safe: a second bundle carrying the component gets the first's constructor back from define(), and the registry is per-tag.

The registry flow (once published)

The library publishes to the forge's npm registry as @pebble/library. The scope is mapped in your committed bunfig.toml — public installs need no token:

[install.scopes]
"@pebble" = "https://toboggan.cloud/npm"
bun add @pebble/library
import "@pebble/toaster"; // the import IS the registration

(The per-component specifier is set when the published package face lands; the workspace names are @pebble/toaster / @pebble/tablet.)

In this ecosystem dependency versions are exact pins, never ranges: "@pebble/library": "0.0.1", and a bump is its own commit. Versions are immutable on the registry — no republish, no unpublish — so an install that resolved once resolves forever.

Status: the registry publish is blocked on the forge deploying its npm registry. Until then, vendoring is the flow; the pin swap is a one-line change when the registry lands.

What you never need

  • pebble itself: bundled into each component's dist.
  • A JSX compiler or a build plugin: the components were compiled at their build time, not yours.
  • sideEffects gymnastics: a component package deliberately does not set sideEffects: false — dropping the import would drop the registration. Keep the import for its side effect; tree-shakers must see it.