@@ -102,7 +102,7 @@ defmodule Phoenix.LiveView.ColocatedJS do
102102 > #### Warning! {: .warning}
103103 >
104104 > LiveView assumes full ownership over the configured `:target_directory`. When
105- > compiling, it will **delete** any files and folders inside the `:target_directory`,
105+ > compiling, it will **delete** any files and folders inside the `:target_directory`,
106106 > that it does not associate with a colocated JavaScript module or manifest.
107107
108108 ### Imports in colocated JS
@@ -275,13 +275,20 @@ defmodule Phoenix.LiveView.ColocatedJS do
275275 end
276276
277277 defp write_new_manifests! ( files ) do
278- files
279- |> Enum . group_by ( fn { _file , config } ->
280- config [ :manifest ] || "index.js"
281- end )
282- |> Enum . each ( fn { manifest , entries } ->
283- write_manifest ( manifest , entries )
284- end )
278+ if files == [ ] do
279+ File . write! (
280+ Path . join ( target_dir ( ) , "index.js" ) ,
281+ "export const hooks = {};\n export default {};"
282+ )
283+ else
284+ files
285+ |> Enum . group_by ( fn { _file , config } ->
286+ config [ :manifest ] || "index.js"
287+ end )
288+ |> Enum . each ( fn { manifest , entries } ->
289+ write_manifest ( manifest , entries )
290+ end )
291+ end
285292 end
286293
287294 defp write_manifest ( manifest , entries ) do
0 commit comments