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

feat(framework): add JSX template support with TypeScript #10046

Merged
merged 239 commits into from
Dec 12, 2024
Merged

feat(framework): add JSX template support with TypeScript #10046

merged 239 commits into from
Dec 12, 2024

Conversation

pskelin
Copy link
Contributor

@pskelin pskelin commented Oct 18, 2024

JSX templates

This change is introducing JSX support for web component templates with full TypeScript support. Main benefits include

  • code completion for properties, events and values
  • type checking
  • navigation from template to component with click
  • easier debugging
  • reduced bundle size

Docs:

https://github.com/SAP/ui5-webcomponents/blob/f6ec6aba443e0e2dc048439e931361e1cf4b2c04/docs/4-development/08-templates.md

Status

  • configure packages tsconfig with correct JSX settings
  • add a jsx-runtime (preact with patches) for working DOM updates
  • automate creation of JSX prop types from class props
  • add eventDetails to describe event names and event parameter types
  • add generation of event handler properties from eventDetails (onSelectionChange={ (e) => { e.detail } })
  • scoping of elements and events (<ui5-button-scoped>, ui5-selection-change event)
  • @bound decorator for methods accessing this and dev check
  • Templating best practices
    • accessing state in the template - use this parameter
    • use properties instead of attributes (and dev time warning)
    • component usage in templates (import class)
    • add key={} when iterating (items.map)
    • class attribute accepts an object of type Record<string, boolean> adding a class for each truthy value
    • write class and style objects inline in the template
    • writing partials and extending templates
    • using ref to get a DOM node instance
    • icon usage with the exported name
  • 1st wave components conversion
  • add docs
  • describe thirdparty
  • what to do with JSX.AriaRole ?

in follow up changes:

  • TSX in cypress tests
  • TSX in playground
  • more components
  • JS consumption

Size improvements

label gzip main gzip fiori
before 364.75 kB 620.38 kB
after 355.59 kB 603.66 kB
delta -9.16 kB -16.72 kB

A note for component developers

If you are developing components, HBS support is deprecated, but will not be removed until the next major release. You should still consider migrating to JSX for the benefits listed above.

If you are extending components from this repo without modifying the template, you can just switch the renderer to JSXRenderer from LitRenderer and the rest remains the same.

If you are extending the templates of components from this repo (or others migrated to JSX), you will need to switch to JSX as well, since implementation of partials is specific to the templating technology.

Fixes: #7896

@pskelin pskelin merged commit f42e7c1 into main Dec 12, 2024
10 checks passed
@pskelin pskelin changed the title feat: add TSX template support feat(framework): add JSX template support with Typescript Dec 12, 2024
@pskelin pskelin changed the title feat(framework): add JSX template support with Typescript feat(framework): add JSX template support with TypeScript Dec 12, 2024
@ui5-webcomponents-bot
Copy link
Collaborator

🎉 This PR is included in version v2.6.0-rc.0 🎉

The release is available on v2.6.0-rc.0

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[framework][Feature Request]: support JSX,TSX templates for renderers
5 participants