gilest

gilest

Phoenix Importmap - Alternative to esbuild

Hi all

Relatively new to Elixir, but was curious to see how Phoenix might run with a basic importmap configuration.

Introducing, phoenix_importmap.

Benefits:
In dev - minimal file-based tooling, removal of esbuild transpilation step, parity with prod
In prod - more granular caching of js files since they are many rather than a few bundles

Curious to know if folks are interested in this approach, anyway.

Usual disclaimer - this is an early stage library. I’ve not yet used it in prod :slightly_smiling_face:

Most Liked

derek-zhou

derek-zhou

Neat. I am using a more bare bone nobuild setup. I made sym links of phoenix js into my static dir:

derek@roastidious:~/projects/gara$ ls -al priv/static/js/
total 36
drwxr-xr-x 3 derek derek 4096 Mar  3 16:20  .
drwxr-xr-x 7 derek derek 4096 Oct 12 15:00  ..
-rw-r--r-- 1 derek derek 2160 Oct 12 15:08  app.js
drwxr-xr-x 2 derek derek 4096 Apr  8  2023  _hooks
lrwxrwxrwx 1 derek derek   54 Oct 12 14:49  phoenix_html.js -> ../../../deps/phoenix_html/priv/static/phoenix_html.js
lrwxrwxrwx 1 derek derek   45 Oct 12 14:51  phoenix.js -> ../../../deps/phoenix/priv/static/phoenix.mjs
lrwxrwxrwx 1 derek derek   68 Oct 12 14:52  phoenix_live_view.js -> ../../../deps/phoenix_live_view/priv/static/phoenix_live_view.esm.js

Then I directly import those phoenix js in my app.js:

import "./phoenix_html.js";
import {Socket} from "./phoenix.js";
import {LiveSocket} from "./phoenix_live_view.js";
import Hooks from "./_hooks/index.js";

If I need to use more than a couple of npm modules, I will consider using the importmap package.

jakeprem

jakeprem

This is really interesting thanks for making it!

I’ll have to take a closer look next time I venture outside the LiveView bubble.

Where Next?

Popular in RFCs Top

dergraf
Hey everyone! :waving_hand: I’ve been working on a side project for the last 4 months that I’m excited to share—it’s called ProxyConf! P...
New
jarlah
Hi! I have recently created, after having tried to get in touch with the creator of excontainers for quite some time, a new library call...
New
wingyplus
I just publish a library called redoc_ui_plug | Hex. The library renders Redoc UI from the openapi specification url. I used this library...
New
tiagodavi
I’ve just created and published my first Elixir library! Ex4j combines the power of Ecto schema with the Bolt protocol + an elegant DSL ...
New
felix-starman
I’ve noticed that often when I find myself needing to manually set content-disposition - [MDN] the advice is usually to use URI.encode_ww...
New
puemos
Hey everyone :waving_hand: Code: GitHub - puemos/overbooked: Overbooked is a self-hosted flexible workplace platform for indie co-wor...
New
tmbb
SciEx - Scientific programming Code here (very early stage): GitHub - tmbb/sci_ex: Scientific programming for Elixir I have decided to s...
New
marick
TL;DR I’ve forked the Lens package, changed the API some, added new lens makers and – most importantly – added a ton of documentation. In...
New
ca1989
Hi all, this week I played a bit with Phoenix and Elm. I ended up with this POC: https://github.com/carlotm/elmex The repository cont...
New
laibulle
Hello, I am playing with quantitative finance with Elixir. This library is more a way for me to explore and learn in this area and especi...
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

We're in Beta

About us Mission Statement