Skip to content

chore(fast-html): use @microsoft/fast-build to build test fixtures#7364

Merged
janechu merged 10 commits intomainfrom
users/janechu/implement-cli-on-fast-html-test-fixtures
Apr 3, 2026
Merged

chore(fast-html): use @microsoft/fast-build to build test fixtures#7364
janechu merged 10 commits intomainfrom
users/janechu/implement-cli-on-fast-html-test-fixtures

Conversation

@janechu
Copy link
Copy Markdown
Collaborator

@janechu janechu commented Apr 1, 2026

Pull Request

📖 Description

Uses @microsoft/fast-build to generate the index.html for the attribute test fixture in @microsoft/fast-html, replacing the previously hand-authored file with a reproducible build step.

  • Adds a build:fixtures script to fast-html that invokes the fast-build CLI to render shadow DOM for each fixture
  • Consolidates fixture component templates into a single templates.html file
  • Introduces entry.html (with {{}} binding syntax) and state.json as the source inputs to the build
  • Fixes the Rust renderer (directive.rs) to resolve {{}} attribute bindings on custom element outer tags even when no parent hydration scope is present
  • Adds explicit error detection in build-fixtures.js so template injection failures are surfaced immediately rather than silently no-oping

👩‍💻 Reviewer Notes

The Rust fix in directive.rs (build_element_open_tag) is small but load-bearing — without it, {{type}} in <test-element type="{{type}}"> would pass through unresolved to the output.

The build-fixtures.js script now throws a descriptive error if <script type="module" is not found in the rendered output before attempting template injection, ensuring build failures are never silently swallowed.

📑 Test Plan

Run npm run build:fixtures -w @microsoft/fast-html and verify the output index.html is correctly generated. All existing Playwright tests for the attribute fixture continue to pass.

✅ Checklist

General

  • I have included a change request file using $ npm run change
  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

⏭ Next Steps

@janechu janechu force-pushed the users/janechu/implement-cli-on-fast-html-test-fixtures branch from 193add6 to 393e034 Compare April 1, 2026 18:48
@janechu janechu marked this pull request as draft April 1, 2026 18:57
@janechu janechu force-pushed the users/janechu/implement-cli-on-fast-html-test-fixtures branch 2 times, most recently from 0f41ae7 to 7e16c43 Compare April 2, 2026 03:16
@janechu janechu changed the title feat(fast-html): use @microsoft/fast-build to build test fixtures chore(fast-html): use @microsoft/fast-build to build test fixtures Apr 2, 2026
@janechu janechu force-pushed the users/janechu/implement-cli-on-fast-html-test-fixtures branch from 7e16c43 to 65a787d Compare April 2, 2026 03:48
@janechu janechu marked this pull request as ready for review April 2, 2026 03:52
janechu added a commit that referenced this pull request Apr 3, 2026
…po (#7372)

## Summary

Addresses the review comment in #7364 — compiled binary files (wasm + generated JS bindings) should not be committed to the repository.

## Changes

### Package
- **`packages/fast-build/package.json`**: Replaced `build:wasm` with a `build` script so `npm run build` at the workspace level generates the wasm files
- **Deleted**: `packages/fast-build/wasm/microsoft_fast_build_bg.wasm`, `microsoft_fast_build.js`, `microsoft_fast_build.d.ts`, `microsoft_fast_build_bg.wasm.d.ts` (all generated files removed from tracking)
- **`.gitignore`**: Added `packages/fast-build/wasm/` to ignore the generated output directory

### Docs
- **`packages/fast-build/CONTRIBUTING.md`**: Updated to reflect that wasm is not committed; contributors run `npm run build -w @microsoft/fast-build` and install `wasm-pack` via `cargo install wasm-pack`
- **`packages/fast-build/DESIGN.md`**: Updated module map to note the wasm files are generated, not committed

### CI
- **`azure-pipelines-ci.yml`** and **`azure-pipelines-cd.yml`**: Install Rust via rustup and `wasm-pack` via `cargo install wasm-pack` before `npm run build`
- **`ci-validate-pr.yml`**, **`ci-validate-platforms.yml`**, **`cd-gh-pages.yml`**: Install `wasm-pack` via `cargo install wasm-pack` before `npm run build` (Rust is pre-installed on GitHub-hosted runners)

## How to build locally

Install prerequisites:
```sh
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Install wasm-pack
cargo install wasm-pack
```

Then from the repository root:
```sh
npm run build -w @microsoft/fast-build
```
janechu and others added 7 commits April 3, 2026 08:36
- Add @microsoft/fast-build as a devDependency
- Add scripts/build-fixtures.js: runs fast-build CLI for SSR rendering
  then injects <f-template> declarations before the <script> tag
- Add build:fixtures npm script
- Add attribute fixture source files: entry.html, state.json,
  templates/test-element.html, templates/test-element-property.html,
  templates/test-element-expression.html
- Regenerate attribute/index.html via fast-build (uses data-fe-c-* markers)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…tes.html

Replaces the individual per-component template files in templates/ with a
single templates.html that wraps each template in <f-template name="...">
and <template> tags, matching the new format expected by @microsoft/fast-build
after the locator update in #7365.

build-fixtures.js updated to:
- pass the single templates.html path instead of a templates/*.html glob
- inject the templates.html content directly (already has <f-template> wrapping)
- drop the readdirSync import (no longer needed)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rebuilds index.html now that the CLI correctly parses <f-template name>
attributes (fixes landed in main via #7368).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Update entry.html to use {{}} bindings for type, activeGroup, and
currentGroup, and populate state.json with the corresponding values.
Fix directive.rs to resolve {{}} attribute bindings on custom elements
even when no parent hydration scope is present.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@janechu janechu force-pushed the users/janechu/implement-cli-on-fast-html-test-fixtures branch from 2932572 to 035143a Compare April 3, 2026 15:37
@radium-v radium-v self-requested a review April 3, 2026 17:10
@janechu janechu requested a review from Copilot April 3, 2026 22:19
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR switches the @microsoft/fast-html attribute test fixture to be generated via @microsoft/fast-build (instead of a hand-authored index.html) and includes a small Rust renderer tweak so {{}} attribute bindings on custom element outer tags resolve even without a parent hydration scope.

Changes:

  • Add a build:fixtures script and a Node builder that runs @microsoft/fast-build and injects fixture templates.
  • Introduce fixture inputs (entry.html, state.json, templates.html) and update the generated index.html.
  • Update fast-build Rust directive rendering to resolve attribute bindings on custom element open tags without a parent hydration scope.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/fast-html/test/fixtures/attribute/templates.html New consolidated <f-template> declarations used as fixture template source
packages/fast-html/test/fixtures/attribute/state.json New state input used to resolve {{}} bindings during fixture build
packages/fast-html/test/fixtures/attribute/entry.html New entry HTML source (with {{}} bindings) consumed by the fixture build
packages/fast-html/test/fixtures/attribute/index.html Updated generated fixture output produced by fast-build + template injection
packages/fast-html/scripts/build-fixtures.js New CLI script to build fixtures via @microsoft/fast-build and inject templates
packages/fast-html/package.json Adds build:fixtures script and @microsoft/fast-build dev dependency
crates/microsoft-fast-build/src/directive.rs Fixes attribute binding resolution on open tags when no parent hydration exists
change/@microsoft-fast-html-63009ec0-ff3c-43ca-a650-621eb74010a3.json Beachball change file for fast-html fixture build chore
change/@microsoft-fast-build-d80fdb63-e6d4-4455-ab31-c345b4e9657b.json Beachball change file for fast-build Rust fix

@janechu janechu merged commit 8ba12ad into main Apr 3, 2026
14 checks passed
@janechu janechu deleted the users/janechu/implement-cli-on-fast-html-test-fixtures branch April 3, 2026 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants