How to correctly use ES6 “export default” with CommonJS “require”?
问题 I've been working through Webpack tutorial. In one of the sections, it gives the code example that contains one line of essence to this question: export default class Button { /* class code here */ } In the next section of said tutorial, titled "Code splitting", the class defined above is loaded on demand, like this: require.ensure([], () => { const Button = require("./Components/Button"); const button = new Button("google.com"); // ... }); Unfortunately, this code throws an exception: