sinwan-compiler 0.2.4 → 0.2.5
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 +37 -14
- package/dist/analyze.d.ts +0 -1
- package/dist/{chunk-w580fdrf.js → chunk-m4rk009c.js} +169 -219
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +5 -3
- package/dist/index.js +39 -39
- package/dist/reactive-wrap.d.ts +4 -0
- package/docs/README.md +38 -19
- package/docs/analyzer.md +63 -52
- package/docs/api.md +77 -26
- package/docs/architecture.md +52 -49
- package/docs/cli.md +24 -17
- package/docs/plugins.md +35 -32
- package/docs/transform.md +109 -34
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,27 +1,50 @@
|
|
|
1
1
|
# sinwan-compiler
|
|
2
2
|
|
|
3
|
-
Shared compiler
|
|
3
|
+
Shared compiler for [Sinwan](https://sinwanjs.com). App code usually never imports this package: **`bun-plugin-sinwan`** and **`vite-plugin-sinwan`** call it for you.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Use this package directly when you write a plugin, run a production analysis pass, or want to understand what the compiler changes in your JSX.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## What it does
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
- [Plugins](docs/plugins.md)
|
|
14
|
-
- [API reference](docs/api.md)
|
|
15
|
-
- [Architecture](docs/architecture.md)
|
|
9
|
+
- **Transforms JSX** so reactive reads become lazy getters the runtime can track.
|
|
10
|
+
- **Hoists static markup** into reusable templates (including `ref` slots).
|
|
11
|
+
- **Wraps exported function components** with `cc()` when they look like components.
|
|
12
|
+
- **Analyzes the project** so static props stay static and only truly reactive props pay for an effect.
|
|
16
13
|
|
|
17
|
-
##
|
|
14
|
+
## Install
|
|
18
15
|
|
|
19
16
|
```bash
|
|
20
|
-
|
|
17
|
+
bun add -d sinwan-compiler
|
|
21
18
|
```
|
|
22
19
|
|
|
23
|
-
|
|
20
|
+
App templates already depend on the Bun or Vite plugin. You only need this package if you call the compiler yourself.
|
|
21
|
+
|
|
22
|
+
## Production analysis
|
|
24
23
|
|
|
25
24
|
```bash
|
|
26
|
-
|
|
25
|
+
bunx sinwan-compiler analyze ./src ./.sinwan/reactive-props.json
|
|
27
26
|
```
|
|
27
|
+
|
|
28
|
+
Then point the plugin at that file:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
sinwan({ analyze: "./.sinwan/reactive-props.json" });
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
In development the plugins keep an incremental `AnalyzerCache` instead. You do not need to run the CLI for `bun run dev` / `vite`.
|
|
35
|
+
|
|
36
|
+
## Documentation
|
|
37
|
+
|
|
38
|
+
| Guide | Topic |
|
|
39
|
+
| ----- | ----- |
|
|
40
|
+
| [Overview](docs/README.md) | How the pieces fit together |
|
|
41
|
+
| [Transform](docs/transform.md) | Wrapping rules, auto-`cc`, template hoisting |
|
|
42
|
+
| [Analyzer](docs/analyzer.md) | Cross-file reactive props, workspaces, cache |
|
|
43
|
+
| [CLI](docs/cli.md) | `analyze` command |
|
|
44
|
+
| [Plugins](docs/plugins.md) | Bun and Vite options |
|
|
45
|
+
| [API](docs/api.md) | Public TypeScript API |
|
|
46
|
+
| [Architecture](docs/architecture.md) | Internals for contributors |
|
|
47
|
+
|
|
48
|
+
## License
|
|
49
|
+
|
|
50
|
+
MIT
|
package/dist/analyze.d.ts
CHANGED
|
@@ -97,7 +97,6 @@ export declare class AnalyzerCache {
|
|
|
97
97
|
private ensureAnalyzed;
|
|
98
98
|
private collectAffected;
|
|
99
99
|
private recomputeFor;
|
|
100
|
-
private recompute;
|
|
101
100
|
}
|
|
102
101
|
export declare function analyze(options: AnalyzeOptions): void;
|
|
103
102
|
export declare function loadMetadata(filePath: string): Map<string, Map<string, Set<string>>>;
|