Galooshi / import-js

A tool to simplify importing JS modules
MIT License
526 stars 70 forks source link

Lodash alias doesn't work #560

Closed LandonSchropp closed 7 months ago

LandonSchropp commented 3 years ago

I'm trying to get ImportJS to automatically import Lodash for me. Here's what my config looks like:

module.exports = {
  aliases: {
    _: "lodash",
  },
  danglingCommas: false,
  maxLineLength: 100
};

When I run ImportJS on a file containing this:

console.log(_.map([ 1, 2, 3 ], x => x * x));

Nothing seems to happen. What am I missing?

Thanks!

trotzig commented 3 years ago

Hi @LandonSchropp! I can confirm this isn't working in my case either. A workaround seems to be if you specify the full path to the lodash module. This works for me:

module.exports = {
  aliases: {
    _: "node_modules/lodash",
  }
};
LandonSchropp commented 3 years ago

@trotzig Thanks for the workaround! That seems to get me past the issue. 🙂

mikabytes commented 7 months ago

Closing this issue as it has become stale. If you feel we should look more into this, please feel free to reopen it. Thanks.