title: (WebPack) TypeError: Object is not a function or its return value is not iterable
body: <p>I have this function <code>buildUpdateExpression</code> that I use in the following <code>Serverless</code> handler and Webpack is returning me a <code>TypeError</code> as seen above directly related to said function as far as the stack trace goes...</p>
  <pre><code>TypeError: Object is not a function or its return value is not iterable
      at .../update-user.js:7:80
      at .../handler-lib.js:4:19
  
  </code></pre>
  <pre><code>1 import handler from &quot;./libs/handler-lib&quot;;
  2 // import dynamoDb from &quot;./libs/dynamodb-lib&quot;;
  3 import buildUpdateExpression from &quot;./libs/utility-lib&quot;;
  4 export const main = handler(async (event, context) =&gt; {
  5  const data = JSON.parse(event.body);
  6  const validExpressionAttributes = [&quot;bio&quot;, &quot;location&quot;, &quot;profile-picture-link&quot;, &quot;website&quot;];
  7  const [updateExpression, expressionAttributeValues] = buildUpdateExpression(validExpressionAttributes, data);
    return {
      updateExpression: updateExpression,
      expressionAttributeValues: expressionAttributeValues
    };
    // const params = {
    //   TableName: process.env.userTableName,
    //   Key: {
    //     &quot;userId&quot;: event.requestContext.identity.cognitoIdentityId
    //   },
    //   ConditionExpression: &quot;userId = :userIdVal&quot;,
    //   UpdateExpression: updateExpression,
    //   ExpressionAttributeValues: expressionAttributeValues,
    //   ReturnValues: &quot;UPDATED_NEW&quot;
    // };
    // await dynamoDb.update(params);
    // return params.Item;
  });
  </code></pre>
  <pre><code>&gt;&gt; libs/utility-lib.js
  export function buildUpdateExpression(validExpressionAttributes, data) {
    const dataLength = Object.keys(data).length;
    let updateExpression = &quot;set &quot;;
    let expressionAttributeValues = {};
    for(let i = 0; i &lt; validExpressionAttributes.length; i += 1) {
      let attribute = validExpressionAttributes[i];
      if(attribute in data) {
        let valueKey = &quot;:&quot; + attribute + &quot;Val&quot;;
        expressionAttributeValues[valueKey] = data[attribute];
        updateExpression += attribute + &quot; = &quot; + valueKey;
        if(i &lt; validExpressionAttributes.length - 1 &amp;&amp; i &lt; dataLength - 1) {
          updateExpression += &quot;, &quot;;
        }
      }
    }
    return [updateExpression, expressionAttributeValues];
  };
  </code></pre>
  <p>I have unit tests that succeed when I do <code>npm test</code></p>
  <pre><code>import { buildUpdateExpression } from &quot;../libs/utility-lib&quot;;
  test(&quot;buildUpdateExpression (1)&quot;, () =&gt; {
    // Input variables
    const validExpressionAttributes = [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;];
    const data = {
      a: 1,
      b: 2,
      c: 3
    };
    // Expected output variables
    const expectedUpdateExpression = &quot;set a = :aVal, b = :bVal, c = :cVal&quot;;
    const expectedExpressionAttributeValues = {
      &quot;:aVal&quot;: 1,
      &quot;:bVal&quot;: 2,
      &quot;:cVal&quot;: 3,
    };
    const [updateExpression, expressionAttributeValues] =
    buildUpdateExpression(validExpressionAttributes, data);
    expect(updateExpression).toEqual(expectedUpdateExpression);
    expect(expressionAttributeValues).toEqual(expectedExpressionAttributeValues);
  });
  </code></pre>
  <pre><code> PASS  tests/utility-lib.test.js
    ✓ buildUpdateExpression (1) (3ms)
    ✓ buildUpdateExpression (2)
    ✓ buildUpdateExpression (3) (1ms)
  
  Test Suites: 1 passed, 1 total
  Tests:       3 passed, 3 total
  Snapshots:   0 total
  Time:        1.597s
  Ran all test suites.
  </code></pre>
  <p>What could be the problem here?</p>