I'd like to export a module using the ES6 syntax only if it is supported in the current runtime. The goal is to develop a library that support different module management systems.
As export
is a keyword, something like will throw a syntax error :
typeof export
ES6 module loaders will be asynchronous while node. js module loaders are not. Here are some key aspects of module loaders: Module code automatically runs in strict mode and there's no way to opt-out of strict mode.
Examples of side effects:A polyfill that enables ES6 features in the browsers that don't support them, like babel polyfill is a side effect. Many jQuery plugins attach themselves to the global jQuery object. Analytics modules that run in the background, monitor user interaction, and send the data to a server.
ES6 comes to your rescue with the concept of Modules. A module organizes a related set of JavaScript code. A module can contain variables and functions. A module is nothing more than a chunk of JavaScript code written in a file.
Use
'noModule' in HTMLScriptElement.prototype
ref
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With