Skip to content

Comments

feat: support --esm#78

Open
lishaduck wants to merge 1 commit intolamdera:lamdera-nextfrom
lishaduck:esm
Open

feat: support --esm#78
lishaduck wants to merge 1 commit intolamdera:lamdera-nextfrom
lishaduck:esm

Conversation

@lishaduck
Copy link

@lishaduck lishaduck commented Feb 18, 2026

Quick Summary: fixes #9.

This definitely needs a lotbit more work but it was a nice project to procrastinate on my physics hw with last night :)

This is my first time actually writing Haskell. I've read through a decent chunk of the wiki but was always too lazy to actually write some. Hopefully it's not completely awful (it is) but please just try to be honest where I've completely gone off the rails.
Oh, also, no AI of any form was used in the writing of this PR. It's all me. If it's slop, it's at least human slop :)

It won't offend me at all if you just close this as "not planned."

TODO:

  • Resupport injections (While it should just be strict mode either way, when loading the file as ESM it breaks.
  • Actually put behind a flag (I added a flag but couldn't figure out how to wire it into codegen without breaking a lot else. It's mostly setup to use an option though.)
  • More Haskellmaxxing magic to minimize the diff
  • Check what happens in --debug and --optimize and be scared
  • elm-esm does some other transformations. Are they important?

Additional Details

Locally developing, it took me a bit to set the whole thing up. I just want to check I'm not missing anything:

  • As per extra/readme.md, HLS doesn't work
  • You need esbuild globally installed the build? Am I missing another package.json? Even with esbuild, it builds but repl-worker gets emptied
  • stack run make src/Index.elm -- --output=assets/elm.mjs && node assets/importer.mjs on the Reactor is about the best I'll get for testing?
  • Should I expect lots of warnings (mostly from dependencies) when compiling?
  • stack test and ghci + :rr will work... fine for checking compile errors, but the tests won't actually pass unless I'm Lamdera team because they rely on the API or similar.

I think this part of the template is just for bug fixes, please correct me if I'm wrong.

SSCCE

  • Elm: ???
  • Browser: ???
  • Operating System: ???

@lishaduck
Copy link
Author

lishaduck commented Feb 18, 2026

Oh, I read the issue and then went and wrote this without referencing it again 😅

A generateEsm function would make this decently simpler 👍🏻 Will refactor it whenever I've next got some (not?) free time.

EDIT: made the changes, much simpler; switches work now!

@lishaduck lishaduck force-pushed the esm branch 2 times, most recently from ed40f5e to 6c627c7 Compare February 18, 2026 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate potential --esm make flag

1 participant