From 32b4bbc572f1c03e52f4be650e750f16dae645f6 Mon Sep 17 00:00:00 2001 From: Hayleigh Thompson Date: Sun, 17 Mar 2024 17:33:50 +0000 Subject: :recycle: Move component entry script into external template. --- src/lustre/cli/build.gleam | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/lustre/cli/build.gleam b/src/lustre/cli/build.gleam index 352329d..656cfcc 100644 --- a/src/lustre/cli/build.gleam +++ b/src/lustre/cli/build.gleam @@ -11,7 +11,7 @@ import glint.{type Command, CommandInput} import glint/flag import lustre/cli/esbuild import lustre/cli/project.{type Module} -import lustre/cli/utils.{keep, replace, try} +import lustre/cli/utils.{keep, replace, template, try} import lustre/cli/step.{type Step} import simplifile @@ -47,11 +47,8 @@ JavaScript module for you to host or distribute. let _ = simplifile.create_directory_all(tempdir) let _ = simplifile.create_directory_all(outdir) let entry = - "import { main } from '../dev/javascript/${project_name}/${project_name}.mjs'; - - main(); - " - |> string.replace("${project_name}", project_name) + template("entry-with-main.mjs") + |> string.replace("{app_name}", project_name) let entryfile = filepath.join(tempdir, "entry.mjs") let ext = case minify { @@ -117,14 +114,10 @@ present. use project_name <- step.try(get_project_name(), keep) let entry = - "import { register } from '../dev/javascript/lustre/client-component.ffi.mjs'; - import { name, ${component} as component } from '../dev/javascript/${project_name}/${module_path}.mjs'; - - register(component(), name); - " - |> string.replace("${component}", component) - |> string.replace("${project_name}", project_name) - |> string.replace("${module_path}", module_path) + template("component-entry.mjs") + |> string.replace("{component_name}", component) + |> string.replace("{app_name}", project_name) + |> string.replace("{module_path}", module_path) let entryfile = filepath.join(tempdir, "entry.mjs") let ext = case minify { -- cgit v1.2.3