Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

Enabling this plugin appears to be breaking lodash.map #104

Closed
paolavness opened this issue Apr 9, 2017 · 2 comments
Closed

Enabling this plugin appears to be breaking lodash.map #104

paolavness opened this issue Apr 9, 2017 · 2 comments
Labels

Comments

@paolavness
Copy link

Without this plugin enabled

        import _ from 'lodash'
        var test = _.map({'a':1, 'b':2}, function(value, key) {
                    return { key: key, value: value };
                })

test is
[{key: a, value: 1}, {key: b, value: 2}]

With this plugin enabled, the same code, test is
undefined

I tried enabling some goodies as per below config, but same undefined result:

        new LodashModuleReplacementPlugin({
            flattening: true,
            paths: true
            })

My Babel preset is

            // BABEL
            {
                test: /\.(js|jsx)$/,
                loader: 'babel-loader',
                exclude: /(node_modules)/,                
                query: {
                    plugins: ['lodash'],
                    presets: ['react', 'es2015', 'stage-1']
                }   
            },

Perhaps something else I need to be doing?

Thank you.

@jdalton jdalton added the invalid label Apr 9, 2017
@jdalton
Copy link
Member

jdalton commented Apr 9, 2017

You'll need to enable the collections feature set.

@jdalton jdalton closed this as completed Apr 9, 2017
@paolavness
Copy link
Author

paolavness commented Apr 9, 2017

EDIT I've done this and although there it worked for the above, webpack/lodash is now throwing an error on a different use case of map, again only when plugin enabled:

        var test = [{key: a, value: 1}, {key: b, value: 2}]
        _.map(test)

Error is:

TypeError: iteratee is not a function
    at arrayMap (webpack:///./~/lodash/_arrayMap.js?:16:21)
    at map (webpack:///./~/lodash/map.js?:50:10)

Points to this block of code:

function arrayMap(array, iteratee) {
  var index = -1,
      length = array == null ? 0 : array.length,
      result = Array(length);

  while (++index < length) {
    result[index] = iteratee(array[index], index, array);   <----- Error here
  }
  return result;
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

2 participants