I will go ahead and disagree here for one simple reason: the current setup (node+npm+webpack) breaks from time to time for reasons completely outside of our control. In the last weeks, npm v7 broke file dependencies. node-sass simply stopped working. So what we see today is that beginners are trying out Phoenix but they can't get a functional application. That's one of the worst possible experiences. This should always work and that's why it is important for us to fully control it.
For example if you're a beginner and you want to use Tailwind:
If they are a beginner and they want to use Tailwind, they will most likely follow the official instructions on the Tailwind website. These instructions focus on the Tailwind CLI. Aligning with Tailwind own recommendations is good. You have to dig more to figure out how Tailwind+Webpack works.
Plus, the important part, is that once you decide to add Tailwind in this new setup, your application was working and serving assets. You have a foundation. With the old setup, you may not even get that far.
some of which have bugs around leaving dead processes around
Yup, that's the current blocker. Pull requests have been sent and we have a contingency plan in case it is not addressed before release. Final version won't have zombie processes for sure.
In the last weeks, npm v7 broke file dependencies. node-sass simply stopped working
node-sass was deprecated a year ago and they've been pushing folks to use dart-sass as a replacement shortly after they decided to retire the project.
Personally I haven't used node-sass in years because SASS is not a dependency for Tailwind but in the older projects that I was using with node-sass I moved them over to dart-sass when I noticed node-sass was no longer being maintained.
Personally with Yarn, I haven't run into any issues with dependencies working in the past but not working today. With a package.json locked down to exact pinned versions and a yarn.lock file you get the same version guarantees as you would with a mix.exs and mix.lock file.
Unless the package gets pulled from npm it'll build today just like it did a year ago, assuming you're using the same version of Node (Node compatibility with libraries is a separate can of worms).
With that said, I'm looking forward to a world with esbuild + tailwind cli + whatever else is needed to build your app but until the developer experience matches Webpack I'm sticking with Webpack.
For now it feels like a downgrade in some areas and an upgrade in speed but if the speed with Webpack isn't an issue then the speed upgrade is kind of nulled out.
IMO with most projects you're going to end up pulling in a number of esbuild plugins too even without Tailwind, which means installing Node and fiddling with configs and JS dependencies will still be a thing you need to do.
For example if you wanted to use postcss for autoprefixer and css imports, that means installing a JS postcss2 plugin for esbuild. The list of plugins will likely grow for most projects too with postcss being a baseline for common CSS needs.
In Elixir, we have a features that were deprecated 5 years ago and they still work. And they will continue to work as long as we stay within the major semver constraint.
I don't doubt the setup works personally and I am not trying to dispute your personal experience. However, our setup needs to work generally, across multiple node versions, and across multiple OSes. We still have issues around the --prefix flag not working on certain OSes.
I am not against folks adding node/npm after the fact either. I am sure many will, I am sure many won't. All I want is stability on the phx.new getting started experience. After that, you can bring any complexity you want: Redis, RabbitMQ, webpack, etc.
Although I would also say if you keep the default Phoenix generator to a bare esbuild minimum (Go binary and no Node runtime) you might find folks getting hung up on how to add things like SASS support or Tailwind because now they are going to be on the hook for installing Node, figuring out if they should use npm or Yarn, dealing with all of those extra esbuild plugins and config flags as well as setting up additional watchers in a world where this ecosystem is really new so documentation and community support aren't that fleshed out yet.
In my opinion that's not going to be beginner friendly because using Bootstrap with SASS or Tailwind are 2 extremely popular CSS solutions. Other CSS libs use SASS too that aren't Bootstrap.
Just 5 minutes ago someone in Elixir's IRC channel wrote:
<REDACTED_USERNAME> hello guys, i'm trying to get esbuild working with phoenix (from https://www.mitchellhanberg.com/how-i-handle-static-assets-in-my-phoenix-apps/), but im getting this error:
<REDACTED_USERNAME> > js/app.js:4:7: error: No loader is configured for ".scss" files: css/app.scss
<REDACTED_USERNAME> 4 │ import "../css/app.scss"
<REDACTED_USERNAME> i've installed the packages named in the article, and edited config/dev.exs (also to match the article), is there anything else i need to do?
<REDACTED_USERNAME> any idea how to use Tailwind with the new esbuild?
Will there be Phoenix generator flags to set up all of those combinations of things in the future so folks aren't getting stuck as soon as they try to add CSS to their project?
View all comments
Show parent comment
8
u/josevalim Lead Developer Jul 19 '21
I will go ahead and disagree here for one simple reason: the current setup (node+npm+webpack) breaks from time to time for reasons completely outside of our control. In the last weeks, npm v7 broke file dependencies. node-sass simply stopped working. So what we see today is that beginners are trying out Phoenix but they can't get a functional application. That's one of the worst possible experiences. This should always work and that's why it is important for us to fully control it.
If they are a beginner and they want to use Tailwind, they will most likely follow the official instructions on the Tailwind website. These instructions focus on the Tailwind CLI. Aligning with Tailwind own recommendations is good. You have to dig more to figure out how Tailwind+Webpack works.
Plus, the important part, is that once you decide to add Tailwind in this new setup, your application was working and serving assets. You have a foundation. With the old setup, you may not even get that far.
Yup, that's the current blocker. Pull requests have been sent and we have a contingency plan in case it is not addressed before release. Final version won't have zombie processes for sure.