Simplify Scripts so that the entrypoint only requires elm-pages as a dependency.

This commit is contained in:
Dillon Kearns 2023-05-01 14:13:17 -07:00
parent bdbb5ac84d
commit e25dcbc8f0
2 changed files with 15 additions and 12 deletions

View File

@ -325,16 +325,11 @@ async function requireElm(compiledElmPath) {
function generatorWrapperFile(moduleName) {
return `port module Main exposing (main)
import BackendTask exposing (BackendTask)
import FatalError
import Cli.Program as Program
import Json.Decode as Decode
import Json.Encode as Encode
import Pages.Internal.Platform.GeneratorApplication
import ${moduleName}
main : Program.StatefulProgram Pages.Internal.Platform.GeneratorApplication.Model Pages.Internal.Platform.GeneratorApplication.Msg (BackendTask FatalError.FatalError ()) Pages.Internal.Platform.GeneratorApplication.Flags
main : Pages.Internal.Platform.GeneratorApplication.Program
main =
Pages.Internal.Platform.GeneratorApplication.app
{ data = ${moduleName}.run
@ -345,13 +340,13 @@ main =
}
port toJsPort : Encode.Value -> Cmd msg
port toJsPort : Pages.Internal.Platform.GeneratorApplication.JsonValue -> Cmd msg
port fromJsPort : (Decode.Value -> msg) -> Sub msg
port fromJsPort : (Pages.Internal.Platform.GeneratorApplication.JsonValue -> msg) -> Sub msg
port gotBatchSub : (Decode.Value -> msg) -> Sub msg
port gotBatchSub : (Pages.Internal.Platform.GeneratorApplication.JsonValue -> msg) -> Sub msg
`;
}
function collect(value, previous) {

View File

@ -1,8 +1,8 @@
module Pages.Internal.Platform.GeneratorApplication exposing (Flags, Model, Msg(..), init, requestDecoder, update, app)
module Pages.Internal.Platform.GeneratorApplication exposing (Program, Flags, Model, Msg(..), init, requestDecoder, update, app, JsonValue)
{-| Exposed for internal use only (used in generated code).
@docs Flags, Model, Msg, init, requestDecoder, update, app
@docs Program, Flags, Model, Msg, init, requestDecoder, update, app, JsonValue
-}
@ -25,6 +25,14 @@ import Pages.StaticHttp.Request
import TerminalText as Terminal
type alias JsonValue =
Decode.Value
type alias Program =
Program.StatefulProgram Model Msg (BackendTask FatalError.FatalError ()) Flags
{-| -}
type alias Flags =
{ compatibilityKey : Int
@ -47,7 +55,7 @@ type Msg
{-| -}
app :
GeneratorProgramConfig
-> Program.StatefulProgram Model Msg (BackendTask FatalError ()) Flags
-> Program
app config =
let
cliConfig : Program.Config (BackendTask FatalError ())