Repository: phoenixframework/phoenix
Pull request #4894 (2022-07-20 17:06:16)

Update to latest gettext and remove all compilers


Patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 16b5c9dc4..73f209c6b 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -42,7 +42,7 @@ jobs:
     steps:
       - uses: actions/checkout@v3
       - name: Download released earth
-        run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.4.1/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
+        run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.5.16/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
       - name: Execute tests
         run: earthly -P --build-arg ELIXIR=${{ matrix.elixir }} --build-arg OTP=${{ matrix.otp }} +integration-test
   npm_test:
@@ -51,6 +51,6 @@ jobs:
     steps:
       - uses: actions/checkout@v3
       - name: Download released earth
-        run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.4.1/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
+        run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.5.16/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
       - name: Execute tests
         run: earthly --build-arg ELIXIR=1.13.3 --build-arg OTP=24.3.4 +npm
diff --git a/Earthfile b/Earthfile
index d276f9c54..635762af0 100644
--- a/Earthfile
+++ b/Earthfile
@@ -8,6 +8,7 @@ all-test:
     BUILD --build-arg ELIXIR=1.13.3 --build-arg OTP=24.3.4 --build-arg RUN_INSTALLER_TESTS=1 +test
 
 test:
+    ARG RUN_INSTALLER_TESTS=0
     FROM +test-setup
     COPY --dir config installer ./
     RUN MIX_ENV=test mix deps.compile
diff --git a/installer/lib/phx_new/generator.ex b/installer/lib/phx_new/generator.ex
index e1ddac365..70a99887c 100644
--- a/installer/lib/phx_new/generator.ex
+++ b/installer/lib/phx_new/generator.ex
@@ -188,11 +188,6 @@ defmodule Phx.New.Generator do
         :error -> adapter_config
       end
 
-    compilers =
-      for {compiler, enabled?} <- [gettext: gettext, phoenix_live_view: html],
-          enabled?,
-          do: inspect(compiler)
-
     version = @phoenix_version
 
     binding = [
@@ -226,8 +221,7 @@ defmodule Phx.New.Generator do
       adapter_module: adapter_module,
       adapter_config: adapter_config,
       generators: nil_if_empty(project.generators ++ adapter_generators(adapter_config)),
-      namespaced?: namespaced?(project),
-      compilers: compilers
+      namespaced?: namespaced?(project)
     ]
 
     %Project{project | binding: binding}
diff --git a/installer/templates/phx_single/lib/app_name_web.ex b/installer/templates/phx_single/lib/app_name_web.ex
index f76598621..09fcd5e9e 100644
--- a/installer/templates/phx_single/lib/app_name_web.ex
+++ b/installer/templates/phx_single/lib/app_name_web.ex
@@ -101,8 +101,9 @@ defmodule <%= @web_namespace %> do
       # Use all HTML functionality (forms, tags, etc)
       use Phoenix.HTML
 
-      # Import LiveView and .heex helpers (live_render, <.link>, <.form>, etc)
+      # Import and alias LiveView and .heex helpers (live_render, <.link>, <.form>, etc)
       import Phoenix.LiveView.Helpers
+      alias Phoenix.LiveView.JS
 <% end %>
       # Import basic rendering functionality (render, render_layout, etc)
       import Phoenix.View
diff --git a/installer/templates/phx_single/mix.exs b/installer/templates/phx_single/mix.exs
index f6a03df12..9679fbb7f 100644
--- a/installer/templates/phx_single/mix.exs
+++ b/installer/templates/phx_single/mix.exs
@@ -11,7 +11,6 @@ defmodule <%= @app_module %>.MixProject do
       lockfile: "../../mix.lock",<% end %>
       elixir: "~> 1.12",
       elixirc_paths: elixirc_paths(Mix.env()),
-      compilers: <%= if @compilers != [] do %>[<%= Enum.join(@compilers, ", ") %>] ++ <% end %>Mix.compilers(),
       start_permanent: Mix.env() == :prod,
       aliases: aliases(),
       deps: deps()
@@ -51,7 +50,7 @@ defmodule <%= @app_module %>.MixProject do
       {:swoosh, "~> 1.3"},<% end %>
       {:telemetry_metrics, "~> 0.6"},
       {:telemetry_poller, "~> 1.0"},<%= if @gettext do %>
-      {:gettext, "~> 0.18"},<% end %>
+      {:gettext, "~> 0.20"},<% end %>
       {:jason, "~> 1.2"},
       {:plug_cowboy, "~> 2.5"}
     ]
diff --git a/installer/templates/phx_umbrella/apps/app_name_web/lib/app_name.ex b/installer/templates/phx_umbrella/apps/app_name_web/lib/app_name.ex
index 6d102da8c..fef41af9f 100644
--- a/installer/templates/phx_umbrella/apps/app_name_web/lib/app_name.ex
+++ b/installer/templates/phx_umbrella/apps/app_name_web/lib/app_name.ex
@@ -99,8 +99,9 @@ defmodule <%= @web_namespace %> do
         router: <%= @web_namespace %>.Router,
         statics: <%= @web_namespace %>.static_paths()
 
-      # Import LiveView and .heex helpers (live_render, <.link>, <.form>, etc)
+      # Import and alias LiveView and .heex helpers (live_render, <.link>, <.form>, etc)
       import Phoenix.LiveView.Helpers
+      alias Phoenix.LiveView.JS
 <% end %>
       use Phoenix.VerifiedRoutes,
         endpoint: <%= @endpoint_module %>,
diff --git a/installer/templates/phx_umbrella/apps/app_name_web/mix.exs b/installer/templates/phx_umbrella/apps/app_name_web/mix.exs
index 2b8d64496..8bf4b05be 100644
--- a/installer/templates/phx_umbrella/apps/app_name_web/mix.exs
+++ b/installer/templates/phx_umbrella/apps/app_name_web/mix.exs
@@ -11,7 +11,6 @@ defmodule <%= @web_namespace %>.MixProject do
       lockfile: "../../mix.lock",
       elixir: "~> 1.12",
       elixirc_paths: elixirc_paths(Mix.env()),
-      compilers: <%= if @compilers != [] do %>[<%= Enum.join(@compilers, ", ") %>] ++ <% end %>Mix.compilers(),
       start_permanent: Mix.env() == :prod,
       aliases: aliases(),
       deps: deps()
@@ -48,7 +47,7 @@ defmodule <%= @web_namespace %>.MixProject do
       {:esbuild, "~> 0.5", runtime: Mix.env() == :dev},<% end %>
       {:telemetry_metrics, "~> 0.6"},
       {:telemetry_poller, "~> 1.0"},<%= if @gettext do %>
-      {:gettext, "~> 0.18"},<% end %><%= if @app_name != @web_app_name do %>
+      {:gettext, "~> 0.20"},<% end %><%= if @app_name != @web_app_name do %>
       {:<%= @app_name %>, in_umbrella: true},<% end %>
       {:jason, "~> 1.2"},
       {:plug_cowboy, "~> 2.5"}
diff --git a/lib/mix/tasks/compile.phoenix.ex b/lib/mix/tasks/compile.phoenix.ex
index 0534d4bee..40d537fbf 100644
--- a/lib/mix/tasks/compile.phoenix.ex
+++ b/lib/mix/tasks/compile.phoenix.ex
@@ -6,14 +6,13 @@ defmodule Mix.Tasks.Compile.Phoenix do
 
   @doc false
   def run(_args) do
-    IO.warn """
+    IO.warn("""
     the :phoenix compiler is no longer required in your mix.exs.
 
     Please find the following line in your mix.exs and remove the :phoenix entry:
 
         compilers: [..., :phoenix, ...] ++ Mix.compilers(),
-
-    """
+    """)
 
     {:ok, _} = Application.ensure_all_started(:phoenix)
 
diff --git a/lib/phoenix/code_reloader.ex b/lib/phoenix/code_reloader.ex
index 70dc3b925..3fa0f498e 100644
--- a/lib/phoenix/code_reloader.ex
+++ b/lib/phoenix/code_reloader.ex
@@ -15,7 +15,7 @@ defmodule Phoenix.CodeReloader do
   This is configured in your application environment like:
 
       config :your_app, YourAppWeb.Endpoint,
-        reloadable_compilers: [:gettext, :phoenix_live_view, :elixir],
+        reloadable_compilers: [:gettext, :elixir],
         reloadable_apps: [:ui, :backend]
 
   Keep in mind `:reloadable_compilers` must be a subset of the
diff --git a/lib/phoenix/endpoint/supervisor.ex b/lib/phoenix/endpoint/supervisor.ex
index 9309104b8..3a1a779d8 100644
--- a/lib/phoenix/endpoint/supervisor.ex
+++ b/lib/phoenix/endpoint/supervisor.ex
@@ -173,7 +173,7 @@ defmodule Phoenix.Endpoint.Supervisor do
       http: false,
       https: false,
       reloadable_apps: nil,
-      reloadable_compilers: [:gettext, :phoenix_live_view, :elixir],
+      reloadable_compilers: [:gettext, :elixir],
       secret_key_base: nil,
       static_url: nil,
       url: [host: "localhost", path: "/"],
diff --git a/mix.exs b/mix.exs
index 65fe968de..b151c75d9 100644
--- a/mix.exs
+++ b/mix.exs
@@ -80,7 +80,7 @@ defmodule Phoenix.MixProject do
       {:ex_doc, "~> 0.24", only: :docs},
       {:ecto, "~> 3.0", only: :docs},
       {:ecto_sql, "~> 3.6", only: :docs},
-      {:gettext, "~> 0.18", only: :docs},
+      {:gettext, "~> 0.20", only: :docs},
       {:telemetry_poller, "~> 1.0", only: :docs},
       {:telemetry_metrics, "~> 0.6", only: :docs},
       {:makeup_eex, ">= 0.1.1", only: :docs},


Test patch:
diff --git a/integration_test/mix.exs b/integration_test/mix.exs
index dfe39db2f..da8f7bb6f 100644
--- a/integration_test/mix.exs
+++ b/integration_test/mix.exs
@@ -47,7 +47,7 @@ defmodule Phoenix.Integration.MixProject do
       {:phoenix_live_dashboard, "~> 0.6"},
       {:telemetry_metrics, "~> 0.6"},
       {:telemetry_poller, "~> 1.0"},
-      {:gettext, "~> 0.18"},
+      {:gettext, "~> 0.20"},
       {:jason, "~> 1.2"},
       {:swoosh, "~> 1.3"},
       {:plug_cowboy, "~> 2.5"},
diff --git a/integration_test/mix.lock b/integration_test/mix.lock
index 39a592bba..06a60461d 100644
--- a/integration_test/mix.lock
+++ b/integration_test/mix.lock
@@ -17,7 +17,7 @@
   "exqlite": {:hex, :exqlite, "0.11.2", "147414ff3790de24cb23941937ce909c9a3ad4b1d96e1510418af2709230f578", [:make, :mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "156f46ac206f56055043e4725f2139a5ec3c90bb668fc9a32edb4ad13fe71f14"},
   "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
   "floki": {:hex, :floki, "0.32.1", "dfe3b8db3b793939c264e6f785bca01753d17318d144bd44b407fb3493acaa87", [:mix], [{:html_entities, "~> 0.5.0", [hex: :html_entities, repo: "hexpm", optional: false]}], "hexpm", "d4b91c713e4a784a3f7b1e3cc016eefc619f6b1c3898464222867cafd3c681a3"},
-  "gettext": {:hex, :gettext, "0.19.1", "564953fd21f29358e68b91634799d9d26989f8d039d7512622efb3c3b1c97892", [:mix], [], "hexpm", "10c656c0912b8299adba9b061c06947511e3f109ab0d18b44a866a4498e77222"},
+  "gettext": {:hex, :gettext, "0.20.0", "75ad71de05f2ef56991dbae224d35c68b098dd0e26918def5bb45591d5c8d429", [:mix], [], "hexpm", "1c03b177435e93a47441d7f681a7040bd2a816ece9e2666d1c9001035121eb3d"},
   "html_entities": {:hex, :html_entities, "0.5.2", "9e47e70598da7de2a9ff6af8758399251db6dbb7eebe2b013f2bbd2515895c3c", [:mix], [], "hexpm", "c53ba390403485615623b9531e97696f076ed415e8d8058b1dbaa28181f4fdcc"},
   "jason": {:hex, :jason, "1.3.0", "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac"},
   "mime": {:hex, :mime, "2.0.2", "0b9e1a4c840eafb68d820b0e2158ef5c49385d17fb36855ac6e7e087d4b1dcc5", [:mix], [], "hexpm", "e6a3f76b4c277739e36c2e21a2c640778ba4c3846189d5ab19f97f126df5f9b7"},
diff --git a/test/phoenix/code_reloader_test.exs b/test/phoenix/code_reloader_test.exs
index b554ef73a..fc80efc2d 100644
--- a/test/phoenix/code_reloader_test.exs
+++ b/test/phoenix/code_reloader_test.exs
@@ -4,7 +4,7 @@ defmodule Phoenix.CodeReloaderTest do
 
   defmodule Endpoint do
     def config(:reloadable_compilers) do
-      [:gettext, :unknown_compiler, :elixir]
+      [:unknown_compiler, :elixir]
     end
 
     def config(:reloadable_apps) do