@wcstack/signals 1.24.0 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,17 +31,18 @@ The public API is shaped after the [TC39 Signals proposal](https://github.com/tc
|
|
|
31
31
|
npm install @wcstack/signals
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
Or buildless via an import map
|
|
34
|
+
Or buildless via an import map. Map the **single** `/dom` entry and import everything from it — it re-exports the whole headless core on top of the DOM helpers, so the page has exactly one reactive instance. Mapping the `.` and `./dom` entries to two esm.run URLs on the same page duplicates the core and breaks reactivity across the seam — see [Buildless](#buildless-import-maps):
|
|
35
35
|
|
|
36
36
|
```html
|
|
37
37
|
<script type="importmap">
|
|
38
38
|
{ "imports": {
|
|
39
|
-
"@wcstack/signals": "https://esm.run/@wcstack/signals",
|
|
40
39
|
"@wcstack/signals/dom": "https://esm.run/@wcstack/signals/dom"
|
|
41
40
|
} }
|
|
42
41
|
</script>
|
|
43
42
|
```
|
|
44
43
|
|
|
44
|
+
On such a page, read `@wcstack/signals` in the Quick-start snippets below as `@wcstack/signals/dom` — the core exports are identical.
|
|
45
|
+
|
|
45
46
|
## Quick start
|
|
46
47
|
|
|
47
48
|
### 1. Signals, computed, effect
|
|
@@ -367,7 +368,12 @@ A step-by-step guide (esbuild / tsc / Vite setups, a verifying `.tsx` example, t
|
|
|
367
368
|
|
|
368
369
|
## Buildless (import maps)
|
|
369
370
|
|
|
370
|
-
Both entries ship as production code-split bundles that import **one shared reactive-core chunk
|
|
371
|
+
Both entries ship as production code-split bundles that import **one shared reactive-core chunk** — but that chunk is imported by **relative path** (`./core-*.esm.js`), so whether a buildless page ends up with one reactive instance depends on how the files are served.
|
|
372
|
+
|
|
373
|
+
- **Map the single `/dom` entry (the recommended CDN form).** `@wcstack/signals/dom` re-exports the entire headless core (`signal` / `computed` / `effect` / `createRoot` / `onCleanup` / `flushSync` / `resource` / `streamResource` / `bindNode` / `nodeSource`) alongside the DOM helpers, so one specifier covers everything and the single instance is structural — nothing depends on chunk sharing. The signals demos in this repo all import from this one entry.
|
|
374
|
+
- **Mapping both specifiers only works from a path-preserving origin.** `.` and `./dom` keep sharing the core only if their relative `./core-*.esm.js` import resolves to the **same URL** — i.e. the whole `dist/` is served as files (self-hosted, or version-pinned path URLs such as `https://cdn.jsdelivr.net/npm/@wcstack/signals@1.25.0/dist/index.esm.js` + `…/dist/dom.esm.js`, both pinned to the same version). A *transforming* ESM endpoint like `https://esm.run/@wcstack/signals` bundles each entry into its own self-contained file, so mapping both esm.run entries ships **two** reactive cores: a signal created through one is invisible to an effect from the other.
|
|
375
|
+
|
|
376
|
+
Bundler users dedupe via the module graph and may use either entry.
|
|
371
377
|
|
|
372
378
|
## Stability
|
|
373
379
|
|
|
@@ -429,7 +435,7 @@ Zero runtime dependencies. Measured gzipped sizes of the minified bundles:
|
|
|
429
435
|
| Shared reactive core chunk (`core-*.esm.min.js`) | **≈ 3.1 KB** |
|
|
430
436
|
| `./dom` layer chunk (`dom.esm.min.js`, on top of the shared core) | **≈ 3.8 KB** |
|
|
431
437
|
|
|
432
|
-
Both published entries import the **one** shared core chunk
|
|
438
|
+
Both published entries import the **one** shared core chunk, so a page that loads `dist/` as files pays for the core only once — a transforming ESM CDN endpoint (esm.run) instead inlines a copy per entry, which is why a buildless page should map only `/dom` (see [Buildless](#buildless-import-maps)). `package.json` declares `"sideEffects": false`, so a bundler tree-shakes away anything you don't import.
|
|
433
439
|
|
|
434
440
|
## Development mode (diagnostics)
|
|
435
441
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wcstack/signals",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.0",
|
|
4
4
|
"description": "Signals-based lightweight reactive core with async-IO resource adapters and a wc-bindable → signal bridge for Web Components. Zero runtime dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|