symfony / recipes

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

fix importmap for assetmapper 6.4 #1245

Closed tacman closed 9 months ago

tacman commented 9 months ago
Q A
License MIT
Doc issue/PR symfony/symfony-docs#...

I'm not sure how to describe what entrypoint does, that should be in the comment section of the importmap, where preload used to be.

github-actions[bot] commented 9 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-1245/index.json
    # On Windows
    SET SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes/flex/pull-1245/index.json
  2. Install the package(s) related to this recipe:

    composer req 'symfony/flex:^1.16'
    composer req 'symfony/asset-mapper:^6.4'
  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/asset-mapper

6.3 vs 6.4 ```diff diff --git a/symfony/asset-mapper/6.3/assets/app.js b/symfony/asset-mapper/6.4/assets/app.js index cb0082a..e3b03ad 100644 --- a/symfony/asset-mapper/6.3/assets/app.js +++ b/symfony/asset-mapper/6.4/assets/app.js @@ -4,4 +4,6 @@ * This file will be included onto the page via the importmap() Twig function, * which should already be in your base.html.twig. */ +import './styles/app.css' + console.log('This log comes from assets/app.js - welcome to AssetMapper! 🎉') diff --git a/symfony/asset-mapper/6.3/importmap.php b/symfony/asset-mapper/6.4/importmap.php index 5c2c21d..6d29807 100644 --- a/symfony/asset-mapper/6.3/importmap.php +++ b/symfony/asset-mapper/6.4/importmap.php @@ -6,8 +6,8 @@ * - "path" is a path inside the asset mapper system. Use the * "debug:asset-map" command to see the full list of paths. * - * - "preload" set to true for any modules that are loaded on the initial - * page load to help the browser download them earlier. + * - "entrypoint" (JavaScript only) set to true for any module that will + * be used as an "entrypoint" (and passed to the importmap() Twig function). * * The "importmap:require" command can be used to add new entries to this file. * @@ -15,7 +15,7 @@ */ return [ 'app' => [ - 'path' => 'app.js', - 'preload' => true, + 'path' => './assets/app.js', + 'entrypoint' => true, ], ]; diff --git a/symfony/asset-mapper/6.3/manifest.json b/symfony/asset-mapper/6.4/manifest.json index c6fb477..c33d2ee 100644 --- a/symfony/asset-mapper/6.3/manifest.json +++ b/symfony/asset-mapper/6.4/manifest.json @@ -6,22 +6,16 @@ }, "aliases": ["asset-mapper", "importmap"], "gitignore": [ - "/%PUBLIC_DIR%/assets/" + "/%PUBLIC_DIR%/assets/", + "/assets/vendor" ], "add-lines": [ { "file": "templates/base.html.twig", - "content": " {{ importmap() }}", + "content": " {{ importmap('app') }}", "position": "after_target", "target": "{% block javascripts %}", "warn_if_missing": true - }, - { - "file": "templates/base.html.twig", - "content": " ", - "position": "after_target", - "target": "{% block stylesheets %}", - "warn_if_missing": true } ], "conflict": { ```
tacman commented 9 months ago

can you ask someone else to do a second review? Happy to make changes if there are still issues, it's a nice way for me to learn about both assetmapper and symfony recipes.

weaverryan commented 9 months ago

We'll wait a day or two to see if someone from the core team notices this. Then I can poke a little bit :). You've done great on this

tacman commented 9 months ago

Thanks! Unrelated, well, related to AssetMapper but not to the recipe, can you see if there's an easy fix to https://github.com/symfony/symfony/discussions/51918? I, too, am obsessed with AssetMapper!

On Tue, Oct 10, 2023 at 1:00 PM Ryan Weaver @.***> wrote:

We'll wait a day or two to see if someone from the core team notices this. Then I can poke a little bit :). You've done great on this

— Reply to this email directly, view it on GitHub https://github.com/symfony/recipes/pull/1245#issuecomment-1755874941, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEXIQM2FGBWVF2W3OLOSULX6V5JBAVCNFSM6AAAAAA5ZCU2E2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJVHA3TIOJUGE . You are receiving this because you authored the thread.Message ID: @.***>

tacman commented 9 months ago

Oops, I'm not sure if I'm doing this right. Looks like there were two reviews that reviewed and approved this, is there another step to merge it?

Thanks, @weaverryan and @maxhelias !

maxhelias commented 9 months ago

A core team (membre of the repository) approval is identifiable with the green validated one and not the gray one like mine.

tacman commented 9 months ago

I'm getting this warning in the javascript console, can it be fixed in the recipe?

  link rel=preload> must have a valid `as` value
symfony new demo-64 --webapp --version=next && cd demo-64 
composer config extra.symfony.allow-contrib true
export SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes/flex/pull-1245/index.json
composer req symfony/asset-mapper:^6.4
composer req symfony/stimulus-bundle:2.x-dev
bin/console make:controller -i AppController
symfony server:start -d
symfony open:local --path=/app
weaverryan commented 9 months ago

Thanks for catching that - I made a PR to fix that