Nezir Zahirovic
Nezir Zahirovic

Enabling Modern JavaScript on npm

Modern JavaScript syntax lets you do more with less code, but how much of the JavaScript we ship to users is actually modern?More recently, developers have adopted differential bundling techniques where two or more distinct sets of JavaScript files are produced to target different environments. The most common example of this is the module/nomodule pattern, which leverages native JS Modules (also known as "ES Modules") support as its “cutting the mustard” test: modules-supporting browsers request modern JavaScript (~ES2017), and older browsers request the more heavily polyfilled and transpiled legacy bundles. Compiling for the set of browsers defined by their JS Modules support is made relatively straightforward courtesy of the targets.esmodules option in @babel/preset-env, and Webpack plugins like babel-esm-plugin make producing two sets of JavaScript bundles mostly painless.


Enabling Modern JavaScript on npm #javascriptba #javascript #nodejs #reactjs #angularjs #vuejs #meteorjs #typecscript #jquery #emberjs #bosnia