Skip to content

Commit 96841f2

Browse files
luisherranzgregberge
authored andcommitted
perf(server): improve lodash imports for serverless bundles (#298)
1 parent 9731e9c commit 96841f2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/server/src/ChunkExtractor.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/* eslint-disable react/no-danger */
22
import path from 'path'
33
import fs from 'fs'
4-
import _ from 'lodash'
4+
import uniq from 'lodash/uniq'
5+
import uniqBy from 'lodash/uniqBy'
6+
import flatMap from 'lodash/flatMap'
57
import React from 'react'
68
import { invariant, LOADABLE_REQUIRED_CHUNKS_KEY } from './sharedInternals'
79
import ChunkExtractorManager from './ChunkExtractorManager'
@@ -17,7 +19,7 @@ function extensionToScriptType(extension) {
1719
}
1820

1921
function getAssets(chunks, getAsset) {
20-
return _.uniqBy(_.flatMap(chunks, chunk => getAsset(chunk)), 'url')
22+
return uniqBy(flatMap(chunks, chunk => getAsset(chunk)), 'url')
2123
}
2224

2325
function handleExtraProps(asset, extraProps) {
@@ -247,7 +249,7 @@ class ChunkExtractor {
247249
}
248250

249251
if (Array.isArray(chunks)) {
250-
return _.uniq(_.flatMap(chunks, one))
252+
return uniq(flatMap(chunks, one))
251253
}
252254

253255
return one(chunks)

0 commit comments

Comments
 (0)