Skip to content

Commit

Permalink
fix(job-runner-bundle): job update too big
Browse files Browse the repository at this point in the history
  • Loading branch information
EYHN committed Oct 19, 2022
1 parent a7e09af commit 34f3f98
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
4 changes: 2 additions & 2 deletions packages/runner/bundle/src/bundle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
JobType,
BundleJobEntryPoint,
} from '@perfsee/server-common'
import { BundleAuditWarning, BundleResult, diffBundleResult } from '@perfsee/shared'
import { briefEntryDiff, BundleAuditWarning, BundleResult, diffBundleResult } from '@perfsee/shared'

export class BundleWorker extends JobWorker<BundleJobPayload> {
private pwd!: string
Expand Down Expand Up @@ -154,7 +154,7 @@ export class BundleWorker extends JobWorker<BundleJobPayload> {
const result: Record<string, BundleJobEntryPoint> = {}

for (const entryPointName in diffResult) {
const entryPoint = diffResult[entryPointName]
const entryPoint = briefEntryDiff(diffResult[entryPointName])
const warnings = this.generateWarnings(
jobResult.entryPoints.find(({ name }) => name === entryPointName)!,
baselineResult?.entryPoints?.find(({ name }) => name === entryPointName),
Expand Down
4 changes: 2 additions & 2 deletions packages/server-common/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import {
FlameChartDiagnostic,
Size,
BundleAuditWarning,
EntryDiff,
HeaderType,
CookieType,
MetricKeyType,
LocalStorageType,
EntryDiffBrief,
} from '@perfsee/shared'

type PartialSnapshotReport = {
Expand Down Expand Up @@ -73,7 +73,7 @@ export interface BundleJobPayload {
baselineReportKey?: string | null
}

export type BundleJobEntryPoint = EntryDiff & {
export type BundleJobEntryPoint = EntryDiffBrief & {
name: string
warnings: BundleAuditWarning[]
}
Expand Down
35 changes: 28 additions & 7 deletions packages/shared/src/bundle/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { keyBy, sortBy, uniq } from 'lodash'
import { keyBy, sortBy, uniq, pick } from 'lodash'

import {
Asset,
Expand Down Expand Up @@ -127,26 +127,47 @@ export function parseResult(job: BundleResult) {
}
}

export interface EntryDiff {
assetsDiff: Diff<AssetInfo[]>
export interface EntryDiffBrief {
assetsCountDiff: Diff<number>
sizeDiff: Diff
initialSizeDiff: Diff
initialJsSizeDiff: Diff
initialCssSizeDiff: Diff
initialAssetsDiff: Diff<AssetInfo[]>
jsSizeDiff: Diff
cssSizeDiff: Diff
chunksDiff: Diff<Chunk[]>
packagesDiff: Diff<PackageInfo[]>
cacheInvalidation: Diff
chunksCountDiff: Diff<number>
packagesCountDiff: Diff<number>
duplicatedPackagesCountDiff: Diff<number>
score: Diff<number | undefined>
}

export interface EntryDiff extends EntryDiffBrief {
assetsDiff: Diff<AssetInfo[]>
initialAssetsDiff: Diff<AssetInfo[]>
chunksDiff: Diff<Chunk[]>
packagesDiff: Diff<PackageInfo[]>
duplicatedPackages: DuplicatePackage[]
packageIssueMap: PackageIssueMap
audits: BundleAuditResult[]
score: Diff<number | undefined>
}

export function briefEntryDiff(entryDiff: EntryDiff): EntryDiffBrief {
return pick(
entryDiff,
'assetsCountDiff',
'sizeDiff',
'initialSizeDiff',
'initialJsSizeDiff',
'initialCssSizeDiff',
'jsSizeDiff',
'cssSizeDiff',
'cacheInvalidation',
'chunksCountDiff',
'packagesCountDiff',
'duplicatedPackagesCountDiff',
'score',
)
}

export interface BundleDiff {
Expand Down

0 comments on commit 34f3f98

Please sign in to comment.