forked from lencioni/webpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(types): add types to GraphHelpers
- Loading branch information
1 parent
e361ba5
commit 19bd475
Showing
2 changed files
with
45 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,64 @@ | ||
exports.connectChunkGroupAndChunk = (chunkGroup, chunk) => { | ||
/** @typedef {import("./Chunk")} Chunk */ | ||
/** @typedef {import("./ChunkGroup")} ChunkGroup */ | ||
/** @typedef {import("./Module")} Module */ | ||
/** @typedef {import("./DependenciesBlock")} DependenciesBlock */ | ||
|
||
/** | ||
* @param {ChunkGroup} chunkGroup the ChunkGroup to connect | ||
* @param {Chunk} chunk chunk to tie to ChunkGroup | ||
* @returns {void} | ||
*/ | ||
const connectChunkGroupAndChunk = (chunkGroup, chunk) => { | ||
if (chunkGroup.pushChunk(chunk)) { | ||
chunk.addGroup(chunkGroup); | ||
} | ||
}; | ||
|
||
exports.connectChunkGroupParentAndChild = (parent, child) => { | ||
/** | ||
* @param {ChunkGroup} parent parent ChunkGroup to connect | ||
* @param {ChunkGroup} child child ChunkGroup to connect | ||
* @returns {void} | ||
*/ | ||
const connectChunkGroupParentAndChild = (parent, child) => { | ||
if (parent.addChild(child)) { | ||
child.addParent(parent); | ||
} | ||
}; | ||
|
||
exports.connectChunkAndModule = (chunk, module) => { | ||
/** | ||
* @param {Chunk} chunk Chunk to connect to Module | ||
* @param {Module} module Module to connect to Chunk | ||
* @returns {void} | ||
*/ | ||
const connectChunkAndModule = (chunk, module) => { | ||
if (module.addChunk(chunk)) { | ||
chunk.addModule(module); | ||
} | ||
}; | ||
|
||
exports.disconnectChunkAndModule = (chunk, module) => { | ||
/** | ||
* @param {Chunk} chunk Chunk being disconnected | ||
* @param {Module} module Module being disconnected | ||
* @returns {void} | ||
*/ | ||
const disconnectChunkAndModule = (chunk, module) => { | ||
chunk.removeModule(module); | ||
module.removeChunk(chunk); | ||
}; | ||
|
||
exports.connectDependenciesBlockAndChunkGroup = (depBlock, chunkGroup) => { | ||
/** | ||
* @param {DependenciesBlock} depBlock DepBlock being tied to ChunkGroup | ||
* @param {ChunkGroup} chunkGroup ChunkGroup being tied to DepBlock | ||
* @returns {void} | ||
*/ | ||
const connectDependenciesBlockAndChunkGroup = (depBlock, chunkGroup) => { | ||
if (chunkGroup.addBlock(depBlock)) { | ||
depBlock.chunkGroup = chunkGroup; | ||
} | ||
}; | ||
|
||
exports.connectChunkGroupAndChunk = connectChunkGroupAndChunk; | ||
exports.connectChunkGroupParentAndChild = connectChunkGroupParentAndChild; | ||
exports.connectChunkAndModule = connectChunkAndModule; | ||
exports.disconnectChunkAndModule = disconnectChunkAndModule; | ||
exports.connectDependenciesBlockAndChunkGroup = connectDependenciesBlockAndChunkGroup; |