Skip to content

Chaining in AMD build? #1426

@knpwrs

Description

@knpwrs

Maybe I'm missing something obvious. The following code works:

require({
  packages: [
    {'name': 'lodash', 'location': 'lodash-amd/modern'}
  ]
}, [
  'lodash'
], function (_) {
  var value = _.chain([1,5,2,3,5]).filter(function (n) {
    return n % 2;
  }).map(function (n) {
    return n * 2;
  }).value();
  console.log(value);
});

But the following code doesn't:

require({
  packages: [
    {'name': 'lodash', 'location': 'lodash-amd/modern'}
  ]
}, [
  'lodash/chain'
], function (_) {
  var value = _.chain([1,5,2,3,5]).filter(function (n) {
    return n % 2;
  }).map(function (n) {
    return n * 2;
  }).value();
  console.log(value);
});

I seem to remember running in to this while using modules in node as well, and I've tried explicitly loading in functions I want to use, but nothing seems to work. I came across this Stackoverflow question. Is a custom build the only way to get chaining along with minimal build size?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions