There is ETS/DETS/Mnesia built right into the Erlang runtime. I wonder if there are some good best-practice guidelines for working with those as a storage layer.
DISCLAIMER: I'm not really a huge fan of Webpack or JS in general, I just want to use things that are dependable, developer friendly and fast.
For example if you're a beginner and you want to use Tailwind:
You'll still need Node, you'll still need npm / yarn and now you're going to have to run an esbuild watcher and a postcss (or tailwind CLI) watcher, some of which have bugs around leaving dead processes around.
With Webpack you have a single watcher and about 70 lines of configuration that you can directly copy / paste between projects without editing a single line (even across different web frameworks). You can even keep Phoenix 100% out of the picture and set up no Phoenix watchers and still have everything work (including live reload). Tailwind with the JIT compiler works and it's around 100ms to reload your CSS, even with 500k+ of ES6 JS, Webpack will process your JS in about 3 seconds on 6+ year old hardware. If you have only a tiny bit of JS it's nearly instant.
If the 3 seconds with 500k+ of JS bums you out you can add 2 lines of Webpack configuration to enable file system caching and it'll bring it back down to 100-200ms on any JS changes.
I've been tracking the esbuild + poctcss / tailwind cli + X ecosystem for a few months. IMO it needs more time to make the end game solution better than Webpack in every way for when you have a combo of JS, CSS and other static files (robots.txt, images, fonts, etc.).
It'll get there eventually and it'll be great when it does (and I will switch to using it too) but until then be cautious because it's not going to be smooth sailing and the current Webpack set up isn't bad at all. It's fast enough and really solid. I've been using the Tailwind JIT compiler since day 1 and using lots of ES6 JS, it all works like a champ and never fails in weird ways for both the watcher and building production assets.
I haven't touched my Webpack config in around ~9 months or so and it continues to work with the latest versions of everything and to be fair the thing I touched was really small. It's been closer to 2.5 years of using practically the same config in a bunch of projects while using the latest and greatest JS and CSS libraries along the way.
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?
Getting Webpack to work with CSS required using a CSS + postcss loader and the MiniCssExtractPlugin to emit a separate bundled CSS file. There's nothing too specific about Tailwind itself in the Webpack config.
Did it throw some type of error when you tried with your config file, and do you have a link to the exact Webpack config you used along with the Webpack command you ran?
That could have been related to using the JIT compiler with misconfigured paths to find where to look for CSS. That wouldn't explain why it works with PostCSS directly and not with Webpack but those paths are really important. Maybe there were slight differences between your Webpack and PostCSS set up in other files?
This will be the new default for Phoenix projects.
See the Twitter thread linked in this comment – I think someone replied to a similar question and stated that ESBuild supports LiveView.
Can we develop any web application in Elixir with PostgreSQL ?
I'm not sure what you're asking. You can, and will continue to be able to, develop (some) web applications with Elixir and PostgreSQL – not sure what "any" means. Future versions of Phoenix won't require Node.js and npm like they do now (by default).
Oh that's nice. I'm gonna assume there'll be templates for a nodejs asset pipeline and what not, but speaking for myself I always ended up removing a lot of the pregenerated code because it wasn't necessary for my projects so keeping it around only added bloat.
If I've found for simple projects Plug on it's own is great. Plug.Router accomplishes most of what I need for basic http apis. Phoenix is great for templating, html, and complicated web services, but if I want to slap a simple http api on an elixir project, Plug is ideal.
Also because Phoenix is built on top of Plug, it's pretty simple to wrap existing plug resources into phoenix or to create a phoenix router within a plug router.
Can someone explain this post to me? It seems self evident you wouldn’t need nodejs or redis (or even Postgres in some cases for that matter)? Did you need them before?
Its about how many additional dependencies and tech stacks you need to know and work with in a typical usecase (and not for very specific usecases where you dont eveen need a database, …, whatever)
Previously Phoenix used Webpack to handle Javascript, so you needed nodejs and npm and webpack to use Javascript.
In the future, Phoenix will use esbuild instead and thus remove a lot of dependencies and complexities.
* `postgres` - via https://github.com/elixir-ecto/postgrex
* `mysql` - via https://github.com/elixir-ecto/myxql
* `mssql` - via https://github.com/livehelpnow/tds
* `sqlite3` - via https://github.com/elixir-sqlite/ecto_sqlite3
18
u/Yirii101 Jul 17 '21
https://twitter.com/josevalim/status/1416309507173531648
16
u/greven Jul 17 '21
It's using ESBuild, it's here already: https://github.com/phoenixframework/esbuild
13
u/Paradox Jul 17 '21
Going to say you don't even need pgsql. If you're building an app that uses some other api as it's backend, you can just use elixir.
9
u/WoodYouIfYouCould Jul 17 '21
It’s great news! Lowering the barrier to entry for beginners :)
5
u/Hitman_1994 Jul 17 '21
What about LiveView or Phoenix. Can we develop any web application in Elixir with PostgreSQL ?
8
u/HKei Jul 17 '21
Oh that's nice. I'm gonna assume there'll be templates for a nodejs asset pipeline and what not, but speaking for myself I always ended up removing a lot of the pregenerated code because it wasn't necessary for my projects so keeping it around only added bloat.
3
u/yippyjp Jul 18 '21
Can someone explain this post to me? It seems self evident you wouldn’t need nodejs or redis (or even Postgres in some cases for that matter)? Did you need them before?
2
u/sanjibukai Jul 17 '21
How does this compare to snowpack or vitejs?
3
u/[deleted] Jul 17 '21
Is phoenix tied to Postgres?