From 96841f29fb692ba88a026735f9b1045bc24e7e05 Mon Sep 17 00:00:00 2001 From: Luis Herranz Date: Tue, 9 Apr 2019 09:03:28 +0200 Subject: [PATCH] perf(server): improve lodash imports for serverless bundles (#298) --- packages/server/src/ChunkExtractor.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/server/src/ChunkExtractor.js b/packages/server/src/ChunkExtractor.js index a611a30e..ce515220 100644 --- a/packages/server/src/ChunkExtractor.js +++ b/packages/server/src/ChunkExtractor.js @@ -1,7 +1,9 @@ /* eslint-disable react/no-danger */ import path from 'path' import fs from 'fs' -import _ from 'lodash' +import uniq from 'lodash/uniq' +import uniqBy from 'lodash/uniqBy' +import flatMap from 'lodash/flatMap' import React from 'react' import { invariant, LOADABLE_REQUIRED_CHUNKS_KEY } from './sharedInternals' import ChunkExtractorManager from './ChunkExtractorManager' @@ -17,7 +19,7 @@ function extensionToScriptType(extension) { } function getAssets(chunks, getAsset) { - return _.uniqBy(_.flatMap(chunks, chunk => getAsset(chunk)), 'url') + return uniqBy(flatMap(chunks, chunk => getAsset(chunk)), 'url') } function handleExtraProps(asset, extraProps) { @@ -247,7 +249,7 @@ class ChunkExtractor { } if (Array.isArray(chunks)) { - return _.uniq(_.flatMap(chunks, one)) + return uniq(flatMap(chunks, one)) } return one(chunks)