-
Notifications
You must be signed in to change notification settings - Fork 147
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
Let's talk about dead code elimination #314
Comments
Hi @andys8, thanks for creating this issue! I think the primary source of confusion is that the documentation was not yet updated to describe the changes of create-elm-app v2 #283. Before In my opinion, introducing Here's what I can propose to solve this issue:
This would reduce the unnecessary configuration and provide a less confusing build optimization setup. How does that sound? |
Sounds awesome! |
Are you interested in working on a PR? |
I could look into getting a PR started, but I'm not familiar with Webpack plugins. Therefore I'm not confident in implementing the details of the second bullet point and making sure nothing broke. |
The interesting part is, that the elm docs suggest running uglifyjs twice (which sounds like a workaround in the first place). uglifyjs elm.js --compress 'pure_funcs="F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9",pure_getters,keep_fargs=false,unsafe_comps,unsafe' | uglifyjs --mangle --output=elm.min.js https://guide.elm-lang.org/optimization/asset_size.html And that's probably the case why var minify = function (elmJs, compressionPasses) {
var compressionResult = ujs.minify(elmJs,
toUglifyJsCompressionConfig(compressionPasses)
)
var mangleResult = ujs.minify(compressionResult.code,
uglifyJsMangleConfig
)
return mangleResult.code
} Again, not too familiar with Webpack configs, but couldn't we have the UglifyJS Plugin definition just twice with different settings? Order is probably deterministic. |
I think they are referring to the UglifyJS configuration property called If I'm not mistaken, the statement about increasing the number of passes is coming from the following discussion elm-community/elm-webpack-loader#142 (comment)
How does that sound? |
Yeah, right. Thanks for the hint for the discussion about passes. So there are two things:
A total of 2-4 runs. My comment above was targeting, how to run uglifyjs with different settings sequentially. But Richard also wrote at the end of the comment, that using Also interesting:
|
You are right, I did not check the code very carefully. After looking into this for some time, I think it might be worth checking https://www.npmjs.com/package/terser-webpack-plugin instead of the UglifyJS plugin. I suspect that it would be okay to use Terser with a single pass with Do you think it's worth running multiple passes? |
The easiest approach would be to use the provided webpack plugin of
The more important part is the note in the elm docs, which suggests, that there is an issue, where standard ugligyjs (commandline) usage will not work as expected, which lead to the manually sequenced calls.
|
Sounds fair 👍 |
@halfzebra Opened PR #315 :) |
Thanks for your work, your PR has been released with the latest patch release. Check it out! 🎉 |
Since dead code elimination is one of the core features of elm 0.19.
Does it make sense to disable dead-code elimination by default?
I guess
DEAD_CODE_ELIMINATION
is about the uglify settings, butelm-webpack-loader
would still set the--optimize
flag.Since the elm documentation itself describes how to run uglify, it should be pretty safe to enable the settings by default.
An alternative approach would integrate
elm-minify
which is implementing a webpack plugin. It's about adding a dependency, but maintaining less directly (in cases this will be improved in the future). In any way the implementation is interesting, since there are differences in the settings.https://github.com/opvasger/elm-minify/blob/master/src/api.js
The text was updated successfully, but these errors were encountered: