Split NPM dependencies to more granular packages#8121
Split NPM dependencies to more granular packages#8121leio10 merged 36 commits intodecidim:developfrom
Conversation
|
I'll leave just few notes regarding this here:
What we would need to get rid of the duplicated
What we would need to get rid of the
IF the first one is solved, we can get rid of the IF the second one is solved, we wouldn't need anymore the Meanwhile, we could setup another repository that automatically builds the Decidim NPM packages so that they can be distributed directly from GitHub. An example of this is available at: |
Also, refactor the package references to be local inside the `packages` folder.
Right now `postcss-preset-env` is not compatible with PostCSS 8. Some packages and the @decidim/webpacker package had the PostCSS 8 dependency which caused multiple versions of these packages to be installed within the packages and within the project folder. This caused `postcss-preset-env` to fail. Related issue: csstools/postcss-preset-env#191
After some refactoring, the git NPM package locations changed which caused also a change in this file. Also, the local package installation no longer requires replacing the `all` folder as the references are now all local inside `packages`.
leio10
left a comment
There was a problem hiding this comment.
Awesome job! Just a few doubts and we can merge this.
| if decidim_gemspec.version.to_s =~ /\.dev$/ | ||
| # With the .dev version the package does not exist at NPM yet. | ||
| { | ||
| dev: "https://gitpkg.now.sh/mainio/decidim/packages_dev/dev?feature/split-npm-packages", |
There was a problem hiding this comment.
💬 Should we remove the branch modifier and use develop?
There was a problem hiding this comment.
Yes, after this is merged (in another PR).
| "npm": "^7.7.2" | ||
| }, | ||
| "dependencies": { | ||
| "@decidim/browserslist-config": "https://gitpkg.now.sh/mainio/decidim/packages/browserslist-config?feature/split-npm-packages", |
There was a problem hiding this comment.
💬 Can we remove the branch reference here? Or do you prefer to create a new PR to change it after merging this?
There was a problem hiding this comment.
Yes, after this is merged (in another PR).
| "npm": "^7.7.2" | ||
| }, | ||
| "dependencies": { | ||
| "@decidim/eslint-config": "https://gitpkg.now.sh/mainio/decidim/packages/eslint-config?feature/split-npm-packages", |
There was a problem hiding this comment.
💬 Same here with the branch reference
There was a problem hiding this comment.
Yes, after this is merged (in another PR).
|
@leio10 Sure, we can change the branch modifier but this has to be merged first so that those packages become available in the Decidim main repository. I was also thinking an alternative how we could get rid of the With that, you can now try out running: $ npm i https://github.com/mainio/decidim-npm-builds/raw/version/0.25.0-dev/builds/decidim-all.tgz |
* develop: (47 commits) New Crowdin updates (#8150) Move the webpacker config override to @decidim/webpacker (#8158) Fix admin stylesheet dynamic imports (#8154) Fix session timeout conflicting with remember me (#7467) Allow to create online meetings without an URL (#8152) Fix verification route issues (#8146) Fix dont save timeout path to session (#8142) Fix access to import CSV results in accountability (#8132) Fix user report notification reported user name (#8130) Allow users to comment and delete their own comments (#8072) New Crowdin updates (#8124) Fix webpacker issues (#8136) Add comments in participatory space presentation page stats block (#8034) Split NPM dependencies to more granular packages (#8121) Metric is not shown when value is zero for blocked and reported users (#8117) Add missing templates translations (#8133) Add missing translation for authorization_modals (#8129) Polls in meetings (#8065) Fix flaky test on initiatives (#8128) Filter participants admin (#8104) ...
🎩 What? Why?
There is a discussion whether Decidim should release NPM packages with the webpacker changes at: #7818
After some PRs (#8066, #8094, #8107) this did not seem necessary as we found a way to control the JS dependencies within the repository. However, the current approach with #8094 and #8119 can be extremely slow as it is cloning the whole Decidim repository to
node_modules. Faster would be obviously to load the dependencies from NPM.Another point to support this change came at #8115 where I needed to override
config/webpack/base.jswhich apparently can change during upgrades (as pointed out by @ferblape at #8115 (comment)). Therefore, it would be safer to place these overrides in@decidim/webpackerpackage than the file that will be automatically updated during upgrades.This proposes some changes for managing the NPM dependencies to help this transition:
packagesfolder. The following packages are introduced:@decidim/corewhich loads the dependencies needed by the Decidim UIs, such as jQuery, GraphiQL, Leaflet, Browserslist configuration, etc.@decidim/devwhich loads the dependencies needed in development, such as axe-core for accessibility checks, stylelint configurations, ESLint configurations@decidim/electionswhich loads the dependencies needed by the elections/votings modules@decidim/webpackerwhich loads the dependencies needed for webpacker and to build the assets with webpacker@decidim/allwhich requires all those packages (except for the@decidim/devpackage which is added in thedevDependencies)@decidim/browserslist-configwhich ships the Browserslist configuration centrally for Decidim and Decidim based applications - marked as a dependency for@decidim/core@decidim/eslint-configwhich ships the ESLint configuration centrally for Decidim and Decidim based applications - marked as a dependency for@decidim/dev@decidim/stylelint-configwhich ships the Stylelint configuration centrally for Decidim and Decidim based applications - marked as a dependency for@decidim/devpackage.json'sdevDependencies(all these used to be insidedependencies)This does not mean that all of the assets would be moved to NPM, this is just the "essentials" that are currently listed in the root
package.json. And also to improve things such as the implementation of #8115.Right now NPM does not support monorepos for git installations (see npm/npm#2974). I also tried to list the dependencies as file dependencies in the root
package.jsonbut that failed too when they are installed on external applications (or the test app for instance) because that approach won't allow NPM to install the dependencies listed in each of those@decidimNPM packages (see npm/cli#2339).As a workaround, I found the
gitpkg.now.shservice which allows installing NPM packages from git repository subfolders.Obviously, it is not meant to stay this way. Eventually these packages should be released to NPM and we should figure out a proper way how we could avoid version conflicts between the gem versions and the NPM package versions. To me it just seems eventually we will need some NPM packages.
It is also installing the packages from our fork right now because those packages do not yet exist at the main repository.
📌 Related Issues
Testing
Create the decidim test/development app and run it with the webpack dev server.
📋 Checklist
docs/.