solid-tag-runtime 0.0.12 → 0.0.13
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/ARCHITECTURE.md +147 -37
- package/README.md +76 -899
- package/docs/README.md +23 -0
- package/docs/api/compile-cache.md +103 -0
- package/docs/api/html.md +83 -0
- package/docs/api/runtime.md +87 -0
- package/docs/compile-cache.md +271 -0
- package/docs/getting-started.md +105 -0
- package/docs/html-runtime.md +112 -0
- package/docs/lifecycle-events.md +77 -0
- package/docs/modules.md +93 -0
- package/docs/rendering.md +65 -0
- package/docs/solid-render.md +111 -0
- package/examples/basic.js +41 -0
- package/examples/compile-cache.js +35 -0
- package/examples/main.tsx +318 -0
- package/examples/render.html +79 -0
- package/index.d.ts +183 -27
- package/package.json +5 -3
- package/src/compile-cache.js +340 -0
- package/src/compiler.js +86 -38
- package/src/index.js +6 -0
- package/src/runtime.js +656 -74
package/README.md
CHANGED
|
@@ -1,45 +1,34 @@
|
|
|
1
1
|
# solid-tag-runtime
|
|
2
2
|
|
|
3
|
-
`solid-tag-runtime` is a
|
|
4
|
-
|
|
5
|
-
It builds on [`solid-tag`](https://www.npmjs.com/package/solid-tag):
|
|
3
|
+
`solid-tag-runtime` is a runtime module system for dynamically defined Solid JSX and JavaScript modules.
|
|
6
4
|
|
|
7
5
|
```text
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
solid-tag
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
solid-tag-runtime
|
|
15
|
-
|
|
16
|
-
@solidjs/html +
|
|
6
|
+
source module
|
|
7
|
+
↓
|
|
8
|
+
solid-tag compiler
|
|
9
|
+
↓
|
|
10
|
+
pre-link compiled artifact
|
|
11
|
+
↓
|
|
12
|
+
solid-tag-runtime linker
|
|
13
|
+
↓
|
|
14
|
+
@solidjs/html + host Solid runtime
|
|
17
15
|
```
|
|
18
16
|
|
|
19
|
-
The package is
|
|
17
|
+
The core package is module-first and DOM-independent. Browser discovery, ownership, declarative rendering, and `<solid-render>` live in the `solid-tag-runtime/html` adapter.
|
|
20
18
|
|
|
21
|
-
##
|
|
19
|
+
## Install
|
|
22
20
|
|
|
23
21
|
```bash
|
|
24
22
|
npm install solid-tag-runtime solid-tag
|
|
25
23
|
```
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
## Create a runtime
|
|
30
|
-
|
|
31
|
-
```ts
|
|
32
|
-
import { createRuntime } from "solid-tag-runtime";
|
|
33
|
-
|
|
34
|
-
const runtime = createRuntime();
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
For a real Solid application, register the host runtime:
|
|
25
|
+
## Quick start
|
|
38
26
|
|
|
39
27
|
```ts
|
|
40
28
|
import * as Solid from "solid-js";
|
|
41
29
|
import * as SolidWeb from "@solidjs/web";
|
|
42
30
|
import html from "@solidjs/html";
|
|
31
|
+
import { createRuntime } from "solid-tag-runtime";
|
|
43
32
|
|
|
44
33
|
const runtime = createRuntime({
|
|
45
34
|
modules: {
|
|
@@ -48,121 +37,31 @@ const runtime = createRuntime({
|
|
|
48
37
|
"@solidjs/html": { default: html },
|
|
49
38
|
},
|
|
50
39
|
});
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
This is important: dynamic modules now use the **same** `solid-js`, `@solidjs/web`, and `@solidjs/html` instances as the host application.
|
|
54
|
-
|
|
55
|
-
## Define and import runtime modules
|
|
56
|
-
|
|
57
|
-
```ts
|
|
58
|
-
runtime.define(
|
|
59
|
-
"/ui/Button.jsx",
|
|
60
|
-
`
|
|
61
|
-
export function Button(props) {
|
|
62
|
-
return (
|
|
63
|
-
<button onClick={props.onClick}>
|
|
64
|
-
{props.children}
|
|
65
|
-
</button>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
`,
|
|
69
|
-
);
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
A second module can import the first one normally:
|
|
73
|
-
|
|
74
|
-
```ts
|
|
75
|
-
runtime.define(
|
|
76
|
-
"/features/Counter.jsx",
|
|
77
|
-
`
|
|
78
|
-
import { createSignal } from "solid-js";
|
|
79
|
-
import { Button } from "../ui/Button.jsx";
|
|
80
|
-
|
|
81
|
-
export function Counter() {
|
|
82
|
-
const [count, setCount] = createSignal(0);
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<Button onClick={() => setCount(value => value + 1)}>
|
|
86
|
-
Count: {count()}
|
|
87
|
-
</Button>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
`,
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
const counterModule = await runtime.import("/features/Counter.jsx");
|
|
94
|
-
|
|
95
|
-
counterModule.Counter;
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
The runtime compiles and links the dependency graph automatically.
|
|
99
40
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
`solid-tag-runtime/html` is the browser/DOM adapter. The core runtime remains DOM-independent.
|
|
104
|
-
|
|
105
|
-
Browser import maps must map the subpath explicitly as well as the package root:
|
|
106
|
-
|
|
107
|
-
```json
|
|
108
|
-
{
|
|
109
|
-
"imports": {
|
|
110
|
-
"solid-tag-runtime": "https://esm.sh/solid-tag-runtime@0.0.12",
|
|
111
|
-
"solid-tag-runtime/html": "https://esm.sh/solid-tag-runtime@0.0.12/html"
|
|
41
|
+
runtime.define("/Greeting.jsx", `
|
|
42
|
+
export default function Greeting() {
|
|
43
|
+
return <p>Hello from runtime JSX</p>;
|
|
112
44
|
}
|
|
113
|
-
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
For simple single-runtime use, the original helpers remain available:
|
|
117
|
-
|
|
118
|
-
```ts
|
|
119
|
-
import {
|
|
120
|
-
registerHTML,
|
|
121
|
-
observeHTML,
|
|
122
|
-
} from "solid-tag-runtime/html";
|
|
45
|
+
`);
|
|
123
46
|
|
|
124
|
-
await
|
|
47
|
+
const module = await runtime.import("/Greeting.jsx");
|
|
48
|
+
module.default;
|
|
125
49
|
```
|
|
126
50
|
|
|
127
|
-
|
|
51
|
+
## Declarative browser modules
|
|
128
52
|
|
|
129
53
|
```ts
|
|
130
54
|
import { createHTMLRuntime } from "solid-tag-runtime/html";
|
|
131
55
|
|
|
132
|
-
const
|
|
56
|
+
const htmlRuntime = createHTMLRuntime(runtime, {
|
|
133
57
|
scope: "main",
|
|
134
58
|
root: document,
|
|
135
59
|
});
|
|
136
60
|
|
|
137
|
-
await
|
|
138
|
-
await html.observe({ registerExisting: false });
|
|
61
|
+
await htmlRuntime.register();
|
|
139
62
|
```
|
|
140
63
|
|
|
141
|
-
|
|
142
|
-
## Render runtime UI
|
|
143
|
-
|
|
144
|
-
`solid-tag-runtime/html` can now mount component exports as an HTML-adapter concern while the core runtime remains DOM-independent.
|
|
145
|
-
|
|
146
|
-
There are two complementary forms:
|
|
147
|
-
|
|
148
|
-
```text
|
|
149
|
-
<script module>
|
|
150
|
-
define a runtime module
|
|
151
|
-
|
|
152
|
-
<script module render>
|
|
153
|
-
define a module + mount one instance
|
|
154
|
-
|
|
155
|
-
<solid-render module>
|
|
156
|
-
reference an existing module + mount one instance
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
### Define and render in one declaration
|
|
160
|
-
|
|
161
|
-
Render the default export into a normal Solid container:
|
|
162
|
-
|
|
163
64
|
```html
|
|
164
|
-
<div id="app"></div>
|
|
165
|
-
|
|
166
65
|
<script
|
|
167
66
|
type="solid-jsx"
|
|
168
67
|
data-solid-runtime="main"
|
|
@@ -170,824 +69,102 @@ Render the default export into a normal Solid container:
|
|
|
170
69
|
render="#app"
|
|
171
70
|
>
|
|
172
71
|
export default function App() {
|
|
173
|
-
return <h1>Hello
|
|
174
|
-
}
|
|
175
|
-
</script>
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
`render` defaults to `module.default`. Select a named export with `component`:
|
|
179
|
-
|
|
180
|
-
```html
|
|
181
|
-
<script
|
|
182
|
-
type="solid-jsx"
|
|
183
|
-
module="/widgets.jsx"
|
|
184
|
-
render="#app"
|
|
185
|
-
component="Counter"
|
|
186
|
-
>
|
|
187
|
-
export function Counter() {
|
|
188
|
-
return <button>Counter</button>;
|
|
72
|
+
return <h1>Hello</h1>;
|
|
189
73
|
}
|
|
190
74
|
</script>
|
|
191
75
|
```
|
|
192
76
|
|
|
193
|
-
Bare `render` mounts
|
|
77
|
+
Bare `render` mounts in place without adding a wrapper:
|
|
194
78
|
|
|
195
79
|
```html
|
|
196
|
-
<p>Before</p>
|
|
197
|
-
|
|
198
80
|
<script type="solid-jsx" module="/Message.jsx" render>
|
|
199
81
|
export default function Message() {
|
|
200
82
|
return <strong>Hello</strong>;
|
|
201
83
|
}
|
|
202
84
|
</script>
|
|
203
|
-
|
|
204
|
-
<p>After</p>
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
The adapter replaces the declaration with an owned start/end marker range and inserts the component between the markers. The module definition and mount lifecycle remain separate: removing the declaration through `html.removeElement()` disposes the Solid owner while module removal follows the existing lifecycle options.
|
|
208
|
-
|
|
209
|
-
`entry` and `render` are intentionally mutually exclusive on one declaration. Use separate declarations when a side-effect entry and a mounted component are both needed.
|
|
210
|
-
|
|
211
|
-
All matching modules in one scan/observer batch are defined before any `entry` or `render` action executes, so a render declaration may import a dependency declared later in the same batch.
|
|
212
|
-
|
|
213
|
-
### Reuse an existing module with `<solid-render>`
|
|
214
|
-
|
|
215
|
-
`<solid-render>` references an already-defined module and remains as the light-DOM mount container:
|
|
216
|
-
|
|
217
|
-
```html
|
|
218
|
-
<solid-render
|
|
219
|
-
data-solid-runtime="main"
|
|
220
|
-
module="/Counter.jsx"
|
|
221
|
-
></solid-render>
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
Named export:
|
|
225
|
-
|
|
226
|
-
```html
|
|
227
|
-
<solid-render
|
|
228
|
-
data-solid-runtime="main"
|
|
229
|
-
module="/widgets.jsx"
|
|
230
|
-
component="Counter"
|
|
231
|
-
></solid-render>
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
Component props use an explicit namespace so renderer configuration can never collide with component prop names:
|
|
235
|
-
|
|
236
|
-
```html
|
|
237
|
-
<solid-render
|
|
238
|
-
module="/UserCard.jsx"
|
|
239
|
-
prop:name="Alice"
|
|
240
|
-
prop:module="billing"
|
|
241
|
-
prop:compact
|
|
242
|
-
></solid-render>
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
Declarative values are conservative:
|
|
246
|
-
|
|
247
|
-
```text
|
|
248
|
-
prop:name="Alice" → "Alice"
|
|
249
|
-
prop:compact → true
|
|
250
|
-
prop:count="42" → "42"
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
Kebab-case prop names normalize to camelCase (`prop:user-id` → `userId`). Arbitrary JavaScript references use the `.props` property:
|
|
254
|
-
|
|
255
|
-
```ts
|
|
256
|
-
const renderer = document.querySelector("solid-render");
|
|
257
|
-
|
|
258
|
-
renderer.props = {
|
|
259
|
-
user,
|
|
260
|
-
onSave,
|
|
261
|
-
service,
|
|
262
|
-
};
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
Programmatic props override `prop:*` attributes. Prop changes update the existing component instance reactively and preserve local Solid state. Changes to `module`, `component`, or `data-solid-runtime` dispose the current component and mount a new identity.
|
|
266
|
-
|
|
267
|
-
Initial light-DOM children become `props.children`:
|
|
268
|
-
|
|
269
|
-
```html
|
|
270
|
-
<solid-render module="/Card.jsx" prop:title="Profile">
|
|
271
|
-
<p>Hello from HTML.</p>
|
|
272
|
-
<solid-render module="/SaveButton.jsx"></solid-render>
|
|
273
|
-
</solid-render>
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
The first implementation deliberately has no named-slot system and no Shadow DOM. Nested `<solid-render>` elements work through normal custom-element connection when captured children are instantiated.
|
|
277
|
-
|
|
278
|
-
The HTML adapter registers the custom element automatically **after the initial declarative script batch is installed** by `register()` / `registerHTML()` or the initial `observe()` / `observeHTML()` pass. `createHTMLRuntime()` intentionally does not upgrade existing `<solid-render>` elements immediately, because doing so could make them import modules before preceding `<script module>` declarations have been registered. Most applications therefore do not need to call a registration helper directly.
|
|
279
|
-
|
|
280
|
-
For custom registries, tests, or explicit registration, the helper remains available:
|
|
281
|
-
|
|
282
|
-
```ts
|
|
283
|
-
import { registerSolidRenderElement } from "solid-tag-runtime/html";
|
|
284
|
-
|
|
285
|
-
registerSolidRenderElement();
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
Multiple `<solid-render>` elements may share one cached runtime module namespace while each mounted component owns independent Solid state. Async module changes are generation-guarded so a stale import can never replace a newer `module`/`component`/runtime selection.
|
|
289
|
-
|
|
290
|
-
`<solid-render>` uses the same runtime-routing rules as declarative scripts. An explicit `data-solid-runtime` selects a controller with that scope **whose root contains the element**. Without an explicit scope, any containing controller that accepts unscoped declarations (`acceptUnscoped: true`) may handle the element. If more than one equally specific controller can handle it, add `data-solid-runtime` to disambiguate. Controllers outside the element's DOM root are never selected as a fallback.
|
|
291
|
-
|
|
292
|
-
Both of these reference the same registered virtual module when used with the correct runtime:
|
|
293
|
-
|
|
294
|
-
```html
|
|
295
|
-
<solid-render module="/ui/Button.jsx"></solid-render>
|
|
296
|
-
<solid-render module="./ui/Button.jsx"></solid-render>
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
Top-level relative module references are normalized as virtual paths; they are not browser URL fetches.
|
|
300
|
-
|
|
301
|
-
A document may safely declare a module and immediately reference it later in the same HTML before calling `register()`:
|
|
302
|
-
|
|
303
|
-
```html
|
|
304
|
-
<script type="solid-jsx" module="/ui/Button.jsx">
|
|
305
|
-
export default function Button() {
|
|
306
|
-
return <button>Ready</button>;
|
|
307
|
-
}
|
|
308
|
-
</script>
|
|
309
|
-
|
|
310
|
-
<solid-render module="/ui/Button.jsx"></solid-render>
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
The adapter installs the declaration batch before existing `solid-render` instances mount. If the custom element class was already registered by another runtime, unresolved instances are retried when the matching module becomes available. A transient startup ordering race therefore does not surface as a `ModuleResolutionError`. If the registration/observer queue settles and the referenced virtual module is still absent, the normal `solid-render` error is reported; the retry behavior does not hide genuine missing-module mistakes.
|
|
314
|
-
|
|
315
|
-
A scope is written to owned script elements as:
|
|
316
|
-
|
|
317
|
-
```html
|
|
318
|
-
<script data-solid-runtime="main" ...></script>
|
|
319
85
|
```
|
|
320
86
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
A scoped declaration that only defines a module may be ignored by non-matching controllers without noise. A scoped declaration with active `render` semantics is different: rendering requests immediate UI work. If no registered HTML runtime with that scope can handle the declaration's DOM root, the adapter emits one deduplicated console warning and an `html-warning` lifecycle event with `code: "unresolved-runtime-scope"`. `executeRenders: false` suppresses this diagnostic because rendering was explicitly disabled.
|
|
324
|
-
|
|
325
|
-
```ts
|
|
326
|
-
html.subscribe("html-warning", event => {
|
|
327
|
-
if (event.code === "unresolved-runtime-scope") {
|
|
328
|
-
console.warn(event.requestedScope, event.moduleId);
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
`<solid-render>` keeps stronger semantics: when it actively connects and cannot resolve its selected runtime, that is a render error rather than only a warning.
|
|
334
|
-
|
|
335
|
-
### Declarative modules
|
|
87
|
+
## Reusable `<solid-render>` instances
|
|
336
88
|
|
|
337
89
|
```html
|
|
338
|
-
<script
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
module="/ui/Button.jsx">
|
|
342
|
-
export function Button(props) {
|
|
343
|
-
return (
|
|
344
|
-
<button onClick={props.onClick}>
|
|
345
|
-
{props.children}
|
|
346
|
-
</button>
|
|
347
|
-
);
|
|
90
|
+
<script type="solid-jsx" module="/Counter.jsx">
|
|
91
|
+
export default function Counter() {
|
|
92
|
+
return <button>Counter</button>;
|
|
348
93
|
}
|
|
349
94
|
</script>
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
Runtime modules import one another normally:
|
|
353
|
-
|
|
354
|
-
```tsx
|
|
355
|
-
import { Button } from "./ui/Button.jsx";
|
|
356
|
-
```
|
|
357
|
-
|
|
358
|
-
All newly discovered scripts in one batch are defined before any newly discovered `entry` module executes, so HTML document order does not require dependencies to appear first.
|
|
359
95
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
```html
|
|
363
|
-
<script
|
|
364
|
-
type="solid-jsx"
|
|
365
|
-
data-solid-runtime="main"
|
|
366
|
-
module="/ui/Button.jsx"
|
|
367
|
-
src="./components/Button.jsx">
|
|
368
|
-
</script>
|
|
96
|
+
<solid-render module="/Counter.jsx"></solid-render>
|
|
97
|
+
<solid-render module="/Counter.jsx"></solid-render>
|
|
369
98
|
```
|
|
370
99
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
### User-created script elements
|
|
374
|
-
|
|
375
|
-
If application code creates a script itself, use the controller to associate it with the correct runtime:
|
|
376
|
-
|
|
377
|
-
```ts
|
|
378
|
-
const script = document.createElement("script");
|
|
379
|
-
script.type = "solid-jsx";
|
|
380
|
-
script.setAttribute("module", "/dynamic/Greeting.jsx");
|
|
381
|
-
script.textContent = `
|
|
382
|
-
export function Greeting(props) {
|
|
383
|
-
return <p>Hello {props.name}</p>;
|
|
384
|
-
}
|
|
385
|
-
`;
|
|
386
|
-
|
|
387
|
-
await html.append(script);
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
`append()` claims the element **before** inserting it in the DOM, stamps the controller scope, then registers it directly. If a `MutationObserver` is active, the later mutation callback sees that the element is already owned and does not compile it twice.
|
|
391
|
-
|
|
392
|
-
For an element that is already in the DOM:
|
|
393
|
-
|
|
394
|
-
```ts
|
|
395
|
-
await html.registerElement(script);
|
|
396
|
-
```
|
|
100
|
+
**In HTML, always use the explicit closing tag.** Do not write `<solid-render ... />`; custom elements are not HTML void elements and the self-closing slash is ignored by the HTML parser.
|
|
397
101
|
|
|
398
|
-
|
|
102
|
+
## Persistent compile cache
|
|
399
103
|
|
|
400
|
-
|
|
104
|
+
`0.0.13` adds an opt-in persistent cache for **pre-link compiler artifacts**. Runtime-specific linked URLs and evaluated module namespaces are never persisted.
|
|
401
105
|
|
|
402
106
|
```ts
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
return <span>{props.children}</span>;
|
|
408
|
-
}
|
|
409
|
-
`,
|
|
410
|
-
});
|
|
411
|
-
```
|
|
412
|
-
|
|
413
|
-
`addModule()` creates the `<script>` element, associates it with the controller, appends it, and registers it.
|
|
414
|
-
|
|
415
|
-
### Observe scripts added by other code
|
|
107
|
+
import {
|
|
108
|
+
createRuntime,
|
|
109
|
+
createIndexedDBCompileCache,
|
|
110
|
+
} from "solid-tag-runtime";
|
|
416
111
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
112
|
+
const runtime = createRuntime({
|
|
113
|
+
compileCache: {
|
|
114
|
+
store: createIndexedDBCompileCache({
|
|
115
|
+
database: "my-app-runtime",
|
|
116
|
+
}),
|
|
117
|
+
namespace: "main",
|
|
118
|
+
version: "1",
|
|
422
119
|
},
|
|
423
120
|
});
|
|
424
|
-
|
|
425
|
-
// Some unrelated code mutates the DOM directly.
|
|
426
|
-
const script = document.createElement("script");
|
|
427
|
-
script.type = "solid-jsx";
|
|
428
|
-
script.setAttribute("data-solid-runtime", "main");
|
|
429
|
-
script.setAttribute("module", "/observed/Thing.jsx");
|
|
430
|
-
script.textContent = `export const value = 42;`;
|
|
431
|
-
document.body.append(script);
|
|
432
|
-
|
|
433
|
-
await html.flush();
|
|
434
|
-
const module = await runtime.import("/observed/Thing.jsx");
|
|
435
|
-
```
|
|
436
|
-
|
|
437
|
-
The observer is for DOM changes that happen **outside** the controller API. Prefer `html.append()` / `html.addModule()` when your code controls insertion because those operations are deterministic and do not depend on observer timing.
|
|
438
|
-
|
|
439
|
-
### Ownership and deduplication
|
|
440
|
-
|
|
441
|
-
All HTML controllers share an internal `WeakMap` of script element → ownership/registration record.
|
|
442
|
-
|
|
443
|
-
That controller model gives these guarantees:
|
|
444
|
-
|
|
445
|
-
- one script element has at most one HTML-runtime owner;
|
|
446
|
-
- manual registration and observer registration cannot compile the same element twice;
|
|
447
|
-
- the same controller can register the same element repeatedly without redefining it;
|
|
448
|
-
- two distinct elements cannot silently define the same HTML-owned module ID;
|
|
449
|
-
- an HTML script cannot silently replace a module already defined outside that HTML controller;
|
|
450
|
-
- `data-solid-runtime` is declarative metadata while the in-memory owner record is authoritative.
|
|
451
|
-
|
|
452
|
-
The controller also exposes lightweight introspection:
|
|
453
|
-
|
|
454
|
-
```ts
|
|
455
|
-
html.owns(script);
|
|
456
|
-
html.getModuleId(script);
|
|
457
|
-
html.getElement("/dynamic/Greeting.jsx");
|
|
458
121
|
```
|
|
459
122
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
```text
|
|
463
|
-
solid-jsx / text/solid-jsx → JSX transformation
|
|
464
|
-
solid-js / text/solid-js → plain JavaScript module
|
|
465
|
-
solid-module → infer from module/src extension
|
|
466
|
-
```
|
|
467
|
-
|
|
468
|
-
`language="js"` or `language="jsx"` may override inference.
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
### Change the observed root
|
|
472
|
-
|
|
473
|
-
The HTML controller can move to a different discovery root without creating a new runtime:
|
|
123
|
+
The cache key is content-based and includes the source hash, compiler fingerprint, artifact ABI, format, and compile-affecting context. Dependency versions and resolver state are deliberately excluded, so unchanged importers can reuse compiler work and relink against changed dependencies.
|
|
474
124
|
|
|
475
125
|
```ts
|
|
476
|
-
|
|
477
|
-
|
|
126
|
+
await runtime.compile("/App.jsx", { cache: "use" });
|
|
127
|
+
await runtime.compile("/App.jsx", { cache: "refresh" });
|
|
128
|
+
await runtime.compile("/App.jsx", { cache: "bypass" });
|
|
478
129
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
appendTo: first,
|
|
482
|
-
});
|
|
483
|
-
|
|
484
|
-
await html.observe({ registerExisting: false });
|
|
485
|
-
|
|
486
|
-
// Rebind a live observer to a different node. Because the observer is already
|
|
487
|
-
// connected, matching scripts already in the new root are registered by default.
|
|
488
|
-
await html.setRoot(second);
|
|
489
|
-
```
|
|
490
|
-
|
|
491
|
-
If the controller is disconnected, `setRoot()` only changes configuration unless `registerExisting: true` is passed:
|
|
492
|
-
|
|
493
|
-
```ts
|
|
494
|
-
await html.setRoot(second, {
|
|
495
|
-
registerExisting: true,
|
|
496
|
-
});
|
|
497
|
-
```
|
|
498
|
-
|
|
499
|
-
Use `registerExisting: false` when switching a live observer but intentionally ignoring scripts already present in the new root.
|
|
500
|
-
|
|
501
|
-
Moving the **same root node** elsewhere in the DOM does not require `setRoot()`. `MutationObserver` remains attached to that node object even when it is reparented.
|
|
502
|
-
|
|
503
|
-
### Move root and append target together
|
|
504
|
-
|
|
505
|
-
When the runtime module area itself moves to another container, `moveTo()` changes both boundaries:
|
|
506
|
-
|
|
507
|
-
```ts
|
|
508
|
-
await html.moveTo(nextContainer, {
|
|
509
|
-
registerExisting: true,
|
|
510
|
-
});
|
|
511
|
-
```
|
|
512
|
-
|
|
513
|
-
For an `Element`, `DocumentFragment`, or `ShadowRoot`, future `append()` / `addModule()` calls insert into that root. For a `Document`, the controller chooses the document body (or document element fallback) as the append target.
|
|
514
|
-
|
|
515
|
-
### Change only the append target
|
|
516
|
-
|
|
517
|
-
Observation and insertion can have different boundaries:
|
|
518
|
-
|
|
519
|
-
```ts
|
|
520
|
-
html.setAppendTarget(document.head);
|
|
521
|
-
```
|
|
522
|
-
|
|
523
|
-
This does not change the currently observed root. The controller exposes the active values for diagnostics:
|
|
524
|
-
|
|
525
|
-
```ts
|
|
526
|
-
html.root;
|
|
527
|
-
html.appendTarget;
|
|
130
|
+
await runtime.compileCache.invalidate("/App.jsx");
|
|
131
|
+
await runtime.compileCache.clear();
|
|
528
132
|
```
|
|
529
133
|
|
|
530
|
-
|
|
134
|
+
## Documentation
|
|
531
135
|
|
|
532
|
-
|
|
136
|
+
The detailed documentation now lives under [`docs/`](./docs/README.md):
|
|
533
137
|
|
|
534
|
-
|
|
138
|
+
- [Getting started](./docs/getting-started.md)
|
|
139
|
+
- [Runtime modules and resolution](./docs/modules.md)
|
|
140
|
+
- [HTML runtime and ownership](./docs/html-runtime.md)
|
|
141
|
+
- [Declarative rendering](./docs/rendering.md)
|
|
142
|
+
- [`<solid-render>`](./docs/solid-render.md)
|
|
143
|
+
- [Lifecycle events](./docs/lifecycle-events.md)
|
|
144
|
+
- [Persistent compile cache](./docs/compile-cache.md)
|
|
145
|
+
- [Core runtime API](./docs/api/runtime.md)
|
|
146
|
+
- [HTML runtime API](./docs/api/html.md)
|
|
147
|
+
- [Compile-cache API](./docs/api/compile-cache.md)
|
|
535
148
|
|
|
536
|
-
|
|
149
|
+
For engineering invariants and design decisions, see [`ARCHITECTURE.md`](./ARCHITECTURE.md).
|
|
537
150
|
|
|
538
|
-
|
|
151
|
+
## Browser import maps
|
|
539
152
|
|
|
540
|
-
|
|
153
|
+
When loading from an import map, map both entries to the same version:
|
|
541
154
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
return <>{props.message} {props.name}</>;
|
|
548
|
-
}
|
|
549
|
-
`);
|
|
550
|
-
|
|
551
|
-
const MyComponent = module.MyComponent;
|
|
552
|
-
```
|
|
553
|
-
|
|
554
|
-
`toModule()` creates an anonymous runtime module, compiles it with `solid-tag`, evaluates it as a real ES module, and returns the module namespace.
|
|
555
|
-
|
|
556
|
-
It is asynchronous because the runtime preserves ES-module-style evaluation rather than using `new Function()`.
|
|
557
|
-
|
|
558
|
-
## `toComponent()`
|
|
559
|
-
|
|
560
|
-
For the common single-component case:
|
|
561
|
-
|
|
562
|
-
```ts
|
|
563
|
-
const MyComponent = await runtime.toComponent(
|
|
564
|
-
`
|
|
565
|
-
export function MyComponent(props) {
|
|
566
|
-
return <div>{props.message}</div>;
|
|
567
|
-
}
|
|
568
|
-
`,
|
|
569
|
-
{ exportName: "MyComponent" },
|
|
570
|
-
);
|
|
571
|
-
```
|
|
572
|
-
|
|
573
|
-
For a default export:
|
|
574
|
-
|
|
575
|
-
```ts
|
|
576
|
-
const Counter = await runtime.toComponent(`
|
|
577
|
-
export default function Counter() {
|
|
578
|
-
return <button>Count</button>;
|
|
155
|
+
```json
|
|
156
|
+
{
|
|
157
|
+
"imports": {
|
|
158
|
+
"solid-tag-runtime": "https://esm.sh/solid-tag-runtime@0.0.13",
|
|
159
|
+
"solid-tag-runtime/html": "https://esm.sh/solid-tag-runtime@0.0.13/html"
|
|
579
160
|
}
|
|
580
|
-
`);
|
|
581
|
-
```
|
|
582
|
-
|
|
583
|
-
## Inject application values as modules
|
|
584
|
-
|
|
585
|
-
The runtime deliberately does not rewrite unresolved identifiers into a magical scope object.
|
|
586
|
-
|
|
587
|
-
Instead, application scope can be expressed as a normal module:
|
|
588
|
-
|
|
589
|
-
```ts
|
|
590
|
-
const [count, setCount] = createSignal(0);
|
|
591
|
-
|
|
592
|
-
runtime.defineModule("@app/state", {
|
|
593
|
-
count,
|
|
594
|
-
setCount,
|
|
595
|
-
});
|
|
596
|
-
```
|
|
597
|
-
|
|
598
|
-
Runtime source imports those references normally:
|
|
599
|
-
|
|
600
|
-
```tsx
|
|
601
|
-
import { count, setCount } from "@app/state";
|
|
602
|
-
|
|
603
|
-
export function Counter() {
|
|
604
|
-
return (
|
|
605
|
-
<button onClick={() => setCount(value => value + 1)}>
|
|
606
|
-
{count()}
|
|
607
|
-
</button>
|
|
608
|
-
);
|
|
609
161
|
}
|
|
610
162
|
```
|
|
611
163
|
|
|
612
|
-
This works for:
|
|
613
|
-
|
|
614
|
-
- Solid signals and setters
|
|
615
|
-
- stores
|
|
616
|
-
- components
|
|
617
|
-
- callbacks
|
|
618
|
-
- services
|
|
619
|
-
- data objects
|
|
620
|
-
- application utilities
|
|
621
|
-
|
|
622
|
-
The values cross the boundary as actual JavaScript references; they are not serialized.
|
|
623
|
-
|
|
624
|
-
## Expose existing components
|
|
625
|
-
|
|
626
|
-
```ts
|
|
627
|
-
runtime.defineModule("@app/components", {
|
|
628
|
-
Button,
|
|
629
|
-
Dialog,
|
|
630
|
-
Card,
|
|
631
|
-
});
|
|
632
|
-
```
|
|
633
|
-
|
|
634
|
-
Then runtime JSX can use them like any other module:
|
|
635
|
-
|
|
636
|
-
```tsx
|
|
637
|
-
import { Button } from "@app/components";
|
|
638
|
-
|
|
639
|
-
export function SaveButton() {
|
|
640
|
-
return <Button>Save</Button>;
|
|
641
|
-
}
|
|
642
|
-
```
|
|
643
|
-
|
|
644
|
-
## URL modules
|
|
645
|
-
|
|
646
|
-
A package or external library can be mapped to a native ESM URL:
|
|
647
|
-
|
|
648
|
-
```ts
|
|
649
|
-
runtime.defineUrl(
|
|
650
|
-
"some-library",
|
|
651
|
-
"https://esm.sh/some-library@1.2.3",
|
|
652
|
-
);
|
|
653
|
-
```
|
|
654
|
-
|
|
655
|
-
Then dynamic modules can write:
|
|
656
|
-
|
|
657
|
-
```js
|
|
658
|
-
import something from "some-library";
|
|
659
|
-
```
|
|
660
|
-
|
|
661
|
-
## Plain JavaScript modules
|
|
662
|
-
|
|
663
|
-
JSX transformation can be disabled per module:
|
|
664
|
-
|
|
665
|
-
```ts
|
|
666
|
-
runtime.define(
|
|
667
|
-
"/config.js",
|
|
668
|
-
`export const value = 42;`,
|
|
669
|
-
{ format: "js" },
|
|
670
|
-
);
|
|
671
|
-
```
|
|
672
|
-
|
|
673
|
-
This is useful when the same runtime graph contains both JSX-backed modules and ordinary JavaScript modules.
|
|
674
|
-
|
|
675
|
-
## Compilation without execution
|
|
676
|
-
|
|
677
|
-
```ts
|
|
678
|
-
runtime.define("/App.jsx", source);
|
|
679
|
-
|
|
680
|
-
const compiled = await runtime.compile("/App.jsx");
|
|
681
|
-
|
|
682
|
-
console.log(compiled.code);
|
|
683
|
-
console.log(compiled.dependencies);
|
|
684
|
-
console.log(compiled.diagnostics);
|
|
685
|
-
```
|
|
686
|
-
|
|
687
|
-
This is useful for editors, debugging tools, and inspecting the exact `html\`\`` output generated by `solid-tag`.
|
|
688
|
-
|
|
689
|
-
## Module graph introspection
|
|
690
|
-
|
|
691
|
-
```ts
|
|
692
|
-
runtime.modules();
|
|
693
|
-
runtime.dependencies("/App.jsx");
|
|
694
|
-
runtime.dependents("/ui/Button.jsx");
|
|
695
|
-
runtime.getModuleInfo("/App.jsx");
|
|
696
|
-
```
|
|
697
|
-
|
|
698
|
-
## Updating modules
|
|
699
|
-
|
|
700
|
-
```ts
|
|
701
|
-
runtime.update("/ui/Button.jsx", newButtonSource);
|
|
702
|
-
|
|
703
|
-
const app = await runtime.import("/App.jsx");
|
|
704
|
-
```
|
|
705
|
-
|
|
706
|
-
Updating a module invalidates its compiled URL and its dependent runtime modules. Re-importing produces a newly linked graph.
|
|
707
|
-
|
|
708
|
-
Existing references to an older module namespace/component are not mutated. Applications that implement live editing should import the updated entry module again.
|
|
709
|
-
|
|
710
|
-
### Define several source modules together
|
|
711
|
-
|
|
712
|
-
```ts
|
|
713
|
-
runtime.defineMany([
|
|
714
|
-
{
|
|
715
|
-
id: "/ui/Button.jsx",
|
|
716
|
-
source: buttonSource,
|
|
717
|
-
},
|
|
718
|
-
{
|
|
719
|
-
id: "/App.jsx",
|
|
720
|
-
source: appSource,
|
|
721
|
-
},
|
|
722
|
-
]);
|
|
723
|
-
```
|
|
724
|
-
|
|
725
|
-
`defineMany()` validates the whole definition list before applying it and rejects duplicate module IDs inside the batch. It is useful when a group of modules should become available before anything is imported. Lifecycle notifications from the batch are published only after every definition has been installed.
|
|
726
|
-
|
|
727
|
-
### Remove modules
|
|
728
|
-
|
|
729
|
-
```ts
|
|
730
|
-
runtime.remove("/ui/Button.jsx");
|
|
731
|
-
```
|
|
732
|
-
|
|
733
|
-
Removal invalidates transitive dependents by default. A later import of a dependent will fail resolution until the missing module is defined again.
|
|
734
|
-
|
|
735
|
-
If you intentionally want to leave currently linked dependents untouched:
|
|
736
|
-
|
|
737
|
-
```ts
|
|
738
|
-
runtime.remove("/ui/Button.jsx", {
|
|
739
|
-
invalidateDependents: false,
|
|
740
|
-
});
|
|
741
|
-
```
|
|
742
|
-
|
|
743
|
-
### Clear a runtime
|
|
744
|
-
|
|
745
|
-
```ts
|
|
746
|
-
runtime.clear();
|
|
747
|
-
```
|
|
748
|
-
|
|
749
|
-
By default `clear()` removes source and URL modules while preserving host modules registered with `defineModule()`. This is convenient for editor/preview resets where the host environment should remain installed.
|
|
750
|
-
|
|
751
|
-
```ts
|
|
752
|
-
runtime.clear({
|
|
753
|
-
preserveHostModules: false,
|
|
754
|
-
});
|
|
755
|
-
```
|
|
756
|
-
|
|
757
|
-
removes everything. The returned array contains the IDs that were removed.
|
|
758
|
-
|
|
759
|
-
### Lifecycle events
|
|
760
|
-
|
|
761
|
-
`0.0.8` expands lifecycle subscriptions into a typed event stream with independent join/leave semantics.
|
|
762
|
-
|
|
763
|
-
Subscribe to everything:
|
|
764
|
-
|
|
765
|
-
```ts
|
|
766
|
-
const unsubscribe = runtime.subscribe(event => {
|
|
767
|
-
console.log(event.type, event);
|
|
768
|
-
});
|
|
769
|
-
```
|
|
770
|
-
|
|
771
|
-
Subscribe to one event type:
|
|
772
|
-
|
|
773
|
-
```ts
|
|
774
|
-
const leaveErrors = runtime.subscribe(
|
|
775
|
-
"module-error",
|
|
776
|
-
event => {
|
|
777
|
-
console.error(event.phase, event.error);
|
|
778
|
-
},
|
|
779
|
-
);
|
|
780
|
-
```
|
|
781
|
-
|
|
782
|
-
Subscribe to several event types:
|
|
783
|
-
|
|
784
|
-
```ts
|
|
785
|
-
const leaveEvaluation = runtime.subscribe(
|
|
786
|
-
["module-evaluating", "module-evaluated"],
|
|
787
|
-
event => {
|
|
788
|
-
console.log(event.type, event.id);
|
|
789
|
-
},
|
|
790
|
-
);
|
|
791
|
-
```
|
|
792
|
-
|
|
793
|
-
Each call owns an independent subscription:
|
|
794
|
-
|
|
795
|
-
```ts
|
|
796
|
-
leaveEvaluation();
|
|
797
|
-
// the error subscription remains active
|
|
798
|
-
```
|
|
799
|
-
|
|
800
|
-
Core events include:
|
|
801
|
-
|
|
802
|
-
```text
|
|
803
|
-
module-defined
|
|
804
|
-
module-updated
|
|
805
|
-
modules-defined
|
|
806
|
-
|
|
807
|
-
module-resolving
|
|
808
|
-
module-resolved
|
|
809
|
-
|
|
810
|
-
module-linking
|
|
811
|
-
module-linked
|
|
812
|
-
|
|
813
|
-
module-invalidated
|
|
814
|
-
module-compiled
|
|
815
|
-
module-evaluating
|
|
816
|
-
module-evaluated
|
|
817
|
-
|
|
818
|
-
module-removed
|
|
819
|
-
module-error
|
|
820
|
-
|
|
821
|
-
runtime-cleared
|
|
822
|
-
runtime-disposed
|
|
823
|
-
```
|
|
824
|
-
|
|
825
|
-
`module-resolved` reports how a specifier was resolved (`relative`, `registered`, `custom`, `native`, and so on). `module-linked` exposes the logical dependency mapping used to link a source module. `modules-defined` marks the completion of a `defineMany()` batch after all definitions have been installed.
|
|
826
|
-
|
|
827
|
-
`module-error.phase` is one of the runtime pipeline phases such as `resolve`, `analyze`, `compile`, `link`, `url-create`, `evaluate`, or `host-bridge`.
|
|
828
|
-
|
|
829
|
-
Subscribers are observational only: they cannot cancel or modify runtime operations, and subscriber exceptions are isolated from runtime execution. Behavioral extension remains separate through the resolver, compiler adapter, and module URL backend.
|
|
830
|
-
|
|
831
|
-
### HTML lifecycle events
|
|
832
|
-
|
|
833
|
-
The HTML controller has its own event stream because DOM ownership/observation is intentionally separate from the core module engine:
|
|
834
|
-
|
|
835
|
-
```ts
|
|
836
|
-
const leaveHTML = html.subscribe(event => {
|
|
837
|
-
console.log(event.type, event);
|
|
838
|
-
});
|
|
839
|
-
```
|
|
840
|
-
|
|
841
|
-
The same selective forms are supported:
|
|
842
|
-
|
|
843
|
-
```ts
|
|
844
|
-
const leaveOwnership = html.subscribe(
|
|
845
|
-
["element-claimed", "element-registered", "element-removed"],
|
|
846
|
-
event => {
|
|
847
|
-
console.log(event.type, event.moduleId);
|
|
848
|
-
},
|
|
849
|
-
);
|
|
850
|
-
```
|
|
851
|
-
|
|
852
|
-
HTML events include:
|
|
853
|
-
|
|
854
|
-
```text
|
|
855
|
-
element-discovered
|
|
856
|
-
element-claimed
|
|
857
|
-
element-loading
|
|
858
|
-
element-loaded
|
|
859
|
-
element-registered
|
|
860
|
-
|
|
861
|
-
element-updating
|
|
862
|
-
element-updated
|
|
863
|
-
element-removing
|
|
864
|
-
element-released
|
|
865
|
-
element-removed
|
|
866
|
-
|
|
867
|
-
observer-connected
|
|
868
|
-
observer-disconnected
|
|
869
|
-
observer-batch
|
|
870
|
-
|
|
871
|
-
root-changing
|
|
872
|
-
root-changed
|
|
873
|
-
append-target-changed
|
|
874
|
-
|
|
875
|
-
entry-executing
|
|
876
|
-
entry-executed
|
|
877
|
-
|
|
878
|
-
render-mounting
|
|
879
|
-
render-mounted
|
|
880
|
-
render-disposing
|
|
881
|
-
render-disposed
|
|
882
|
-
|
|
883
|
-
html-warning
|
|
884
|
-
html-error
|
|
885
|
-
```
|
|
886
|
-
|
|
887
|
-
Ownership-related events include an `origin` describing how the element entered the controller (`observer`, `append`, `register-element`, `add-module`, and related internal scan origins). This is useful for tracing observer/manual-registration races and proving that an explicit `append()` was not processed a second time by the observer.
|
|
888
|
-
|
|
889
|
-
`html-warning` currently reports non-fatal adapter diagnostics. `unresolved-runtime-scope` is emitted once per render declaration/scope when `data-solid-runtime` requests immediate rendering but no registered controller can handle that scoped declaration. The event includes `requestedScope`, `registeredScopes`, `moduleId` when available, and whether a matching scope exists outside the declaration's root.
|
|
890
|
-
|
|
891
|
-
`observer-batch` summarizes a DOM discovery pass instead of exposing noisy raw `MutationRecord` objects. `element-loading` / `element-loaded` are emitted for `src`-backed modules, and entry events distinguish evaluation caused by an HTML `entry` declaration from an ordinary `runtime.import()`. Render events cover both `<script render>` and `<solid-render>`; `source` identifies `script-render` versus `solid-render`, and `mode` identifies selector, in-place, or container mounting.
|
|
892
|
-
|
|
893
|
-
Like core runtime subscribers, HTML subscribers are observational and exception-isolated.
|
|
894
|
-
|
|
895
|
-
## HTML-owned module updates and removal
|
|
896
|
-
|
|
897
|
-
When a script element is already owned by an HTML runtime controller, update the runtime module from the current element contents with:
|
|
898
|
-
|
|
899
|
-
```ts
|
|
900
|
-
script.textContent = `
|
|
901
|
-
export function Card() {
|
|
902
|
-
return <div>updated</div>;
|
|
903
|
-
}
|
|
904
|
-
`;
|
|
905
|
-
|
|
906
|
-
await html.updateElement(script);
|
|
907
|
-
```
|
|
908
|
-
|
|
909
|
-
`updateElement()` keeps the existing logical module ID and calls `runtime.update()` underneath. Changing the element's logical `module` identity is intentionally rejected; remove and register it again instead.
|
|
910
|
-
|
|
911
|
-
Release an owned element explicitly with:
|
|
912
|
-
|
|
913
|
-
```ts
|
|
914
|
-
await html.removeElement(script);
|
|
915
|
-
```
|
|
916
|
-
|
|
917
|
-
By default this:
|
|
918
|
-
|
|
919
|
-
1. removes the runtime module,
|
|
920
|
-
2. invalidates its dependents,
|
|
921
|
-
3. releases HTML ownership, and
|
|
922
|
-
4. removes the script element from the DOM.
|
|
923
|
-
|
|
924
|
-
The two lifecycles can be controlled independently:
|
|
925
|
-
|
|
926
|
-
```ts
|
|
927
|
-
await html.removeElement(script, {
|
|
928
|
-
removeModule: false,
|
|
929
|
-
removeFromDOM: true,
|
|
930
|
-
});
|
|
931
|
-
```
|
|
932
|
-
|
|
933
|
-
This is intentionally explicit: ordinary DOM removal does not silently delete a runtime module.
|
|
934
|
-
|
|
935
|
-
## Custom resolution
|
|
936
|
-
|
|
937
|
-
```ts
|
|
938
|
-
const runtime = createRuntime({
|
|
939
|
-
resolve(specifier, importer) {
|
|
940
|
-
if (specifier.startsWith("@ui/")) {
|
|
941
|
-
return `/ui/${specifier.slice(4)}`;
|
|
942
|
-
}
|
|
943
|
-
},
|
|
944
|
-
});
|
|
945
|
-
```
|
|
946
|
-
|
|
947
|
-
Default runtime resolution supports:
|
|
948
|
-
|
|
949
|
-
- exact virtual module IDs
|
|
950
|
-
- relative virtual imports
|
|
951
|
-
- absolute virtual paths
|
|
952
|
-
- registered URL modules
|
|
953
|
-
- native/bare imports when `allowNativeImports` is enabled
|
|
954
|
-
|
|
955
|
-
## Native imports
|
|
956
|
-
|
|
957
|
-
`allowNativeImports` defaults to `true`.
|
|
958
|
-
|
|
959
|
-
This means an unresolved **bare** import can be left for the browser's native module resolver/import map:
|
|
960
|
-
|
|
961
|
-
```ts
|
|
962
|
-
const runtime = createRuntime({
|
|
963
|
-
allowNativeImports: true,
|
|
964
|
-
});
|
|
965
|
-
```
|
|
966
|
-
|
|
967
|
-
Relative and absolute virtual paths are different. If `/ui/Button.jsx` or `./ui/Button.jsx` does not resolve to a registered runtime module, `runtime.import()` throws `ModuleResolutionError`; it does not turn the path into a browser/native network import. Use `defineUrl()` or an actual absolute URL when native URL loading is intended.
|
|
968
|
-
|
|
969
|
-
Set `allowNativeImports` to `false` when even unresolved bare imports must be explicitly registered with the runtime.
|
|
970
|
-
|
|
971
|
-
## Runtime lifecycle
|
|
972
|
-
|
|
973
|
-
```ts
|
|
974
|
-
runtime.invalidate("/App.jsx");
|
|
975
|
-
runtime.remove("/Unused.jsx");
|
|
976
|
-
runtime.clear();
|
|
977
|
-
runtime.dispose();
|
|
978
|
-
```
|
|
979
|
-
|
|
980
|
-
`invalidate()` forces fresh compilation/evaluation without deleting the module definition. `remove()` deletes one definition, `clear()` resets a group of definitions, and `dispose()` permanently tears down the runtime instance.
|
|
981
|
-
|
|
982
164
|
## Current limitations
|
|
983
165
|
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
-
|
|
987
|
-
-
|
|
988
|
-
-
|
|
989
|
-
- module updates create new module identities; already-held namespaces/components remain the old version
|
|
990
|
-
- TypeScript/TSX parsing depends on what the underlying `solid-tag` compiler supports
|
|
991
|
-
- this package is **not a security sandbox**; loaded source executes with the privileges of the page
|
|
992
|
-
|
|
993
|
-
See [`ARCHITECTURE.md`](./ARCHITECTURE.md) for the detailed design and decision log.
|
|
166
|
+
- runtime-defined source-module cycles are not supported yet
|
|
167
|
+
- generated browser modules require a compatible CSP for the selected module URL backend
|
|
168
|
+
- persistent compile caching is an optimization, not a security sandbox
|
|
169
|
+
- already-held namespace/component references are not mutated by module updates
|
|
170
|
+
- TypeScript/TSX support depends on the configured compiler
|