Skip to content

Commit

Permalink
perf(server): improve lodash imports for serverless bundles (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
luisherranz authored and gregberge committed Apr 9, 2019
1 parent 9731e9c commit 96841f2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/server/src/ChunkExtractor.js
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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) {
Expand Down Expand Up @@ -247,7 +249,7 @@ class ChunkExtractor {
}

if (Array.isArray(chunks)) {
return _.uniq(_.flatMap(chunks, one))
return uniq(flatMap(chunks, one))
}

return one(chunks)
Expand Down

0 comments on commit 96841f2

Please sign in to comment.