@kudzujs/core 0.8.33 → 0.8.34
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/MIGRATION_ROADMAP.md +7 -1
- package/PERFORMANCE.md +52 -1
- package/README.md +1 -1
- package/RELEASES.md +34 -0
- package/docs/next-architecture/README.md +1 -1
- package/docs/next-architecture/compiler-current-architecture.md +4 -3
- package/docs/next-architecture/large-application-ai-native-roadmap.md +7 -4
- package/docs/next-architecture/versioning.md +2 -1
- package/framework/compiler/project-session.mjs +72 -3
- package/framework/compiler/source-compiler.mjs +24 -37
- package/framework/compiler/worker-compiler.mjs +3 -3
- package/package.json +2 -1
package/MIGRATION_ROADMAP.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
This document is the source of truth for Kudzu's product direction, architecture invariants, and future development order. Read it before extending React-shaped syntax or browser capabilities.
|
|
4
4
|
|
|
5
|
-
The executable post-`0.8.
|
|
5
|
+
The executable post-`0.8.34` compiler and large-application sequence is maintained in [`docs/next-architecture/large-application-ai-native-roadmap.md`](./docs/next-architecture/large-application-ai-native-roadmap.md). Follow its PR dependencies for implementation work; this document remains authoritative when selecting or accepting a migration capability.
|
|
6
6
|
|
|
7
7
|
[`GOAL_A.md`](./GOAL_A.md) and [`GOAL_B.md`](./GOAL_B.md) are completed capability-validation records. Their commerce and realtime dashboard fixtures prove general lifecycle, navigation, async-workflow, and Worker capabilities; they are not separate product verticals or future priority lists.
|
|
8
8
|
|
|
@@ -308,6 +308,12 @@ This queue orders the next investigations by general migration value. Start only
|
|
|
308
308
|
- Programmatic build and development entry points accept an explicit root while omitted roots preserve call-time CWD and existing CLI behavior.
|
|
309
309
|
- One process compiles two independent roots with identical module names and verifies isolated config, HTML, `.kudzu`, source results, and Worker output; no browser runtime or migration syntax changes.
|
|
310
310
|
|
|
311
|
+
### Completed In 0.8.34
|
|
312
|
+
|
|
313
|
+
- Each unchanged source module is parsed and export-summarized once per ProjectSession, with source-text invalidation and no cross-project cache sharing.
|
|
314
|
+
- Read-only graph consumers share a canonical AST while importer normalization deep-clones every node and repairs independent parent links before transformation.
|
|
315
|
+
- A 100-importer fixture proves bounded parse/summary work and identical source results without changing accepted migration syntax or browser output.
|
|
316
|
+
|
|
311
317
|
## Cross-Cutting Performance Gates
|
|
312
318
|
|
|
313
319
|
Every migration feature must preserve:
|
package/PERFORMANCE.md
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
1
|
# Performance Records
|
|
2
2
|
|
|
3
|
-
Reproducibility classes: `npm run benchmark`, `npm run benchmark:keyed`, and `npm run benchmark:
|
|
3
|
+
Reproducibility classes: `npm run benchmark`, `npm run benchmark:keyed`, `npm run benchmark:native`, and `npm run benchmark:module-cache` are maintained in this repository; `npm run benchmark:commerce` is a maintained paired runner over the public external storefront; older excluded-workspace sections are historical provenance only and are not current framework rankings.
|
|
4
|
+
|
|
5
|
+
## P0.7 Parsed Module And Export Summary Cache
|
|
6
|
+
|
|
7
|
+
Measured UTC 2026-08-11 on an Intel Core i5-9500 with 6 physical/logical cores, 31.2 GiB RAM, Linux 6.17.0-19-generic x64, Node 24.14.0, and npm 11.9.0. The baseline was clean tag `v0.8.33` at `65c96b13802c73e9c9a109cebbaac88bae7704a7`; both targets used the same installed dependencies. The implementation and maintained benchmark patch had SHA-256 `bca61b37f14c77488c4a35b62856faa6b471dd01081abcb69c47027b3b4615d9`, produced by:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
git diff --binary v0.8.33..v0.8.34 -- framework/compiler/project-session.mjs framework/compiler/source-compiler.mjs framework/compiler/worker-compiler.mjs test/compiler-passes.test.mjs test/module-cache-performance.mjs package.json | sha256sum
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The maintained in-memory fixture has 100 page importers sharing one barrel component and helper, for 103 unique modules. Each sample starts a fresh Node process; fixture generation and result hashing occur outside timing. Three warm-ups followed by 21 alternating samples compiled every reachable module. The candidate parsed and summarized each unique module once and created 200 importer-local normalization clones. Baseline and candidate produced the same 382,603-byte serialized source-result graph with SHA-256 `8c35b3f6d2c571306bd97c4d51d4af76ca244badd36c57363bf579ef961f41aa`.
|
|
14
|
+
|
|
15
|
+
| Target | Compiler median | Range | Peak RSS median | Parse / summary / clone misses |
|
|
16
|
+
|---|---:|---:|---:|---:|
|
|
17
|
+
| `v0.8.33` | 2,386.735 ms | 1,183.385–3,249.719 ms | 261.3 MiB | not instrumented |
|
|
18
|
+
| P0.7 candidate | 2,188.745 ms | 1,321.352–2,957.883 ms | 257.1 MiB | 103 / 103 / 200 |
|
|
19
|
+
|
|
20
|
+
Both timing arrays drifted upward during the run, making their raw 8.29% median difference unsuitable as an improvement claim. Round-paired candidate-minus-baseline differences had a +33.324 ms median, with the candidate faster in 9/21 pairs and the baseline faster in 12/21. Peak RSS ranges also overlap. This establishes bounded parse/summary work and identical compiler output with no material performance conclusion on this machine; it does not establish a speedup.
|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
v0.8.33: [1512.096,1244.231,1183.385,1655.352,1669.380,2033.448,1820.868,1774.702,1847.652,1889.290,2386.735,2926.474,2853.159,3249.719,2716.963,2569.254,2531.427,2727.951,2483.411,2492.172,2597.774]
|
|
24
|
+
candidate: [1943.630,1416.969,1321.352,1603.967,1340.557,1440.993,1913.509,2060.240,1796.133,2011.796,2188.745,2888.145,2957.883,2947.417,2750.287,2745.883,2799.166,2620.866,2499.916,2541.054,2530.391]
|
|
25
|
+
paired candidate-baseline: [431.534,172.738,137.967,-51.385,-328.823,-592.455,92.641,285.538,-51.519,122.506,-197.990,-38.329,104.724,-302.302,33.324,176.629,267.739,-107.085,16.505,48.882,-67.383]
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
git worktree add --detach /tmp/opencode/kudzu-v0.8.33 v0.8.33
|
|
30
|
+
ln -s "$PWD/node_modules" /tmp/opencode/kudzu-v0.8.33/node_modules
|
|
31
|
+
BASELINE_ROOT=/tmp/opencode/kudzu-v0.8.33 CANDIDATE_ROOT="$PWD" WARMUPS=3 RUNS=21 npm run benchmark:module-cache
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Current Cross-Framework Whole-Build Context
|
|
35
|
+
|
|
36
|
+
This separate local check is not a parsed-module-cache comparison or maintained ranking. The external `/tmp/opencode/kudzu-dependency-benchmark` workspace is not Git-provenanced. It used Kudzu's current candidate, React 19.2.7, Vue 3.5.40, Svelte 5.56.6, Astro 7.1.1, and Vite 7.3.6. Every target emitted matched initial device content, and headless Chrome passed detail fetch, list filters, empty state, superseded async command, stale-result rejection, and HTTP error behavior. React, Vue, and Svelte perform separate client, SSR, and prerender builds; Astro uses its native build; Kudzu runs one static compiler build, so build stages and artifact architectures differ.
|
|
37
|
+
|
|
38
|
+
| Target | Build median | HTML raw / gzip | JavaScript raw / gzip | Total output |
|
|
39
|
+
|---|---:|---:|---:|---:|
|
|
40
|
+
| Kudzu | 856.2 ms | 5,647 B / 1,324 B | 30,712 B / 12,233 B | 36,359 B |
|
|
41
|
+
| React SSR | 2,802.0 ms | 1,338 B / 562 B | 195,864 B / 61,488 B | 197,202 B |
|
|
42
|
+
| Vue SSR | 2,295.3 ms | 1,348 B / 567 B | 69,643 B / 27,756 B | 70,991 B |
|
|
43
|
+
| Svelte SSR | 2,972.9 ms | 1,399 B / 582 B | 40,781 B / 15,898 B | 42,180 B |
|
|
44
|
+
| Astro native | 1,482.9 ms | 3,307 B / 1,229 B | 2,201 B / 883 B | 3,307 B |
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
Kudzu: [672.2,697.5,796.0,856.2,884.2,937.9,985.9]
|
|
48
|
+
React SSR: [2238.5,2345.7,2598.5,2802.0,2843.9,2848.5,3253.6]
|
|
49
|
+
Vue SSR: [1968.1,2068.9,2150.7,2295.3,2494.6,2617.1,3380.0]
|
|
50
|
+
Svelte SSR: [2615.6,2922.0,2926.6,2972.9,3020.5,3168.3,3739.9]
|
|
51
|
+
Astro native: [1444.9,1445.7,1451.2,1482.9,1732.5,1744.0,2236.9]
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The cross-framework result provides current whole-build context only. It does not show that Kudzu's module cache is faster than another framework's cache: this fixture has one application module per target and exposes no equivalent parser/cache counters. A cache-specific cross-framework claim would require matched 100-importer module graphs, equivalent output, equal cold/warm policy, and framework-specific cache instrumentation.
|
|
4
55
|
|
|
5
56
|
## 2026-08-11 React, Vue, And Svelte Check
|
|
6
57
|
|
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Kudzu compiles ordinary React-shaped TypeScript and TSX into complete static HTM
|
|
|
14
14
|
|
|
15
15
|
> Experimental `0.8.x`: the compiler API and supported TSX surface may change.
|
|
16
16
|
|
|
17
|
-
**Latest release: 0.8.
|
|
17
|
+
**Latest release: 0.8.34 - Session-local module cache.** Each unchanged source module is parsed and export-summarized once per ProjectSession, while every transformer receives an independent deep clone so mutable TypeScript AST state cannot leak across importers or projects. Read the [release notes](./RELEASES.md#0834---session-local-module-cache), open the [release page](https://github.com/kudzujs/kudzu/releases/tag/v0.8.34), or follow the [architecture packet](./docs/next-architecture/README.md).
|
|
18
18
|
|
|
19
19
|
- [Documentation](https://kudzujs.cloud/docs)
|
|
20
20
|
- [Installation guide](https://kudzujs.cloud/docs#install)
|
package/RELEASES.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# Kudzu Releases
|
|
2
2
|
|
|
3
|
+
## 0.8.34 - Session-local module cache
|
|
4
|
+
|
|
5
|
+
Kudzu 0.8.34 completes P0.7 by making source parsing and supported-export summarization proportional to unique modules within one ProjectSession instead of repeated importer edges.
|
|
6
|
+
|
|
7
|
+
### Changed in 0.8.34
|
|
8
|
+
|
|
9
|
+
- ProjectSession caches one canonical read-only TypeScript AST and one narrow export summary for each file/source-text pair.
|
|
10
|
+
- Reachability, static collection, Zustand, client-helper, style, layout-diagnostic, and Worker graph consumers reuse canonical module records.
|
|
11
|
+
- Importer normalization receives a deep clone of every node with independent parent links; transformed mutable AST is never shared between transformer contexts.
|
|
12
|
+
- Source-text changes invalidate the parsed tree and export summary together, and independent ProjectSessions never share records.
|
|
13
|
+
- Export summaries preserve the existing supported direct, aliased, default, and named re-export forms. Stable ModuleSymbol/SiteId identity and `export *` expansion remain P0.8 work.
|
|
14
|
+
- Optional injected counters expose parse, summary, and clone misses to tests and the maintained benchmark without production logging.
|
|
15
|
+
|
|
16
|
+
### Performance
|
|
17
|
+
|
|
18
|
+
- A 100-importer fixture contains 103 unique page/barrel/component/helper modules. The candidate records exactly 103 parses, 103 export summaries, and 200 importer-local clones.
|
|
19
|
+
- Baseline and candidate produce the same 382,603-byte source-result graph and SHA-256 digest.
|
|
20
|
+
- The 21-pair timing run drifted materially on the measurement host. Paired candidate-minus-baseline differences had a +33.324 ms median, with the candidate faster in 9/21 pairs; no material speedup or regression is claimed.
|
|
21
|
+
- A separate matched SSR/native whole-build check measured Kudzu at 856.2 ms, Astro at 1,482.9 ms, Vue at 2,295.3 ms, React at 2,802.0 ms, and Svelte at 2,972.9 ms. Every target passed the same Chrome behavior validation; this is whole-build context, not a module-cache comparison.
|
|
22
|
+
|
|
23
|
+
### Validation
|
|
24
|
+
|
|
25
|
+
- `npm run check`, `npm test`, `npm run test:package`, and all 193 tests pass.
|
|
26
|
+
- Unit coverage verifies cache hits, source-text invalidation, export summaries, cross-session isolation, independent cloned node identity, and clone-local parent links.
|
|
27
|
+
- Existing imported components, re-export cycles, static collections, Zustand, client helpers, Workers, source diagnostics, and generated artifacts remain covered.
|
|
28
|
+
- The repository build emits 149 pages; unaffected static routes remain complete zero-JavaScript documents.
|
|
29
|
+
- P0.8 stable ModuleSymbol and SiteId is next.
|
|
30
|
+
|
|
31
|
+
### Upgrade
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install @kudzujs/core@^0.8.34
|
|
35
|
+
```
|
|
36
|
+
|
|
3
37
|
## 0.8.33 - Project-scoped compilation
|
|
4
38
|
|
|
5
39
|
Kudzu 0.8.33 completes P0.6 by replacing import-time project globals with an explicit build-scoped ProjectSession. Independent roots can now compile in one Node process without sharing paths, source records, graph resolution, or Worker compiler ownership.
|
|
@@ -11,7 +11,7 @@ The top-level [`GOAL_A.md`](../../GOAL_A.md) and [`GOAL_B.md`](../../GOAL_B.md)
|
|
|
11
11
|
| C: state/resource model | Research only | Reduced fixtures expose a limitation |
|
|
12
12
|
| D: routing compatibility | Current behavior preserved | Revisit only with migration evidence and invariant review |
|
|
13
13
|
|
|
14
|
-
The active post-`0.8.
|
|
14
|
+
The active post-`0.8.34` implementation sequence is [`large-application-ai-native-roadmap.md`](./large-application-ai-native-roadmap.md). P0.7 parsed module and export summary caching is complete; P0.8 stable ModuleSymbol and SiteId is next. The plan orders compiler semantic generalization, large-application foundations, compatibility boundaries, AI tooling, and production validation without changing the invariants below.
|
|
15
15
|
|
|
16
16
|
## Required Invariants
|
|
17
17
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Current Compiler Architecture
|
|
2
2
|
|
|
3
|
-
This maps the current `0.8.
|
|
3
|
+
This maps the current `0.8.34` architecture, built on the completed `0.8.23` Goal A compiler foundation. File and function names are the stable references; line numbers are intentionally omitted because later work may still move code.
|
|
4
4
|
|
|
5
5
|
## Responsibility Map
|
|
6
6
|
|
|
@@ -8,6 +8,7 @@ This maps the current `0.8.33` architecture built on the completed `0.8.23` Goal
|
|
|
8
8
|
|---|---|---|
|
|
9
9
|
| CLI entry | [`bin/kudzu.mjs`](../../bin/kudzu.mjs) | Dispatches build and development commands. |
|
|
10
10
|
| Project session | [`framework/compiler/project-session.mjs`](../../framework/compiler/project-session.mjs), `createProjectSession()` | Owns one absolute root, standard project paths, source records, bound graph operations, and Worker compiler for a build. Omitted roots resolve from call-time CWD. |
|
|
11
|
+
| Parsed module cache | [`framework/compiler/project-session.mjs`](../../framework/compiler/project-session.mjs) | Parses each unchanged source module and summarizes its supported exports once per ProjectSession. Read-only graph/export/style/Worker consumers share the canonical tree; normalization receives a fresh deep clone with independent parent links. |
|
|
11
12
|
| Build orchestration | [`framework/build.mjs`](../../framework/build.mjs), `build()` | Coordinates config, discovery, source compilation, RouteIR rendering, CapabilityIR projection, generator invocation, artifact emission, and `afterBuild`. |
|
|
12
13
|
| Reachability/import resolution | [`framework/compiler/source-compiler.mjs`](../../framework/compiler/source-compiler.mjs), `reachableSourceFiles()`; [`framework/compiler/source-graph.mjs`](../../framework/compiler/source-graph.mjs), `ordinaryRuntimeDependencies()`, `resolveSourceImport()` | Starts from page entries, follows relative runtime imports/re-exports and validated Worker references, excludes unreachable migration source, and fails unresolved ordinary edges or dynamic imports at the importer source location before code generation. |
|
|
13
14
|
| Ordered normalization | [`framework/compiler/normalization-pipeline.mjs`](../../framework/compiler/normalization-pipeline.mjs), `applyNormalizationPasses()`; [`framework/compiler/source-compiler.mjs`](../../framework/compiler/source-compiler.mjs), `normalizeCompilerSource()` | Applies migration/resource passes in order and repairs TypeScript parent pointers after every structural change. Imported source uses the same pipeline. |
|
|
@@ -38,7 +39,7 @@ This maps the current `0.8.33` architecture built on the completed `0.8.23` Goal
|
|
|
38
39
|
|
|
39
40
|
```text
|
|
40
41
|
src/pages entries + config
|
|
41
|
-
-> ProjectSession(root) with project paths, source records, graph, and Worker compiler
|
|
42
|
+
-> ProjectSession(root) with project paths, source records, parsed/export caches, graph, and Worker compiler
|
|
42
43
|
-> project discovery and reachable relative graph
|
|
43
44
|
-> compileSource()
|
|
44
45
|
-> ordered normalization and parent repair
|
|
@@ -70,7 +71,7 @@ The browser consumes static HTML first. State seeds and descriptors in that HTML
|
|
|
70
71
|
- Transient component rewrite indexes remain source-local AST indexes; handler, binding, derived, keyed, effect, and component ownership now have explicit JSON-safe source results.
|
|
71
72
|
- `build()` still owns explicit artifact selection and filesystem writes after generator results are produced.
|
|
72
73
|
- Runtime generators intentionally specialize readable authored sources through exact anchors; every required anchor fails closed, but a future generator format may remove this transitional dependency.
|
|
73
|
-
- Source reachability and source compilation remain in one session-bound compiler factory because both consume the same normalization and import graph contracts;
|
|
74
|
+
- Source reachability and source compilation remain in one session-bound compiler factory because both consume the same normalization and import graph contracts. Export summaries deliberately preserve the existing narrow forms; stable ModuleSymbol and SiteId identity remains P0.8 work.
|
|
74
75
|
- Imported, specialized, and compiler-synthesized trees still use conservative name/scope fallback where the source-local binding index does not own the complete AST; cross-module semantics remain deferred to stable ModuleSymbol and SiteId work.
|
|
75
76
|
|
|
76
77
|
These are future simplification opportunities, not incomplete Goal A contracts. Goal A changed no source support, browser output semantics, or browser architecture.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Status
|
|
4
4
|
|
|
5
|
-
Active execution plan after `0.8.
|
|
5
|
+
Active execution plan after `0.8.34`. This document turns the current compiler audit into an ordered implementation program. It does not mark any planned capability as supported and does not authorize a React runtime, VDOM, hydration, retained browser component tree, generic rerenderer, public store/query/resource API, SPA router, or islands.
|
|
6
6
|
|
|
7
7
|
[`MIGRATION_ROADMAP.md`](../../MIGRATION_ROADMAP.md) remains authoritative for product invariants and fixture-driven feature selection. This plan is authoritative for the order and completion evidence of compiler generalization, large-application foundations, compatibility boundaries, AI tooling, and scale validation. If implementation evidence changes a boundary, update this document before broadening a patch.
|
|
8
8
|
|
|
@@ -34,7 +34,7 @@ The current limiting architecture is observable in these files:
|
|
|
34
34
|
|
|
35
35
|
| Concern | Current owner | Limitation to remove |
|
|
36
36
|
|---|---|---|
|
|
37
|
-
| Project graph | `framework/compiler/project-session.mjs`, `source-graph.mjs`, `build.mjs` | Explicit build-scoped root and source ownership;
|
|
37
|
+
| Project graph | `framework/compiler/project-session.mjs`, `source-graph.mjs`, `build.mjs` | Explicit build-scoped root, parsed-module/export-summary cache, and source ownership; narrow export resolution and no incremental invalidation remain |
|
|
38
38
|
| Normalization | `framework/compiler/source-compiler.mjs`, focused passes | Pass order and package ownership are implicit; semantically equal source often follows different shape-specific paths |
|
|
39
39
|
| Component/state analysis | `framework/compiler/source-compiler.mjs`, `analysis/component-analysis.mjs` | AST identity, identifier text, source offsets, and caller-side AST specialization remain central |
|
|
40
40
|
| Handler/binding analysis | `framework/compiler/descriptor-session.mjs`, `handler-lowering.mjs` | Capture/import/state discovery is name-based and arbitrary handlers become code before IR finalization |
|
|
@@ -135,7 +135,8 @@ This is an incremental evolution of the current repository:
|
|
|
135
135
|
- [x] P0.4 Async native handler ownership is complete in `0.8.31`. Mounted native registrations invalidate direct/captured setters, queued commits, and captured refs before listener removal. Chrome route, keyed-row, document-disposal, and synchronous event-dispatch checks, all 189 tests, and packed-package smoke pass without cancelling application promises or adding a scheduler.
|
|
136
136
|
- [x] P0.5 Staged and collision-safe output is complete in `0.8.32`. Production output completes in one project-local staging tree, public files are compared against generated route/runtime/handler/chunk/Worker/CSS paths while copying, `afterBuild` runs before rollback-safe promotion, and ordinary failures preserve the prior `dist`. Same-root overlap and stale locks fail closed; after stale-lock removal, an interrupted promotion backup recovers on the next admitted build. Focused collision/replacement/dev checks pass with equivalent `v0.8.31` commerce deploy output; `.kudzu` remains compiler scratch for P0.6.
|
|
137
137
|
- [x] P0.6 Explicit ProjectSession is complete in `0.8.33`. Each build owns an absolute root, project paths, source records, bound graph operations, and Worker compiler. Explicit-root build/dev entry points preserve omitted-root CLI CWD behavior. One imported build function compiles two same-shaped roots with isolated config, HTML, `.kudzu`, source results, and Worker bundles; all 191 tests and package checks pass without browser or source-syntax changes.
|
|
138
|
-
- [
|
|
138
|
+
- [x] P0.7 Parsed module and export summary caching is complete in `0.8.34`. Canonical read-only source trees and narrow export summaries are invalidated together by source text and remain ProjectSession-local; every normalization context receives a deep clone with independent parent links. A 100-importer fixture parses and summarizes 103 unique page/barrel/component/helper modules exactly once and creates 200 importer-local clones. The maintained paired benchmark preserves the complete source-result digest and establishes no material timing or peak-RSS conclusion; all 193 tests and package checks pass without broadening exports, source syntax, or browser output.
|
|
139
|
+
- [ ] P0.8 Stable ModuleSymbol and SiteId is next. Cross-module declarations, aliases, re-exports, owners, and call sites must stop depending on transient AST identity outside one pass.
|
|
139
140
|
|
|
140
141
|
### P0: Semantic Correctness And Compiler Foundation
|
|
141
142
|
|
|
@@ -309,6 +310,8 @@ Every result carries a stable source-local binding slot, debug name, declaration
|
|
|
309
310
|
|
|
310
311
|
**Done condition:** each unchanged module is parsed and summarized once per project session; transformed mutable AST is not shared across transformer contexts.
|
|
311
312
|
|
|
313
|
+
**Completed in `0.8.34`:** ProjectSession caches one canonical parsed tree and one supported-export summary per file/source-text pair. Reachability, static collection, Zustand, client-helper, style, layout-diagnostic, and Worker graph reads reuse canonical trees; importer normalization deep-clones every node and repairs clone-local parents. Optional injected counters add no production logging. Unit coverage proves source invalidation and cross-session isolation; 100 pages sharing one barrel component and helper produce 103 parse misses, 103 summary misses, and 200 independent normalization clones.
|
|
314
|
+
|
|
312
315
|
### PR 8: Stable ModuleSymbol And SiteId
|
|
313
316
|
|
|
314
317
|
**Objective:** represent declarations, imports, re-exports, component calls, hooks, and ownership sites independently of transformed AST identity.
|
|
@@ -463,4 +466,4 @@ The first comparison is Kudzu versus React + Vite using the same agent, model, t
|
|
|
463
466
|
|
|
464
467
|
## Immediate Decision
|
|
465
468
|
|
|
466
|
-
PR 1 through PR
|
|
469
|
+
PR 1 through PR 7 are complete. The next PR is **PR 8: Stable ModuleSymbol And SiteId**. Do not skip directly to a store, resource, router, virtualization, or ecosystem package feature.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Planned Version Sequence
|
|
2
2
|
|
|
3
|
-
This is an execution sequence, not release history. `0.8.16` through `0.8.
|
|
3
|
+
This is an execution sequence, not release history. `0.8.16` through `0.8.34` are completed scopes represented by package/release records.
|
|
4
4
|
|
|
5
5
|
Keep each patch behavior-preserving and independently reviewable. If a boundary proves inseparable, revise this plan before combining releases; do not silently broaden a patch.
|
|
6
6
|
|
|
@@ -24,6 +24,7 @@ Keep each patch behavior-preserving and independently reviewable. If a boundary
|
|
|
24
24
|
| `0.8.31` | Invalidate pending native-handler contexts when their route, keyed, conditional, or document DOM owner is released. | Late setters, queued commits, and captured refs cannot mutate replacement ownership; synchronous dispatch remains within the performance gate and runtime bytes are recorded. |
|
|
25
25
|
| `0.8.32` | Stage and validate production output before rollback-safe promotion, reject same-root overlap, and tighten keyed browser paths. | Build/hook failures preserve the prior output, stale locks fail closed, interrupted backups recover on the next admitted build after lock removal, public/generated collisions fail, and deploy output remains equivalent. |
|
|
26
26
|
| `0.8.33` | Move root, graph, source records, compiler paths, and Worker ownership into an explicit build-scoped ProjectSession. | Two independent roots compile through one imported build entry without config, source, `.kudzu`, Worker, or output leakage; CLI CWD behavior remains unchanged. |
|
|
27
|
+
| `0.8.34` | Cache canonical parsed modules and narrow export summaries within one ProjectSession while cloning transformer input. | A 100-importer fixture parses and summarizes 103 unique modules once, creates independent normalization trees, preserves the complete source-result digest, and leaks no cache state across projects. |
|
|
27
28
|
|
|
28
29
|
## Sequence Rules
|
|
29
30
|
|
|
@@ -1,21 +1,90 @@
|
|
|
1
1
|
import { join, resolve } from "node:path"
|
|
2
|
+
import ts from "typescript"
|
|
2
3
|
import { assetPath } from "./path-helpers.mjs"
|
|
3
4
|
import { createSourceGraph } from "./source-graph.mjs"
|
|
4
5
|
import { createWorkerCompiler } from "./worker-compiler.mjs"
|
|
5
6
|
|
|
6
|
-
export function createProjectSession(projectRoot = process.cwd()) {
|
|
7
|
+
export function createProjectSession(projectRoot = process.cwd(), { counters, sourceIndex = new Map() } = {}) {
|
|
7
8
|
const root = resolve(projectRoot)
|
|
8
9
|
const sourceDirectory = join(root, "src")
|
|
9
10
|
const graph = createSourceGraph(root)
|
|
11
|
+
const modules = createModuleCache(sourceIndex, graph.parseSourceFile, counters)
|
|
10
12
|
return {
|
|
11
13
|
root,
|
|
12
14
|
sourceDirectory,
|
|
13
15
|
pagesDirectory: join(sourceDirectory, "pages"),
|
|
14
16
|
workDirectory: join(root, ".kudzu"),
|
|
15
17
|
outputDirectory: join(root, "dist"),
|
|
16
|
-
sourceIndex
|
|
18
|
+
sourceIndex,
|
|
17
19
|
sourceFiles: new Set(),
|
|
18
20
|
graph,
|
|
19
|
-
|
|
21
|
+
modules,
|
|
22
|
+
workerCompiler: createWorkerCompiler({ root, sourceDirectory, assetPath, readSourceModule: modules.read, ...graph })
|
|
20
23
|
}
|
|
21
24
|
}
|
|
25
|
+
|
|
26
|
+
function createModuleCache(sourceIndex, parseSourceFile, counters) {
|
|
27
|
+
const records = new Map()
|
|
28
|
+
const increment = name => {
|
|
29
|
+
if (counters) counters[name] = (counters[name] ?? 0) + 1
|
|
30
|
+
}
|
|
31
|
+
const read = (file, source = sourceIndex.get(file)) => {
|
|
32
|
+
if (typeof source !== "string") throw new Error(`Source text is unavailable for ${file}`)
|
|
33
|
+
const cached = records.get(file)
|
|
34
|
+
if (cached?.source === source) return cached
|
|
35
|
+
const sourceFile = parseSourceFile(file, source)
|
|
36
|
+
increment("parsedModules")
|
|
37
|
+
const exports = summarizeExports(sourceFile)
|
|
38
|
+
increment("exportSummaries")
|
|
39
|
+
const record = { source, sourceFile, exports }
|
|
40
|
+
records.set(file, record)
|
|
41
|
+
return record
|
|
42
|
+
}
|
|
43
|
+
const clone = (file, factory, context) => {
|
|
44
|
+
const visit = node => {
|
|
45
|
+
const copy = factory.cloneNode(node)
|
|
46
|
+
ts.setTextRange(copy, node)
|
|
47
|
+
ts.setOriginalNode(copy, node)
|
|
48
|
+
return ts.visitEachChild(copy, visit, context)
|
|
49
|
+
}
|
|
50
|
+
const sourceFile = visit(read(file).sourceFile)
|
|
51
|
+
ts.setParentRecursive(sourceFile, false)
|
|
52
|
+
increment("clonedModules")
|
|
53
|
+
return sourceFile
|
|
54
|
+
}
|
|
55
|
+
return { clone, read }
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function summarizeExports(sourceFile) {
|
|
59
|
+
const exports = new Map()
|
|
60
|
+
const add = (name, value) => {
|
|
61
|
+
if (!exports.has(name)) exports.set(name, value)
|
|
62
|
+
}
|
|
63
|
+
for (const statement of sourceFile.statements) {
|
|
64
|
+
if (ts.isFunctionDeclaration(statement)) {
|
|
65
|
+
const exported = statement.modifiers?.some(modifier => modifier.kind === ts.SyntaxKind.ExportKeyword)
|
|
66
|
+
const isDefault = statement.modifiers?.some(modifier => modifier.kind === ts.SyntaxKind.DefaultKeyword)
|
|
67
|
+
if (isDefault) add("default", { kind: "function", local: statement.name?.text })
|
|
68
|
+
if (exported && statement.name) add(statement.name.text, { kind: "function", local: statement.name.text })
|
|
69
|
+
continue
|
|
70
|
+
}
|
|
71
|
+
if (ts.isVariableStatement(statement) && statement.modifiers?.some(modifier => modifier.kind === ts.SyntaxKind.ExportKeyword)) {
|
|
72
|
+
for (const declaration of statement.declarationList.declarations) if (ts.isIdentifier(declaration.name)) add(declaration.name.text, { kind: "local", local: declaration.name.text })
|
|
73
|
+
continue
|
|
74
|
+
}
|
|
75
|
+
if (ts.isExportAssignment(statement) && !statement.isExportEquals && ts.isIdentifier(statement.expression)) {
|
|
76
|
+
add("default", { kind: "local", local: statement.expression.text })
|
|
77
|
+
continue
|
|
78
|
+
}
|
|
79
|
+
if (!ts.isExportDeclaration(statement) || !statement.exportClause || !ts.isNamedExports(statement.exportClause)) continue
|
|
80
|
+
for (const element of statement.exportClause.elements) {
|
|
81
|
+
if (element.isTypeOnly) continue
|
|
82
|
+
const name = element.name.text
|
|
83
|
+
const imported = (element.propertyName ?? element.name).text
|
|
84
|
+
add(name, statement.moduleSpecifier && ts.isStringLiteral(statement.moduleSpecifier)
|
|
85
|
+
? { kind: "reexport", imported, specifier: statement.moduleSpecifier.text, node: statement }
|
|
86
|
+
: { kind: "local", local: imported })
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return exports
|
|
90
|
+
}
|
|
@@ -22,8 +22,9 @@ import { createProjectSession } from "./project-session.mjs"
|
|
|
22
22
|
import { createZustandPass } from "./zustand-pass.mjs"
|
|
23
23
|
|
|
24
24
|
export function createSourceCompiler(project) {
|
|
25
|
-
const { root, sourceDirectory, pagesDirectory, workDirectory, workerCompiler } = project
|
|
26
|
-
const { ordinaryRuntimeDependencies,
|
|
25
|
+
const { root, sourceDirectory, pagesDirectory, workDirectory, workerCompiler, modules } = project
|
|
26
|
+
const { ordinaryRuntimeDependencies, resolveSourceImport, runtimeModuleReference } = project.graph
|
|
27
|
+
const parseSourceFile = (file, source) => modules.read(file, source).sourceFile
|
|
27
28
|
const staticAssetExtensions = new Set([".avif", ".gif", ".ico", ".jpeg", ".jpg", ".otf", ".png", ".svg", ".ttf", ".webp", ".woff", ".woff2"])
|
|
28
29
|
|
|
29
30
|
function compileSource(file, sourceFiles, sourceIndex, staticFiles, cssModules, base) {
|
|
@@ -282,7 +283,7 @@ function createKudzuTransformer({ semantic, handlerUrl, file, sourceFiles, sourc
|
|
|
282
283
|
const importedSource = target => {
|
|
283
284
|
let result = importedSourceCache.get(target)
|
|
284
285
|
if (!result) {
|
|
285
|
-
result = normalizeCompilerSource(
|
|
286
|
+
result = normalizeCompilerSource(modules.clone(target, context.factory, context), { base, context, file: target, sourceFiles, sourceIndex })
|
|
286
287
|
importedSourceCache.set(target, result)
|
|
287
288
|
}
|
|
288
289
|
return result.sourceFile
|
|
@@ -2723,33 +2724,19 @@ function resolveComponentExport(file, exportName, getSource, sourceFiles, trail
|
|
|
2723
2724
|
if (trail.includes(key)) throw new Error(`Imported keyed list component re-export cycle: ${[...trail, key].map(entry => relative(root, entry.slice(0, entry.lastIndexOf(":")))).join(" -> ")}`)
|
|
2724
2725
|
const sourceFile = getSource(file)
|
|
2725
2726
|
const nextTrail = [...trail, key]
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
if (
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
if (component) return component
|
|
2740
|
-
}
|
|
2741
|
-
if (ts.isExportDeclaration(statement) && ts.isNamedExports(statement.exportClause)) {
|
|
2742
|
-
const entry = statement.exportClause.elements.find(element => !element.isTypeOnly && element.name.text === exportName)
|
|
2743
|
-
if (!entry) continue
|
|
2744
|
-
const imported = (entry.propertyName ?? entry.name).text
|
|
2745
|
-
if (statement.moduleSpecifier && ts.isStringLiteral(statement.moduleSpecifier)) {
|
|
2746
|
-
if (!statement.moduleSpecifier.text.startsWith(".")) throw sourceNodeError(statement, sourceFile, "Imported keyed list components must use relative TypeScript re-exports")
|
|
2747
|
-
const target = resolveSourceImport(file, statement.moduleSpecifier.text, sourceFiles)
|
|
2748
|
-
return resolveComponentExport(target, imported, getSource, sourceFiles, nextTrail)
|
|
2749
|
-
}
|
|
2750
|
-
const component = localComponentDeclaration(sourceFile, imported)
|
|
2751
|
-
if (component) return component
|
|
2752
|
-
}
|
|
2727
|
+
const entry = modules.read(file).exports.get(exportName)
|
|
2728
|
+
if (entry?.kind === "reexport") {
|
|
2729
|
+
if (!entry.specifier.startsWith(".")) throw sourceNodeError(entry.node, modules.read(file).sourceFile, "Imported keyed list components must use relative TypeScript re-exports")
|
|
2730
|
+
const target = resolveSourceImport(file, entry.specifier, sourceFiles)
|
|
2731
|
+
return resolveComponentExport(target, entry.imported, getSource, sourceFiles, nextTrail)
|
|
2732
|
+
}
|
|
2733
|
+
if (entry?.kind === "function" && !entry.local) {
|
|
2734
|
+
const component = sourceFile.statements.find(statement => ts.isFunctionDeclaration(statement) && statement.modifiers?.some(modifier => modifier.kind === ts.SyntaxKind.DefaultKeyword))
|
|
2735
|
+
if (component) return component
|
|
2736
|
+
}
|
|
2737
|
+
if (entry?.local) {
|
|
2738
|
+
const component = localComponentDeclaration(sourceFile, entry.local)
|
|
2739
|
+
if (component) return component
|
|
2753
2740
|
}
|
|
2754
2741
|
throw new Error(`${relative(root, file)} does not export a statically analyzable keyed list component named ${JSON.stringify(exportName)}`)
|
|
2755
2742
|
}
|
|
@@ -2771,8 +2758,8 @@ async function collectClientModules(entries, sourceFiles) {
|
|
|
2771
2758
|
while (queue.length) {
|
|
2772
2759
|
const file = queue.shift()
|
|
2773
2760
|
if (modules.has(file)) continue
|
|
2774
|
-
const source = await readFile(file, "utf8")
|
|
2775
|
-
const sourceFile =
|
|
2761
|
+
const source = project.sourceIndex.get(file) ?? await readFile(file, "utf8")
|
|
2762
|
+
const sourceFile = project.modules.read(file, source).sourceFile
|
|
2776
2763
|
workerCompiler.rejectConstructions(sourceFile, sourceFile, "Relative TypeScript Worker construction is only supported directly inside an inline useEffect() callback, not imported client helpers")
|
|
2777
2764
|
if (containsJsx(sourceFile)) throw new Error(`${relative(root, file)} Imported client helpers must not contain JSX`)
|
|
2778
2765
|
rejectUnsupportedClientImports(sourceFile, file)
|
|
@@ -2974,12 +2961,12 @@ const normalizeReactRouterSyntax = createRouterPass({ withBase })
|
|
|
2974
2961
|
return { collectClientModules, compileClientModule, compiledPath, compileSource, layoutExportError, orderSourceStyles, reachableSourceFiles, safeStaticFiles }
|
|
2975
2962
|
}
|
|
2976
2963
|
|
|
2977
|
-
const currentCompiler =
|
|
2964
|
+
const currentCompiler = sourceIndex => createSourceCompiler(createProjectSession(process.cwd(), { sourceIndex }))
|
|
2978
2965
|
export const collectClientModules = (...arguments_) => currentCompiler().collectClientModules(...arguments_)
|
|
2979
2966
|
export const compileClientModule = (...arguments_) => currentCompiler().compileClientModule(...arguments_)
|
|
2980
2967
|
export const compiledPath = (...arguments_) => currentCompiler().compiledPath(...arguments_)
|
|
2981
|
-
export const compileSource = (...arguments_) => currentCompiler().compileSource(...arguments_)
|
|
2982
|
-
export const layoutExportError = (...arguments_) => currentCompiler().layoutExportError(...arguments_)
|
|
2983
|
-
export const orderSourceStyles = (...arguments_) => currentCompiler().orderSourceStyles(...arguments_)
|
|
2984
|
-
export const reachableSourceFiles = (...arguments_) => currentCompiler().reachableSourceFiles(...arguments_)
|
|
2968
|
+
export const compileSource = (...arguments_) => currentCompiler(arguments_[2]).compileSource(...arguments_)
|
|
2969
|
+
export const layoutExportError = (...arguments_) => currentCompiler(new Map([[arguments_[0], arguments_[1]]])).layoutExportError(...arguments_)
|
|
2970
|
+
export const orderSourceStyles = (...arguments_) => currentCompiler(arguments_[2]).orderSourceStyles(...arguments_)
|
|
2971
|
+
export const reachableSourceFiles = (...arguments_) => currentCompiler(arguments_[2]).reachableSourceFiles(...arguments_)
|
|
2985
2972
|
export const safeStaticFiles = (...arguments_) => currentCompiler().safeStaticFiles(...arguments_)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto"
|
|
2
|
-
import { mkdir
|
|
2
|
+
import { mkdir } from "node:fs/promises"
|
|
3
3
|
import { dirname, relative, resolve, sep } from "node:path"
|
|
4
4
|
import { build as bundle } from "esbuild"
|
|
5
5
|
import ts from "typescript"
|
|
@@ -9,7 +9,7 @@ export function createWorkerCompiler({
|
|
|
9
9
|
root,
|
|
10
10
|
sourceDirectory,
|
|
11
11
|
assetPath,
|
|
12
|
-
|
|
12
|
+
readSourceModule,
|
|
13
13
|
resolveSourceImport,
|
|
14
14
|
runtimeModuleReference
|
|
15
15
|
}) {
|
|
@@ -106,7 +106,7 @@ export function createWorkerCompiler({
|
|
|
106
106
|
const file = queue.shift()
|
|
107
107
|
if (visited.has(file)) continue
|
|
108
108
|
visited.add(file)
|
|
109
|
-
const sourceFile =
|
|
109
|
+
const sourceFile = readSourceModule(file).sourceFile
|
|
110
110
|
if (containsJsx(sourceFile)) throw sourceNodeError(sourceFile, sourceFile, "Worker modules must not contain JSX")
|
|
111
111
|
const visit = node => {
|
|
112
112
|
if (ts.isImportEqualsDeclaration(node)) throw sourceNodeError(node, sourceFile, "TypeScript import-equals declarations are not supported in Worker modules; use a relative ESM import")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kudzujs/core",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.34",
|
|
4
4
|
"description": "HTML-first TSX framework with synchronous state semantics and no virtual DOM",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"benchmark": "node test/performance.mjs",
|
|
59
59
|
"benchmark:keyed": "node test/keyed-performance.mjs",
|
|
60
60
|
"benchmark:commerce": "node test/commerce-build-performance.mjs",
|
|
61
|
+
"benchmark:module-cache": "node test/module-cache-performance.mjs",
|
|
61
62
|
"benchmark:native": "node test/native-performance.mjs",
|
|
62
63
|
"prepublishOnly": "npm run check && npm test",
|
|
63
64
|
"deploy": "wrangler deploy",
|