-
-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
📦 Release – Elm Land v0.19.0 #59
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✅ Deploy Preview for elm-land ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
ryan-haskell
changed the title
📦 Release – Elm Land v0.18.2
📦 Release – Elm Land v0.19.0
Apr 23, 2023
…r when there are debug remnants
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When working with Elm Land, users benefit from automatically generated code. Users define Elm code in the
src/
folder, while the generated stuff lives under an.elm-land/src
folder.Because the generated code references code in
src
, it's possible to create a valid Elm module that causes issues in generated Elm Land code.This leads to compiler errors in the
.elm-land
folder, which is super confusing for folks. ( If they don't have control over those files, why are they seeing errors in them? )There have also been limitations reported around certain features:
onUrlChanged
from a page or a layoutSolution
1. Better error messages
The goal for the next release is to make sure all Elm compiler errors only occur within the user's
src
folder.This means we'll need to catch issues before reporting Elm compiler messages, if the user's code doesn't match Elm Land's expectations for modules.
🕵️ If you're curious, here are the specific error messages that will be added:
Pages
page
exports in any pageModel
exports in any stateful pageMsg
exports in any stateful pagepage
function doesn't return the expected type ( Ex:page : String
won't compile! )Layouts
Settings
toProps
, and ensure an Elm Land error message lets people know, to reduce confusionlayout
exports in any layoutSettings
exports in any layoutModel
exports in any layoutMsg
exports in any layoutlayout
function doesn't return the expected typeOther modules
Auth
expects a valid:User
onPageLoad
Effect
expects a valid:Effect
none
map
toCmd
Shared
expects a valid:Flags
decoder
Model
Msg
init
update
subscriptions
Shared.Model
expects a valid:Model
Shared.Msg
expects a valid:Msg
View
expects a valid:View
map
none
fromString
toBrowserDocument
elm-land.json
"Problems" page
https://elm.land/problems#missing-page-export
2. Route event functions
Every page and layout will have access to the following new URL hook functions:
3. Upgraded Layout system
The high-level idea for "layouts" in Elm Land is great, but we want to make sure they are useful in more scenarios. This update allows a layout's
Props
type to include a singlemsg
parameter.This enables you to send page messages from a layout, or even embed multiple page views within any layout. Here's an example of a
Props
type:This means if you have a "header" layout, you'll be able to embed interactive buttons the header bar, that have different behavior depending on the page.
Here's a visual example of when this might be useful:
4. Better guides, more resources
All the stuff mentioned above wasn't very time-consuming to implement. The hard part is making sure the next Elm Land release has more documentation, and it's even better than before!
To give you a sense of the scale, here's the current before/after for the official Elm Land guide (not shipped yet!):
💥 Breaking changes
Because you're using Elm, making the upgrade will be easy! The compiler will walk you through all the changes you'll need to make, one step at a time. This section is here to provide additional context into why the changes were made, in case you're curious!
1. "Catch-all" parameters now use
List String
Previously, creating a file at
src/Blog/ALL_.elm
created params namedfirst_
andrest_
. This has been replaced with a simpleall_
, to better match a user's intuition after learning about dynamic routes:Note: If you have a use case that needs "non-empty lists", this is still possible by using a dynamic folder before the catch-all:
2. Generated
Layouts.Layout
type now takes amsg
variableIn order to support the ability to send page messages and embed more than one page view, we've extended the layout
Props
type so it can include an optionalmsg
parameter.Because the
Props
type is used in the generated.elm-land/src/Layouts.elm
file, you'll need to make the following change to any page usingPage.withLayout
:3. The
Settings
type has been renamed toProps
layouts can define specific information passed in from a page. previously, this data was called
Settings
Elm Land now calls that data "props". If you are using any layouts today, you'll see an Elm Land error message expecting a
Props
type to be exposed.The solution is to rename
Settings
toProps
:3. New
parentProps
type variable onLayout
This release also comes with an update to how pages provide props to their layouts. We've removed the extra field nesting when using a layout.
For example, if you defined a
Layouts.Header
file with the followingProps
:Here's what you'll need to change for any page that is using this layout:
Hopefully, you'll find that this change:
Props
To make this work, in each existing layout, you'll also need to add the
parentProps
type variable on the return value of yourlayout
function.For top-level layouts:
If this is not a nested layout, add the
()
type. There are no parent props to worry about for top-level layouts likeLayouts.Sidebar
orLayouts.Default
:For nested layouts:
If this is a nested layout, add the
Props
type for the parent of the layout. For example, a layout atLayouts.Sidebar.Header
would use the props forLayouts.Sidebar
.To get the code to compile, use the new
Layout.withParentProps
function to provide the correct props:4.
Auth.viewLoadingPage
added,Auth.Action.showLoadingPage
lost an argFor compatibility with Lamdera, we've changed how
Auth.Action.showLoadingPage
works. Rather than passing yourView Never
into theshowLoadingPage
function, you'll define your loading page view within your customizedAuth
module.If you have customized the
Auth
module, here's what you'll need to do:If your customized
Auth
module is usingAuth.Action.showLoadingPage
, just move the existingView Never
argument from it's current location into the body of theviewLoadingPage
function.5. The
Effect.toCmd
module replacedfromCmd
withbatch
If you have customized your
Effect
module, you'll get a compiler error complaining that thefromCmd
field is no longer available. For compatibility with Lamdera, we've replaced this with abatch
field that should enable any features.If you were using the
fromCmd
argument, check out examples/11-error-reporting to learn how you can use thebatch
function to send commands in a slightly different way.Great documentation, approachable APIs, and clear error messages are a big part of what makes Elm so wonderful.
I'm very excited to get closer to sharing the next release, which will emphasize these core values in the Elm Land framework! 🌈