You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Pull Request
## 📖 Description
This draft removes the remaining packaging-time side-effect assumptions from `@microsoft/fast-element` and flips the package to `"sideEffects": false`.
- make `declarative.js` import-pure by moving declarative runtime setup behind a lazy internal runtime hook
- convert `debug.js` to an explicit value-based entrypoint while keeping `index.debug.js` and `index.rollup.debug.js` opt-in debug behavior intact
- keep the shared FAST debug-message lookup and idle-callback setup working after the metadata flip
- update the directly related docs/tests and package metadata for the final sideEffects cleanup
## 👩�� Reviewer Notes
The main review points are `declarative/runtime.ts`, the debug entrypoint changes, and the package metadata flip in `package.json`. The important question is whether the package is now honestly safe to ship with `sideEffects: false`; the changed tests/builds are aimed at that exact concern.
## 📑 Test Plan
- `npm run build -w @microsoft/fast-element`
- `npm run test:chromium -w @microsoft/fast-element`
- `node build/biome-changed.mjs`
- `node build/biome-changed.mjs check`
- `npm run doc:ci -w @microsoft/fast-element`
- `npm run doc:exports:ci -w @microsoft/fast-element`
- `npm run test:playwright -w @microsoft/fast-element`
## ✅ Checklist
### General
- [x] I have included a change request file using `$ npm run change`
- [x] I have added tests for my changes.
- [x] I have tested my changes.
- [x] I have updated the project documentation to reflect my changes.
- [x] I have read the [CONTRIBUTING](https://github.com/microsoft/fast/blob/main/CONTRIBUTING.md) documentation and followed the [standards](https://github.com/microsoft/fast/blob/main/CODE_OF_CONDUCT.md#our-standards) for this project.
Copy file name to clipboardExpand all lines: packages/fast-element/DECLARATIVE_DESIGN.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,7 +72,7 @@ a waiting FAST element definition.
72
72
73
73
### `TemplateParser` — declarative HTML parser
74
74
75
-
A standalone class that converts declarative HTML template markup into the `strings` and `values` arrays that `ViewTemplate.create()` consumes. It is used by `TemplateElement` internally but can also be used independently for programmatic template compilation. The parsing pipeline is fully synchronous — no promises are allocated during template resolution. A `StringsAccumulator` tracks the running concatenation of preceding HTML, eliminating repeated O(N) `join("")` calls at each binding site.
75
+
A standalone class that converts declarative HTML template markup into the `strings` and `values` arrays that `ViewTemplate.create()` consumes. It is used by `TemplateElement` internally but can also be used independently for programmatic template compilation. The parsing pipeline is fully synchronous — no promises are allocated during template resolution. A `StringsAccumulator` tracks the running concatenation of preceding HTML, eliminating repeated O(N) `join("")` calls at each binding site.`createTemplate()` also performs the declarative runtime's lazy installation of hydratable `ViewTemplate` support and declarative debug messages.
76
76
77
77
### `Schema` — JSON schema builder
78
78
@@ -179,7 +179,7 @@ packages/fast-element/
179
179
│ └── declarative/
180
180
│ ├── index.ts # Declarative barrel export
181
181
│ ├── interfaces.ts # Message enum (error codes)
182
-
│ ├── debug.ts # Human-readable debug messages registered with FAST
|`parse()`| public | Entry point: parses declarative HTML into `{ strings, values }`. |
364
-
|`createTemplate()`| public | Creates a `ViewTemplate` from resolved strings and values. |
364
+
|`createTemplate()`| public | Creates a `ViewTemplate` from resolved strings and values, lazily enabling declarative hydration support. |
365
365
|`resolveStringsAndValues()`| private | Creates `strings`/`values` arrays and delegates to `resolveInnerHTML()`. |
366
366
|`resolveInnerHTML()`| private | Recursive HTML parser that dispatches to data binding or template directive handlers. |
367
367
|`resolveDataBinding()`| private | Thin dispatcher that routes to `resolveContentBinding()`, `resolveAttributeBinding()`, or `resolveAttributeDirectiveBinding()`. |
-`FASTElement.define()` no longer uses `templateOptions` to delay platform definition or connection.
76
-
- Elements can still be defined before a template is attached; a later `FASTElementDefinition.template` update notifies connected elements so they can render or hydrate with the new template.
75
+
-`FASTElement.define()` no longer uses `templateOptions` to delay platform
76
+
definition or connection.
77
+
- Elements can still be defined before a template is attached; a later
78
+
`FASTElementDefinition.template` update notifies connected elements so they
79
+
can render or hydrate with the new template.
77
80
78
81
### Migration steps
79
82
80
83
1. Remove `templateOptions` from element definitions.
81
-
2. Continue calling `define({ name })` when a definition needs to exist before its template is attached.
82
-
3. If a template is supplied later, assign `FASTElementDefinition.template` (or use the declarative runtime that does so for you).
84
+
2. Continue calling `define({ name })` when a definition needs to exist before
85
+
its template is attached.
86
+
3. If a template is supplied later, assign `FASTElementDefinition.template` (or
87
+
use the declarative runtime that does so for you).
88
+
89
+
## Debug entrypoint explicit enablement (v3)
90
+
91
+
### Import changes
92
+
93
+
| Before | After |
94
+
|---|---|
95
+
|`import "@microsoft/fast-element/debug.js";`|`import { enableDebug } from "@microsoft/fast-element/debug.js"; enableDebug();`|
96
+
97
+
### Migration steps
98
+
99
+
1. Replace setup-only `debug.js` imports with an explicit `enableDebug()` call.
100
+
2. Keep using the root package `development` export or debug rollup bundle when
101
+
you want debug behavior enabled automatically.
83
102
84
103
## Declarative event handler `e` removal (v3)
85
104
@@ -119,8 +138,8 @@ data source.
119
138
|`@microsoft/fast-element/install-hydration.js`| No replacement needed — prerendered path is built into `ElementController`|
120
139
121
140
The `install-hydratable-view-templates.js` side-effect import is still
122
-
available and is applied automatically by
123
-
`@microsoft/fast-element/declarative.js` for hydration marker support.
141
+
available, but `@microsoft/fast-element/declarative.js` now installs the
142
+
hydration runtime lazily when declarative APIs create a template.
Bundle sizes for each tree-shakeable export are tracked in [`SIZES.md`](./SIZES.md) and regenerated on every build. See the [Export Sizes](https://www.fast.design/docs/3.x/resources/export-sizes/) documentation page for the latest numbers.
@@ -82,8 +94,9 @@ controller when styles need to change.
82
94
FAST Element also publishes a declarative HTML runtime from
83
95
`@microsoft/fast-element/declarative.js`. This entrypoint exports
0 commit comments