Closed MatTheCat closed 3 weeks ago
I guess it would break compilers wanting to interact with the StimulusBundle by adding or removing the /* stimulusFetch: 'lazy' */
comment in controllers. Wouldn't it be better to decorate or replace the stimulus.asset_mapper.controllers_map_generator
service in that case?
It feels to me a very internal matter... and a very logical change.
To make one of your custom controllers lazy, add a special comment on top: [...]
To me it's never an AssetMapper thing, but a source code thing, so..
I'd even call this a feature to be honest , as it would remove the following constraint:
[!NOTE] If you write your controllers using TypeScript, make sure removeComments is not set to true in your TypeScript config.
https://symfony.com/bundles/StimulusBundle/current/index.html#lazy-stimulus-controllers
So i'm clearly 👍 on this
@MatTheCat Do you think you could add a test or two ?
Test added!
Thanks!
Thanks for fixing this bug Mathieu.
The StimulusBundle allows to mark a controller as lazy using a
/* stimulusFetch: 'lazy' */
comment, but it will be searched in said controller’s compiled content. If the compilation removes that comment (it typically happens when using minifiers), then the controller is no longer considered lazy by theControllersMapGenerator
.This PR makes the comment searched in source files, so that its presence doesn’t depend on the compilation’s result.