Skip to content

Commit

Permalink
Add comment explaining chunk merge strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Nov 27, 2022
1 parent abffc11 commit 03fdcc0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
17 changes: 17 additions & 0 deletions browser/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,23 @@ Repository: https://github.com/calvinmetcalf/minimalistic-assert.git
---------------------------------------

## pretty-bytes
License: MIT
By: Sindre Sorhus
Repository: sindresorhus/pretty-bytes

> MIT License
>
> Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (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.
---------------------------------------

## sourcemap-codec
License: MIT
By: Rich Harris
Expand Down
12 changes: 12 additions & 0 deletions src/utils/chunkAssignment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,18 @@ function createChunks(
}));
}

/**
* This function tries to get rid of small chunks by merging them with other
* chunks. In order to merge chunks, one must obey the following rule:
* - When merging several chunks, at most one of the chunks can have side
* effects
* - When one of the chunks has side effects, the entry points depending on that
* chunk need to be a super set of the entry points depending on the other
* chunks
* - Pure chunks can always be merged
* - We use the entry point dependence signature to calculate "chunk distance",
* i.e. how likely it is that two chunks are loaded together
*/
function getOptimizedChunks(
chunkModulesBySignature: { [chunkSignature: string]: Module[] },
minChunkSize: number
Expand Down

0 comments on commit 03fdcc0

Please sign in to comment.