@zerowire/unplugin 0.1.0 → 0.1.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 +69 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# @zerowire/unplugin
|
|
2
|
+
|
|
3
|
+
Universal Ahead-of-Time build plugin for zerowire TypeScript binary codec and validator.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`@zerowire/unplugin` intercepts `compileWireCodec<T>()` macro calls in TypeScript code at build time and transforms them into compiled, branchless `DataView` validators, lazy Flyweight classes, and binary encoders. AST extraction and layout packing run via native Rust (`oxc_parser`), operating at sub-millisecond speeds without calling `tsc`.
|
|
8
|
+
|
|
9
|
+
Supported bundlers include Vite, Rolldown, Rollup, and esbuild.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pnpm add -D @zerowire/unplugin @zerowire/runtime
|
|
15
|
+
# or
|
|
16
|
+
npm install -D @zerowire/unplugin @zerowire/runtime
|
|
17
|
+
# or
|
|
18
|
+
bun add -d @zerowire/unplugin @zerowire/runtime
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Bundler Configuration
|
|
22
|
+
|
|
23
|
+
### Vite
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
// vite.config.ts
|
|
27
|
+
import { defineConfig } from "vite";
|
|
28
|
+
import { zerowireVite } from "@zerowire/unplugin";
|
|
29
|
+
|
|
30
|
+
export default defineConfig({
|
|
31
|
+
plugins: [zerowireVite()],
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Rollup and Rolldown
|
|
36
|
+
|
|
37
|
+
```javascript
|
|
38
|
+
// rollup.config.js
|
|
39
|
+
import { zerowireRollup } from "@zerowire/unplugin";
|
|
40
|
+
|
|
41
|
+
export default {
|
|
42
|
+
plugins: [zerowireRollup()],
|
|
43
|
+
};
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### esbuild
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import esbuild from "esbuild";
|
|
50
|
+
import { zerowireEsbuild } from "@zerowire/unplugin";
|
|
51
|
+
|
|
52
|
+
await esbuild.build({
|
|
53
|
+
entryPoints: ["src/index.ts"],
|
|
54
|
+
bundle: true,
|
|
55
|
+
outfile: "dist/bundle.js",
|
|
56
|
+
plugins: [zerowireEsbuild()],
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## How It Works
|
|
61
|
+
|
|
62
|
+
1. During bundling, `@zerowire/unplugin` scans imported source files for `compileWireCodec<T>()` markers.
|
|
63
|
+
2. The Rust compiler extracts the target interface `T` using `oxc_parser` and `oxc_allocator`.
|
|
64
|
+
3. The layout packer sorts fixed fields by alignment (8B -> 4B -> 2B -> 1B) and emits a self-contained JavaScript codec module.
|
|
65
|
+
4. The call site is replaced with the compiled codec class, providing zero-overhead execution with no runtime compiler dependency.
|
|
66
|
+
|
|
67
|
+
## License
|
|
68
|
+
|
|
69
|
+
MIT OR Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zerowire/unplugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "AOT build plugin for zerowire TypeScript validator and binary codec",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@zerowire/runtime": "0.1.
|
|
30
|
+
"@zerowire/runtime": "0.1.1",
|
|
31
31
|
"unplugin": "^2.2.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@zerowire/napi": "0.1.
|
|
34
|
+
"@zerowire/napi": "0.1.1",
|
|
35
35
|
"typescript": "^5.8.0",
|
|
36
36
|
"vitest": "^3.0.0"
|
|
37
37
|
},
|