MacDownApp / macdown

Open source Markdown editor for macOS.
https://macdown.uranusjr.com/
9.44k stars 1.09k forks source link

Migrate some script to modern JavaScript #959

Open FranklinYu opened 6 years ago

FranklinYu commented 6 years ago

@uranusjr has mentioned in https://github.com/MacDownApp/macdown/pull/958#discussion_r180462883 that we may convert/rewrite some script with modern JavaScript (i.e. ES6+). We need transpiler (such as Bable) because according to this post, WebView in macOS 10.11 uses WebKit 601.7.8 (i.e. Safari 9, according to Wikipedia), which supports virtually nothing in ES6.

Simple Babel config should be OK:

{
  "presets": ["env"]
}

This would transform latest JavaScript to ES5, which (I assume) works well even in WebKit 536.30.1 in macOS 10.8.

Still I'm not sure whether it's necessary to migrate all JavaScript files. In addition, #952 may need modification or rework, such as renaming the folder to asset-generator.

uranusjr commented 6 years ago

All 10.11 machines should be able to upgrade to the latest (11.1) version, which supports most useful ES6 and CSS3 features. Babel is still a good idea regardless however IMO.

FranklinYu commented 6 years ago

@uranusjr Yes, but the WebKit for WebView will not upgrade even if user upgrade their Safari, as explained in this answer. Safari will bundle its own WebKit to run on older platforms.

New major Safari versions not only add shiny new features, and bugs, they sometimes also remove things. Some ill faded -webkit prefixes come to mind. WebKit is part of the SDK which guaranties you that your app will not break on such updates.

uranusjr commented 6 years ago

OMG