feat: add @microsoft/fast-build npm package with WASM CLI#7358
Merged
Conversation
93ca1dd to
29e64f7
Compare
- Add wasm-bindgen as a conditional WASM-target dependency to the
microsoft-fast-build Rust crate (zero-dependency for native targets)
- Add src/wasm.rs exposing render() and render_with_templates() via
wasm-bindgen for use in Node.js
- Build the crate to WASM (NodeJS target) with wasm-pack
- Create packages/fast-build/ with:
- package.json (@microsoft/fast-build, no runtime npm dependencies)
- bin/fast.js: CLI supporting `fast build` with arguments:
--templates="<glob>" custom element HTML templates (warns if missing)
--output="output.html" (default: output.html)
--entry="index.html" (default: index.html)
--state="state.json" (default: state.json)
- wasm/: compiled WASM module and JS bindings
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The build/ workspace already uses @microsoft/fast-build. Rename the new package to @microsoft/fast-html-build and regenerate package-lock.json. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…uild Rename build/ workspace from @microsoft/fast-build to @microsoft/fast-build-tools so the new packages/fast-build package can use the @microsoft/fast-build name as intended. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
sites/website/scripts/generate-docs.cjs imports this utility from @microsoft/fast-build. Move it from build/ into packages/fast-build so the import continues to resolve now that this package owns the name. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The WASM output is pre-built and committed. Renaming the script from 'build' to 'build:wasm' prevents the workspace-wide 'npm run build' from failing in environments without wasm-pack installed. Developers can still regenerate the WASM explicitly with 'npm run build:wasm'. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
3031fc5 to
acac11b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wraps the
microsoft-fast-buildRust crate as a WebAssembly module and exposes it as a new npm package@microsoft/fast-buildwith afast buildCLI.Changes
crates/microsoft-fast-buildcrate-type = ["cdylib", "rlib"]toCargo.tomlto support WASM compilationwasm-bindgenas a conditional WASM-only dependency — native targets remain zero-dependencysrc/wasm.rsexposing two#[wasm_bindgen]functions:render(entry, state)— render a template with JSON staterender_with_templates(entry, templates_json, state)— render with custom element templates passed as a JSON mappackages/fast-build(new)package.json—@microsoft/fast-build, no runtime npm dependencies; includes abuildscript to regenerate the WASM viawasm-packbin/fast.js— CLI supportingfast buildwith:--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 bywasm-pack --target nodejs)Notes