Configure webpacker additional paths and entry points programmatically#8066
Conversation
Adds the ability to programmatically add additional paths for Rails Webpacker within the Decidim engines.
@andreslucena It might help resolving #8028 but there are also other pending changes at #7942 which are also required. I won't guarantee that but I think it might help. Regarding #8006, the webpacker install command is still needed to run but yes, this sure gets rid of the statically configured paths. |
|
Amazing job @ahukkanen!! 😍 |
|
@leio10 On my part it's ready to be reviewed but I would like other people to also confirm if this is the correct way to solve the problem. |
|
I'm also taking a look. Great job @ahukkanen, I wanted to avoid hacking on Webpacker classes but might be the path to follow |
|
After reviewing it it solves the problem of the webpacker.yml in a nice way and it's definitely an improvement on my proposed solution. I'm updating #7942 with the last version of bulletin board to have a version without sprockets. On the regards with the issue with package.json Decidim dependencies included in the Rails app I haven't been able to think in a better approach, so let's wait to @leio10 feedback. Maybe from this PR, Webpacker could be moved again to Decidim gem, but I'm not sure and it'd need some experimentation to validate. |
|
@ferblape IMO the Decidim NPM dependencies should be managed as a Decidim's own NPM package. Then instances could just do this in their {
"dependencies": {
"@decidim/essentials": "^0.25.0"
}
}And in the Decidim upgrade task, you could just update the version number from the |
|
Will that npm package just contain the package.json of Decidim? |
|
@ferblape At first: yes. Later possibly something else too (once the related discussion is resolved). |
|
Hi @ferblape @ahukkanen, let me try to summarize what I understood until now, to see if I have a clear idea of the situation:
Please let me know if I'm missing something here. Regarding NPM packages, I don't see any benefit on having just one big package. I think we could use the same approach that we are using with the ruby gems: one independent package per module and a set of well defined dependencies between them. I know that it's more work but that could be automated. In fact, that was the idea from the beginning for the Decidim project, to have small parts as less coupled as possible, so I don't see a reason to not do that in the JS part. That say, and again if I'm not missing anything, I'd say that IMHO the best approach would be to publish one NPM package for each module and request to apps maintainers to add webpacker with a What do you think? |
I'm still not sure whether all Decidim gems should be released as their own NPM packages. It would be still possible to do overrides that way too as @leio10 mentioned, but we would have to give priority for the registered In case all modules had their own NPM package, it probably would make Decidim upgrades a bit more difficult, having to manage all that in a single place. And I'm a bit worried what happens if the gems are running on |
|
@leio10 do you want me to help you to create a package.json that contains all the dependencies? In fact I can't create it an publish on Decidim npm account, but I could prepare the generators to use it in a new PR? |
|
@ferblape I think right now you can already do that by pulling the Decidim's npm i --save decidim/decidim#developBefore that is released to NPM, I would suggest to move some of the dependencies to
Maybe the released package should be named something like |
|
ok, @ahukkanen @ferblape my plan is to review and merge this PR to close open issues, and then I'll address the |
|
@ahukkanen I'm following the webpacker component migration guide and it was not updated with this PR. Could you add these changes to the guide? Thanks! /cc @ferblape |
🎩 What? Why?
As discussed in email with @andreslucena @ferblape @carolromero @oriolgual @furilo et al. there are currently some issues with defining the webpacker additional paths and entrypoints right now.
This PR proposes a solution for this problem by introducing a new configuration convention to define these in the engine's
config/assets.rbwhere they are loaded during Webpacker initialization. During webpacker initialization a newwebpacker_runtime.ymlconfiguration file is created in the application'stmpfolder where these configurations are stored to make them available for Webpacker.This requires a small hack in the Webpacker runner class that is included in this PR.
The benefits that this provides:
This is a proposal how to solve it, it still requires further discussion from the community.
📌 Related Issues
Testing
Run the development app with the webpack-dev-server.
📋 Checklist
docs/.