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
refactor(db): embed evaluator factories directly in IR nodes
Replace global registry pattern with embedded factories for true tree-shaking:
- Func nodes now carry their evaluator factory directly
- Aggregate nodes now carry their config (factory + valueTransform) directly
- Remove registry.ts and aggregate-registry.ts files
- Update all operators to pass factory as 3rd argument to Func
- Update all aggregates to pass config as 3rd argument to Aggregate
- Update internal code (optimizer, predicate-utils, expressions) to
preserve factories when transforming Func nodes
- Add array overloads to and() and or() for internal usage
- Update tests to use builder functions instead of creating IR directly
This design eliminates the need for side-effect imports and ensures
only imported operators/aggregates are bundled.
Copy file name to clipboardExpand all lines: .changeset/auto-register-operators.md
+34-12Lines changed: 34 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,35 +2,53 @@
2
2
"@tanstack/db": patch
3
3
---
4
4
5
-
Add auto-registering operators and aggregates for tree-shaking support and custom extensibility.
5
+
Refactor operators and aggregates to embed their evaluators directly in IR nodes for true tree-shaking support and custom extensibility.
6
6
7
-
Each operator and aggregate now bundles its builder function and evaluator in a single file, registering itself when imported. This enables:
7
+
Each operator and aggregate now bundles its builder function and evaluator factory in a single file. The factory is embedded directly in the `Func` or `Aggregate` IR node, eliminating the need for a global registry. This enables:
8
8
9
-
-**Tree-shaking**: Only operators/aggregates you import are included in your bundle
10
-
-**Custom operators**: Use `registerOperator()` to add your own operators
11
-
-**Custom aggregates**: Use `registerAggregate()` to add your own aggregate functions
9
+
-**True tree-shaking**: Only operators/aggregates you import are included in your bundle
10
+
-**No global registry**: No side-effect imports needed; each node is self-contained
11
+
-**Custom operators**: Create custom operators by building `Func` nodes with a factory
12
+
-**Custom aggregates**: Create custom aggregates by building `Aggregate` nodes with a config
0 commit comments