solid-optimizer 0.4.1 → 1.0.0-next.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 +74 -47
- package/dist/{compile-BQuBDA0Q.d.mts → compile-BRCj4UN7.d.mts} +15 -22
- package/dist/compile-BRCj4UN7.d.mts.map +1 -0
- package/dist/{compile-CqhOfBvG.mjs → compile-BpoiBa6b.mjs} +943 -670
- package/dist/compile-BpoiBa6b.mjs.map +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/vite.d.mts +3 -10
- package/dist/vite.d.mts.map +1 -1
- package/dist/vite.mjs +305 -204
- package/dist/vite.mjs.map +1 -1
- package/package.json +10 -11
- package/src/compile.ts +16 -40
- package/src/constants.ts +42 -2
- package/src/context.ts +3 -0
- package/src/copy-size.ts +73 -0
- package/src/fold.ts +619 -17
- package/src/inline.ts +352 -292
- package/src/memo.ts +161 -30
- package/src/provider.ts +40 -75
- package/src/scope.ts +14 -1
- package/src/size.ts +35 -75
- package/src/vite/globals.ts +67 -0
- package/src/vite/index.ts +279 -264
- package/src/vite/inject.ts +14 -4
- package/src/vite/runtime.ts +23 -3
- package/dist/compile-BQuBDA0Q.d.mts.map +0 -1
- package/dist/compile-CqhOfBvG.mjs.map +0 -1
- package/src/server.ts +0 -275
package/README.md
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
# solid-optimizer
|
|
2
2
|
|
|
3
|
-
> Experimental compile-time optimizer for SolidJS
|
|
3
|
+
> Experimental compile-time optimizer for SolidJS 2.0
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/solid-optimizer)
|
|
6
6
|
|
|
7
7
|
`solid-optimizer` rewrites JSX before Solid's JSX transform lowers it. It inlines components and resolves control flow whose outcome is known at build time, so more markup lands in fewer templates.
|
|
8
8
|
|
|
9
|
+

|
|
10
|
+
|
|
9
11
|
## Install
|
|
10
12
|
|
|
13
|
+
The Solid 2.0 version is published under the `next` tag. The `latest` version is for Solid 1.x.
|
|
14
|
+
|
|
11
15
|
```bash
|
|
12
|
-
npm i -D solid-optimizer
|
|
16
|
+
npm i -D solid-optimizer@next
|
|
13
17
|
```
|
|
14
18
|
|
|
15
19
|
```bash
|
|
16
|
-
yarn add -D solid-optimizer
|
|
20
|
+
yarn add -D solid-optimizer@next
|
|
17
21
|
```
|
|
18
22
|
|
|
19
23
|
```bash
|
|
20
|
-
pnpm add -D solid-optimizer
|
|
24
|
+
pnpm add -D solid-optimizer@next
|
|
21
25
|
```
|
|
22
26
|
|
|
23
27
|
## Usage
|
|
@@ -44,10 +48,10 @@ The input and the output both keep their JSX. Run the JSX transform after `compi
|
|
|
44
48
|
- `sharedComponents` maps top-level components that other modules use too to the number of modules that use them, this one included. Inlining one only counts its share of the declaration. `0` keeps the declaration whatever is inlined.
|
|
45
49
|
- `contexts` turns context provider removal on or off. Defaults to `true`.
|
|
46
50
|
- `memos` turns memo inlining on or off. Defaults to `true`.
|
|
47
|
-
- `server` compiles for the server. It removes `createEffect` and `onMount`, and reduces `untrack`, `batch`, `startTransition`, `createDeferred`, `getListener`, `createMemo`, `createRenderEffect`, and `createComputed` to what they do on the server. Defaults to `false`.
|
|
48
51
|
- `builtIns` lists the names of Solid's built-in components. A tag only folds when it is one of them. An empty list turns control-flow folding off.
|
|
49
|
-
- `moduleSources` lists the modules Solid's built-ins are imported from. Defaults to `['solid-js', '
|
|
52
|
+
- `moduleSources` lists the modules Solid's built-ins are imported from. Defaults to `['solid-js', '@solidjs/web']`.
|
|
50
53
|
- `importedConstants` holds the constants of imported modules, keyed by the import specifier as the code writes it, then by export name. An import of one of them folds like a local `const`. See [Constants from other modules](#constants-from-other-modules).
|
|
54
|
+
- `globalConstants` holds values of global names and paths, such as `{ __DEV__: false, 'import.meta.env.MODE': 'production' }`. A path starts at `import.meta` or at a name the module does not declare, and folds like a constant.
|
|
51
55
|
- `maxPasses` limits how many rounds run. Compilation stops early once a round changes nothing. Defaults to `10`.
|
|
52
56
|
- `sourceMap` turns the source map on or off. Defaults to `true`.
|
|
53
57
|
- `report` records what the inline, provider, and memo passes leave alone, and why. The result lists them in `skipped`, each with its pass, a reason code, and a name. Defaults to `false`.
|
|
@@ -75,7 +79,7 @@ It keeps `export const` bindings whose value folds, a `let` the module never wri
|
|
|
75
79
|
|
|
76
80
|
## Vite
|
|
77
81
|
|
|
78
|
-
`solid-optimizer/vite` replaces
|
|
82
|
+
`solid-optimizer/vite` replaces `@solidjs/vite-plugin`. It takes the same options and wraps the official plugin, so SSR, server functions, and HMR keep working.
|
|
79
83
|
|
|
80
84
|
```js
|
|
81
85
|
// vite.config.js
|
|
@@ -87,7 +91,7 @@ export default defineConfig({
|
|
|
87
91
|
});
|
|
88
92
|
```
|
|
89
93
|
|
|
90
|
-
|
|
94
|
+
`@solidjs/vite-plugin` and `vite` are peer dependencies.
|
|
91
95
|
|
|
92
96
|
The plugin optimizes in one of two modes.
|
|
93
97
|
|
|
@@ -97,21 +101,20 @@ The plugin optimizes in one of two modes.
|
|
|
97
101
|
Both modes fold constants imported from other modules in the project.
|
|
98
102
|
|
|
99
103
|
- Each import is resolved and loaded by the bundler, so aliases, virtual modules, and plugins that rewrite the module are respected.
|
|
100
|
-
- A module with JSX is
|
|
101
|
-
- `define` and `import.meta.env` values
|
|
104
|
+
- A module with JSX is read from this plugin's own output for it. It is skipped when it imports the importer, directly or through other modules of the project, since the two transforms would wait for each other.
|
|
105
|
+
- `define` entries and `import.meta.env` values fold in both modes, when every build environment gives them the same primitive value. `import.meta.env.SSR` never folds, since the server and client builds differ on it.
|
|
102
106
|
- Dependencies are not read, and nothing is read while serving.
|
|
103
107
|
|
|
104
108
|
The optimizer is off while serving. Set `optimizer.dev` to run module mode in dev too.
|
|
105
109
|
|
|
106
110
|
### Options
|
|
107
111
|
|
|
108
|
-
The plugin takes every option of
|
|
112
|
+
The plugin takes every option of `@solidjs/vite-plugin`, plus `optimizer`.
|
|
109
113
|
|
|
110
|
-
- `optimizer: false` uses
|
|
114
|
+
- `optimizer: false` uses `@solidjs/vite-plugin` as it is.
|
|
111
115
|
- `optimizer.fold`, `optimizer.inline`, `optimizer.alwaysInline`, `optimizer.contexts`, `optimizer.memos`, and `optimizer.maxPasses` work like the `compile` options.
|
|
112
116
|
- `optimizer.mode` is `'auto'` by default. Set it to `'module'` to never keep JSX through bundling.
|
|
113
117
|
- `optimizer.dev` also optimizes while serving. Defaults to `false`.
|
|
114
|
-
- `optimizer.server` applies the `server` option in server builds. Defaults to `true`.
|
|
115
118
|
- `optimizer.report` reports what stays as written in each build, and why. `true` prints it. A function receives it instead, once per build environment. Defaults to `false`.
|
|
116
119
|
|
|
117
120
|
### Report
|
|
@@ -120,17 +123,17 @@ The plugin takes every option of `vite-plugin-solid`, plus `optimizer`.
|
|
|
120
123
|
|
|
121
124
|
```
|
|
122
125
|
solid-optimizer: what stays as written in client
|
|
123
|
-
inline
|
|
124
|
-
inline
|
|
125
|
-
inline no-host
|
|
126
|
+
inline lazy 4 About, Chart, Dashboard, Settings
|
|
127
|
+
inline copy-no-host 1 Home (./pages/Home)
|
|
128
|
+
inline no-host 1 Home
|
|
126
129
|
```
|
|
127
130
|
|
|
128
131
|
Each line is a pass, a reason, how many times it happened, and the names it happened to. The reasons for the inline pass:
|
|
129
132
|
|
|
130
133
|
- `props-use` and `view-use` mean the component uses its props in a way other than `props.name`, a spread onto an element, or a `merge()` or `omit()` view, such as passing them to a function.
|
|
131
134
|
- `component-params`, `component-body`, `component-return`, `component-async`, `component-recursive`, and `component-this` mean the component's own shape is not supported.
|
|
132
|
-
- `call-spread
|
|
133
|
-
- `no-host` means the component has statements, and the call is not in JSX a component
|
|
135
|
+
- `call-spread` and `call-namespace` mean the call site passes a spread or a namespaced attribute. `call-ref` means its `ref` is an expression other than a name or a function, and `ref-use` means the component uses `props.ref` other than as a `ref`.
|
|
136
|
+
- `no-host` means the component has statements, and the call is not in JSX that a component or one of Solid's callbacks returns. A `<Show>` child or a `fallback` is one such place.
|
|
134
137
|
- `size` means the copies would be larger than the calls.
|
|
135
138
|
- `lazy`, `imported`, `nested`, and `not-a-function` mean the tag is not a component declared at the top of the same module or chunk.
|
|
136
139
|
- A reason that starts with `copy-` is about copying a component from another module. `copy-package` means it comes from `node_modules`, `copy-cycle` means the two modules import each other, `copy-wrapper` means the component only returns a call of another component in its module, and `copy-size` means the copy was larger.
|
|
@@ -139,11 +142,11 @@ The provider pass reports `open-component`, `open-call`, `open-new`, `open-sprea
|
|
|
139
142
|
|
|
140
143
|
### Limits
|
|
141
144
|
|
|
142
|
-
- Chunk mode is skipped when the `babel` option is set
|
|
145
|
+
- Chunk mode is skipped when the `babel` option is set or `compiler` is `'babel'`, since those passes need each module.
|
|
143
146
|
- An export named `__so_local$name` is added to a module for each local binding its exported components need, so a copy in another module can import it. In chunk mode, entry modules get none.
|
|
144
147
|
- A component used in several chunks is copied into each of them, where each copy is no larger than its call.
|
|
145
148
|
- Components from dependencies in `node_modules` are not copied.
|
|
146
|
-
-
|
|
149
|
+
- `.tsrx` modules are lowered by the official plugin and are not optimized.
|
|
147
150
|
|
|
148
151
|
## Features
|
|
149
152
|
|
|
@@ -182,36 +185,40 @@ Solid then creates one template for `<main>` instead of two.
|
|
|
182
185
|
- A read of `props.name` becomes the attribute's expression. Solid passes dynamic props as getters, so the expression runs at every read, as before.
|
|
183
186
|
- A static prop that must be evaluated once, like a function read twice, is stored in a `const` first.
|
|
184
187
|
- `{props.children}`, and a prop whose value is JSX, splice their JSX in place so it joins the template.
|
|
185
|
-
- Statements in the component body move into the
|
|
188
|
+
- Statements in the component body move into the function whose returned JSX holds the call. The call must sit directly in that JSX, with only intrinsic elements and fragments around it. The function must run untracked, once each time it creates that JSX:
|
|
189
|
+
- a component;
|
|
190
|
+
- the child callback of `<For>` or `<Repeat>`;
|
|
191
|
+
- the child callback of `<Show>` or `<Match>`, when it takes the value;
|
|
192
|
+
- the callback given to `render`.
|
|
186
193
|
- Bindings declared in the component get fresh names in every copy.
|
|
187
194
|
- A component nothing else uses is removed.
|
|
188
195
|
|
|
189
196
|
A component inlines when all of these hold:
|
|
190
197
|
|
|
191
198
|
- It is declared once at the top level, with a capitalized name.
|
|
192
|
-
- Its parameter is one identifier that is only read as `props.name`, spread onto an element as `{...props}`, or passed to `
|
|
199
|
+
- Its parameter is one identifier that is only read as `props.name`, spread onto an element as `{...props}`, or passed to `merge()` and `omit()`. See below.
|
|
193
200
|
- Its body ends in the only `return`, and that `return` returns JSX.
|
|
194
201
|
- It does not use `this`, `arguments`, `super`, or `new.target`.
|
|
195
|
-
- The call site has no spread attribute
|
|
202
|
+
- The call site has no spread attribute and no namespaced attribute.
|
|
203
|
+
- A `ref` at the call site moves to the element the component gives `props.ref` to, when its value is a name, a function, or an array of them, and the component only uses `props.ref` as the `ref` of an element, of another component, or in a spread. Both run while the element is made, untracked, so the element gets the same ref.
|
|
196
204
|
|
|
197
|
-
The props can go through `
|
|
205
|
+
The props can go through `merge()` and `omit()` first, declared as a `const` in the component:
|
|
198
206
|
|
|
199
207
|
```jsx
|
|
200
208
|
function Button(props) {
|
|
201
|
-
const merged =
|
|
202
|
-
const
|
|
209
|
+
const merged = merge({ type: 'button' }, props);
|
|
210
|
+
const rest = omit(merged, 'label');
|
|
203
211
|
return (
|
|
204
212
|
<button type={merged.type} {...rest}>
|
|
205
|
-
{
|
|
213
|
+
{props.label}
|
|
206
214
|
</button>
|
|
207
215
|
);
|
|
208
216
|
}
|
|
209
217
|
```
|
|
210
218
|
|
|
211
219
|
- A default has to be a literal, like `'button'`, `0`, or `false`.
|
|
212
|
-
- `
|
|
213
|
-
- A view can only be read as `view.name`, spread onto an element, or passed to another `
|
|
214
|
-
- A prop that can be `undefined` falls back to the default behind it, the way `mergeProps()` reads it.
|
|
220
|
+
- `omit()` has to name its keys as string literals.
|
|
221
|
+
- A view can only be read as `view.name`, spread onto an element, or passed to another `merge()` or `omit()`.
|
|
215
222
|
- A spread becomes the attributes the call site passes, and it cannot repeat an attribute the element already has. Its `children` become the element's children, so the element must have none of its own.
|
|
216
223
|
|
|
217
224
|
Inlining accepts two differences:
|
|
@@ -238,7 +245,7 @@ Set `alwaysInline` to inline every component that can be.
|
|
|
238
245
|
|
|
239
246
|
### Context inlining
|
|
240
247
|
|
|
241
|
-
A context provider
|
|
248
|
+
A context provider whose readers are all visible is removed, and each read gets the provider's value.
|
|
242
249
|
|
|
243
250
|
```jsx
|
|
244
251
|
const Theme = createContext();
|
|
@@ -251,9 +258,9 @@ function Label() {
|
|
|
251
258
|
export function App() {
|
|
252
259
|
return (
|
|
253
260
|
<main>
|
|
254
|
-
<Theme
|
|
261
|
+
<Theme value="dark">
|
|
255
262
|
<Label />
|
|
256
|
-
</Theme
|
|
263
|
+
</Theme>
|
|
257
264
|
</main>
|
|
258
265
|
);
|
|
259
266
|
}
|
|
@@ -281,41 +288,61 @@ See [strategy.md](https://github.com/lxsmnsyc/solid-optimizer/blob/main/strategy
|
|
|
281
288
|
|
|
282
289
|
### Memo inlining
|
|
283
290
|
|
|
284
|
-
A `createMemo` whose result is new on every run,
|
|
291
|
+
A `createMemo` whose result is new on every run, such as an object, array, or JSX, never stops an update. When it is also read once, as the whole of a tracked JSX expression, the read runs the computation itself.
|
|
285
292
|
|
|
286
293
|
```jsx
|
|
287
294
|
const style = createMemo(() => ({ color: color() }));
|
|
288
295
|
return <p style={style()} />;
|
|
289
296
|
```
|
|
290
297
|
|
|
291
|
-
becomes `<p style={{ color: color() }} />`.
|
|
298
|
+
becomes `<p style={{ color: color() }} />`. See [strategy.md](https://github.com/lxsmnsyc/solid-optimizer/blob/main/strategy.md) for the exact rules.
|
|
299
|
+
|
|
300
|
+
A memo whose computation folds to a literal never changes. Every call of it becomes the literal, however many there are, when each call comes after the declaration and nothing else uses the memo.
|
|
292
301
|
|
|
293
|
-
|
|
302
|
+
```jsx
|
|
303
|
+
const size = createMemo(() => 1 + 2);
|
|
304
|
+
return <p>{size() * 2}</p>;
|
|
305
|
+
```
|
|
294
306
|
|
|
295
|
-
|
|
307
|
+
becomes `<p>{6}</p>`.
|
|
296
308
|
|
|
297
|
-
|
|
298
|
-
- `untrack(fn)` and `batch(fn)` become `fn()`, and `startTransition(fn)` calls `fn()` and returns nothing.
|
|
299
|
-
- `createDeferred(source)` becomes `source`, and `getListener()` becomes `null`.
|
|
300
|
-
- `createMemo`, `createRenderEffect`, and `createComputed` run their function once, in place.
|
|
309
|
+
Solid's `children` helper over JSX, read once as an element's child, becomes that JSX. The helper resolves JSX the same way inserting it does, and nothing makes it run again.
|
|
301
310
|
|
|
302
|
-
|
|
311
|
+
```jsx
|
|
312
|
+
const c = children(() => <b>x</b>);
|
|
313
|
+
return <div>{c()}</div>;
|
|
314
|
+
```
|
|
303
315
|
|
|
304
|
-
|
|
316
|
+
becomes `<div><b>x</b></div>`. This is what a component that calls `children(() => props.children)` leaves once it is inlined with JSX children.
|
|
305
317
|
|
|
306
318
|
### Constant folding and control flow
|
|
307
319
|
|
|
308
|
-
This follows the `optimize` option of
|
|
320
|
+
This follows the `optimize` option of `@solidjs/compiler` ([solidjs/solid#3231](https://github.com/solidjs/solid/pull/3231)).
|
|
309
321
|
|
|
310
322
|
- Constant expressions fold, including `const` bindings and `let` bindings nothing writes to, at any scope.
|
|
311
323
|
- Branches that a constant condition never takes are removed. So are statements after a `return`, `throw`, `break`, or `continue`.
|
|
312
324
|
- `<Show when>` becomes its children or its `fallback`.
|
|
313
325
|
- `<For each>` becomes its `fallback` when `each` is an empty array literal or a falsy constant.
|
|
314
|
-
- `<
|
|
326
|
+
- `<For>` over a constant list becomes one copy of its row per item, when the copies are estimated to be no larger than the loop. The list is an array literal, or a `const` of one that only `<For>` reads and that is not exported. Each item is a primitive literal, or an object literal of them. The row has to be an arrow function whose body is JSX without a `ref` or a spread, and read the item as `item.key`, or as itself when it is a primitive.
|
|
327
|
+
|
|
328
|
+
```jsx
|
|
329
|
+
const LINKS = [
|
|
330
|
+
{ href: '/', label: 'Home' },
|
|
331
|
+
{ href: '/docs', label: 'Docs' },
|
|
332
|
+
];
|
|
333
|
+
<nav>
|
|
334
|
+
<For each={LINKS}>{(link) => <a href={link.href}>{link.label}</a>}</For>
|
|
335
|
+
</nav>;
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
becomes `<nav><a href={'/'}>{'Home'}</a><a href={'/docs'}>{'Docs'}</a></nav>`, which lowers to one template. Each row had its own owner, so this shifts the hydration keys after it.
|
|
339
|
+
|
|
340
|
+
- `<Repeat count>` becomes its `fallback` when `count` is below one.
|
|
315
341
|
- `<Switch>` drops each `<Match>` that is always false, and becomes the first `<Match>` that is always true.
|
|
316
|
-
- `<Dynamic component="div">` becomes `<div>`.
|
|
342
|
+
- `<Dynamic component="div">` becomes `<div>`. `<Dynamic component={Card}>` becomes `<Card>` when `Card` is a capitalized component declared at the top level, as a function or with `lazy`, that nothing reassigns. An imported component stays, since an import could hold a tag name.
|
|
343
|
+
- A call of an arrow function whose body is JSX, such as a render prop left by inlining, becomes the JSX when it is an element's child and each argument is a constant or a binding nothing reassigns. `{((n) => <li>{n}</li>)(1)}` becomes `<li>{1}</li>`. A `ref` or a spread in the JSX keeps the call, since both run while the JSX is made.
|
|
317
344
|
|
|
318
|
-
A built-in only folds when the tag resolves to Solid's component. The tag must bind to nothing, or be imported from one of `moduleSources`. A tag with a spread attribute or a function child never folds. `<Portal>`, `<
|
|
345
|
+
A built-in only folds when the tag resolves to Solid's component. The tag must bind to nothing, or be imported from one of `moduleSources`. A tag with a spread attribute or a function child never folds. `<Portal>`, `<Loading>`, `<Errored>`, and `<Reveal>` never fold.
|
|
319
346
|
|
|
320
347
|
A call to Solid's `lazy` is marked `/* @__PURE__ */`, so the bundler drops one that a folded branch left unused, along with its chunk.
|
|
321
348
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { SourceMap } from "@jridgewell/remapping";
|
|
2
2
|
import MagicString from "magic-string";
|
|
3
3
|
import "oxc-parser";
|
|
4
|
+
//#region src/value.d.ts
|
|
5
|
+
type Primitive = string | number | boolean | null | undefined;
|
|
6
|
+
//#endregion
|
|
4
7
|
//#region src/context.d.ts
|
|
5
8
|
/** The passes that record what they leave alone. */
|
|
6
9
|
type SkipPass = 'inline' | 'contexts' | 'memos';
|
|
@@ -16,9 +19,6 @@ interface Skip {
|
|
|
16
19
|
readonly name: string;
|
|
17
20
|
}
|
|
18
21
|
//#endregion
|
|
19
|
-
//#region src/value.d.ts
|
|
20
|
-
type Primitive = string | number | boolean | null | undefined;
|
|
21
|
-
//#endregion
|
|
22
22
|
//#region src/constants.d.ts
|
|
23
23
|
/**
|
|
24
24
|
* The constants each imported module exports, keyed by the import specifier
|
|
@@ -48,19 +48,6 @@ interface CompileOptions {
|
|
|
48
48
|
* @default true
|
|
49
49
|
*/
|
|
50
50
|
inline?: boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Compile for the server: remove `createEffect` and `onMount`, and reduce
|
|
53
|
-
* `untrack`, `batch`, `startTransition`, `createDeferred`, `getListener`,
|
|
54
|
-
* `createMemo`, `createRenderEffect`, and `createComputed` to what they do
|
|
55
|
-
* on the server.
|
|
56
|
-
*
|
|
57
|
-
* This runs once, after the other passes. The server and client build
|
|
58
|
-
* make the same folding and inlining decisions from the same code, so the
|
|
59
|
-
* server renders the tree the client hydrates.
|
|
60
|
-
*
|
|
61
|
-
* @default false
|
|
62
|
-
*/
|
|
63
|
-
server?: boolean;
|
|
64
51
|
/**
|
|
65
52
|
* Remove context providers whose reads are all visible, and give each
|
|
66
53
|
* read the provider's value.
|
|
@@ -79,14 +66,14 @@ interface CompileOptions {
|
|
|
79
66
|
* The names of Solid's built-in components. A tag only folds when it is
|
|
80
67
|
* one of these, and an empty list turns control-flow folding off.
|
|
81
68
|
*
|
|
82
|
-
* @default ['For', 'Show', 'Switch', 'Match', '
|
|
69
|
+
* @default ['For', 'Show', 'Switch', 'Match', 'Loading', 'Reveal', 'Portal', 'Repeat', 'Dynamic', 'Errored']
|
|
83
70
|
*/
|
|
84
71
|
builtIns?: readonly string[];
|
|
85
72
|
/**
|
|
86
73
|
* The modules that export Solid's built-in components. A tag imported from
|
|
87
74
|
* anywhere else is a different component.
|
|
88
75
|
*
|
|
89
|
-
* @default ['solid-js', '
|
|
76
|
+
* @default ['solid-js', '@solidjs/web']
|
|
90
77
|
*/
|
|
91
78
|
moduleSources?: readonly string[];
|
|
92
79
|
/**
|
|
@@ -108,6 +95,12 @@ interface CompileOptions {
|
|
|
108
95
|
* like a local `const`. `constantExports` reads them from a module.
|
|
109
96
|
*/
|
|
110
97
|
importedConstants?: ImportedConstants;
|
|
98
|
+
/**
|
|
99
|
+
* Values of global names and paths that fold like constants, such as the
|
|
100
|
+
* `define` entries of a bundler: `{ __DEV__: false, 'import.meta.env.MODE': 'production' }`.
|
|
101
|
+
* A path starts at `import.meta` or at a name the module does not declare.
|
|
102
|
+
*/
|
|
103
|
+
globalConstants?: Readonly<Record<string, Primitive>>;
|
|
111
104
|
/**
|
|
112
105
|
* The exports of imported modules that are contexts made by Solid's
|
|
113
106
|
* `createContext`, keyed by the import specifier as the code writes it.
|
|
@@ -191,9 +184,9 @@ interface ModuleConstants {
|
|
|
191
184
|
* Reads what a module imports and the constants it exports, so that
|
|
192
185
|
* `compile` can fold them in the modules that import it.
|
|
193
186
|
*
|
|
194
|
-
* Only `filename` and `
|
|
187
|
+
* Only `filename`, `importedConstants`, and `globalConstants` of the options are used.
|
|
195
188
|
*/
|
|
196
|
-
declare function readModuleConstants(code: string, options?: Pick<CompileOptions, 'filename' | 'importedConstants'>): ModuleConstants;
|
|
189
|
+
declare function readModuleConstants(code: string, options?: Pick<CompileOptions, 'filename' | 'importedConstants' | 'globalConstants'>): ModuleConstants;
|
|
197
190
|
//#endregion
|
|
198
|
-
export { readModuleConstants as a,
|
|
199
|
-
//# sourceMappingURL=compile-
|
|
191
|
+
export { readModuleConstants as a, SkipPass as c, compile as i, Primitive as l, CompileResult as n, ImportedConstants as o, ModuleConstants as r, Skip as s, CompileOptions as t };
|
|
192
|
+
//# sourceMappingURL=compile-BRCj4UN7.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-BRCj4UN7.d.mts","names":[],"sources":["../src/value.ts","../src/context.ts","../src/constants.ts","../src/compile.ts"],"mappings":";;;;KAUY;;;;KC0DA;;;;;UAMK;WACN,MAAM;;WAEN;;WAEA;;;;;;;;KC5DC,oBAAoB,SAAS,eAAe,SAAS,eAAe;;;UCF/D;;;;;;;EAOf;;;;;;;EAOA;;;;;;EAMA;;;;;;;EAOA;;;;;;;EAOA;;;;;;;EAOA;;;;;;;EAOA;;;;;;EAMA,iBAAiB,SAAS;;;;;;;EAO1B;;;;;;EAMA,oBAAoB;;;;;;EAMpB,kBAAkB,SAAS,eAAe;;;;;;EAM1C,mBAAmB,SAAS;;;;;;;;EAQ5B,mBAAmB,SAAS;;;;;;;;EAQ5B;;;;;;;;EAQA;;;;;;EAMA;;;;;;;EAOA;;UAGe;EACf;;EAEA,KAAK;;;;;EAKL,UAAU;;;;;;;;;;;;;iBAmGI,QAAQ,cAAc,UAAS,iBAAsB;UA0DpD;;;;;EAKf;;;;;;EAMA,SAAS,eAAe;;;;;;;;iBASV,oBACd,cACA,UAAS,KAAK,wEACb"}
|