jsgui3-server 0.0.148 → 0.0.149
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/.github/workflows/control-scan-manifest-check.yml +31 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-071799b982906680f5fd699d.js +40 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-07352945ad5c92654fcb8b65.js +39 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-138a601fadb6191ea314c6fd.js +39 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-171f6c381c2cadf2e9fa7087.js +39 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-1d973388156b84a04373fac9.js +39 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-20e117bc8a10d2cd16234bbe.js +40 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-2b028a82b0e5efddba42425f.js +39 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-4518556cd5c7e059e82b22b8.js +40 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-5bac1aa0f213902f718ed74f.js +40 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-5f9996ac7822caf777d92f56.js +39 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-60a92c702e65fd9cf748e3ec.js +39 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-6164c1f8f738995c541895d2.js +44 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-6718a85eb9e5aa782dd47a05.js +45 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-69e280f14e37aee76a1d4675.js +39 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-7570d1b030d44b111ed59c4c.js +39 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-7798c9bbd55e510d5039f936.js +42 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-78cd511ea1ef18ecb03d1be5.js +40 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-7d482e0b95bcb5e3c543118b.js +43 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-80e9476d1127c55b40fdb36f.js +40 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-810ced55d5320a3088a05b13.js +40 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-8423565f1a40e329afc8c6cf.js +40 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-900bef783b8cee36506ec282.js +39 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-a1a37aff6416fdad74040ddf.js +39 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-ad48d5e8eda40f175b4df090.js +39 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-aec5a2d963015528c9099462.js +39 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-af9d34e0f1722fab9e28c269.js +39 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-b818e4015e2f1fe86280b5ab.js +41 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-bcb2541adc70b7aba61768c5.js +44 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-bfe89d2c78ed44f95ed7dd73.js +40 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-c06f04806a1e688e1187110c.js +40 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-c3f3adf904f585afc544b96a.js +39 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-d45acb873e1d8e32d5e60f2e.js +39 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-db06f132533706f4a0163b8c.js +39 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-f660f40d78b135fc8560a862.js +39 -0
- package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-f9dee4ec18a96e09bee06bae.js +39 -0
- package/README.md +85 -3
- package/admin-ui/client.js +8 -8
- package/dev-status.svg +139 -0
- package/docs/api-reference.md +301 -43
- package/docs/books/jsgui3-bundling-research-book/00-table-of-contents.md +35 -0
- package/docs/books/jsgui3-bundling-research-book/01-pipeline-and-runtime-semantics.md +34 -0
- package/docs/books/jsgui3-bundling-research-book/02-javascript-bundling-core.md +36 -0
- package/docs/books/jsgui3-bundling-research-book/03-style-extraction-and-css-compilation.md +35 -0
- package/docs/books/jsgui3-bundling-research-book/04-static-publishing-and-delivery.md +39 -0
- package/docs/books/jsgui3-bundling-research-book/05-current-limits-and-size-bloat-vectors.md +25 -0
- package/docs/books/jsgui3-bundling-research-book/06-unused-module-elimination-strategy.md +77 -0
- package/docs/books/jsgui3-bundling-research-book/07-jsgui3-html-control-and-mixin-pruning.md +63 -0
- package/docs/books/jsgui3-bundling-research-book/08-test-and-verification-methodology.md +43 -0
- package/docs/books/jsgui3-bundling-research-book/09-roadmap-and-rollout.md +42 -0
- package/docs/books/jsgui3-bundling-research-book/10-further-research-strategies-and-upgrades.md +211 -0
- package/docs/books/jsgui3-bundling-research-book/README.md +35 -0
- package/docs/bundling-system-deep-dive.md +9 -4
- package/docs/comprehensive-documentation.md +49 -18
- package/docs/configuration-reference.md +152 -27
- package/docs/core/README.md +19 -0
- package/docs/core/jsgui3-server-core-book/00-table-of-contents.md +21 -0
- package/docs/core/jsgui3-server-core-book/01-startup-readiness-state-machine.md +41 -0
- package/docs/core/jsgui3-server-core-book/02-resource-abstraction-and-lifecycle.md +92 -0
- package/docs/core/jsgui3-server-core-book/03-resource-pool-and-event-topology.md +47 -0
- package/docs/core/jsgui3-server-core-book/04-sse-publisher-semantics.md +41 -0
- package/docs/core/jsgui3-server-core-book/05-serve-factory-resource-wiring.md +46 -0
- package/docs/core/jsgui3-server-core-book/06-e2e-testing-methodology.md +48 -0
- package/docs/core/jsgui3-server-core-book/07-defect-detection-and-hardening-loop.md +47 -0
- package/docs/publishers-guide.md +59 -4
- package/docs/resources-guide.md +184 -35
- package/docs/simple-server-api-design.md +72 -17
- package/docs/system-architecture.md +18 -14
- package/examples/controls/15) window, observable SSE/server.js +6 -1
- package/examples/controls/19) window, auto observable ui/server.js +9 -0
- package/examples/controls/20) window, task manager app/README.md +133 -0
- package/examples/controls/20) window, task manager app/client.js +797 -0
- package/examples/controls/20) window, task manager app/server.js +178 -0
- package/examples/controls/6) window, color_palette/client.js +165 -68
- package/examples/controls/9) window, date picker/client.js +362 -76
- package/examples/controls/9b) window, shared data.model mirrored date pickers/client.js +104 -83
- package/examples/jsgui3-html/06) theming/client.js +22 -1
- package/examples/jsgui3-html/10) binding-debugger/client.js +137 -1
- package/http/responders/static/Static_Route_HTTP_Responder.js +52 -34
- package/lab/experiments/capture-color-controls.js +196 -0
- package/lab/results/screenshots/color-controls/full_page.png +0 -0
- package/lab/results/screenshots/color-controls/section_1_color_grid_12x12.png +0 -0
- package/lab/results/screenshots/color-controls/section_2_color_grid_4x2.png +0 -0
- package/lab/results/screenshots/color-controls/section_3_color_palette.png +0 -0
- package/lab/results/screenshots/color-controls/section_4_palette_comparison.png +0 -0
- package/lab/results/screenshots/color-controls/section_5_raw_swatches.png +0 -0
- package/lab/results/screenshots/color-controls/section_6_optimized_crayola.png +0 -0
- package/lab/results/screenshots/color-controls/section_7_pastel_palette.png +0 -0
- package/lab/results/screenshots/color-controls/section_8_extended_144.png +0 -0
- package/lab/screenshot-utils.js +248 -0
- package/module.js +11 -4
- package/package.json +12 -2
- package/publishers/Publishers.js +4 -3
- package/publishers/helpers/assigners/static-compressed-response-buffers/Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner.js +5 -5
- package/publishers/http-sse-publisher.js +341 -0
- package/resources/process-resource.js +950 -0
- package/resources/processors/bundlers/js/esbuild/Advanced_JS_Bundler_Using_ESBuild.js +129 -33
- package/resources/processors/bundlers/js/esbuild/Core_JS_Non_Minifying_Bundler_Using_ESBuild.js +18 -7
- package/resources/processors/bundlers/js/esbuild/JSGUI3_HTML_Control_Optimizer.js +829 -0
- package/resources/remote-process-resource.js +355 -0
- package/resources/server-resource-pool.js +354 -41
- package/serve-factory.js +441 -259
- package/server.js +89 -13
- package/tests/README.md +66 -4
- package/tests/admin-ui-render.test.js +24 -0
- package/tests/assigners.test.js +56 -40
- package/tests/bundling-default-control-elimination.puppeteer.test.js +260 -0
- package/tests/configuration-validation.test.js +21 -18
- package/tests/content-analysis.test.js +7 -6
- package/tests/control-optimizer-cache-behavior.test.js +52 -0
- package/tests/control-scan-manifest-regression.test.js +144 -0
- package/tests/end-to-end.test.js +15 -14
- package/tests/error-handling.test.js +222 -179
- package/tests/fixtures/bundling-default-button-client.js +37 -0
- package/tests/fixtures/bundling-default-window-client.js +34 -0
- package/tests/fixtures/control_scan_manifest_expectations.json +48 -0
- package/tests/fixtures/resource-monitor-client.js +319 -0
- package/tests/helpers/puppeteer-e2e-harness.js +317 -0
- package/tests/http-sse-publisher.test.js +136 -0
- package/tests/performance.test.js +69 -65
- package/tests/process-resource.test.js +138 -0
- package/tests/publishers.test.js +7 -7
- package/tests/remote-process-resource.test.js +160 -0
- package/tests/sass-controls.e2e.test.js +7 -1
- package/tests/serve-resources.test.js +270 -0
- package/tests/serve.test.js +120 -50
- package/tests/server-resource-pool.test.js +106 -0
- package/tests/small-controls-bundle-size.test.js +252 -0
- package/tests/test-runner.js +13 -1
- package/tests/window-examples.puppeteer.test.js +204 -1
- package/tests/window-resource-integration.puppeteer.test.js +585 -0
- package/tests/temp_invalid.js +0 -7
- package/tests/temp_invalid_utf8.js +0 -1
- package/tests/temp_malformed.js +0 -10
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# 7. jsgui3-html Control and Mixin Pruning
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
|
|
5
|
+
Allow `jsgui3-html` to grow in feature breadth while keeping simple app bundles lightweight by pruning unused controls, mixins, and helper modules.
|
|
6
|
+
|
|
7
|
+
## Constraint Surface
|
|
8
|
+
|
|
9
|
+
`jsgui3-html` usage often includes:
|
|
10
|
+
|
|
11
|
+
- direct imports (`const {Window} = require('jsgui3-html').controls`)
|
|
12
|
+
- registry-style access (`jsgui.controls.some_control`)
|
|
13
|
+
- inheritance chains and mixin composition
|
|
14
|
+
|
|
15
|
+
Pruning must account for all three.
|
|
16
|
+
|
|
17
|
+
## Reachability Model
|
|
18
|
+
|
|
19
|
+
Build a typed symbol graph with nodes:
|
|
20
|
+
|
|
21
|
+
- controls
|
|
22
|
+
- mixins
|
|
23
|
+
- utility helpers
|
|
24
|
+
- transitive runtime support modules
|
|
25
|
+
|
|
26
|
+
Edges:
|
|
27
|
+
|
|
28
|
+
- static import/require edges
|
|
29
|
+
- inheritance edges
|
|
30
|
+
- mixin application edges
|
|
31
|
+
- registry publication edges
|
|
32
|
+
|
|
33
|
+
A module is retained if any retained symbol depends on it.
|
|
34
|
+
|
|
35
|
+
## Beyond Controls and Mixins
|
|
36
|
+
|
|
37
|
+
The same graph can prune additional payload classes:
|
|
38
|
+
|
|
39
|
+
- optional theme packs
|
|
40
|
+
- optional icon packs
|
|
41
|
+
- optional debug instrumentation
|
|
42
|
+
- optional adapter layers (for features not used by the app)
|
|
43
|
+
- feature-local helper modules that are only referenced by pruned controls
|
|
44
|
+
|
|
45
|
+
## Packaging Recommendation
|
|
46
|
+
|
|
47
|
+
Within `jsgui3-html`, define explicit boundaries:
|
|
48
|
+
|
|
49
|
+
- `core` (always lightweight baseline)
|
|
50
|
+
- optional feature groups (advanced controls, diagnostics, heavy widgets)
|
|
51
|
+
|
|
52
|
+
Then allow bundler elimination to prune unused optional groups based on symbol reachability.
|
|
53
|
+
|
|
54
|
+
## Dynamic-Access Safety
|
|
55
|
+
|
|
56
|
+
When dynamic registry access is detected and symbol resolution is uncertain:
|
|
57
|
+
|
|
58
|
+
- `safe` profile retains uncertain candidates
|
|
59
|
+
- manifest records reason as `dynamic_access_uncertain`
|
|
60
|
+
|
|
61
|
+
## Result
|
|
62
|
+
|
|
63
|
+
This produces consistent APIs while allowing bundle contents to shrink significantly for narrow use cases.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# 8. Test and Verification Methodology
|
|
2
|
+
|
|
3
|
+
## Verification Principle
|
|
4
|
+
|
|
5
|
+
Bundle-size optimization is valid only if behavioral equivalence is maintained for supported usage profiles.
|
|
6
|
+
|
|
7
|
+
## Test Layers
|
|
8
|
+
|
|
9
|
+
1. Unit tests for elimination graph logic
|
|
10
|
+
2. Integration tests for bundler output and route serving
|
|
11
|
+
3. E2E browser tests for real interaction flows (Puppeteer)
|
|
12
|
+
4. Size-regression tests with per-fixture budgets
|
|
13
|
+
|
|
14
|
+
## Bundle Correctness Tests
|
|
15
|
+
|
|
16
|
+
For each fixture app:
|
|
17
|
+
|
|
18
|
+
- generate baseline bundle (elimination disabled)
|
|
19
|
+
- generate optimized bundle (elimination enabled)
|
|
20
|
+
- compare runtime outcomes and key DOM/event traces
|
|
21
|
+
- compare bundle size deltas against expected thresholds
|
|
22
|
+
|
|
23
|
+
## Puppeteer Scenarios
|
|
24
|
+
|
|
25
|
+
For control-heavy examples:
|
|
26
|
+
|
|
27
|
+
- open page and wait for control activation markers
|
|
28
|
+
- perform high-specificity interactions (drag, resize, date pick, color pick, keyboard paths)
|
|
29
|
+
- assert expected UI state and emitted network/API behavior
|
|
30
|
+
|
|
31
|
+
For resource-integrated flows:
|
|
32
|
+
|
|
33
|
+
- verify client-visible state updates driven by server resources
|
|
34
|
+
- verify SSE/event paths where applicable
|
|
35
|
+
- confirm no missing-symbol/runtime errors caused by pruning
|
|
36
|
+
|
|
37
|
+
## Gating Policy
|
|
38
|
+
|
|
39
|
+
A prune policy cannot be promoted from experimental to default unless:
|
|
40
|
+
|
|
41
|
+
- all functional suites pass
|
|
42
|
+
- bundle manifest diff is stable and explainable
|
|
43
|
+
- size regression thresholds are met across representative fixtures.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# 9. Roadmap and Rollout
|
|
2
|
+
|
|
3
|
+
## Phase A: Baseline Instrumentation
|
|
4
|
+
|
|
5
|
+
- emit module graph manifest without pruning
|
|
6
|
+
- add CI artifact publishing for manifests
|
|
7
|
+
- add docs for reading retention reasons
|
|
8
|
+
|
|
9
|
+
Exit criteria:
|
|
10
|
+
- manifests generated for all target example fixtures
|
|
11
|
+
- no behavior changes
|
|
12
|
+
|
|
13
|
+
## Phase B: Safe Pruning Profile
|
|
14
|
+
|
|
15
|
+
- implement `safe` elimination profile
|
|
16
|
+
- prune only proven unreachable and side-effect-safe modules
|
|
17
|
+
- add fail-fast option for uncertain prune attempts
|
|
18
|
+
|
|
19
|
+
Exit criteria:
|
|
20
|
+
- full test suite green
|
|
21
|
+
- measurable JS size reductions on simple apps
|
|
22
|
+
- zero runtime regressions
|
|
23
|
+
|
|
24
|
+
## Phase C: jsgui3-html Symbol-Aware Pruning
|
|
25
|
+
|
|
26
|
+
- add control/mixin symbol graph pass
|
|
27
|
+
- integrate registry publication edge tracking
|
|
28
|
+
- support optional feature-group retention manifests
|
|
29
|
+
|
|
30
|
+
Exit criteria:
|
|
31
|
+
- significant size reductions for minimal-control apps
|
|
32
|
+
- controlled retention for dynamic access cases
|
|
33
|
+
|
|
34
|
+
## Phase D: Operational Hardening
|
|
35
|
+
|
|
36
|
+
- add deterministic chunk/hash strategy if route model evolves
|
|
37
|
+
- enforce size budgets in CI
|
|
38
|
+
- document migration path for package authors to declare side effects explicitly
|
|
39
|
+
|
|
40
|
+
## Non-Goal
|
|
41
|
+
|
|
42
|
+
Runtime hot-switching of elimination profiles is not required. Build-time consistency with predictable APIs is the target.
|
package/docs/books/jsgui3-bundling-research-book/10-further-research-strategies-and-upgrades.md
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# 10. Further Research: Strategies and Upgrades
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
This chapter extends the initial roadmap with additional strategies validated against current official tooling documentation. The goal is to improve both:
|
|
6
|
+
|
|
7
|
+
- elimination quality (more dead code removed safely)
|
|
8
|
+
- operational confidence (clear reason codes and controlled risk)
|
|
9
|
+
|
|
10
|
+
## A. Strengthen Existing Esbuild-Centric Strategy
|
|
11
|
+
|
|
12
|
+
### A1. Turn Build Metadata into First-Class Artifact
|
|
13
|
+
|
|
14
|
+
Current proposal already introduces a manifest. Upgrade it to include:
|
|
15
|
+
|
|
16
|
+
- esbuild `metafile` `inputs` and `outputs` mapping
|
|
17
|
+
- importer chains for each retained module
|
|
18
|
+
- side-effect reason code (`annotation`, `package_side_effects`, `plugin_side_effects`, `unknown`)
|
|
19
|
+
- unresolved dynamic-import reason code where relevant
|
|
20
|
+
|
|
21
|
+
Why: esbuild exposes a structured metadata graph and textual analysis hooks suitable for deterministic retention explanations.
|
|
22
|
+
|
|
23
|
+
### A2. Add Plugin-Level Side-Effect Overrides (Safe Allowlist Only)
|
|
24
|
+
|
|
25
|
+
Esbuild plugin `onResolve` supports returning `sideEffects: false`. Use this only through a strict allowlist generated from audited modules, never broad regex defaults.
|
|
26
|
+
|
|
27
|
+
Why: this provides precision beyond package-level `sideEffects` fields and enables selective pruning of known-safe internal modules.
|
|
28
|
+
|
|
29
|
+
### A3. Improve Annotation Fault Tolerance
|
|
30
|
+
|
|
31
|
+
Support an explicit fallback mode for bad third-party annotations:
|
|
32
|
+
|
|
33
|
+
- default: respect annotations (`/* @__PURE__ */`, `package.json sideEffects`)
|
|
34
|
+
- safe fallback: set `ignoreAnnotations: true` for known-problem dependency subsets
|
|
35
|
+
|
|
36
|
+
Why: esbuild documents annotation misuse as a real breakage source; controlled fallback prevents production outages.
|
|
37
|
+
|
|
38
|
+
### A4. Prefer ESM Paths Where Safe
|
|
39
|
+
|
|
40
|
+
For packages that expose both CommonJS and ESM, prefer ESM paths where validated to improve tree shaking.
|
|
41
|
+
|
|
42
|
+
Why: esbuild explicitly notes tree shaking depends on ESM `import`/`export` and does not work on CommonJS modules the same way.
|
|
43
|
+
|
|
44
|
+
## B. Add Multi-Chunk Strategy (Not Just Single /js/js.js)
|
|
45
|
+
|
|
46
|
+
### B1. Optional ESM Split Build Profile
|
|
47
|
+
|
|
48
|
+
Add an optional bundler profile that emits ESM with splitting enabled (`format: 'esm'`, `splitting: true`) and chunk names with content hashes.
|
|
49
|
+
|
|
50
|
+
Use for:
|
|
51
|
+
|
|
52
|
+
- multi-page apps
|
|
53
|
+
- heavy optional controls loaded by `import()`
|
|
54
|
+
|
|
55
|
+
Do not force this profile for simple examples where a single file remains desirable.
|
|
56
|
+
|
|
57
|
+
### B2. Route and HTML Preparation Upgrade
|
|
58
|
+
|
|
59
|
+
Current static route assigner assumes one JS and one CSS file. Add a preparer mode that:
|
|
60
|
+
|
|
61
|
+
- maps every emitted JS/CSS asset to static routes
|
|
62
|
+
- injects `<script type="module">` plus chunk graph references where required
|
|
63
|
+
- supports content-hash file names for cache correctness
|
|
64
|
+
|
|
65
|
+
## C. Use Safety Ladder from Rollup Research as Policy Design Input
|
|
66
|
+
|
|
67
|
+
Even if the implementation remains esbuild-first, Rollup's treeshake policy surface is a useful design model:
|
|
68
|
+
|
|
69
|
+
- `safest`
|
|
70
|
+
- `recommended`
|
|
71
|
+
- `smallest`
|
|
72
|
+
|
|
73
|
+
Adopt equivalent policy semantics in `jsgui3-server` elimination config:
|
|
74
|
+
|
|
75
|
+
- `safe` (strict side-effect conservatism)
|
|
76
|
+
- `balanced` (some side-effect assumptions)
|
|
77
|
+
- `aggressive` (max pruning, stronger contracts)
|
|
78
|
+
|
|
79
|
+
Include explicit controls for assumptions analogous to:
|
|
80
|
+
|
|
81
|
+
- module side effects
|
|
82
|
+
- property-read side effects
|
|
83
|
+
- try/catch deoptimization behavior
|
|
84
|
+
- manually pure function sets
|
|
85
|
+
|
|
86
|
+
## D. Package Boundary Strategy for jsgui3-html
|
|
87
|
+
|
|
88
|
+
### D1. Subpath Exports for Feature Addressability
|
|
89
|
+
|
|
90
|
+
Restructure `jsgui3-html` package exports so controls and mixins have stable subpath entry points (for example, `./controls/date_picker.js`, `./mixins/draggable.js`, `./core/...`).
|
|
91
|
+
|
|
92
|
+
Why: Node package `exports` and subpath exports give explicit package contracts and allow bundlers to consume narrow entry points instead of broad index hubs.
|
|
93
|
+
|
|
94
|
+
### D2. Core vs Optional Feature Groups
|
|
95
|
+
|
|
96
|
+
Define package layers:
|
|
97
|
+
|
|
98
|
+
- `core` minimal runtime
|
|
99
|
+
- optional groups (`advanced-controls`, `diagnostics`, `themes`, etc.)
|
|
100
|
+
|
|
101
|
+
Then bind elimination policies to these boundaries for predictable pruning.
|
|
102
|
+
|
|
103
|
+
### D3. Internal Imports Field for Maintainability
|
|
104
|
+
|
|
105
|
+
Use package `imports` (private `#...` aliases) inside `jsgui3-html` to stabilize internal paths while allowing refactors that do not leak into public imports.
|
|
106
|
+
|
|
107
|
+
## E. Compression and Minification Escalation Path
|
|
108
|
+
|
|
109
|
+
### E1. Keep Esbuild as Default Minifier
|
|
110
|
+
|
|
111
|
+
Esbuild is very fast and adequate for most builds.
|
|
112
|
+
|
|
113
|
+
### E2. Optional High-Compression Pass
|
|
114
|
+
|
|
115
|
+
For release artifacts that need additional byte reduction, provide an optional second minification pass profile (e.g., Terser pure-function tuning). Keep this opt-in due to risk/perf tradeoffs.
|
|
116
|
+
|
|
117
|
+
### E3. Experimental Extreme Profile
|
|
118
|
+
|
|
119
|
+
Document (not default) an experimental path for Closure Compiler `ADVANCED_OPTIMIZATIONS` for controlled targets only, with strict compatibility guardrails.
|
|
120
|
+
|
|
121
|
+
## F. Coverage-Guided Optimization (Puppeteer + CDP)
|
|
122
|
+
|
|
123
|
+
### F1. Coverage Collection Pipeline
|
|
124
|
+
|
|
125
|
+
Use Puppeteer coverage APIs in E2E suites:
|
|
126
|
+
|
|
127
|
+
- `page.coverage.startJSCoverage(...)`
|
|
128
|
+
- `page.coverage.startCSSCoverage(...)`
|
|
129
|
+
- stop coverage and persist per-script ranges
|
|
130
|
+
|
|
131
|
+
Enable block-level coverage for high resolution.
|
|
132
|
+
|
|
133
|
+
### F2. Precise CDP Coverage for Deep Diagnostics
|
|
134
|
+
|
|
135
|
+
For targeted diagnostics, integrate CDP Profiler precise coverage APIs (`startPreciseCoverage`, `takePreciseCoverage`) in controlled runs.
|
|
136
|
+
|
|
137
|
+
### F3. Correct Interpretation Rule
|
|
138
|
+
|
|
139
|
+
Coverage is advisory, not authoritative:
|
|
140
|
+
|
|
141
|
+
- never auto-prune solely from observed runtime coverage
|
|
142
|
+
- use coverage to identify candidates for lazy loading or refactor, then validate with static safety rules
|
|
143
|
+
|
|
144
|
+
## G. Concrete Upgrades to Existing jsgui3-server Plan
|
|
145
|
+
|
|
146
|
+
### G1. New Config Surface (Proposed)
|
|
147
|
+
|
|
148
|
+
```js
|
|
149
|
+
bundler: {
|
|
150
|
+
elimination: {
|
|
151
|
+
enabled: true,
|
|
152
|
+
profile: 'safe', // safe | balanced | aggressive
|
|
153
|
+
emit_manifest: true,
|
|
154
|
+
include_importer_chains: true,
|
|
155
|
+
fail_on_uncertain_prune: true,
|
|
156
|
+
plugin_side_effect_overrides: {
|
|
157
|
+
allowlist: []
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
chunking: {
|
|
161
|
+
profile: 'single', // single | esm_split
|
|
162
|
+
chunk_names: 'chunks/[name]-[hash]'
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### G2. Manifest Enrichment (Proposed)
|
|
168
|
+
|
|
169
|
+
Add fields:
|
|
170
|
+
|
|
171
|
+
- `retained_reason_code`
|
|
172
|
+
- `side_effect_source`
|
|
173
|
+
- `importer_chain`
|
|
174
|
+
- `dynamic_access_risk`
|
|
175
|
+
- `runtime_coverage_seen` (optional diagnostic field)
|
|
176
|
+
|
|
177
|
+
### G3. Test Expansion
|
|
178
|
+
|
|
179
|
+
- policy conformance tests per profile (`safe`, `balanced`, `aggressive`)
|
|
180
|
+
- split profile routing/injection tests
|
|
181
|
+
- manifest stability snapshots
|
|
182
|
+
- Puppeteer coverage capture and diff reporting
|
|
183
|
+
|
|
184
|
+
## H. Prioritized Execution Order
|
|
185
|
+
|
|
186
|
+
1. Implement manifest enrichment on top of current esbuild flow.
|
|
187
|
+
2. Add safe plugin-side-effect allowlist mechanism.
|
|
188
|
+
3. Add ESM split profile behind feature flag.
|
|
189
|
+
4. Add package-boundary changes in `jsgui3-html` (`exports`/subpaths/core layering).
|
|
190
|
+
5. Add optional secondary minifier profile.
|
|
191
|
+
6. Integrate coverage-guided diagnostics into CI reports.
|
|
192
|
+
|
|
193
|
+
## Source Notes
|
|
194
|
+
|
|
195
|
+
External strategies in this chapter are based on current official docs for esbuild, Rollup, webpack, Node package exports/imports, Puppeteer coverage APIs, and Chrome DevTools Protocol coverage APIs.
|
|
196
|
+
|
|
197
|
+
Primary references:
|
|
198
|
+
|
|
199
|
+
- https://esbuild.github.io/api/
|
|
200
|
+
- https://esbuild.github.io/plugins/
|
|
201
|
+
- https://rollupjs.org/configuration-options/
|
|
202
|
+
- https://webpack.js.org/guides/tree-shaking/
|
|
203
|
+
- https://webpack.js.org/plugins/split-chunks-plugin/
|
|
204
|
+
- https://nodejs.org/api/packages.html
|
|
205
|
+
- https://babeljs.io/docs/babel-plugin-transform-modules-commonjs
|
|
206
|
+
- https://terser.org/docs/options/#compress-options
|
|
207
|
+
- https://developers.google.com/closure/compiler/docs/compilation_levels
|
|
208
|
+
- https://developers.google.com/closure/compiler/docs/api-tutorial3
|
|
209
|
+
- https://pptr.dev/api/puppeteer.coverage.startjscoverage
|
|
210
|
+
- https://pptr.dev/api/puppeteer.coverage.startcsscoverage
|
|
211
|
+
- https://chromedevtools.github.io/devtools-protocol/tot/Profiler/#method-startPreciseCoverage
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# JSGUI3 Bundling Research Book
|
|
2
|
+
|
|
3
|
+
This book documents how JS and CSS bundling currently works in `jsgui3-server`, then defines a practical path to remove unused modules, controls, mixins, and related code from final bundles without breaking runtime behavior.
|
|
4
|
+
|
|
5
|
+
## Scope
|
|
6
|
+
|
|
7
|
+
- Current runtime bundling semantics (implementation-first, file-path grounded)
|
|
8
|
+
- Existing optimization surface and current limits
|
|
9
|
+
- Dead-module elimination strategy for application code and `jsgui3-html`
|
|
10
|
+
- Control/mixin reachability and pruning model
|
|
11
|
+
- Verification strategy (unit, integration, e2e, and size-regression)
|
|
12
|
+
|
|
13
|
+
## Intended Readers
|
|
14
|
+
|
|
15
|
+
- Maintainers changing bundling internals
|
|
16
|
+
- Contributors adding controls or mixins to `jsgui3-html`
|
|
17
|
+
- Agents implementing bundle-size reduction work
|
|
18
|
+
|
|
19
|
+
## Reading Order
|
|
20
|
+
|
|
21
|
+
1. [00 Table of Contents](00-table-of-contents.md)
|
|
22
|
+
2. [01 Pipeline and Runtime Semantics](01-pipeline-and-runtime-semantics.md)
|
|
23
|
+
3. [02 JavaScript Bundling Core](02-javascript-bundling-core.md)
|
|
24
|
+
4. [03 Style Extraction and CSS Compilation](03-style-extraction-and-css-compilation.md)
|
|
25
|
+
5. [04 Static Publishing and Delivery](04-static-publishing-and-delivery.md)
|
|
26
|
+
6. [05 Current Limits and Size-Bloat Vectors](05-current-limits-and-size-bloat-vectors.md)
|
|
27
|
+
7. [06 Unused Module Elimination Strategy](06-unused-module-elimination-strategy.md)
|
|
28
|
+
8. [07 jsgui3-html Control and Mixin Pruning](07-jsgui3-html-control-and-mixin-pruning.md)
|
|
29
|
+
9. [08 Test and Verification Methodology](08-test-and-verification-methodology.md)
|
|
30
|
+
10. [09 Roadmap and Rollout](09-roadmap-and-rollout.md)
|
|
31
|
+
11. [10 Further Research: Strategies and Upgrades](10-further-research-strategies-and-upgrades.md)
|
|
32
|
+
|
|
33
|
+
## Status
|
|
34
|
+
|
|
35
|
+
This is a working research book. It is designed to be updated as the bundling system evolves.
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
# Bundling System Deep Dive
|
|
2
|
-
|
|
3
|
-
##
|
|
1
|
+
# Bundling System Deep Dive
|
|
2
|
+
|
|
3
|
+
## Research Track
|
|
4
|
+
|
|
5
|
+
For the active, chaptered research track on lightweight bundle strategy and unused-module elimination, use:
|
|
6
|
+
`docs/books/jsgui3-bundling-research-book/README.md`
|
|
7
|
+
|
|
8
|
+
## When to Read
|
|
4
9
|
|
|
5
10
|
This document provides detailed technical documentation of JSGUI3 Server's bundling system. Read this when:
|
|
6
11
|
- You need to understand how JavaScript and CSS bundling works internally
|
|
@@ -522,4 +527,4 @@ Key takeaways:
|
|
|
522
527
|
- **Debugging**: Use debug mode and logging for troubleshooting
|
|
523
528
|
- **Performance**: Fast for development, optimizable for production
|
|
524
529
|
|
|
525
|
-
For issues not covered here, check the [troubleshooting guide](docs/troubleshooting.md) or create an issue in the repository.
|
|
530
|
+
For issues not covered here, check the [troubleshooting guide](docs/troubleshooting.md) or create an issue in the repository.
|
|
@@ -15,7 +15,7 @@ This document provides detailed technical documentation for the JSGUI3 Server fr
|
|
|
15
15
|
- You're troubleshooting complex issues or performance problems
|
|
16
16
|
- You need to understand deployment, security, and production considerations
|
|
17
17
|
|
|
18
|
-
**Note:** Start with [README.md](../README.md) for project overview and basic usage. For server API design principles, see [docs/simple-server-api-design.md](docs/simple-server-api-design.md).
|
|
18
|
+
**Note:** Start with [README.md](../README.md) for project overview and basic usage. For server API design principles, see [docs/simple-server-api-design.md](docs/simple-server-api-design.md). For bundling internals and elimination strategy research, see [docs/books/jsgui3-bundling-research-book/README.md](docs/books/jsgui3-bundling-research-book/README.md).
|
|
19
19
|
|
|
20
20
|
# JSGUI3 Server - Comprehensive Documentation
|
|
21
21
|
|
|
@@ -118,8 +118,9 @@ This section is a short, task-oriented runway for AI agents that need to act qui
|
|
|
118
118
|
**Start here:**
|
|
119
119
|
1. Identify the target subsystem: examples, bundlers, publishers, or controls.
|
|
120
120
|
2. Jump to the focused guide: `docs/books/jsgui3-mvvm-fullstack/README.md`.
|
|
121
|
-
3.
|
|
122
|
-
4.
|
|
121
|
+
3. For bundle-size and pruning work, use: `docs/books/jsgui3-bundling-research-book/README.md`.
|
|
122
|
+
4. Make the smallest change that can pass a targeted test.
|
|
123
|
+
5. Run the narrow test file first, then widen if needed.
|
|
123
124
|
|
|
124
125
|
**Minimal commands:**
|
|
125
126
|
```bash
|
|
@@ -489,14 +490,16 @@ Main entry point for starting the server.
|
|
|
489
490
|
**Parameters:**
|
|
490
491
|
- `options` (object): Server configuration object
|
|
491
492
|
|
|
492
|
-
**Options:**
|
|
493
|
-
- `ctrl` or `Ctrl`: Main control class constructor
|
|
494
|
-
- `pages`: Object defining multiple pages with routes as keys
|
|
495
|
-
- `api`: Object defining API endpoints
|
|
496
|
-
- `
|
|
497
|
-
- `
|
|
498
|
-
- `
|
|
499
|
-
- `
|
|
493
|
+
**Options:**
|
|
494
|
+
- `ctrl` or `Ctrl`: Main control class constructor
|
|
495
|
+
- `pages`: Object defining multiple pages with routes as keys
|
|
496
|
+
- `api`: Object defining API endpoints
|
|
497
|
+
- `resources`: Object/array of managed resource definitions
|
|
498
|
+
- `events`: Enable/configure built-in SSE endpoint for resource lifecycle events
|
|
499
|
+
- `src_path_client_js`: Path to client-side JavaScript file
|
|
500
|
+
- `port`: Server port (default: 8080)
|
|
501
|
+
- `host`: Server host (default: all IPv4 interfaces)
|
|
502
|
+
- `debug`: Enable debug mode (default: false)
|
|
500
503
|
|
|
501
504
|
**Returns:** Promise that resolves to the server instance
|
|
502
505
|
|
|
@@ -527,17 +530,45 @@ const server = await Server.serve({
|
|
|
527
530
|
port: 3000
|
|
528
531
|
});
|
|
529
532
|
|
|
530
|
-
// With API endpoints
|
|
531
|
-
const server = await Server.serve({
|
|
532
|
-
ctrl: DashboardControl,
|
|
533
|
+
// With API endpoints
|
|
534
|
+
const server = await Server.serve({
|
|
535
|
+
ctrl: DashboardControl,
|
|
533
536
|
src_path_client_js: require.resolve('./client.js'),
|
|
534
537
|
api: {
|
|
535
538
|
'status': () => ({ uptime: process.uptime() }),
|
|
536
539
|
'users': async () => await getUsers()
|
|
537
|
-
},
|
|
538
|
-
port: 3000
|
|
539
|
-
});
|
|
540
|
-
|
|
540
|
+
},
|
|
541
|
+
port: 3000
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
// With managed resources and SSE lifecycle events
|
|
545
|
+
let server_with_resources;
|
|
546
|
+
server_with_resources = await Server.serve({
|
|
547
|
+
api: {
|
|
548
|
+
'resources/summary': () => server_with_resources.resource_pool.summary
|
|
549
|
+
},
|
|
550
|
+
resources: {
|
|
551
|
+
worker_direct: {
|
|
552
|
+
type: 'process',
|
|
553
|
+
command: process.execPath,
|
|
554
|
+
args: ['worker.js'],
|
|
555
|
+
autoRestart: true
|
|
556
|
+
},
|
|
557
|
+
worker_pm2: {
|
|
558
|
+
type: 'process',
|
|
559
|
+
processManager: { type: 'pm2' }, // pm2Path optional
|
|
560
|
+
command: process.execPath,
|
|
561
|
+
args: ['worker.js']
|
|
562
|
+
},
|
|
563
|
+
remote_worker: {
|
|
564
|
+
type: 'remote',
|
|
565
|
+
host: '127.0.0.1',
|
|
566
|
+
port: 3400
|
|
567
|
+
}
|
|
568
|
+
},
|
|
569
|
+
events: true // creates /events and forwards resource lifecycle events
|
|
570
|
+
});
|
|
571
|
+
```
|
|
541
572
|
|
|
542
573
|
### Publishers API
|
|
543
574
|
|