bimba-cli 0.5.0 → 0.5.1

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 CHANGED
@@ -40,6 +40,18 @@ bunx bimba src/index.imba --serve --port 5200 --html public/index.html
40
40
  - Injects an importmap built from your `package.json` dependencies
41
41
  - Injects an HMR client that swaps component prototypes without a full page reload
42
42
 
43
+ **HMR internals:**
44
+
45
+ When a file changes, the server recompiles it and sends an `update` message over WebSocket. The browser re-imports the module with a fresh `?t=` cache-bust query.
46
+
47
+ Since Imba custom elements can't be registered twice (`customElements.define` throws on duplicates), bimba intercepts all `define` calls. On first load the class is registered normally and stored in a map. On hot reload, instead of registering again, bimba copies all methods and static properties from the new class onto the original class prototype — so existing element instances in the DOM immediately get the new `render()` and other methods without losing their state (`el.active`, `el.count`, etc.).
48
+
49
+ After patching, bimba clears each element's Imba render cache (anonymous `Symbol` keys pointing to DOM nodes) and sets `innerHTML = ''`, so the new render method starts from a clean slate. Then `imba.commit()` triggers a re-render of all mounted components.
50
+
51
+ CSS is handled automatically: Imba's runtime calls `imba_styles.register()` during module execution, which updates the `<style>` tag in place — no extra DOM work needed.
52
+
53
+ Duplicate root elements (caused by `imba.mount()` running again on re-import) are removed by a dedup pass over `document.body.children` before any other HMR logic runs.
54
+
43
55
  **HTML setup:** add a `data-entrypoint` attribute to the script tag that loads your bundle. The dev server will replace it with your `.imba` entrypoint and inject the importmap above it:
44
56
 
45
57
  ```html
@@ -54,10 +66,6 @@ bunx bimba src/index.imba --serve --port 5200 --html public/index.html
54
66
 
55
67
  `--html <path>` — path to your HTML file (auto-detected from `./index.html`, `./public/index.html`, `./src/index.html` if omitted)
56
68
 
57
- `--hmr-mode <css|full>` — HMR mode (default: `css`)
58
- - `css` — CSS-only hot reload (injects styles instantly, full reload on JS changes)
59
- - `full` — full HMR with element swapping (prototype replacement, no page reload)
60
-
61
69
  Static files are resolved relative to the HTML file's directory first, then from the project root (for `node_modules`, `src`, etc.).
62
70
 
63
71
  ---
@@ -95,7 +103,3 @@ bunx bimba src/index.imba --outdir public/js --watch --clearcache
95
103
  `--port <number>` — port for the dev server (default: `5200`). Used with `--serve`.
96
104
 
97
105
  `--html <path>` — custom HTML file path. Used with `--serve`.
98
-
99
- `--hmr-mode <css|full>` — HMR mode for dev server (default: `css`)
100
- - `css` — CSS-only hot reload (injects styles instantly without reload, triggers full reload only when JS changes)
101
- - `full` — full HMR with element swapping (swaps component prototypes, no page reload at all)
package/index.js CHANGED
@@ -27,7 +27,6 @@ try {
27
27
  serve: { type: 'boolean' },
28
28
  port: { type: 'string' },
29
29
  html: { type: 'string' },
30
- hmrmode: { type: 'string' },
31
30
  },
32
31
  strict: true,
33
32
  allowPositionals: true,
@@ -55,14 +54,6 @@ if (!fs.existsSync(bunfigPath)) {
55
54
  }
56
55
  }
57
56
 
58
- // Validate hmr-mode flag
59
- if (flags.hmrmode && !['css', 'full'].includes(flags.hmrmode)) {
60
- console.log("");
61
- console.log(theme.failure("Invalid value for --hmr-mode. Use 'css' (default) or 'full'."));
62
- console.log("");
63
- process.exit(0);
64
- }
65
-
66
57
  // help: more on bun building params here: https://bun.sh/docs/bundler
67
58
  if(flags.help) {
68
59
  console.log("");
@@ -80,7 +71,6 @@ if(flags.help) {
80
71
  console.log(" "+theme.flags('--serve')+" Start dev server with Hot Module Replacement");
81
72
  console.log(" "+theme.flags('--port <number>')+" Port for the dev server (default: 5200)");
82
73
  console.log(" "+theme.flags('--html <path>')+" Custom HTML file path (auto-detected if omitted)");
83
- console.log(" "+theme.flags('--hmr-mode <css|full>')+" HMR mode: 'css' = CSS-only reload (default), 'full' = element swap");
84
74
  console.log("");
85
75
  process.exit(0);
86
76
  }
@@ -96,7 +86,7 @@ if (flags.serve) {
96
86
  console.log("");
97
87
  process.exit(1);
98
88
  }
99
- serve(entrypoint, { port: parseInt(flags.port) || 5200, html: flags.html, hmrMode: flags.hmrmode || 'css' });
89
+ serve(entrypoint, { port: parseInt(flags.port) || 5200, html: flags.html });
100
90
  }
101
91
  // no entrypoint or outdir
102
92
  else if(!entrypoint || !flags.outdir) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bimba-cli",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/HeapVoid/bimba.git"