From 8847d3a728cbe7f88b59a95f001f82a70e4026a4 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 3 Feb 2023 10:53:10 +0100 Subject: [PATCH] Remove logging --- browser/LICENSE.md | 17 +++++++++ src/utils/chunkAssignment.ts | 73 +----------------------------------- 2 files changed, 18 insertions(+), 72 deletions(-) diff --git a/browser/LICENSE.md b/browser/LICENSE.md index c2e698fd4c3..b29d7e4fd4e 100644 --- a/browser/LICENSE.md +++ b/browser/LICENSE.md @@ -226,3 +226,20 @@ Repository: https://github.com/calvinmetcalf/minimalistic-assert.git > LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE > OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR > PERFORMANCE OF THIS SOFTWARE. + +--------------------------------------- + +## pretty-bytes +License: MIT +By: Sindre Sorhus +Repository: sindresorhus/pretty-bytes + +> MIT License +> +> Copyright (c) Sindre Sorhus (https://sindresorhus.com) +> +> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/utils/chunkAssignment.ts b/src/utils/chunkAssignment.ts index 7f6befd064a..2495f5ac1fb 100644 --- a/src/utils/chunkAssignment.ts +++ b/src/utils/chunkAssignment.ts @@ -1,4 +1,3 @@ -import prettyBytes from 'pretty-bytes'; import ExternalModule from '../ExternalModule'; import Module from '../Module'; import { getNewSet, getOrCreate } from './getOrCreate'; @@ -272,67 +271,30 @@ function getOptimizedChunks( ) { timeStart('optimize chunks', 3); const chunkPartition = getPartitionedChunks(chunkModulesBySignature, minChunkSize); - console.log(`Created ${ - chunkPartition.big.pure.size + - chunkPartition.big.sideEffect.size + - chunkPartition.small.pure.size + - chunkPartition.small.sideEffect.size - } chunks ------ pure side effects -small ${`${chunkPartition.small.pure.size}`.padEnd(5, ' ')} ${chunkPartition.small.sideEffect.size} - big ${`${chunkPartition.big.pure.size}`.padEnd(5, ' ')} ${chunkPartition.big.sideEffect.size} -Unoptimized chunks contain ${getNumberOfCycles(chunkPartition)} cycles. -`); - if (chunkPartition.small.sideEffect.size > 0) { - console.log( - `Trying to find merge targets for ${ - chunkPartition.small.sideEffect.size - } chunks smaller than ${prettyBytes(minChunkSize)} with side effects...` - ); mergeChunks( chunkPartition.small.sideEffect, [chunkPartition.small.pure, chunkPartition.big.pure], minChunkSize, chunkPartition ); - console.log( - `${chunkPartition.small.sideEffect.size} chunks smaller than ${prettyBytes( - minChunkSize - )} with side effects remaining.\nGenerated chunks contain ${getNumberOfCycles( - chunkPartition - )} cycles.\n` - ); } if (chunkPartition.small.pure.size > 0) { - console.log( - `Trying to find merge targets for ${ - chunkPartition.small.pure.size - } pure chunks smaller than ${prettyBytes(minChunkSize)}...` - ); mergeChunks( chunkPartition.small.pure, [chunkPartition.small.pure, chunkPartition.big.sideEffect, chunkPartition.big.pure], minChunkSize, chunkPartition ); - - console.log( - `${chunkPartition.small.pure.size} pure chunks smaller than ${prettyBytes( - minChunkSize - )} remaining.\nGenerated chunks contain ${getNumberOfCycles(chunkPartition)} cycles.\n` - ); } timeEnd('optimize chunks', 3); - const result = [ + return [ ...chunkPartition.small.sideEffect, ...chunkPartition.small.pure, ...chunkPartition.big.sideEffect, ...chunkPartition.big.pure ]; - console.log(`${result.length} chunks remaining.`); - return result; } const CHAR_DEPENDENT = 'X'; @@ -387,39 +349,6 @@ function getPartitionedChunks( }; } -function getNumberOfCycles(partition: ChunkPartition) { - const parents = new Set(); - const analysedChunks = new Set(); - let cycles = 0; - - const analyseChunk = (chunk: ChunkDescription) => { - for (const dependency of chunk.dependencies) { - if (parents.has(dependency)) { - if (!analysedChunks.has(dependency)) { - cycles++; - } - continue; - } - parents.add(dependency); - analyseChunk(dependency); - } - analysedChunks.add(chunk); - }; - - for (const chunk of [ - ...partition.big.pure, - ...partition.big.sideEffect, - ...partition.small.pure, - ...partition.small.sideEffect - ]) { - if (!parents.has(chunk)) { - parents.add(chunk); - analyseChunk(chunk); - } - } - return cycles; -} - function sortChunksAndAddDependencies( chunkLists: ChunkDescription[][], chunkByModule: Map