Thanks for pointing that out.
I feel like your argument is very development-centric, and my argument is very user-centric. Both are fine. Both are valid.
And I feel both do not contradict each other.
TL;DR:
- Separate development and production via different repositories.
- Ship Mautic with pre-built assets, because NPM serves the devs, but not the user.
- I am not against NPM! I just don’t think it adds that much of a benefit during installation, so that the added complexity is worth it.
Ah, I totally understand this. I’d make the same point. I can even envision me being confused by that.
At the same time, I feel like this mixes up two things that should be separated: Development and shipping for production.
Separating dev and production
From my personal and anecdotal experience, it’s a common practice to maintain different repositories for development and production.
In development, it’s absolutely reasonable for contributors to build static files themselves. To prevent the issues you pointed out.
For production releases, however, bundling static files not only makes installation for users more smooth. It also is—from my experience—common practice (see Neos or WordPress).
Examples
AFAIK the way Neos deals with this is having a dedicated repository for development and one for “production”. I.e. a repository the tagged versions get committed to, (along with the built static assets) and where composer pulls from.
A lazy 30 sec search seems to show the same for WordPress—I don’t know if this is actually the case, THB. But fact is, WordPress comes with JS built already.
A way for Mautic?
So how about adding an additional production repository? It basically mirrors the already existing development repository.
Something like this:
This makes development easier for devs as there will be no static file conflicts.
It keeps installing as easy as it was with M4.
Only disadvantage is that someone hast to
- switch to the mautic-production-distribution
- (force) checkout the 5.x branch
- build the assets
- commits the assets
- tag the latest commit
I (maybe naively) don’t think that this is something that takes more than 2 minutes. You’d probably automate this very easily.
Role of composer vs. NPM
Mautic is fundamentally a PHP project. This makes Composer a natural fit.
Composer simplifies many things for devs as well as users, like plugin installation and overall management.
Hence, shipping with composer makes totally sense. (And Mautic has to be shipped somehow )
NPM on the other hand does nothing, really (yes, I’m totally exaggerating). What I mean by that:
If 100 people install Mautic, all of them need to build the JS files. This can be avoided if just one runs NPM, builds the JS and Mautic gets shipped with pre-built JS.
So, there is no gain for the user. It’s just one more step, one thing that adds complexity and, most significantly, one thing that introduces a new breaking point.
No user advantage
The only “advantage” I see for people running NPM is to get security patches for the JS files.
BUT:
- I’m pretty certain most people won’t run npm after an installation, just to get JS updates. They run it along with an Mautic update. So this literally leaves them at the same place as when Mautic comes with pre-built files. (Plus: Someone who really wants JS updates still can run NPM, no matter if Mautic comes with pre-built files or not).
- Most of Mautics JS (if I am not mistaken) is used in the backend. Exploiting a JS vulnerability requires someone who has access to the dashboard. If this is the case, the problem goes far beyond a JS vulnerability.
- Even in the case of a severe JS security issue: People still can run NPM.
Plus: NPM will introduce new problems
There are already forum posts about issues with NPM. The more people try to upgrade, the more problems will arise. It is inevitable.
This consumes valuable time that could be spent helping people with more substantial issues (or contributing code).
Shipping pre-built JS will prevent this.
User perspective and Mautic growth
As NPM adds friction to users. This will lead to people giving up on Mautic, turning to Mailchimp or what have you.
We don’t know how big the impact might be. But I’d say every user lost to issues that can (from my POV easily) avoided would be a bummer.
Which one did I miss? This?
I hope I answered that. If not please tell me what I missed.
I’m positive that if the two domains (dev and prod) are separated there (hopefully) won’t be any confusion for people contributing to the code. Additionally, there won’t be any burden on the Mautic user.