Remove AMD?
giuem opened this issue ยท 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) {}
AMD will be removed after v1.3.0
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.
AMD will be removed after v1.3.0
8 months later it is still there ๐๏ธ
- try { module.exports = DisqusJS; } catch (e) { }
+ export { DisqusJS }