GithubHelp home page GithubHelp logo

Comments (8)

brandondoran avatar brandondoran commented on May 16, 2024 1

I too get an error in my webpack build after adding "lodash" to .babelrc. I have not figured it out yet.

webpack --config webpack.config.js --progress --profile --colors

/Users/brandon/projects/XXXXXX/babel-core/lib/transformation/file/options/option-manager.js:243
      this.log.error("Invalid options type for " + alias, TypeError);

My problem was I added "lodash" to presets instead of plugins in .babelrc. Works like a charm once I corrected that.

from babel-plugin-lodash.

viveleroi avatar viveleroi commented on May 16, 2024

I have, without any issue. I added this plugin to the .babelrc config file, included lodash in my source, and presto. https://github.com/helion3/inspire-tree/tree/bundle

from babel-plugin-lodash.

jjt avatar jjt commented on May 16, 2024

I'm facing the same issue here, and I'm wondering if it has to do with babel-plugin-resolver, which I'm using.

At index.js#L59, this check in ImportDeclaration always fails because it's getting the absolute path:

if (value.indexOf('lodash') !== -1) console.log(value);
// -> /Users/jjt/path/to/project/node_modules/lodash

// L59: This conditional always fails because it's an absolute path
if (fp || value == 'lodash') {
  // ...
}

from babel-plugin-lodash.

megawac avatar megawac commented on May 16, 2024

@jjt interesting, would #15 work if we added support for something like

[require('babel-plugin-transform-es2015-template-literals'), { 'lodash-path': 'node_modules/lodash'}]

Though because your path there is absolute it would not be possible to transfer that logic between computers

Also if someone is interested in making a webpack example it'd be greatly appreciated

from babel-plugin-lodash.

jdalton avatar jdalton commented on May 16, 2024

I've gotten the babel plugin to work in a dummy webpack project.
I'll add a doc example soon. It's basically:

  'module': {
    'loaders': [{
      'loader': 'babel',
      'test': /\.js$/,
      'exclude': /node_modules/,
      'query': {
        'plugins': ['lodash'],
        'presets': ['es2015']
      }
    }]
  }

In next release of babel-plugin-lodash will also allow you to pass the lodash package id so that it won't have to guess:

'query': {
  'plugins': [['lodash', { 'id': 'lodash-compat' }]],
  'presets': ['es2015']
}

from babel-plugin-lodash.

megawac avatar megawac commented on May 16, 2024

Nice that was originally how I was going to solve #15

from babel-plugin-lodash.

jdalton avatar jdalton commented on May 16, 2024

Nice that was originally how I was going to solve #15

This is also how we're able to test lodash, lodash-es, and lodash-compat at once too.

from babel-plugin-lodash.

jdalton avatar jdalton commented on May 16, 2024

Patched with 5416a85 and 7352d96.

from babel-plugin-lodash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.