How does app.js resolve the phoenix imports?

It’s esbuild doing that. It uses NODE_PATH for module resolution which is configured in config/config.exs:

config :esbuild,
  version: "0.17.11",
  default: [
    args:
      ~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
    cd: Path.expand("../assets", __DIR__),
    env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
  ]

You can read a bit more here.

2 Likes