SukkaW / DisqusJS

:speech_balloon: Render Disqus comments in Mainland China using Disqus API
https://disqusjs.skk.moe
MIT License
646 stars 56 forks source link

Remove AMD? #23

Open giuem opened 5 years ago

giuem commented 5 years ago

As this article said,

AMD is no longer a popular format, making it a likely distant fourth contender to ES Modules, CommonJS and globals. The problems AMD solves have been moved elsewhere - typically into the realm of module bundlers like Webpack and Rollup. Instead of asynchronous loading as a feature of our chosen module formats, it's an implementation detail of our chosen bundler.

We can remove AMD to save bytes as the article mentioned.

function DisqusJS(config) {}
// attempt to export for CommonJS
try { module.exports = DisqusJS; } catch (e) {}  
SukkaW commented 4 years ago

AMD will be removed after v1.3.0

giuem commented 4 years ago

And enable babel loose mode will save a few bytes since code is cleaner. It also brings performance improvement. (e.g. for...of)

gulp.task('minify-js', () => gulp.src('src/**/*.js')
    .pipe(babel({
        "presets": [
            ["@babel/env", {
                "targets": configs.browsers,
+               "loose": true
            }]
        ]
    }))

BTW, I strongly recommend use bundlesize to trace the bundle size changes.

kidonng commented 4 years ago

AMD will be removed after v1.3.0

8 months later it is still there 🕊️

- try { module.exports = DisqusJS; } catch (e) { }
+ export { DisqusJS }