Symfony UX 2.0 & Stimulus 3 Support

Symfony UX is an initiative and set of libraries centered around the Stimulus JavaScript library. And today, I'm pleased to announce several new releases: Version 2.0 of all symfony/ux libraries Version 3.0 of @symfony/stimulus-bridge Version 2.0 of @symfony/stimulus-testing What does this all mean? Let's find out!

Stimulus 3 Support Stimulus 3.0 - a new major version - was released in September. It includes a few nice new features - like a "debug" mode and "values defaults" - but no major changes and no backwards compatibility breaks. So why the new major version? Because the library was renamed from stimulus to @hotwired/stimulus. Yup, the name of the library changed... but not much else. However, the name change required Symfony's UX libraries to need a new major version.

Symfony UX Changes There are 4 big changes with the new Symfony UX releases: 1) Support changed from stimulus to @hotwired/stimulus The biggest change with the new major releases listed above is that support for stimulus was dropped and replaced with @hotwired/stimulus (i.e. version 3 of the library). This difference won't be noticeable in your applications, except that you'll need to adjust the import { Controller } from 'stimulus' lines in your code (see about upgrading below). 2) Support for IE11 was dropped Version 3 of Stimulus dropped support for IE11. We did the same thing in our Symfony UX libraries and incorporated a brand new build system. The result is smaller final JavaScript sizes. If you need to continue supporting IE 11, use Stimulus 2 and the previous version of the UX libraries. 3) data- Attributes Changed to the Values API Many of the UX packages allowed you to configure things by adding data- attributes to an element. Those have been replaced by using the "Values API" from Stimulus, which is a bit nicer anyways. For example, if you use symfony/ux-lazy-image, then previously the code looked like this:

    {# Code for the old, 1.x version #}

This code would now need to be updated to this:

    {# Code for the new, 2.x version #}

See the README - or CHANGELOG (e.g. Lazy Image CHANGELOG) - of each library for a full set of changes. In addition to the above items, symfony/ux-chartjs was updated to use chart.js version 3, and various new events were added to UX controllers to make them more configurable.

How do I Upgrade? To upgrade, you'll need to update a number of packages at the same time and make an adjustment to each Stimulus controller in your project: Remove stimulus from your package.json file and replace it with "@hotwired/stimulus": "^3.0". Also change your @symfony/webpack-encore version to ^1.7 and @symfony/stimulus-bridge to ^3.0. After making these changes, run yarn install. Update all of your controllers to replace any imports for stimulus with imports from @hotwired/stimulus:

    -import { Controller } from 'stimulus';

+import { Controller } from '@hotwired/stimulus';

In composer.json, update any symfony/ux- packages that you have installed to version ^2.0. Run composer up "symfony/ux-". Once that finishes, run yarn install --force. And... that's it! Congratulations on upgrading to Stimulus 3. Happy UX'ing!

                Sponsor the Symfony project.

https://symfony.com/blog/symfony-ux-2-0-and-stimulus-3-support?utm_source=Symfony%20Blog%20Feed&utm_medium=feed

Établi 3y | 9 déc. 2021 à 17:20:23


Connectez-vous pour ajouter un commentaire

Autres messages de ce groupe

Back on the inspiring SymfonyCon Vienna 2024!

We were absolutely thrilled to gather with the incredible Symfony community for the first time in Vienna, Austria, from December 5th to 6th, surrounded by the warm and festive atmosphere of the

31 janv. 2025 à 12:30:18 | Symfony
SymfonyLive Paris 2025 : Reveal of workshop topics!

SymfonyLive Paris 2025, conference in French language only, will take place from March 27 to 28! The schedule is currently being revealed as we go along. More details are available here.

💻

30 janv. 2025 à 08:50:03 | Symfony
Get Symfony news on your favorite social network

Symfony has been active on X, Mastodon, and Bluesky for some time, but until recently, not all platforms received equal attention. Since Twitter (now X) was our first social network, all blog posts we

29 janv. 2025 à 14:20:10 | Symfony
SymfonyLive Berlin 2025: Demystify the magic of the Container

SymfonyLive Berlin 2025, conference held in English, will take place from April 1 to 4! The schedule is being revealed gradually. More details are available here.

As we are now unveiling th

29 janv. 2025 à 14:20:10 | Symfony
Twig CVE-2025-24374: Missing output escaping for the null coalesce operator

Affected versions

Twig versions >=3.16.0,<3.19.0 are affected by this security issue.

The issue has been fixed in Twig 3.19.0.

Description

When using the null coalesce operator (??), output esc

29 janv. 2025 à 09:40:06 | Symfony
Symfony 6.4.18 released

Symfony 6.4.18 has just been released. Here is the list of the most important changes since 6.4.17:

bug #58889 [Serializer] Handle default context in Serializer (@Valmonzo)

bug #59631 [HttpClient

29 janv. 2025 à 09:40:05 | Symfony
Symfony 7.1.11 released

Symfony 7.1.11 has just been released. Here is the list of the most important changes since 7.1.10:

bug #58889 [Serializer] Handle default context in Serializer (@Valmonzo)

bug #59631 [HttpClient

29 janv. 2025 à 09:40:05 | Symfony