Dependencies on Router and Router.Helpers causing slow recompilation in Phoenix app

Hmm, here’s some code that does suggest the plugs being related.

We use a LayoutPlug in the Router pipelines to set a site-specific layout template based on some conn/config.

Here’s an example excerpt from our router:

pipeline :general_store do
  plug :browser

  plug Store.LayoutPlug
end

scope "/my-page", Store do
  pipe_through :general_store

  get "/", ContentController, :page
end

A simplified LayoutPlug looks like:

def call(conn, _opts) do
  layout = determine_layout(conn)

  conn
  |> Phoenix.Controller.put_layout({Store.LayoutView, layout})
end

Because Store.LayoutView is referenced in the plug, any changes I make to the app.html.ex template requires the plug -> router recompilation.

If I comment out the plug Store.LayoutPlug and move the put_layout into the ContentController.page/2 action, the recompilation behavior goes away. Unfortunately, it’s important for us to plug the router, since all downstream controllers depend on this.

I’m not sure how to separate the pipelines from routes as you suggest.