mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-26 13:21:42 +03:00
3.5 KiB
3.5 KiB
3.0 Upgrade Notes
elm.json
- Add dependency
"lamdera/codecs": "1.0.0"
File Structure
rm -rf .elm-pages
- Add
app/
toelm.json
source-directories
mkdir app && mv src/Page/ app/Route
- Move
public/index.js
to the top-level project folder:mv public/index.js index.js
Shared.elm
- Change
Cmd Msg
toEffect Msg
init
no longer passes inMaybe Browser.Navigation.Key
- instead,Effect.toCmd
receives theBrowser.Navigation.Key
Page -> RouteBuilder
buildWithLocalState
no longer receivesMaybe Browser.Navigation.Key
- useEffect
insteadPage.prerender
->RouteBuilder.preRender
Secrets
Pages.Secrets
is no longer needed! It used to be necessary to ensure that server secrets didn't end up included in data for hydrating the page from your OptimizedDecoders. Now, only the final data payload is optimized (not intermediary data in the pipeline). So if your finalData
andActionData
types on your page do not have any server secrets, then your hydrated data won't either.- When you didn't use any secrets but did
Secrets.succeed
and pulled in no secrets, you can removeSecrets.succeed
. - When you need to use secrets (previously
Pages.Secrets.with
), instead ofPages.Secrets
, you can now useBackendTask.Env.expect
to pull in server
- When you didn't use any secrets but did
Other Notes
import Page exposing (Page, StaticPayload)
->import RouteBuilder exposing (StatelessRoute, StaticPayload)
Html.map Pages.Msg.UserMsg
- In Shared.elm,
view
now returns a List of HTML instead of single HTML. The HTML elements in this list will be at the top-level of thebody
tag, with two hidden elements above them (rendered by the framework for accessibility functionality).body : List (Html msg)
- For
RouteBuilder.preRender
pages, theMsg
must be defined astype alias Msg = ()
- Additional type variable in
StaticPayload
.StaticPayload Data RouteParams
->StaticPayload Data ActionData RouteParams
- Must expose
ActionData
from each Route Module - Copy these files from example repo
app/ErrorPage.elm
app/Effect.elm
elm-pages add
is replaced byelm-pages codegen
elm-pages codegen
command (to create generated files, helpful for build servers) is renamed toelm-pages gen
- Route modules exposed value defining the route used to be called
page
, now needs to beroute
- In
Route.link
function, theRoute
used to be the first argument, it is now the last argument (works nicely if you pipe the Route in as an argument). secrets that you need (just don't put sensitive data into yourData
orActionData
types. Example:BackendTask.Env.expect "MY_ENVIRONMENT_VARIABLE_SECRET" |> BackendTask.andThen (\secret -> myBackendTaskThatUsesASecret secret)
- In Shared.elm and Route Modules,
init
andupdate
functions no longer return aCmd msg
but instead anEffect msg
Maybe Browser.Navigation.Key
is no longer passed in toShared.init
. Instead, you get access to it inEffect
, so you can create variants in yourEffect
type for anything that needs that typeSiteConfig
type no longer has any type variablesSiteConfig Data
->SiteConfig
Site.config
no longer takes adata : BackendTask Data
field. Instead,{ head : BackendTask (List Head.Tag), ... }
is a BackendTask so you can resolve any data you need for global site head tags there.SiteConfig
no longer includes amanifest : ...
field. Instead, you can generate a manifest.json file in yourApi.elm
module (TODO link to example)