Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: symfony/flex
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.19.5
Choose a base ref
...
head repository: symfony/flex
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.20.0
Choose a head ref
  • 2 commits
  • 10 files changed
  • 3 contributors

Commits on May 26, 2023

  1. add AddLinesConfigurator + updating PackageJsonSynchronizer for symfo…

    …ny/asset-mapper
    
    Co-authored-by: Ryan Weaver <ryan@symfonycasts.com>
    kbond and weaverryan committed May 26, 2023
    Configuration menu
    Copy the full SHA
    0b70eb3 View commit details
    Browse the repository at this point in the history
  2. feature #975 New "add-lines" configurator for simple file patching + …

    …importmap support (kbond)
    
    This PR was merged into the 1.x branch.
    
    Discussion
    ----------
    
    New "add-lines" configurator for simple file patching + importmap support
    
    Hi!
    
    Today, WebpackEncoreBundle's recipe contains the UX/Stimulus files. Soon, I will introduce a new StimulusBundle - https://github.com/weaverryan/stimulus-bundle - so that the WebpackEncoreBundle can be used without Stimulus and (more importantly) the `stimulus_()` functions can be used with AssetMapper (i.e. without Encore).
    
    This makes the recipe setup more... interesting :). This PR adds 2 things:
    
    ## importmap support in `JsonSynchronizer`
    
    `JsonSynchronizer` now has 2 modes, based on the presence/absence of the `importmap.php` file. If that file is present, then:
    
    * A) A new [symfony.importmap](https://github.com/weaverryan/stimulus-bundle/blob/148f6f9412e7063f9945d0947f206081d3311d7a/assets/package.json#L8-L11) config is read from the bundle's `package.json` file and these are added to the `importmap.php` file by running the `bin/console importmap:require` command. The `path:` prefix is used to refer to a "local" file in the bundle. Sometimes the importmap entries will be different than what's needed for `package.json`, hence having both configs.
    
    * B) The `controllers.json` file is updated like normal
    
    Also, a new [symfony.needsPackageAsADependency](https://github.com/weaverryan/stimulus-bundle/blob/148f6f9412e7063f9945d0947f206081d3311d7a/assets/package.json#LL7C10-L7C35) config key was added specifically for StimulusBundle. If `true`, no `file:/vendor/...` package will be added to `package.json` when using Encore.
    
    ## add-lines Configurator
    
    The new `add-lines` configurator is able to add entire lines to the `top`, `bottom` of `after_target` of existing files (if they exist). Example usage:
    
    ```json
    "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
        }
    ]
    ```
    
    There is also a `requires` key to only run if another package is installed. This is needed because StimulusBundle will need a [different assets/bootstrap.js](https://github.com/weaverryan/recipes/blob/3ab0e996ae22af665ec83bf0634f1163b533bc36/symfony/stimulus-bundle/1.0/manifest.json#L23-L33) based on if Encore vs AssetMapper is installed
    
    Cheers!
    
    Commits
    -------
    
    0b70eb3 add AddLinesConfigurator + updating PackageJsonSynchronizer for symfony/asset-mapper
    fabpot committed May 26, 2023
    Configuration menu
    Copy the full SHA
    49059a1 View commit details
    Browse the repository at this point in the history
Loading