mnater / Hyphenopoly

Hyphenation for node and Polyfill for client-side hyphenation.
http://mnater.github.io/Hyphenopoly/
MIT License
694 stars 44 forks source link

Minified Hyphonpoly.js fails after "npm run prepare" on WSL Debian + Github Desktop for Windows #134

Closed ReLater closed 4 years ago

ReLater commented 4 years ago

Hyphonopoly 4.6.0.

I'm using Windows Subsystem for Linux (WSL)/Debian on Windows 10. Maybe that's the reason(???). The repositories are located on a WIN hard disc.

After cloning this repository I started npm i and/or npm run prepare. My goal was to get the terser minified JS files in directory /min/, too.

Afterwards I tested the created files with my Joomla plugin on Vivaldi.

The uncompressed files work like expected.

With the minified Hyphenopoly.js I got fatal errors finishing with "Hyphenopoly timed out" and mentionig problems with RegExpressions in code that pointed to this code block.

0002

Afterwards I minified Hyphonpoly.js with PrePros. Same results and errors. Then I found a terser option in PrePros "ASCII only" ("escape Unicode characters in strings and regexps (affects directives with non-ascii characters becoming invalid)").

The resulting file worked without throwing errors.

0003

Then I tried to find a solution for the terser line in minify.sh and after 1, 2 hours of Trial&Error i finally used

terser Hyphenopoly.js -o min/Hyphenopoly.js --comments -c passes=3,unsafe -m --warn -b beautify=false,ascii_only=true

I haven't tested the resulting file but it looks OK (somehow)

0004

mnater commented 4 years ago

Hmm.

I cannot reproduce. First I thought this could be an issue with Vivaldi. So I installed Vivaldi for Mac (3.1.1929.45: everything works fine). Then I installed Vivaldi on Windows 10 (3.1.1929.45: everything works fine). So I thought maybe there's an issue when using WSL. So I set up WSL on Windows 10 with Ubuntu 20.04 LTS, cloned the repository, installed npm, ran npm run prepare, copied the min folder to IIS and opened the testsuite in Vivaldi and Edge (everything works fine)...

So I'm stuck here. Could you please give me some more details:

Could this be an issue when creating the Joomla-Plugin? (I once run in some problems when cutting and pasting the code on Mac.)

BTW: If possible I'd like to not use ascii_only since this makes the code larger.

ReLater commented 4 years ago

Thank you for quick response.

I will make further tests and inform you more detailed.

The code in my image 1 is correct in principle? With other words: The characters like \Uxyz2 shall be "translated" to Unicode characters during minification? Or should the \Uxyz2s inside the RegExp stay intact?

Can you attach a minified Hyphenopoly.js?

Could this be an issue when creating the Joomla-Plugin?

No because I work old-fashioned there without npm, package.json. dependencies or so (https://github.com/GHSVS-de/plg_system_hyphenateghsvs). I simply copy the created files and not the content. Upload them to GitHub. At the end it gets only zipped by GitHub ("Draft a new Release") which results in an installable Joomla extension.

The images above are from my local repository/clone before this copy/upload. I cloned the repository directly from here and also cloned another one with steps like described in https://github.com/mnater/Hyphenopoly/issues/128 (.gitattributes).

Vivaldi

I always use the newest available version

Vivaldi | 3.1.1929.45 (Stable channel) (32-Bit)
-- | --
Überarbeitung | 1eb3263017ed42270818939fbff241845938a81f
Betriebssystem | Windows 10 OS Version 1909 (Build 18363.900)
JavaScript | V8 8.3.110.13
Flash | (Deaktiviert)
User-Agent | Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.119 Safari/537.36
Befehlszeile | "C:\Users\root\AppData\Local\Vivaldi\Application\vivaldi.exe" --flag-switches-begin --flag-switches-end --enable-audio-service-sandbox --save-page-as-mhtml
Ausführbarer Pfad | C:\Users\root\AppData\Local\Vivaldi\Application\vivaldi.exe
Profilpfad | C:\Users\root\AppData\Local\Vivaldi\User Data\Default
mnater commented 4 years ago

Image 1 looks correct. You can find a min version here: https://github.com/mnater/Hyphenopoly/tree/master/docs/min

ReLater commented 4 years ago

Because the files in docs/min work fine for me I close here until I find the time to make further investigations with one of the next Hyphenopoly releases. Upgrading WSL and the coupled Debian seems to be a "too big risk" for my daily work at the moment ;-)

Thanks for your (wasted) time!