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

Wrong argument to uglifyjs on .../hints/optimize.md #2162

Closed
DrTobe opened this issue Jan 6, 2021 · 6 comments
Closed

Wrong argument to uglifyjs on .../hints/optimize.md #2162

DrTobe opened this issue Jan 6, 2021 · 6 comments

Comments

@DrTobe
Copy link

DrTobe commented Jan 6, 2021

Quick Summary: The argument --output=elm.min.js to uglifyjs should be --output elm.min.js

Additional Details

On https://github.com/elm/compiler/blob/master/hints/optimize.md, this appears twice. First, in "here is how I would optimize", second in the scripts section.

uglifyjs fails with "ERROR: invalid option --output=elm.min.js"

I have installed uglify-js 3.12.4

If you can not reproduce this, please let me know. Thanks.

@github-actions
Copy link

github-actions bot commented Jan 6, 2021

Thanks for reporting this! To set expectations:

  • Issues are reviewed in batches, so it can take some time to get a response.
  • Ask questions a community forum. You will get an answer quicker that way!
  • If you experience something similar, open a new issue. We like duplicates.

Finally, please be patient with the core team. They are trying their best with limited resources.

@Eptarch
Copy link

Eptarch commented Jan 28, 2021

I happen to encounter the same.
Inspecting uglifyjs -h showed that uglifyjs doesn't know what --output=elm.min.js means, but it perfectly understands --output elm.min.js
so the .sh should look like this:

#!/bin/sh

set -e

js="elm.js"
min="elm.min.js"

elm make --optimize --output=$js $@

uglifyjs $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 $min

echo "Initial size: $(cat $js | wc -c) bytes  ($js)"
echo "Minified size:$(cat $min | wc -c) bytes  ($min)"
echo "Gzipped size: $(cat $min | gzip -c | wc -c) bytes"

I hope it helps ;]

@Caleb-Irwin
Copy link
Contributor

I ran into this exact problem some time ago when I was first learning Elm. I eventually figured it out. Is there a PR for this?

I can also confirm this works:

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

@Caleb-Irwin
Copy link
Contributor

Caleb-Irwin commented Jan 31, 2021

It should be the same on every system as (if memory serves) it is handled by uglifyjs directly. So I will add a PR.

@evancz
Copy link
Member

evancz commented Feb 3, 2021

Thanks to @Caleb-Irwin for the fix.

@evancz evancz closed this as completed Feb 3, 2021
@Caleb-Irwin
Copy link
Contributor

No problem! Happy to help Elm.

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

No branches or pull requests

4 participants