DisqusJS icon indicating copy to clipboard operation
DisqusJS copied to clipboard

Remove AMD?

Open giuem opened this issue 6 years ago • 3 comments

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) {}  

giuem avatar Feb 12 '19 17:02 giuem

AMD will be removed after v1.3.0

SukkaW avatar Nov 04 '19 16:11 SukkaW

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.

giuem avatar Nov 05 '19 02:11 giuem

AMD will be removed after v1.3.0

8 months later it is still there 🕊️

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

kidonng avatar Jul 11 '20 17:07 kidonng