Greg Gum
Greg Gum

Reputation: 38079

Using "import" in webpack

I have been using jspm and want to test out using Webpack.

I have followed this tutorial.

However, when I run the example, the js errors on

 import _ from 'lodash';

Is there a different way I should be writing this import statement? Should I use a transpiler on it to turn it into a require statement?

Upvotes: 1

Views: 119

Answers (1)

Felix Kling
Felix Kling

Reputation: 817010

Webpack 1 doesn't support ES6, so yes, in that case you have to use a transpiler.

Webpack 2 supports ES6 and can perform advanced optimizations when working with ES6 modules, but you might still need a transpiler if you use other ES6 features that are not supported by the environment you want to executed the code in.

Upvotes: 1

Related Questions