@backtickjs/bundler 0.1.10 → 0.2.0

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
@@ -10,7 +10,7 @@ npm install @backtickjs/bundler @backtickjs/core
10
10
 
11
11
  ## Usage
12
12
 
13
- For React Native, write CommonJS and serve it; the app fetches it and runs it with `evaluate` from `@backtickjs/react-native-client`:
13
+ For React Native, write CommonJS and serve it; the app fetches it and runs it with `execRoot` from `@backtickjs/core/cjs`:
14
14
 
15
15
  ```tsx
16
16
  import { bundler } from "@backtickjs/bundler";
@@ -23,8 +23,8 @@ const modules = {
23
23
  };
24
24
 
25
25
  // In a request handler:
26
- const bundle = await bundler.build({ input: <Home />, modules });
27
- const { code } = bundle.generate({ format: "cjs" });
26
+ const build = await bundler.build({ input: <Home />, modules });
27
+ const { code } = build.generate({ format: "cjs" });
28
28
  response.setHeader("content-type", "text/javascript");
29
29
  response.end(code);
30
30
  ```
@@ -34,11 +34,11 @@ For the web, write an ES module whose default export is the value, and load it w
34
34
  ```tsx
35
35
  import { bundler } from "@backtickjs/bundler";
36
36
  import { cs } from "@backtickjs/core";
37
- import { createRoot } from "@backtickjs/react/client";
37
+ import { createRoot } from "react-dom/client" with { backtick: "client" };
38
38
  import { Home } from "./Home.js";
39
39
 
40
40
  const element = <Home />;
41
- const bundle = await bundler.build({
41
+ const build = await bundler.build({
42
42
  input: cs`$createRoot(document.getElementById("app")!).render($element)`,
43
43
  modules: {
44
44
  react: "19.2.3",
@@ -46,23 +46,23 @@ const bundle = await bundler.build({
46
46
  "react-dom/client": "19.2.3",
47
47
  },
48
48
  });
49
- const { code } = bundle.generate({ format: "es", sourcemap: "inline" });
49
+ const { code } = build.generate({ format: "es", sourcemap: "inline" });
50
50
  ```
51
51
 
52
52
  ### `modules`
53
53
 
54
- The modules the client provides, by specifier, each at the exact version of the package it comes from: `"react-dom/client": "19.2.3"`. The server decides which to bundle for: one app version, or one per build with [`@backtickjs/builds`](https://github.com/backtickjs/backtick/tree/main/packages/builds). Those modules are left out of the bundle, which imports (`es`) or requires (`cjs`) them. `build` rejects a script that imports from any other module, or whose import needs a range that doesn't include the version given: an adapter's (`^19.2.3` for `@backtickjs/react`) or one written with `createImport`.
54
+ The modules the client provides, by specifier, each at the exact version of the package it comes from: `"react-dom/client": "19.2.3"`. The server decides which to bundle for: one app version, or one per build with [`@backtickjs/builds`](https://github.com/backtickjs/backtick/tree/main/packages/builds). Those modules are left out of the bundle, which imports (`es`) or requires (`cjs`) them. `build` rejects a script that imports from any other module, or whose import is typed against a version the one given isn't compatible with: an earlier one, or another major. `19.2.3` for `react` takes any later 19.x.
55
55
 
56
56
  `supports(modules, specifier, range)` makes the same check, for a server choosing what to draw for a client: `supports(modules, "expo-haptics", "^15")`.
57
57
 
58
58
  ### What crosses into a script
59
59
 
60
- Spliced values are written into the bundle as data, never as code. What can't cross, `build` rejects before anything reaches the client; [Errors](https://backtickjs.com/docs/errors#from-the-bundler) has each message and its fix.
60
+ Spliced values are written into the bundle as data, never as code. What can't cross, `build` rejects before anything reaches the client; [Errors](https://backtickjs.com/docs/errors/#from-the-bundler) has each message and its fix.
61
61
 
62
62
  ### Formats
63
63
 
64
64
  - `"es"`: an ES module, for a web page. Packages are imported by specifier, which the page's import map resolves.
65
- - `"cjs"`: CommonJS, for a client that provides `require` itself, as a React Native app does through `evaluate`.
65
+ - `"cjs"`: CommonJS, for a client that provides `require` itself, as a React Native app does through `execRoot`.
66
66
 
67
67
  ### Source maps
68
68
 
@@ -70,17 +70,16 @@ Spliced values are written into the bundle as data, never as code. What can't cr
70
70
 
71
71
  ## API
72
72
 
73
- - `bundler.build({ input, modules })`: runs the server components in `input` and returns a `Bundle`. Async.
74
- - `Bundle.generate({ format, sourcemap })`: writes the bundle; returns `{ code, map }`, where `map` is `null` without a source map.
75
- - Types: `BuildOptions`, `OutputOptions`, `OutputChunk`, `Bundle`.
73
+ - `bundler.build({ input, modules })`: runs the server components in `input` and returns a `Build`. Async.
74
+ - `Build.generate({ format, sourcemap })`: writes the bundle; returns `{ code, map }`, where `code` is a `Bundle<T>` (from `@backtickjs/core`), typed by what `input` is on the client, and `map` is `null` without a source map.
75
+ - Types: `BuildOptions`, `OutputOptions`, `OutputChunk`, `Build`.
76
76
 
77
77
  ## Related
78
78
 
79
- - [`@backtickjs/core`](https://github.com/backtickjs/backtick/tree/main/packages/core): the `cs` tag
80
- - [`@backtickjs/react-native-client`](https://github.com/backtickjs/backtick/tree/main/packages/react-native-client): runs a `cjs` bundle in a React Native app
81
- - [`@backtickjs/react`](https://github.com/backtickjs/backtick/tree/main/adapters/react), [`@backtickjs/react-native`](https://github.com/backtickjs/backtick/tree/main/adapters/react-native), [`@backtickjs/solid-js`](https://github.com/backtickjs/backtick/tree/main/adapters/solid-js): framework adapters
82
- - [How it works](https://backtickjs.com/docs/how-it-works)
83
- - [Errors](https://backtickjs.com/docs/errors)
79
+ - [`@backtickjs/core`](https://github.com/backtickjs/backtick/tree/main/packages/core): the `cs` tag, and `execRoot`, which runs a bundle in the app
80
+ - [`@backtickjs/jsx-react`](https://github.com/backtickjs/backtick/tree/main/packages/jsx-react), [`@backtickjs/jsx-solid`](https://github.com/backtickjs/backtick/tree/main/packages/jsx-solid): each framework's JSX
81
+ - [How it works](https://backtickjs.com/docs/how-it-works/)
82
+ - [Errors](https://backtickjs.com/docs/errors/)
84
83
 
85
84
  ## License
86
85
 
@@ -1,4 +1,4 @@
1
- import { type ClientModule } from "@backtickjs/core";
1
+ import { type ScriptModule } from "@backtickjs/core";
2
2
  import type { Names } from "../print/code.js";
3
3
  import type { Modules } from "../modules.js";
4
4
  /**
@@ -7,9 +7,9 @@ import type { Modules } from "../modules.js";
7
7
  * root, as code; and what they import.
8
8
  */
9
9
  export interface BundleTree {
10
- readonly modules: readonly (readonly [string, ClientModule])[];
10
+ readonly modules: readonly (readonly [string, ScriptModule])[];
11
11
  readonly constants: readonly (readonly [string, string])[];
12
12
  readonly root: string;
13
13
  readonly names: Names;
14
14
  }
15
- export declare function buildBundle(value: unknown, provided: Modules): Promise<BundleTree>;
15
+ export declare function buildBundle(spliceable: unknown, provided: Modules): Promise<BundleTree>;
@@ -1,6 +1,6 @@
1
- import { isClientImport, isClientScript, isJsxElement, } from "@backtickjs/core";
1
+ import { isClientExec, isClientImport, isClientScript, isJsxElement, } from "@backtickjs/core";
2
2
  import { expandServerComponents } from "./expandServerComponents.js";
3
- import { bindingsOf, capturesOf } from "./params.js";
3
+ import { bindingsOf, capturesOf, isValue } from "./params.js";
4
4
  import { sourceName } from "./bindingKey.js";
5
5
  import { array, arrow, call, createNames, imported, literal, object, } from "../print/code.js";
6
6
  // Names a binding may not take: what strict code cannot bind. Every name the
@@ -25,7 +25,7 @@ const rootScope = () => ({ bindings: new Set(), read: new Set() });
25
25
  // name, a capture is threaded under that one name the whole way down — an
26
26
  // intermediate script that binds a same-looking variable has a different
27
27
  // unique name, so there is nothing to disambiguate and nothing to rename.
28
- export async function buildBundle(value, provided) {
28
+ export async function buildBundle(spliceable, provided) {
29
29
  const names = createNames(provided);
30
30
  // Each script's number, in the order rendering first reaches it. Two
31
31
  // scripts written at one source location are one declaration, so the first
@@ -86,21 +86,19 @@ export async function buildBundle(value, provided) {
86
86
  const passKeys = (target, hole) => bindingsOf(target.module.params[hole]);
87
87
  // A script's label: `$cs` and its number.
88
88
  const labelOf = (target) => `$cs${numbers.get(target)}`;
89
- // Every function the bundle writes is a closure: a function script, and the
90
- // thunk a splice is handed over as. One whose code reads nothing of the
89
+ // The thunk a splice is handed over as. One whose code reads nothing of the
91
90
  // scope it's written in, beyond its own parameters, is the same function
92
91
  // wherever it's written, so the bundle makes it once, as a constant, and
93
- // the same code anywhere else is that constant: a client component keeps
94
- // its identity across renders, and a value spliced at every level of a deep
95
- // composition is written once per level, not once per path. Making a
96
- // function runs nothing, so sharing one isn't observable; everything is
97
- // still rendered where it stands.
92
+ // the same code anywhere else is that constant: a value spliced at every
93
+ // level of a deep composition is written once per level, not once per path.
94
+ // A thunk is the bundle's own, never the script's, so sharing one isn't
95
+ // observable; everything is still rendered where it stands.
98
96
  const constants = [];
99
97
  const byCode = new Map();
100
- // `write` renders a closure's code in a scope that records what it reads:
101
- // a constant's label if it read nothing of `scope` beyond `own`, its
98
+ // `write` renders a thunk's code in a scope that records what it reads: a
99
+ // constant's label if it read nothing of `scope` beyond `own`, its
102
100
  // parameters, or else the code, written where it's used.
103
- const closure = (scope, own, write, name) => {
101
+ const thunk = (scope, own, write) => {
104
102
  const read = new Set();
105
103
  const code = write({
106
104
  bindings: new Set([...scope.bindings, ...own]),
@@ -113,27 +111,39 @@ export async function buildBundle(value, provided) {
113
111
  }
114
112
  let label = byCode.get(code);
115
113
  if (label === undefined) {
116
- label = `${name}${constants.length}`;
114
+ label = `$thunk${constants.length}`;
117
115
  byCode.set(code, label);
118
116
  constants.push([label, code]);
119
117
  }
120
118
  return label;
121
119
  };
122
- // A `once` script is one value: its code run at the top of the bundle,
123
- // where nothing encloses it, and every read is that constant. One per
124
- // script, which is one per call of `once`, not per code: two runs of a host
125
- // function that each make a context are two contexts, as two calls of
126
- // `createContext` are. Running code is observable, so unlike a function it
127
- // is never shared by code.
120
+ // A function, a class and a `once` script are each one value (see
121
+ // `isValue`): its code run at the top of the bundle, where nothing encloses
122
+ // it, and every read is that constant. One per script, not per code: two
123
+ // runs of a host function that each make a function are two functions, and
124
+ // two that each make a context two contexts, as in plain TypeScript.
125
+ //
126
+ // A function or a class that reads a variable of the scope it's read in,
127
+ // itself or through what it's handed, is made there instead, as one
128
+ // declared in a function is. A `once` script that does is refused.
128
129
  const values = new Map();
129
- const valueOf = (script) => {
130
+ const valueOf = (script, scope) => {
130
131
  let label = values.get(script);
131
- if (label === undefined) {
132
- const code = call(labelOf(scriptFor(script)), exprCallArgs(script, rootScope()));
133
- label = `$value${constants.length}`;
134
- values.set(script, label);
135
- constants.push([label, code]);
132
+ if (label !== undefined) {
133
+ return label;
136
134
  }
135
+ const at = script.once
136
+ ? rootScope()
137
+ : { bindings: scope.bindings, read: new Set() };
138
+ const code = call(labelOf(scriptFor(script)), exprCallArgs(script, at));
139
+ const outside = [...at.read].filter((key) => scope.bindings.has(key));
140
+ if (outside.length > 0) {
141
+ outside.forEach((key) => scope.read.add(key));
142
+ return code;
143
+ }
144
+ label = `$value${constants.length}`;
145
+ values.set(script, label);
146
+ constants.push([label, code]);
137
147
  return label;
138
148
  };
139
149
  // Writes a value as the code it becomes: composition as data, which is what
@@ -141,34 +151,34 @@ export async function buildBundle(value, provided) {
141
151
  // what to hand it; everything else is its literal form. Rendered in order,
142
152
  // one value after the other, so the table follows the order rendering first
143
153
  // reached each script. Expansion has refused cycles, so it ends.
144
- const render = (value, scope = rootScope()) => {
145
- if (isClientScript(value)) {
146
- if (value.once) {
147
- return valueOf(value);
154
+ const render = (spliceable, scope = rootScope()) => {
155
+ if (isClientScript(spliceable)) {
156
+ if (isValue(spliceable)) {
157
+ return valueOf(spliceable, scope);
148
158
  }
149
- const target = scriptFor(value);
150
- if (target.module.kind !== "function") {
151
- return call(labelOf(target), exprCallArgs(value, scope));
152
- }
153
- return closure(scope, [], (inner) => call(labelOf(target), exprCallArgs(value, inner)), "$function");
159
+ return call(labelOf(scriptFor(spliceable)), exprCallArgs(spliceable, scope));
160
+ }
161
+ if (isJsxElement(spliceable)) {
162
+ return renderJsx(spliceable);
154
163
  }
155
- if (isJsxElement(value)) {
156
- return renderJsx(value);
164
+ if (isClientImport(spliceable)) {
165
+ return imported(names, spliceable);
157
166
  }
158
- if (isClientImport(value)) {
159
- return imported(names, value);
167
+ if (isClientExec(spliceable)) {
168
+ names.exec = true;
169
+ return "$exec";
160
170
  }
161
- if (value === null ||
162
- value === undefined ||
163
- typeof value === "number" ||
164
- typeof value === "bigint" ||
165
- typeof value === "string" ||
166
- typeof value === "boolean") {
167
- return literal(value);
171
+ if (spliceable === null ||
172
+ spliceable === undefined ||
173
+ typeof spliceable === "number" ||
174
+ typeof spliceable === "bigint" ||
175
+ typeof spliceable === "string" ||
176
+ typeof spliceable === "boolean") {
177
+ return literal(spliceable);
168
178
  }
169
- if (Array.isArray(value)) {
179
+ if (Array.isArray(spliceable)) {
170
180
  const elements = [];
171
- for (const element of value) {
181
+ for (const element of spliceable) {
172
182
  elements.push(render(element, scope));
173
183
  }
174
184
  return array(elements);
@@ -176,8 +186,8 @@ export async function buildBundle(value, provided) {
176
186
  // A host function is host code, which never reaches the client: client
177
187
  // code is written in a script, and reaches another as one.
178
188
  // A server component among them, written as a tag: `<$Rule />`.
179
- if (typeof value === "function") {
180
- const { name } = value;
189
+ if (typeof spliceable === "function") {
190
+ const { name } = spliceable;
181
191
  throw new Error((name === ""
182
192
  ? "Can't splice a host function"
183
193
  : `Can't splice the host function \`${name}\``) +
@@ -186,7 +196,7 @@ export async function buildBundle(value, provided) {
186
196
  "server component, draw it with a tag in a braced splice: " +
187
197
  `\`{\${<${/^[A-Z]/.test(name) ? name : "Name"} />}}\`.`);
188
198
  }
189
- if (typeof value !== "object") {
199
+ if (typeof spliceable !== "object") {
190
200
  throw new Error("Can't splice a symbol: a bundle can't write one that is the same " +
191
201
  "symbol on the client. Splice a string, and make the symbol from it " +
192
202
  "in a script: cs`Symbol.for($key)`.");
@@ -196,14 +206,14 @@ export async function buildBundle(value, provided) {
196
206
  // vanish — so fail loudly instead. An object with behaviour is built by a
197
207
  // client function: `state` for what it holds, arrows for what may be done
198
208
  // to it.
199
- const prototype = Object.getPrototypeOf(value);
209
+ const prototype = Object.getPrototypeOf(spliceable);
200
210
  if (prototype !== Object.prototype && prototype !== null) {
201
- const name = value.constructor?.name ?? "an unknown class";
211
+ const name = spliceable.constructor?.name ?? "an unknown class";
202
212
  throw new Error(`Can't splice this \`${name}\` instance: only plain objects cross into ` +
203
213
  "a client script. Build one with a client function instead.");
204
214
  }
205
215
  const entries = [];
206
- for (const [key, entry] of Object.entries(value)) {
216
+ for (const [key, entry] of Object.entries(spliceable)) {
207
217
  entries.push([key, render(entry, scope)]);
208
218
  }
209
219
  return object(entries);
@@ -239,7 +249,7 @@ export async function buildBundle(value, provided) {
239
249
  // nested inside it.
240
250
  const passed = [...passKeys(target, index), ...capturesOf(target)];
241
251
  // A thunk taking them, the splice rendered inside it.
242
- parts.push(closure(scope, passed, (inner) => arrow(passed.map(displayName), render(arg, inner)), "$thunk"));
252
+ parts.push(thunk(scope, passed, (inner) => arrow(passed.map(displayName), render(arg, inner))));
243
253
  }
244
254
  for (const key of capturesOf(target)) {
245
255
  parts.push(capExpr(key, scope));
@@ -263,7 +273,7 @@ export async function buildBundle(value, provided) {
263
273
  };
264
274
  // Every server component first, so siblings run at once; then the drawing,
265
275
  // in order. Nothing encloses the root, so nothing it holds can capture.
266
- const root = render(await expandServerComponents(value));
276
+ const root = render(await expandServerComponents(spliceable));
267
277
  // In table order, which is the order rendering first reached each script.
268
278
  const modules = [...numbers.keys()].map((script) => [labelOf(script), script.module]);
269
279
  return { modules, constants, root, names };
@@ -1 +1 @@
1
- {"version":3,"file":"buildBundle.js","sourceRoot":"","sources":["../../src/bundle/buildBundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,cAAc,EACd,cAAc,EACd,YAAY,GAEb,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACL,KAAK,EACL,KAAK,EACL,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,OAAO,EACP,MAAM,GACP,MAAM,kBAAkB,CAAC;AAkB1B,6EAA6E;AAC7E,4EAA4E;AAC5E,4BAA4B;AAC5B,MAAM,QAAQ,GAAG,CAAC,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAUzD,MAAM,SAAS,GAAG,GAAU,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI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AChE,8BAA8B,CACjC,CAAC;IACJ,CAAC,CAAC;IAEF,2EAA2E;IAC3E,wEAAwE;IACxE,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,sBAAsB,CAAC,UAAU,CAAC,CAAC,CAAC;IAC9D,0EAA0E;IAC1E,MAAM,OAAO,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CACrC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,CAAU,CACtD,CAAC;IACF,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAC7C,CAAC"}
@@ -3,5 +3,5 @@ interface Ancestors {
3
3
  readonly value: object;
4
4
  readonly parent: Ancestors | null;
5
5
  }
6
- export declare function expandServerComponents(value: unknown, ancestors?: Ancestors | null, values?: Map<ClientScript, Promise<unknown>>): Promise<unknown>;
6
+ export declare function expandServerComponents(spliceable: unknown, ancestors?: Ancestors | null, values?: Map<ClientScript, Promise<unknown>>): Promise<unknown>;
7
7
  export {};
@@ -1,4 +1,5 @@
1
1
  import { isClientImport, isClientScript, isJsxElement, } from "@backtickjs/core";
2
+ import { isValue } from "./params.js";
2
3
  const CYCLE_ERROR = "Can't splice a value that contains itself: a bundle writes each value " +
3
4
  "out in full, so a cycle never ends. Break the cycle before splicing it.";
4
5
  const contains = (ancestors, value) => {
@@ -18,58 +19,59 @@ const contains = (ancestors, value) => {
18
19
  // the client code it bottoms out in reaches the bundle. A value holding no
19
20
  // server component comes back as the same object.
20
21
  //
21
- // A `once` script is one value, so what it splices is expanded once, however
22
- // many places read it: a server component inside it runs once. `values` holds
22
+ // A function, a class and a `once` script are each one value (see `isValue`),
23
+ // so what one splices is expanded once, however many places read it: a server
24
+ // component inside it runs once. `values` holds
23
25
  // each one's expansion for the call.
24
- export async function expandServerComponents(value, ancestors = null, values = new Map()) {
25
- if (typeof value !== "object" || value === null) {
26
- return value;
26
+ export async function expandServerComponents(spliceable, ancestors = null, values = new Map()) {
27
+ if (typeof spliceable !== "object" || spliceable === null) {
28
+ return spliceable;
27
29
  }
28
- if (contains(ancestors, value)) {
30
+ if (contains(ancestors, spliceable)) {
29
31
  throw new Error(CYCLE_ERROR);
30
32
  }
31
- const inside = { value, parent: ancestors };
33
+ const inside = { value: spliceable, parent: ancestors };
32
34
  const all = (entries) => Promise.all(entries.map((entry) => expandServerComponents(entry, inside, values)));
33
- if (isJsxElement(value)) {
34
- const { type } = value;
35
+ if (isJsxElement(spliceable)) {
36
+ const { type } = spliceable;
35
37
  // A tag the client draws is left for rendering to refuse.
36
38
  if (typeof type !== "function" || isClientImport(type)) {
37
- return value;
39
+ return spliceable;
38
40
  }
39
- return expandServerComponents(await type(value.props), inside, values);
41
+ return expandServerComponents(await type(spliceable.props), inside, values);
40
42
  }
41
- if (isClientScript(value)) {
43
+ if (isClientScript(spliceable)) {
42
44
  const expanded = async () => {
43
- const args = await all(value.args);
44
- return args.every((arg, index) => arg === value.args[index])
45
- ? value
46
- : { ...value, args };
45
+ const args = await all(spliceable.args);
46
+ return args.every((arg, index) => arg === spliceable.args[index])
47
+ ? spliceable
48
+ : { ...spliceable, args };
47
49
  };
48
- if (!value.once) {
50
+ if (!isValue(spliceable)) {
49
51
  return expanded();
50
52
  }
51
- let made = values.get(value);
53
+ let made = values.get(spliceable);
52
54
  if (made === undefined) {
53
55
  made = expanded();
54
- values.set(value, made);
56
+ values.set(spliceable, made);
55
57
  }
56
58
  return made;
57
59
  }
58
- if (Array.isArray(value)) {
59
- const elements = await all(value);
60
- return elements.every((element, index) => element === value[index])
61
- ? value
60
+ if (Array.isArray(spliceable)) {
61
+ const elements = await all(spliceable);
62
+ return elements.every((element, index) => element === spliceable[index])
63
+ ? spliceable
62
64
  : elements;
63
65
  }
64
66
  // Only plain objects cross; rendering refuses anything else.
65
- const prototype = Object.getPrototypeOf(value);
67
+ const prototype = Object.getPrototypeOf(spliceable);
66
68
  if (prototype !== Object.prototype && prototype !== null) {
67
- return value;
69
+ return spliceable;
68
70
  }
69
- const entries = Object.entries(value);
71
+ const entries = Object.entries(spliceable);
70
72
  const expanded = await all(entries.map(([, entry]) => entry));
71
73
  if (expanded.every((entry, index) => entry === entries[index][1])) {
72
- return value;
74
+ return spliceable;
73
75
  }
74
76
  // Defined, not assigned, so a `__proto__` key stays a key.
75
77
  return Object.fromEntries(entries.map(([key], index) => [key, expanded[index]]));
@@ -1 +1 @@
1
- {"version":3,"file":"expandServerComponents.js","sourceRoot":"","sources":["../../src/bundle/expandServerComponents.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EACd,cAAc,EACd,YAAY,GACb,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,GACf,wEAAwE;IACxE,yEAAyE,CAAC;AAS5E,MAAM,QAAQ,GAAG,CAAC,SAA2B,EAAE,KAAa,EAAW,EAAE;IACvE,KAAK,IAAI,EAAE,GAAG,SAAS,EAAE,EAAE,KAAK,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC;QACrD,IAAI,EAAE,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,8EAA8E;AAC9E,6EAA6E;AAC7E,0EAA0E;AAC1E,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,2EAA2E;AAC3E,kDAAkD;AAClD,EAAE;AACF,6EAA6E;AAC7E,8EAA8E;AAC9E,qCAAqC;AACrC,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,KAAc,EACd,YAA8B,IAAI,EAClC,SAAS,IAAI,GAAG,EAAkC;IAElD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,QAAQ,CAA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1,4 @@
1
1
  import type { ClientScript, Param } from "@backtickjs/core";
2
2
  export declare function bindingsOf(param: Param | undefined): readonly string[];
3
+ export declare function isValue(script: ClientScript): boolean;
3
4
  export declare function capturesOf(script: ClientScript): readonly string[];
@@ -3,6 +3,15 @@
3
3
  export function bindingsOf(param) {
4
4
  return param?.kind === "splice" ? param.bindings : [];
5
5
  }
6
+ // Whether a script is one value for the bundle, made once at its top: a
7
+ // `once` script, a function and a class, as a module-level one is. A function
8
+ // or a class that reads a variable of the script around it, itself or through
9
+ // what it's handed, is made where it's read instead (see `valueOf`).
10
+ export function isValue(script) {
11
+ return (script.once === true ||
12
+ script.module.kind === "function" ||
13
+ script.module.kind === "class");
14
+ }
6
15
  // The binding keys a script captures, in parameter order.
7
16
  export function capturesOf(script) {
8
17
  return script.module.params.flatMap((param) => param.kind === "capture" ? [param.key] : []);
@@ -1 +1 @@
1
- {"version":3,"file":"params.js","sourceRoot":"","sources":["../../src/bundle/params.ts"],"names":[],"mappings":"AAEA,4EAA4E;AAE5E,6DAA6D;AAC7D,MAAM,UAAU,UAAU,CAAC,KAAwB;IACjD,OAAO,KAAK,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;AACxD,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,UAAU,CAAC,MAAoB;IAC7C,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAC5C,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAC5C,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"params.js","sourceRoot":"","sources":["../../src/bundle/params.ts"],"names":[],"mappings":"AAEA,4EAA4E;AAE5E,6DAA6D;AAC7D,MAAM,UAAU,UAAU,CAAC,KAAwB;IACjD,OAAO,KAAK,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;AACxD,CAAC;AAED,wEAAwE;AACxE,8EAA8E;AAC9E,8EAA8E;AAC9E,qEAAqE;AACrE,MAAM,UAAU,OAAO,CAAC,MAAoB;IAC1C,OAAO,CACL,MAAM,CAAC,IAAI,KAAK,IAAI;QACpB,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,UAAU;QACjC,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO,CAC/B,CAAC;AACJ,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,UAAU,CAAC,MAAoB;IAC7C,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAC5C,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAC5C,CAAC;AACJ,CAAC"}
package/dist/bundler.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Spliceable, SplicesAs } from "@backtickjs/core";
1
+ import type { Bundle, Spliceable, Spliced, SplicesAs } from "@backtickjs/core";
2
2
  import type { Modules } from "./modules.js";
3
3
  export interface BuildOptions<T = Spliceable> {
4
4
  readonly input: T;
@@ -8,26 +8,30 @@ export interface OutputOptions {
8
8
  readonly format: "es" | "cjs";
9
9
  readonly sourcemap?: false | "inline" | "hidden";
10
10
  }
11
- /** What `generate` writes: the code, and its map where one was asked for. */
12
- export interface OutputChunk {
13
- readonly code: string;
11
+ /**
12
+ * What `generate` writes: the bundle, which runs to a `T`, and its map where
13
+ * one was asked for.
14
+ */
15
+ export interface OutputChunk<T = unknown> {
16
+ readonly code: Bundle<T>;
14
17
  readonly map: string | null;
15
18
  }
16
- /** A built bundle, written out by `generate`. */
17
- export interface Bundle {
18
- generate(options: OutputOptions): OutputChunk;
19
+ /** What `build` makes of a value that is a `T` on the client, written out by
20
+ * `generate`. */
21
+ export interface Build<T = unknown> {
22
+ generate(options: OutputOptions): OutputChunk<T>;
19
23
  }
20
24
  /**
21
25
  * What runs your components and hands back what they drew, shaped as Rollup
22
26
  * is: a build, then output from it.
23
27
  *
24
- * const bundle = await bundler.build({ input: <Home />, modules });
25
- * const { code, map } = bundle.generate({ format: "es", sourcemap: "hidden" });
28
+ * const build = await bundler.build({ input: <Home />, modules });
29
+ * const { code, map } = build.generate({ format: "es", sourcemap: "hidden" });
26
30
  *
27
- * The module's default export is the value (CommonJS: `module.exports`). A
28
- * namespace rather than a bare function, so `bundle` stays a name a caller can
29
- * give what comes back.
31
+ * `code` is the bundle, a module whose default export is the value (CommonJS:
32
+ * `module.exports`). A namespace rather than a bare function, so `build`
33
+ * stays a name a caller can give what comes back.
30
34
  */
31
35
  export declare const bundler: {
32
- build<T extends [T] extends [SplicesAs<T>] ? unknown : Spliceable>({ input, modules, }: BuildOptions<T>): Promise<Bundle>;
36
+ build<T extends [T] extends [SplicesAs<T>] ? unknown : Spliceable>({ input, modules, }: BuildOptions<T>): Promise<Build<Spliced<T>>>;
33
37
  };
package/dist/bundler.js CHANGED
@@ -4,12 +4,12 @@ import { printBundle } from "./print/printBundle.js";
4
4
  * What runs your components and hands back what they drew, shaped as Rollup
5
5
  * is: a build, then output from it.
6
6
  *
7
- * const bundle = await bundler.build({ input: <Home />, modules });
8
- * const { code, map } = bundle.generate({ format: "es", sourcemap: "hidden" });
7
+ * const build = await bundler.build({ input: <Home />, modules });
8
+ * const { code, map } = build.generate({ format: "es", sourcemap: "hidden" });
9
9
  *
10
- * The module's default export is the value (CommonJS: `module.exports`). A
11
- * namespace rather than a bare function, so `bundle` stays a name a caller can
12
- * give what comes back.
10
+ * `code` is the bundle, a module whose default export is the value (CommonJS:
11
+ * `module.exports`). A namespace rather than a bare function, so `build`
12
+ * stays a name a caller can give what comes back.
13
13
  */
14
14
  export const bundler = {
15
15
  async build({ input, modules, }) {
@@ -18,7 +18,9 @@ export const bundler = {
18
18
  const tree = await buildBundle(input, modules);
19
19
  return {
20
20
  generate: ({ format, sourcemap = false }) => {
21
- const { code, map } = printBundle(tree, format);
21
+ const printed = printBundle(tree, format);
22
+ const code = printed.code;
23
+ const map = printed.map;
22
24
  if (sourcemap === false) {
23
25
  return { code, map: null };
24
26
  }
@@ -26,7 +28,10 @@ export const bundler = {
26
28
  return { code, map };
27
29
  }
28
30
  const url = `data:application/json;charset=utf-8,${encodeURIComponent(map)}`;
29
- return { code: `${code}\n//# sourceMappingURL=${url}`, map };
31
+ return {
32
+ code: `${code}\n//# sourceMappingURL=${url}`,
33
+ map,
34
+ };
30
35
  },
31
36
  };
32
37
  },
@@ -1 +1 @@
1
- {"version":3,"file":"bundler.js","sourceRoot":"","sources":["../src/bundler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAiCrD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,KAAK,CAAC,KAAK,CAA8D,EACvE,KAAK,EACL,OAAO,GACS;QAChB,0EAA0E;QAC1E,uEAAuE;QACvE,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC/C,OAAO;YACL,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,GAAG,KAAK,EAAE,EAAE,EAAE;gBAC1C,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;gBAChD,IAAI,SAAS,KAAK,KAAK,EAAE,CAAC;oBACxB,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;gBAC7B,CAAC;gBACD,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;oBAC3B,OAAO,EAAE,IAAI,EAAE,GAAG,E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