Commit 4450aef
authored
feat: add @microsoft/fast-build npm package with WASM CLI (#7358)
## Summary
Wraps the `microsoft-fast-build` Rust crate as a WebAssembly module and exposes it as a new npm package `@microsoft/fast-build` with a `fast build` CLI.
## Changes
### `crates/microsoft-fast-build`
- Added `crate-type = ["cdylib", "rlib"]` to `Cargo.toml` to support WASM compilation
- Added `wasm-bindgen` as a **conditional WASM-only dependency** — native targets remain zero-dependency
- Added `src/wasm.rs` exposing two `#[wasm_bindgen]` functions:
- `render(entry, state)` — render a template with JSON state
- `render_with_templates(entry, templates_json, state)` — render with custom element templates passed as a JSON map
### `packages/fast-build` (new)
- `package.json` — `@microsoft/fast-build`, **no runtime npm dependencies**; includes a `build` script to regenerate the WASM via `wasm-pack`
- `bin/fast.js` — CLI supporting `fast build` with:
- `--templates="<glob>"` — glob pattern(s) for custom element HTML templates; warns if not provided or no files match
- `--output="output.html"` — output file (default: `output.html`)
- `--entry="index.html"` — entry HTML template (default: `index.html`)
- `--state="state.json"` — state JSON file (default: `state.json`)
- `wasm/` — pre-built WASM module and JS bindings (generated by `wasm-pack --target nodejs`)
## Notes
- All file I/O and glob resolution is done in plain Node.js with no external dependencies
- The existing Rust unit test suite continues to pass1 parent fb1ac76 commit 4450aef
14 files changed
Lines changed: 668 additions & 2 deletions
File tree
- build
- change
- crates/microsoft-fast-build
- src
- packages/fast-build
- bin
- wasm
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments