-
-
Notifications
You must be signed in to change notification settings - Fork 341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Stimulus] Asset folders and files are required when they shouldn't need to be, if using the AssetMapper #2566
Comments
This is not something uncommon, as recipes are exactly made in that particular objective.
The main feature of the StimulusBundle, when used with AssetMapper, is to handle your controllers. So it does need this file to exist, one reason beeing this file references the ux packages (from Symfony but outside too): the "symfony-ux" tag in composer.json allow quick-config. We are not talking about a component here, but a Bundle :)
If you install a dependencies that requires the FrameworkBundle, you will have a lot of constraints regarding folders, files, etc. Every time someone installs a package, the balance between pros and cons must be examined, and the end choice will always be yours.
I'm not sure to see the link with the rest of the topic. Symfony did not force you to use AssetMapper, even less to use Stimulus. Proof is you just went back with Webpack Encore. But you chose to use a package that bring some Stimulus with it.. making the need for some integration not absurd to me.
I do understand the frustration here. Really. And I will have a look at this after more urgent matters. Now, "making that choice impossible" may be a bit dramatic for a file :) |
I appreciate you wanting to look into it whenever you have time to share for it.
I understand, but any bundle can have a dependency on any other bundle, so enforcing that this file exists on the main project even if it doesn't use Stimulus is excessive. But I think you understood that issue so no point in debating that any further.
Most of my frustration comes from the fact that Symfony is moving in a direction where I have to customize more and more because the default options make no sense for the kinds of projects I work with. The AssetMapper feels inferior to Webpack for any decently complex project, and Stimulus just doesn't have the ecosystem to warrant being the default choice, yet both of these get installed if you start a webapp project using the Symfony command. This is why I decided to give the AssetMapper a fair chance to change my mind so that I can stick as close to the default setup as possible, only for me to run into this particular issue.
I don't make a habit out of putting dummy files into my repository that will only end up confusing some junior coworker somewhere down the line. ;) |
You can check your current config and see if some bundles are writing paths here.
If not, i think (based on the following config) you can prevent all this
If you configure Stimulus with an empty array of path, or just any other directory, would it work ? # Default configuration for extension with alias: "stimulus"
stimulus:
controller_paths:
# Default:
- %kernel.project_dir%/assets/controllers
controllers_json: '%kernel.project_dir%/assets/controllers.json' |
@NMe84 ? |
I'm using a Sonata Admin in a project where I decided to give the new AssetMapper a shot despite my kneejerk reaction that Webpack was a better choice. I don't use Stimulus or
symfony/ux
in my project itself, but Sonata recently added a Stimulus dependency for its filters in their effort to move away from jQuery. No problem so far, I understand that move considering how much Symfony itself has opinionated itself and wants people to use this library, even if I don't agree with the way that is pushed itself.There are two problems here and I'm not sure if one causes the other or not, but the end result is that I've had to switch back from using the AssetMapper to using Webpack again to be able to move forward with my updated dependencies. My first issue was that the Stimulus Bundle recipe ran when I upgraded Sonata, meaning I had to remove
bootstrap.js
, thecontrollers
folder and a reference to the bootstrap file from my app.js, since I have no interest in keeping those files around.This exposes the second problem: when I remove those files and folders, generating my importmap breaks with the error: The "/var/www/html/assets/controllers" directory does not exist. This is triggered by ControllersMapGenerator::loadCustomControllers() by the
$finder->in()
call. Creating the folder changes the error to show that it wants to use the still non-existent controllers.json file.Stacktrace:

I feel like I should not be required to have any particular setup (let alone folder structure) just because one of my dependencies decides to use the Stimulus bundle. I raised the issue before that I felt Symfony should not be opinionated about which frontend library I want to use, and the response back then was that I can just opt not to use it. But this particular design flaw (bug?) is making that choice impossible in combination with Sonata and the AssetMapper.
The text was updated successfully, but these errors were encountered: