mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
docs(chord): slice 7b brief: plugin dependencies
This commit is contained in:
parent
601461e205
commit
b857fbd8a9
2 changed files with 14 additions and 2 deletions
|
|
@ -100,7 +100,11 @@ plugins/notes/
|
|||
- **`peerDependencies`** are **host packages**: the running app supplies them, one instance per process (one Chord,
|
||||
one React; `instanceof ChordError` and React hooks only work that way). The bundler never copies them.
|
||||
- **`dependencies`** are the plugin's own npm packages (`marked`): installed into the plugin's `node_modules` with
|
||||
`--ignore-scripts` and bundled into every facet that imports them.
|
||||
`--ignore-scripts` and bundled into every facet that imports them. **Decided** (owner, 2026-10-29): bundled by
|
||||
default; on Node a plugin may keep named packages external by an explicit list, `"chord": { "external":
|
||||
["better-sqlite3"] }`. Server and worker facets then load them from the plugin's `node_modules` with `createRequire`,
|
||||
as pi 1.0 loads extension dependencies, native addons included; they stay in Node's module cache until the process
|
||||
ends, so a new version takes effect after a restart. A browser or TUI facet that imports one fails to build.
|
||||
- **No `tsconfig.json` is needed.** The bundler strips types and does not type-check; JSX is compiled with the
|
||||
automatic React runtime, a fixed setting of the loader. A plugin may keep a `tsconfig.json` for its editor and for
|
||||
`tsc --noEmit` (the SDK ships one to extend); the loader ignores it.
|
||||
|
|
@ -147,6 +151,7 @@ Each facet is built on its own, as one script. The bundler starts at the facet f
|
|||
| the plugin's own files (`./store.ts`, `./NoteList.tsx`) | inlined into the facet's script |
|
||||
| another plugin's contract (`../sessions/contract.ts`, or `@pi/sessions/contract` for an installed package) | inlined too: a copy, so a plugin carries the contract version it was built against (`accepts` needs that); only contracts and side-effect-free modules may be imported across plugins |
|
||||
| an npm package in `dependencies` (`marked`) | inlined, resolved from the plugin's own `node_modules` |
|
||||
| an npm package listed in `chord.external` (Node facets only) | external: `require`d from the plugin's own `node_modules` at evaluation |
|
||||
| a host package (`@earendil-works/chord/next`, `react`, `@app/core`, …) | **external**: a parameter of the script, the host's instance at load time |
|
||||
| a Node builtin (`node:fs`) | external, through the `require` the loader passes (server and worker facets only; a web facet that imports one fails to build) |
|
||||
| CSS (`import "./notes.css"`) | collected into one stylesheet per web facet |
|
||||
|
|
|
|||
|
|
@ -208,7 +208,10 @@ named by their directory).</p>
|
|||
<li><strong><code>peerDependencies</code></strong> are <strong>host packages</strong>: the running app supplies them, one instance per process (one Chord,
|
||||
one React; <code>instanceof ChordError</code> and React hooks only work that way). The bundler never copies them.</li>
|
||||
<li><strong><code>dependencies</code></strong> are the plugin's own npm packages (<code>marked</code>): installed into the plugin's <code>node_modules</code> with
|
||||
<code>--ignore-scripts</code> and bundled into every facet that imports them.</li>
|
||||
<code>--ignore-scripts</code> and bundled into every facet that imports them. <strong>Decided</strong> (owner, 2026-10-29): bundled by
|
||||
default; on Node a plugin may keep named packages external by an explicit list, <code>"chord": { "external": ["better-sqlite3"] }</code>. Server and worker facets then load them from the plugin's <code>node_modules</code> with <code>createRequire</code>,
|
||||
as pi 1.0 loads extension dependencies, native addons included; they stay in Node's module cache until the process
|
||||
ends, so a new version takes effect after a restart. A browser or TUI facet that imports one fails to build.</li>
|
||||
<li><strong>No <code>tsconfig.json</code> is needed.</strong> The bundler strips types and does not type-check; JSX is compiled with the
|
||||
automatic React runtime, a fixed setting of the loader. A plugin may keep a <code>tsconfig.json</code> for its editor and for
|
||||
<code>tsc --noEmit</code> (the SDK ships one to extend); the loader ignores it.</li>
|
||||
|
|
@ -266,6 +269,10 @@ returns nothing.</p>
|
|||
<td>inlined, resolved from the plugin's own <code>node_modules</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>an npm package listed in <code>chord.external</code> (Node facets only)</td>
|
||||
<td>external: <code>require</code>d from the plugin's own <code>node_modules</code> at evaluation</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>a host package (<code>@earendil-works/chord/next</code>, <code>react</code>, <code>@app/core</code>, …)</td>
|
||||
<td><strong>external</strong>: a parameter of the script, the host's instance at load time</td>
|
||||
</tr>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue