Skip to content
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

Migrate to PureScript 0.15 #112

Merged
merged 9 commits into from
May 4, 2022
Merged

Migrate to PureScript 0.15 #112

merged 9 commits into from
May 4, 2022

Conversation

thomashoneyman
Copy link
Owner

This pull request migrates Real World Halogen from PureScript 0.14 to 0.15 and from Halogen 6 to 7.

The biggest update to the compiler in PureScript 0.15 is the switch from CommonJS to ES modules. Among other benefits, the new output results in up to 25% smaller bundles (Real World Halogen dropped 100kb, from 600kb to 500kb 🎉). It also means that we no longer need to use zephyr, so that has been dropped from this project. Learn more:

Halogen 7 is an intentionally tiny release that mostly provides compatibility with PureScript 0.15. It has no changes that affected Real World Halogen. Still, it may have changes that affect you, so it's worth reading that migration guide too:

And that's about it! Upgrading to the latest compiler and Halogen release is pretty painless.

@thomashoneyman thomashoneyman merged commit e5db323 into main May 4, 2022
@thomashoneyman thomashoneyman deleted the trh/purescript-0.15 branch May 4, 2022 14:37
@paulyoung
Copy link

Zephyr stopped working in my project after I upgraded to 0.15 and I came here to see what you might be doing.

Can you explain why Zephyr is no longer needed, or are you just satisfied the the bundle is small enough to remove it? Thanks!

@paulyoung
Copy link

FWIW, my build started failing with errors like this:

✘ [ERROR] Could not resolve "./foreign.js"

    dce-output/Effect/index.js:3:23:
      3 │ var $foreign = require("./foreign.js");

@paulyoung
Copy link

According to this, it seems like tools like webpack should now be able to do DCE. I'm also using esbuild so curious how that works out.

https://discord.com/channels/864614189094928394/872650895744176188/983717748666413108

@thomashoneyman
Copy link
Owner Author

thomashoneyman commented Jun 11, 2022

JS bundlers had a hard time performing dead code elimination on the CommonJS output of the PureScript compiler prior to 0.15. For that reason, I relied on Zephyr to perform DCE on the PureScript code, and then bundled the result.

However, the PureScript 0.15 compiler produces ES modules as output, with purity annotations, which greatly helps bundlers like webpack and esbuild along. Bundling the output of the PureScript 0.15 compiler is typically about 30% smaller than bundling the output of PureScript 0.14 compiled to corefn and then run through Zephyr.

The end result: Zephyr isn't needed anymore. If you need any extra motivation, I don't believe there's a version of Zephyr that even works with the PureScript 0.15 compiler.

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.

2 participants