elm / compiler

Compiler for Elm, a functional language for reliable webapps.
https://elm-lang.org/
BSD 3-Clause "New" or "Revised" License
7.48k stars 659 forks source link

Dangerous advice in optimize.md wrt Unicode #2246

Open VulumeCode opened 2 years ago

VulumeCode commented 2 years ago

Quick Summary: Using a Unicode symbol like "↵" in an Elm string works fine. After following the uglifyjs advice in optimize.md it has encoding issues.

https://github.com/elm/compiler/blob/master/hints/optimize.md

It seems to work fine without mangling, but I don't trust it any further.

github-actions[bot] commented 2 years ago

Thanks for reporting this! To set expectations:

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

lydell commented 2 years ago

Hi!

I tried to reproduce this (because I’m interested in minifying Elm code; I wrote https://discourse.elm-lang.org/t/what-i-ve-learned-about-minifying-elm-code/7632).

But I didn’t manage.

module Main exposing (main)

import Html

main = Html.text "↵"
<!doctype html>
<html lang="en">
<title>test</title>
<script src="elm.min.js"></script>
<div id="node1"></div>
<script>
  Elm.Uni.init({ node: node1 })
</script>

Followed the commands at https://github.com/elm/compiler/blob/39949053f9469862b17006e3965f3b440414d13c/hints/optimize.md#instructions

UglifyJS version 3.15.3.

The “↵” displays correctly both before and after minification.

Am I missing something? Do you have steps to reproduce?