Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove dependencies for TSX components and fix features #10449

Merged
merged 22 commits into from
Jan 6, 2025

Conversation

vladitasev
Copy link
Contributor

@vladitasev vladitasev commented Jan 2, 2025

Deprecate dependencies in @customElement

Background

  1. When jsxRenderer is used, scoping comes out of the box when dependencies are used as components in the .tsx (f.e. <Button>), and was never supported if they were used directly as tags (f.e. <ui5-button>) anyway.

  2. Additionally, components no longer await for their dependencies to be defined (since chore: call customElements.define synchronously #9857)

This makes the dependencies option in @customElement relevant only for the scoping functionality of litRenderer and can be discarded for all JSX-based components.

Features

The TSX rework made features' dependencies hard dependencies of the respective components via the templates, thus defeating the purpose of features (to load less dependencies when the feature is not needed).

This change fixes this by extracting the feature-relevant part of the template and moving it into the feature itself. Affected components:

  • Input.ts
  • ColorPicker.ts

Additionally, Toolbar.ts no longer aggregates the dependencies of its items as this comes out of the box now. @dobrinyonkov

Handling components that import their own items

Some components automatically import their items (f.e. Wizard.ts -> WizardStep.ts) to facilitate users.

These components used dependencies for that purpose by declaring their item as a dependency. With this change the item is imported as an unnamed import (f.e. import "./WizardStep.js")

Note: the ComboBox.ts component imports both its item, relying on the side effect (per documentation / API contract) and also its item's "instanceof" function, thus requiring two imports of the same module. Otherwise, the item will be tree-shaken.

Breaking changes

This change fixes some bugs - a few components used to import items they should not have imported. If an application relied on such a bug, and did not import the component explicitly, it will break:

  • The side navigation group was imported by side navigation, which was a bug (users may want to have no groups, only normal items/subitems), and was missing from the bundle. @TeodorTaushanov

  • The calendar legend was imported by calendar, which was a bug (users may want to have no legend), and was missing from the bundle. @tsanislavgatev

@vladitasev vladitasev changed the title chore: remove dependencies for jsxRender chore: remove dependencies for jsxRenderer Jan 2, 2025
@vladitasev vladitasev changed the title chore: remove dependencies for jsxRenderer chore: remove dependencies for jsxRenderer-enabled components Jan 2, 2025
@vladitasev vladitasev changed the title chore: remove dependencies for jsxRenderer-enabled components fix: remove dependencies for TSX components and fix features Jan 3, 2025
@vladitasev vladitasev merged commit a2b5f6f into main Jan 6, 2025
10 checks passed
@vladitasev vladitasev deleted the remove-dependencies branch January 6, 2025 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants