Repository navigation
UIRoot: registerComponents, the tag components to register (3.1.6) - #59
Merged
Merged
Conversation
….1.6
The first UIRoot registered every component markup can create by tag,
and whatever is registered is compiled in: `<ui-document>` alone brings
in the `markdown` package. An app that writes none of those tags can now
pass `registerComponents: () {}`, or register only those it uses.
Without it all of them are registered, as before.
A nullable parameter, not an overridable method: dart2js keeps a method
every subclass overrides (and a default-value tear-off too), but drops
the `?? registerAllComponents` branch once every call site passes one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #59 +/- ##
=======================================
Coverage 92.89% 92.89%
=======================================
Files 34 34
Lines 9420 9422 +2
=======================================
+ Hits 8751 8753 +2
Misses 669 669
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
- bones_ui_root_register_components_test.dart: every built-in tag but the one registered is absent; the registration runs once, before the first render; a registered <ui-dialog> becomes its component, an unregistered <ui-document> stays a plain element, a dialog made in code needs none. - bones_ui_root_register_all_components_test.dart: the default registers every tag component, and <ui-document> renders its markdown. - register_components_tree_shaking_test.dart (VM): compiles four minimal apps with dart2js. Registering none drops every component and the markdown package (309,510 to 218,698 bytes gzipped); registering UIDialog keeps only it; one root without registerComponents keeps them all. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
The first
UIRootregisters every component markup can create by tag (<ui-button>,<ui-document>,<ui-dialog>,<ui-svg>...). Whatever is registered is compiled in, so every app ships all of them;<ui-document>alone brings in themarkdownpackage and its HTML-entity tables.UIRoot(..., registerComponents: ...): the components to register. Without it all of them are, as before (new staticUIRoot.registerAllComponents).() {}; one that uses a few passes those (UIDialog.register). EveryUIRootof the app must pass it.UIConsole.get()still runs unconditionally: it sets up logging, it is not a tag component.Why a nullable parameter, not an overridable method or a default value: dart2js keeps a method that every instantiated subclass overrides, and keeps a default-value tear-off too; checked in a toy program and in the app. It does drop the
registerComponents ?? registerAllComponentsfallback once inference sees every call site passes one.Measured in UnyCities (four roots, its only component a dialog created in code):
main.dart.jswent from 484,964 to 398,322 bytes gzipped, 18% smaller (1,608,618 to 1,335,230 raw). Its 500 browser tests pass on dart2js and dart2wasm.Tests:
bones_ui_root_register_components_test.dart(browser): a root registering onlyUIDialoghasui-dialogand none of the other built-in tags; the registration runs once, before the first render. In rendered markup, a registered<ui-dialog>becomes its component, an unregistered<ui-document>stays a plain element (its text as written, no<h1>), and a dialog created in code needs no registration.bones_ui_root_register_all_components_test.dart(browser): withoutregisterComponentsevery tag component is registered, and<ui-document>renders its markdown. A separate file because registration happens once per app.register_components_tree_shaking_test.dart(VM, integration): compiles four minimal apps intest/register_components/withdart compile js -O2and checks what is in the output:markdownui-document,ui-svg...UIDialogonlyui-dialog() {}, one defaultThe last row is the documented caveat: every
UIRootmust pass it.Full suite passes locally: VM (34), Chrome dart2wasm (551) and dart2js (551); format, analyze (
--fatal-infos --fatal-warnings) anddependency_validatorare clean.🤖 Generated with Claude Code