Search code examples
javascriptecmascript-6amdwebpackcommonjs

Webpack with ES6: module import policy


I noticed that in many sample projects with webpack & ES6 (also in my current) to import an external module require is sued instead of ES6's import.

Is there any benefit from using require/module.exports instead of import/export in app bundled with webpack?


Solution

  • I feel that's just a convention. I would stick to import/export given it's the new standard.

    There's one exception to this rule - require.ensure. If you want to set up split points, that's what you have to use for now. This will likely change when webpack 2 gets out.