Skip to content

Commit aae0486

Browse files
janechuCopilot
andcommitted
fix: consolidate fast-element export entrypoints
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 8eb2a69 commit aae0486

22 files changed

Lines changed: 325 additions & 114 deletions

File tree

.github/skills/typescript/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { type Constructable, isFunction } from "../interfaces.js";
1818
Sub-entry-points expose focused APIs through the `exports` map:
1919

2020
```ts
21-
import { twoWay } from "@microsoft/fast-element/binding/two-way.js";
21+
import { twoWay } from "@microsoft/fast-element/binding.js";
2222
import { reactive } from "@microsoft/fast-element/state.js";
2323
import { composedParent } from "@microsoft/fast-element/utilities.js";
2424
```
@@ -95,7 +95,7 @@ export const template = html<MyElement>`
9595
Two-way bindings require a sub-entry-point import:
9696

9797
```ts
98-
import { twoWay } from "@microsoft/fast-element/binding/two-way.js";
98+
import { twoWay } from "@microsoft/fast-element/binding.js";
9999
```
100100

101101
### Partial HTML

examples/todo-app/src/todo-app.template.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { html, repeat } from "@microsoft/fast-element";
2-
import { twoWay } from "@microsoft/fast-element/binding/two-way.js";
2+
import { twoWay } from "@microsoft/fast-element/binding.js";
33
import type { TodoApp } from "./todo-app.js";
44
import type { Todo } from "./todo-list.js";
55
import "./todo-form.js";
@@ -34,7 +34,7 @@ export const template = html<TodoApp>`
3434
&times;
3535
</button>
3636
</li>
37-
`
37+
`,
3838
)}
3939
</ul>
4040
`;

examples/todo-app/src/todo-form.template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { html } from "@microsoft/fast-element";
2-
import { twoWay } from "@microsoft/fast-element/binding/two-way.js";
2+
import { twoWay } from "@microsoft/fast-element/binding.js";
33
import type { TodoForm } from "./todo-form.js";
44

55
export const template = html<TodoForm>`
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# Introduction
22

3-
This document (and the linked documents) explains how the exports and side effects of `@microsoft/fast-element` are used to create custom elements.
3+
This document (and the linked documents) explains how the exports and side
4+
effects of `@microsoft/fast-element` are used to create custom elements,
5+
including the focused `binding.js`, `hydration.js`, and `declarative.js`
6+
sub-entrypoints.
47

58
## Glossary
69

710
- [Overview](./ARCHITECTURE_OVERVIEW.md): How the `@microsoft/fast-element` should be used by a developer and what code is executed during the first render.
811
- [`FASTElement`](./ARCHITECTURE_FASTELEMENT.md): How the `FASTElement` is architected.
912
- [`html` tagged template literal](./ARCHITECTURE_HTML_TAGGED_TEMPLATE_LITERAL.md): How the `html` tagged template literal takes and converts the contents into a `ViewTemplate`.
10-
- [`Updates` queue](./ARCHITECTURE_UPDATES.md): How updates to attributes and observables are processed.
13+
- [`Updates` queue](./ARCHITECTURE_UPDATES.md): How updates to attributes and observables are processed.

packages/fast-element/DESIGN.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,12 @@ This gives FAST automatic, fine-grained dependency tracking without explicit dec
174174

175175
`normalizeBinding(value)` converts raw arrow functions or static values into a `Binding` object.
176176

177+
The focused public binding entrypoint
178+
`@microsoft/fast-element/binding.js` is implemented by
179+
`src/binding/exports.ts`. It groups the optional `signal` and `twoWay`
180+
helpers with the core binding primitives so callers no longer need nested
181+
subpath imports.
182+
177183
---
178184

179185
### html Tagged Template Literal
@@ -350,8 +356,11 @@ the imperative `html` API:
350356
The `src/declarative.ts` entrypoint owns the declarative-only side effects:
351357
registering debug messages and installing hydratable view templates. This keeps
352358
the root `@microsoft/fast-element` barrel free of declarative side effects and
353-
utility-subpath collisions. See [`DECLARATIVE_DESIGN.md`](./DECLARATIVE_DESIGN.md)
354-
for the detailed architecture.
359+
utility-subpath collisions, while `src/hydration/exports.ts` backs the grouped
360+
`@microsoft/fast-element/hydration.js` entrypoint for low-level hydration
361+
utilities and manual install hooks. See
362+
[`DECLARATIVE_DESIGN.md`](./DECLARATIVE_DESIGN.md) for the detailed
363+
architecture.
355364

356365
---
357366

@@ -528,6 +537,7 @@ src/
528537
│ └── update-queue.ts # Updates (UpdateQueue)
529538
├── binding/
530539
│ ├── binding.ts # Binding abstract base class, BindingDirective
540+
│ ├── exports.ts # Focused binding entrypoint (binding.js)
531541
│ ├── one-way.ts # oneWay, listener
532542
│ ├── one-time.ts # oneTime
533543
│ └── normalize.ts # normalizeBinding helper
@@ -567,9 +577,11 @@ src/
567577
│ ├── utilities.ts # Declarative parsing and proxy utilities
568578
│ └── syntax.ts # Declarative syntax constants
569579
├── state/
580+
│ ├── exports.ts # Focused state entrypoint (state.js)
570581
│ ├── state.ts # state() helper (beta)
571582
│ └── watch.ts # watch() helper (beta)
572583
└── hydration/
584+
├── exports.ts # Focused hydration entrypoint (hydration.js)
573585
└── target-builder.ts # Hydration target resolution
574586
```
575587

packages/fast-element/MIGRATION.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,33 @@ removed `@microsoft/fast-html` package.
5353
APIs; the declarative entrypoint owns the debug-message and hydratable-view
5454
side effects.
5555

56+
## Focused export paths (v3)
57+
58+
FAST Element now groups optional bindings and hydration helpers behind dedicated
59+
sub-entrypoints instead of exposing multiple nested legacy paths.
60+
61+
### Removed exports
62+
63+
| Import | Replacement |
64+
|---|---|
65+
| `@microsoft/fast-element/binding/two-way.js` | `@microsoft/fast-element/binding.js` |
66+
| `@microsoft/fast-element/binding/signal.js` | `@microsoft/fast-element/binding.js` |
67+
| `@microsoft/fast-element/element-hydration.js` | `@microsoft/fast-element/hydration.js` |
68+
| `@microsoft/fast-element/install-element-hydration.js` | `@microsoft/fast-element/hydration.js` |
69+
| `@microsoft/fast-element/install-hydratable-view-templates.js` | `@microsoft/fast-element/hydration.js` |
70+
| `@microsoft/fast-element/metadata.js` | No public replacement |
71+
| `@microsoft/fast-element/pending-task.js` | No public replacement |
72+
73+
### Migration steps
74+
75+
1. Update two-way and signal imports to `@microsoft/fast-element/binding.js`.
76+
2. Update hydration utility imports to `@microsoft/fast-element/hydration.js`.
77+
3. Replace manual side-effect imports with
78+
`installElementHydration()` or `installHydratableViewTemplates()` from
79+
`@microsoft/fast-element/hydration.js` only when you need those hooks
80+
outside `@microsoft/fast-element/declarative.js`.
81+
4. Remove any direct imports from `metadata.js` or `pending-task.js`.
82+
5683
## Prerendered Content Optimization (v2 → v3)
5784

5885
### Removed exports
@@ -70,9 +97,10 @@ removed `@microsoft/fast-html` package.
7097
|---|---|
7198
| `@microsoft/fast-element/install-hydration.js` | No replacement needed — prerendered path is built into `ElementController` |
7299

73-
The `install-hydratable-view-templates.js` side-effect import is still
74-
available and is applied automatically by
75-
`@microsoft/fast-element/declarative.js` for hydration marker support.
100+
Hydratable `ViewTemplate` support is still applied automatically by
101+
`@microsoft/fast-element/declarative.js`. For manual installation, import
102+
`installHydratableViewTemplates()` from
103+
`@microsoft/fast-element/hydration.js`.
76104

77105
### Changed behavior
78106

packages/fast-element/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,28 @@ importing `@microsoft/fast-element`.
6565

6666
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.
6767

68+
## Focused Entry Points
69+
70+
Use the dedicated sub-entrypoints when you only need optional binding or
71+
hydration APIs:
72+
73+
```ts
74+
import { twoWay } from "@microsoft/fast-element/binding.js";
75+
import {
76+
HydrationMarkup,
77+
installHydratableViewTemplates,
78+
} from "@microsoft/fast-element/hydration.js";
79+
```
80+
81+
`binding.js` groups the optional binding helpers (`twoWay`, `signal`,
82+
`Signal`, and related types) behind a single public path. `hydration.js`
83+
groups the low-level hydration utilities and the manual install hooks used
84+
outside `declarative.js`.
85+
86+
`@microsoft/fast-element/declarative.js` still installs hydratable
87+
`ViewTemplate` support automatically. The legacy `metadata.js` and
88+
`pending-task.js` subpaths are no longer part of the public export map.
89+
6890
## Dynamic Style Application
6991

7092
When runtime state or external signals need to add or remove styles, create the

packages/fast-element/SIZES.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ Bundle sizes for `@microsoft/fast-element` exports.
44

55
| Export | Minified | Gzip | Brotli |
66
|--------|----------|------|--------|
7-
| CDN Rollup Bundle | 63.06 KB | 18.80 KB | 16.88 KB |
8-
| FASTElement | 23.30 KB | 7.32 KB | 6.60 KB |
9-
| Updates | 3.45 KB | 1.43 KB | 1.21 KB |
10-
| Observable | 7.96 KB | 2.94 KB | 2.62 KB |
11-
| observable | 8.00 KB | 2.95 KB | 2.62 KB |
12-
| attr | 3.39 KB | 1.37 KB | 1.13 KB |
13-
| children | 5.99 KB | 2.29 KB | 2.01 KB |
14-
| css | 4.47 KB | 1.78 KB | 1.54 KB |
15-
| ref | 4.96 KB | 1.96 KB | 1.71 KB |
16-
| slotted | 5.78 KB | 2.22 KB | 1.95 KB |
17-
| volatile | 8.05 KB | 2.97 KB | 2.63 KB |
7+
| CDN Rollup Bundle | 63.16 KB | 18.83 KB | 16.88 KB |
8+
| FASTElement | 23.03 KB | 7.22 KB | 6.50 KB |
9+
| Updates | 3.18 KB | 1.32 KB | 1.10 KB |
10+
| Observable | 7.69 KB | 2.83 KB | 2.52 KB |
11+
| observable | 7.73 KB | 2.85 KB | 2.53 KB |
12+
| attr | 933 B | 481 B | 417 B |
13+
| children | 5.72 KB | 2.17 KB | 1.92 KB |
14+
| css | 1.99 KB | 919 B | 819 B |
15+
| ref | 4.69 KB | 1.85 KB | 1.62 KB |
16+
| slotted | 5.51 KB | 2.11 KB | 1.85 KB |
17+
| volatile | 7.78 KB | 2.87 KB | 2.54 KB |
1818
| when | 2.40 KB | 978 B | 786 B |
19-
| html | 27.14 KB | 8.88 KB | 7.96 KB |
20-
| repeat | 30.79 KB | 9.81 KB | 8.82 KB |
19+
| html | 26.97 KB | 8.80 KB | 7.89 KB |
20+
| repeat | 30.52 KB | 9.71 KB | 8.72 KB |

packages/fast-element/package.json

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,9 @@
4040
"test": "./src/declarative/utilities.ts",
4141
"default": "./dist/esm/declarative/utilities.js"
4242
},
43-
"./binding/two-way.js": {
44-
"types": "./dist/dts/binding/two-way.d.ts",
45-
"default": "./dist/esm/binding/two-way.js"
46-
},
47-
"./binding/signal.js": {
48-
"types": "./dist/dts/binding/signal.d.ts",
49-
"default": "./dist/esm/binding/signal.js"
43+
"./binding.js": {
44+
"types": "./dist/dts/binding/exports.d.ts",
45+
"default": "./dist/esm/binding/exports.js"
5046
},
5147
"./render.js": {
5248
"types": "./dist/dts/templating/render.d.ts",
@@ -64,10 +60,6 @@
6460
"types": "./dist/dts/context.d.ts",
6561
"default": "./dist/esm/context.js"
6662
},
67-
"./metadata.js": {
68-
"types": "./dist/dts/metadata.d.ts",
69-
"default": "./dist/esm/metadata.js"
70-
},
7163
"./testing.js": {
7264
"types": "./dist/dts/testing/exports.d.ts",
7365
"default": "./dist/esm/testing/exports.js"
@@ -76,21 +68,9 @@
7668
"types": "./dist/dts/di/di.d.ts",
7769
"default": "./dist/esm/di/di.js"
7870
},
79-
"./element-hydration.js": {
80-
"types": "./dist/dts/components/hydration.d.ts",
81-
"default": "./dist/esm/components/hydration.js"
82-
},
83-
"./install-element-hydration.js": {
84-
"types": "./dist/dts/components/install-hydration.d.ts",
85-
"default": "./dist/esm/components/install-hydration.js"
86-
},
87-
"./install-hydratable-view-templates.js": {
88-
"types": "./dist/dts/templating/install-hydratable-view-templates.d.ts",
89-
"default": "./dist/esm/templating/install-hydratable-view-templates.js"
90-
},
91-
"./pending-task.js": {
92-
"types": "./dist/dts/pending-task.d.ts",
93-
"default": "./dist/esm/pending-task.js"
71+
"./hydration.js": {
72+
"types": "./dist/dts/hydration/exports.d.ts",
73+
"default": "./dist/esm/hydration/exports.js"
9474
},
9575
"./dom-policy.js": {
9676
"types": "./dist/dts/dom-policy.d.ts",
@@ -104,12 +84,7 @@
10484
},
10585
"unpkg": "dist/fast-element.min.js",
10686
"sideEffects": [
107-
"./dist/esm/debug.js",
108-
"./dist/esm/declarative.js",
109-
"./dist/esm/polyfills.js",
110-
"./dist/esm/components/install-hydration.js",
111-
"./dist/esm/templating/install-hydratable-view-templates.js",
112-
"./dist/esm/interfaces.js"
87+
"./dist/esm/debug.js"
11388
],
11489
"scripts": {
11590
"clean": "clean dist temp test-results",
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Binding exports for focused access to FAST binding APIs.
3+
* @public
4+
*/
5+
export type { BindingDirective } from "./binding.js";
6+
export { Binding } from "./binding.js";
7+
export { normalizeBinding } from "./normalize.js";
8+
export { oneTime } from "./one-time.js";
9+
export { listener, oneWay } from "./one-way.js";
10+
export { Signal, signal } from "./signal.js";
11+
export type { TwoWayBindingOptions } from "./two-way.js";
12+
export { TwoWaySettings, twoWay } from "./two-way.js";

0 commit comments

Comments
 (0)