@decohere/flux 0.0.1-dev.20261123.374 → 0.0.1-dev.20261123.379

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.
Files changed (2) hide show
  1. package/README.md +15 -3
  2. package/package.json +7 -7
package/README.md CHANGED
@@ -36,7 +36,7 @@ The `flux` command is on `@decohere/cli` (this package is the API):
36
36
  npm i -D @decohere/cli
37
37
  ```
38
38
 
39
- With pnpm, see [Using pnpm](../../docs/getting-started.md#using-pnpm).
39
+ With pnpm, see [Using pnpm](../../docs/guide/getting-started.md#using-pnpm).
40
40
 
41
41
  That installs the `flux`, `forge`, and `decohere` bins. Then:
42
42
 
@@ -161,7 +161,7 @@ So keep the default. An agent's saves in one go land inside it, and its one-at-a
161
161
 
162
162
  The `export default { async [Symbol.asyncDispose]() { … } }` in the server example above is that contract. Close servers, pools, and timers there — not in a `process.on("SIGINT")` handler Flux does not own.
163
163
 
164
- **HTTP APIs** scaffold `export default app`. `App.dispose` disposes the root DI container, then Scribe. Constructed services that implement `Symbol.asyncDispose` (or `Symbol.dispose`) are torn down automatically — including the HTTP provider. Background work (timers, feeds, pollers) belongs in a [hosted service](../http/README.md#hosted-services): its signal is aborted and it is stopped on every reboot, so nothing keeps running into the next one. Put teardown on the service; do not wrap the default export, and do not keep workers in globals across reboots.
164
+ **HTTP APIs** scaffold `export default app`. `App.dispose` disposes the root DI container, then Scribe. Constructed services that implement `Symbol.asyncDispose` (or `Symbol.dispose`) are torn down automatically — including the HTTP provider. Background work (timers, feeds, pollers) belongs in a [hosted service](../core/README.md#hosted-services): its signal is aborted and it is stopped on every reboot, so nothing keeps running into the next one. Put teardown on the service; do not wrap the default export, and do not keep workers in globals across reboots.
165
165
 
166
166
  Flux clears its reference to the object *before* calling dispose, so a failed boot cannot dispose the same instance twice.
167
167
 
@@ -241,7 +241,7 @@ Only source files (`.ts`) that a served entry imports trigger a reboot.
241
241
 
242
242
  **Memory grows over a long session.** Each reboot imports changed modules under a new `?version=` URL, and Node's ES module cache never releases the old versions. That's fine for a working day; if a session runs for days with thousands of reboots, restart it.
243
243
 
244
- Flux uses **Forge’s compiler** (`@decohere/forge/transpile`), with one SWC config per project built once per run. It never loads the TypeScript compiler: SWC strips types without checking them, so type errors are `forge typecheck`'s job. SWC leaves imports as written; Flux's resolve hook maps each one to its TypeScript source: `@scope/pkg` and `@scope/pkg/sub` through the the workspace package aliases (and tsconfig `paths`), `./file.js` and `./file` to `file.ts` or `file.tsx`, `./file.mjs` to `file.mts`, `./file.cjs` to `file.cts` (which runs as CommonJS), and `./dir` to `dir/index.ts`. Doing it in one place, instead of in SWC (`jsc.paths`, `resolveFully`) and again in the hook, made loading about 20% faster once Node and SWC are warm (`pnpm bench flux-load`). Before Node imports an entry, Flux compiles it and the files it imports, following their imports out from the entry, in parallel on SWC's thread pool. The load hook is synchronous and would otherwise compile one file at a time; files the app never imports, such as tests, are not compiled. A file that fails to compile there is compiled again when Node loads it, and that load fails with the file's name, as before. That is a debug rule so you can edit a library and hit HMR without a pre-build or `node_modules` workspace symlink. Release still resolves through real `node_modules` (published `exports` / `main`).
244
+ Flux uses **Forge’s compiler** (`@decohere/forge/transpile`), with one SWC config per project built once per run. It never loads the TypeScript compiler: SWC strips types without checking them, so type errors are `forge typecheck`'s job. SWC leaves imports as written; Flux's resolve hook maps each one to its TypeScript source: `@scope/pkg` and `@scope/pkg/sub` through the workspace package aliases (and tsconfig `paths`), `./file.js` and `./file` to `file.ts` or `file.tsx`, `./file.mjs` to `file.mts`, `./file.cjs` to `file.cts` (which runs as CommonJS), and `./dir` to `dir/index.ts`. Doing it in one place, instead of in SWC (`jsc.paths`, `resolveFully`) and again in the hook, made loading about 20% faster once Node and SWC are warm (`pnpm bench flux-load`). Before Node imports an entry, Flux compiles it and the files it imports, following their imports out from the entry, in parallel on SWC's thread pool. The load hook is synchronous and would otherwise compile one file at a time; files the app never imports, such as tests, are not compiled. A file that fails to compile there is compiled again when Node loads it, and that load fails with the file's name, as before. That is a debug rule so you can edit a library and hit HMR without a pre-build or `node_modules` workspace symlink. Release still resolves through real `node_modules` (published `exports` / `main`).
245
245
 
246
246
  Why aliases, and a tree of where a symlink misses `src/index.ts`: [Forge — debug path aliases](../forge/README.md#debug-path-aliases-not-node_modules-links).
247
247
 
@@ -272,3 +272,15 @@ await server.dispose();
272
272
  `flux.run` keeps Node ESM hooks registered for the process so the imported graph can still load `.ts`. Do not dispose the loader after a successful run.
273
273
 
274
274
  Slice helpers (`classifySliceProjects`, `normalizeSlicePrefix`, …) and the engine types (`SourceModuleLoader`, `HotReloadServer`) stay exported for tests and tooling; the CLI and `flux` facade are the primary surfaces.
275
+
276
+ ## Working on this package
277
+
278
+ For contributors to Decohere: how the package is laid out and tested. Using it needs nothing below.
279
+
280
+ `src/` is flat today. Flux is a CLI module, `FluxModule` (`flux.module.ts`), with the `run` and `serve` commands and actions (`run.command.ts`, `run.action.ts`, `serve.command.ts`, `serve.action.ts`). Beside them:
281
+
282
+ - the loader: `source-module-loader.ts` (Node's resolve and load hooks), `rewrite-serve-specifier.ts` (an import to its TypeScript source), `static-imports.ts` (compiling ahead along the imports) and `transpile-disk-cache.ts`;
283
+ - serving: `hot-reload-server.ts` (HMR reboots), `slice-serve.ts` (which projects `flux serve <dir>` runs) and `deferred-script-runner.ts` (projects with a script of their own);
284
+ - `flux.ts`: the `flux` namespace object (`flux.run`, `flux.serve`, `flux.dispose`) for code that runs Flux without the CLI.
285
+
286
+ The canonical suite is the flux CLI's, `projects/cli/tests/flux.integration.spec.ts`; `tests/hmr.server.spec.ts` covers `HotReloadServer` edges the CLI can't see ([testing](../../docs/contributing/testing/README.md#canonical-suite-ownership)). Specs are in `tests/` today and move beside the code ([ADR 0027](../../docs/contributing/adr/0027-code-design.md)). `bench/` holds the load, run, serve and transpile benchmarks.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decohere/flux",
3
- "version": "0.0.1-dev.20261123.374",
3
+ "version": "0.0.1-dev.20261123.379",
4
4
  "description": "Hot module reload server for Node.js ESM applications",
5
5
  "keywords": [
6
6
  "typescript",
@@ -33,12 +33,12 @@
33
33
  "test": "echo \"Error: no test specified\" && exit 1"
34
34
  },
35
35
  "dependencies": {
36
- "@decohere/core": "0.0.1-dev.20261123.374",
37
- "@decohere/crucible": "0.0.1-dev.20261123.374",
38
- "@decohere/devkit": "0.0.1-dev.20261123.374",
39
- "@decohere/forge": "0.0.1-dev.20261123.374",
40
- "@decohere/scribe": "0.0.1-dev.20261123.374",
41
- "@decohere/workspace": "0.0.1-dev.20261123.374",
36
+ "@decohere/core": "0.0.1-dev.20261123.379",
37
+ "@decohere/crucible": "0.0.1-dev.20261123.379",
38
+ "@decohere/devkit": "0.0.1-dev.20261123.379",
39
+ "@decohere/forge": "0.0.1-dev.20261123.379",
40
+ "@decohere/scribe": "0.0.1-dev.20261123.379",
41
+ "@decohere/workspace": "0.0.1-dev.20261123.379",
42
42
  "commander": "^13.1.0"
43
43
  },
44
44
  "devDependencies": {}