Webpack and external libraries

According to the Webpack documentation, you can use the externals property on the config object “to specify dependencies for your library that are not resolved by webpack, but become dependencies of the output. This means they are imported from the enviroment while runtime [sic].” The example on that page illustrates it really well, using jQuery. … Read more

How to import part of object in ES6 modules

Unfortunately import statements does not work like object destructuring. Curly braces here mean that you want to import token with this name but not property of default export. Look at this pairs of import/export: //module.js export default ‘A’; export var B = ‘B’; //script.js import A from ‘./a.js’; //import value on default export import {B} … Read more

supporting both CommonJS and AMD

Yes, and I owe this answer to ded and his awesome modules: (function(name, definition) { if (typeof module != ‘undefined’) module.exports = definition(); else if (typeof define == ‘function’ && typeof define.amd == ‘object’) define(definition); else this[name] = definition(); }(‘mod’, function() { //This is the code you would normally have inside define() or add to … Read more