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
Update transformer-elm
to use swc
instead of terser
#8134
Conversation
There's a paragraph in https://github.com/parcel-bundler/parcel/blob/v2/CONTRIBUTING.md#getting-started-with-bug-fixing:
|
Looks like swc expects the options to have a different format.
|
Hi @balazs-lengyel, thanks for following up on this! Here are the options I'm providing to the {
compress: {
keep_fargs: false,
passes: 2,
pure_funcs: elmPureFuncs,
pure_getters: true,
unsafe_arrows: true,
unsafe_comps: true,
unsafe_Function: true,
unsafe_math: true,
unsafe_symbols: true,
unsafe_methods: true,
unsafe_proto: true,
unsafe_regexp: true,
unsafe_undefined: true,
},
mangle: false,
} It diverges more from the Terser options currently used by the Parcel Elm transformer because I based it off of the Terser configuration that I was previously using with Webpack. |
a040116
to
1bfb013
Compare
Thanks @mischnic! It seems that I have gone full circle until I understood the error messages and what I needed to do. Now I've rebased and force pushed Thanks @rjdellecese for sharing, did you need any of the additional settings for elm specific reasons or was it just for your project specific needs? |
My project began its life using Webpack via https://github.com/halfzebra/create-elm-app, so it was pretty much just a translation of what had been configured there—that is, I have no particular reason to believe that just using the previously-specified options in Parcel's existing Elm transformer wouldn't work just fine (unless I'm forgetting something). |
04b8f49
to
351bca9
Compare
@mischnic: Updated - can you restart CI? |
I don't see how to fix further tests (failed HMR/css) - can you give me a hint on how to approach that? |
You can ignore them, these tests are flakey |
If there is nothing else to do, I'd say this is done! |
So what exactly is the motivation here? That for some inputs, Terser is very slow/doesn't terminate at all in a reasonable time? |
Yes, terser doesn't terminate for elm programs after they reach (some unknown) size/complexity or use a pattern where the elm compiler puts too much stress on terser. While testing on a private project and waiting for this bug to occur, I found that the swc minified version was in the same ballpark as the terser one (usually much less then 1kB difference on the up to ~50kB results) This has hit:
This PR fixed the build issue I had, with the only caveat that i couldn't test the full application as I needed to comment out some parts of the js/css while doing the |
56d801c
to
516f0b8
Compare
516f0b8
to
fc5ca07
Compare
never mind! I just realized that this seems to be fixed in terser! |
In terser/terser#1212, it seems? Thank you @ChristophP for reporting the issue! |
↪️ Pull Request
The elm transformer is broken for at least some bigger elm applications (see for example #7585). The reason is that terser doesn't really like the JS output by the elm compiler (see for example https://discourse.elm-lang.org/t/ot-webpack-terser-build-issue/7606)
In the discussion for #7585 @rjdellecese wrote about using
swc
instead ofterser
to solve the issue without turning of optimization, but there was no code shared. So I tried to recreate the work from the description.The only issue have with this PR is that my practical JS knowledge is limited and I couldn't get the plugin to work locally for testing. It should be a trivial change though. Any feedback/pointer on how to get a local version of
transformer-elm
working on a nix-based system are appreciated!💻 Examples
No publicly shareable codebase, but the issue seems to happen whenever terser is used to optimize elm applications above a certain size/complexity.
🚨 Test instructions
✔️ PR Todo