symfony / recipes

Symfony Recipes Repository
https://github.com/symfony/recipes/blob/flex/main/RECIPES.md
MIT License
956 stars 472 forks source link

[StimulusBundle] Removing ux_controller_link_tags() #1262

Closed weaverryan closed 6 months ago

weaverryan commented 7 months ago
Q A
License MIT
Doc issue/PR StimulusBundle docs already updated

StimulusBundle + AssetMapper 6.4 no longer needs ux_controller_link_tags(). We can't target StimulusBundle's recipe based on the version of AssetMapper, but now that 6.4 is released, I think we should target recipe at the latest version.

github-actions[bot] commented 7 months ago

Thanks for the PR 😍

How to test these changes in your application

  1. Define the SYMFONY_ENDPOINT environment variable:

    # On Unix-like (BSD, Linux and macOS)
    export SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes/flex/pull-1262/index.json
    # On Windows
    SET SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes/flex/pull-1262/index.json
  2. Install the package(s) related to this recipe:

    composer req 'symfony/flex:^1.16'
    composer req 'symfony/stimulus-bundle:^2.13'
  3. Don't forget to unset the SYMFONY_ENDPOINT environment variable when done:

    # On Unix-like (BSD, Linux and macOS)
    unset SYMFONY_ENDPOINT
    # On Windows
    SET SYMFONY_ENDPOINT=

Diff between recipe versions

In order to help with the review stage, I'm in charge of computing the diff between the various versions of patched recipes. I'm going keep this comment up to date with any updates of the attached patch.

symfony/stimulus-bundle

2.8 vs 2.9 ```diff diff --git a/symfony/stimulus-bundle/2.9/assets/bootstrap.js b/symfony/stimulus-bundle/2.9/assets/bootstrap.js new file mode 100644 index 0000000..2689398 --- /dev/null +++ b/symfony/stimulus-bundle/2.9/assets/bootstrap.js @@ -0,0 +1,2 @@ +// register any custom, 3rd party controllers here +// app.register('some_controller_name', SomeImportedController); diff --git a/symfony/stimulus-bundle/2.9/assets/controllers/hello_controller.js b/symfony/stimulus-bundle/2.9/assets/controllers/hello_controller.js new file mode 100644 index 0000000..e847027 --- /dev/null +++ b/symfony/stimulus-bundle/2.9/assets/controllers/hello_controller.js @@ -0,0 +1,16 @@ +import { Controller } from '@hotwired/stimulus'; + +/* + * This is an example Stimulus controller! + * + * Any element with a data-controller="hello" attribute will cause + * this controller to be executed. The name "hello" comes from the filename: + * hello_controller.js -> "hello" + * + * Delete this file or adapt it for your use! + */ +export default class extends Controller { + connect() { + this.element.textContent = 'Hello Stimulus! Edit me in assets/controllers/hello_controller.js'; + } +} diff --git a/symfony/stimulus-bundle/2.9/assets/controllers.json b/symfony/stimulus-bundle/2.9/assets/controllers.json new file mode 100644 index 0000000..a1c6e90 --- /dev/null +++ b/symfony/stimulus-bundle/2.9/assets/controllers.json @@ -0,0 +1,4 @@ +{ + "controllers": [], + "entrypoints": [] +} diff --git a/symfony/stimulus-bundle/2.8/manifest.json b/symfony/stimulus-bundle/2.9/manifest.json index ff66e87..60e0ddb 100644 --- a/symfony/stimulus-bundle/2.8/manifest.json +++ b/symfony/stimulus-bundle/2.9/manifest.json @@ -2,5 +2,46 @@ "bundles": { "Symfony\\UX\\StimulusBundle\\StimulusBundle": ["all"] }, - "aliases": ["stimulus", "stimulus-bundle"] + "copy-from-recipe": { + "assets/": "assets/" + }, + "aliases": ["stimulus", "stimulus-bundle"], + "conflict": { + "symfony/webpack-encore-bundle": "<2.0", + "symfony/flex": "<1.20.0 || >=2.0.0,<2.3.0" + }, + "add-lines": [ + { + "file": "webpack.config.js", + "content": "\n // enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js)\n .enableStimulusBridge('./assets/controllers.json')", + "position": "after_target", + "target": ".splitEntryChunks()" + }, + { + "file": "assets/app.js", + "content": "import './bootstrap.js';", + "position": "top", + "warn_if_missing": true + }, + { + "file": "assets/bootstrap.js", + "content": "import { startStimulusApp } from '@symfony/stimulus-bridge';\n\n// Registers Stimulus controllers from controllers.json and in the controllers/ directory\nexport const app = startStimulusApp(require.context(\n '@symfony/stimulus-bridge/lazy-controller-loader!./controllers',\n true,\n /\\.[jt]sx?$/\n));", + "position": "top", + "requires": "symfony/webpack-encore-bundle" + }, + { + "file": "assets/bootstrap.js", + "content": "import { startStimulusApp } from '@symfony/stimulus-bundle';\n\nconst app = startStimulusApp();", + "position": "top", + "requires": "symfony/asset-mapper" + }, + { + "file": "templates/base.html.twig", + "content": " {{ ux_controller_link_tags() }}", + "position": "after_target", + "target": "{% block stylesheets %}", + "warn_if_missing": true, + "requires": "symfony/asset-mapper" + } + ] } ```
2.9 vs 2.13 ```diff diff --git a/symfony/stimulus-bundle/2.9/manifest.json b/symfony/stimulus-bundle/2.13/manifest.json index 60e0ddb..4701215 100644 --- a/symfony/stimulus-bundle/2.9/manifest.json +++ b/symfony/stimulus-bundle/2.13/manifest.json @@ -34,14 +34,6 @@ "content": "import { startStimulusApp } from '@symfony/stimulus-bundle';\n\nconst app = startStimulusApp();", "position": "top", "requires": "symfony/asset-mapper" - }, - { - "file": "templates/base.html.twig", - "content": " {{ ux_controller_link_tags() }}", - "position": "after_target", - "target": "{% block stylesheets %}", - "warn_if_missing": true, - "requires": "symfony/asset-mapper" } ] } ```