ckotzbauer/lodash-loader

Allow change import in es2015 mode

Closed this issue · 5 comments

Hi,

I need the change the replace of the import in es2015 mode (because of typescript config).

Can you add an option to change the replace by:
return "import _" + lodashModule + " from \"lodash/" + lodashModule + "\";\n";
?

Thanks!

Hi,

so you need instead of this as result:

import * as _each from "lodash/each";

this here with _each as default export?

import _each from "lodash/each";

With import * as _each from "lodash/each"; works too, but the extension is ts, so it's replaced by require('lodash/each').

So maybe with an option like importMode with

  • legacy (ts => commonjs, js => es6)
  • commonjs import a = require('a') (o maybe var a = require('a'))
  • es6 import * as a from 'a' or import a from 'a' (both works with lodash because it exports the function as default too)
  • auto Try to use the same way as is in code with regex?

Yes, I can implement this different behavior.

@JoniJnm Released in 1.1.0

Thanks!