Skip to content

Commit

Permalink
Merge pull request #7603 from webpack/feature/chunk-module-index
Browse files Browse the repository at this point in the history
add per chunk index and index2
  • Loading branch information
sokra committed Jun 27, 2018
2 parents 408c4ca + e655de8 commit 486e760
Show file tree
Hide file tree
Showing 13 changed files with 665 additions and 452 deletions.
44 changes: 44 additions & 0 deletions lib/ChunkGroup.js
Expand Up @@ -70,6 +70,12 @@ class ChunkGroup {
this.chunks = [];
/** @type {OriginRecord[]} */
this.origins = [];
/** Indicies in top-down order */
/** @private @type {Map<Module, number>} */
this._moduleIndicies = new Map();
/** Indicies in bottom-up order */
/** @private @type {Map<Module, number>} */
this._moduleIndicies2 = new Map();
}

/**
Expand Down Expand Up @@ -447,6 +453,44 @@ class ChunkGroup {
return result;
}

/**
* Sets the top-down index of a module in this ChunkGroup
* @param {Module} module module for which the index should be set
* @param {number} index the index of the module
* @returns {void}
*/
setModuleIndex(module, index) {
this._moduleIndicies.set(module, index);
}

/**
* Gets the top-down index of a module in this ChunkGroup
* @param {Module} module the module
* @returns {number} index
*/
getModuleIndex(module) {
return this._moduleIndicies.get(module);
}

/**
* Sets the bottom-up index of a module in this ChunkGroup
* @param {Module} module module for which the index should be set
* @param {number} index the index of the module
* @returns {void}
*/
setModuleIndex2(module, index) {
this._moduleIndicies2.set(module, index);
}

/**
* Gets the bottom-up index of a module in this ChunkGroup
* @param {Module} module the module
* @returns {number} index
*/
getModuleIndex2(module) {
return this._moduleIndicies2.get(module);
}

checkConstraints() {
const chunk = this;
for (const child of chunk._children) {
Expand Down

0 comments on commit 486e760

Please sign in to comment.