webpack
Advanced tools
Comparing version 4.44.1 to 4.46.0
@@ -687,2 +687,6 @@ /** | ||
/** | ||
* Enable to ignore fatal errors happening during resolving of 'resolve.roots'. Usually such errors should not happen, but this option is provided for backward-compatibility. | ||
*/ | ||
ignoreRootsErrors?: boolean; | ||
/** | ||
* Field names from the description file (package.json) which are used to find the default entry point | ||
@@ -708,2 +712,6 @@ */ | ||
/** | ||
* Prefer to resolve server-relative URLs (starting with '/') as absolute paths before falling back to resolve in 'resolve.roots'. | ||
*/ | ||
preferAbsolute?: boolean; | ||
/** | ||
* Custom resolver | ||
@@ -715,3 +723,3 @@ */ | ||
/** | ||
* A list of directories in which requests that are server-relative URLs (starting with '/') are resolved. On non-windows system these requests are tried to resolve as absolute path first. | ||
* A list of directories in which requests that are server-relative URLs (starting with '/') are resolved. | ||
*/ | ||
@@ -718,0 +726,0 @@ roots?: string[]; |
@@ -41,4 +41,4 @@ /* | ||
/** | ||
* @typedef {Object} ChunkGroupDep | ||
* @property {AsyncDependenciesBlock} block referencing block | ||
* @typedef {Object} BlockChunkGroupConnection | ||
* @property {ChunkGroupInfo} originChunkGroupInfo origin chunk group | ||
* @property {ChunkGroup} chunkGroup referenced chunk group | ||
@@ -147,3 +147,3 @@ */ | ||
* @param {Map<ChunkGroup, ChunkGroupInfo>} chunkGroupInfoMap mapping from chunk group to available modules | ||
* @param {Map<ChunkGroup, ChunkGroupDep[]>} chunkDependencies dependencies for chunk groups | ||
* @param {Map<AsyncDependenciesBlock, BlockChunkGroupConnection[]>} blockConnections connection for blocks | ||
* @param {Set<DependenciesBlock>} blocksWithNestedBlocks flag for blocks that have nested blocks | ||
@@ -156,3 +156,3 @@ * @param {Set<ChunkGroup>} allCreatedChunkGroups filled with all chunk groups that are created here | ||
chunkGroupInfoMap, | ||
chunkDependencies, | ||
blockConnections, | ||
blocksWithNestedBlocks, | ||
@@ -235,2 +235,4 @@ allCreatedChunkGroups | ||
let chunkGroup; | ||
/** @type {ChunkGroupInfo} */ | ||
let chunkGroupInfo; | ||
/** @type {DependenciesBlock} */ | ||
@@ -270,2 +272,3 @@ let block; | ||
} | ||
blockConnections.set(b, []); | ||
} else { | ||
@@ -277,7 +280,6 @@ // TODO webpack 5 remove addOptions check | ||
// 2. We store the Block+Chunk mapping as dependency for the chunk | ||
let deps = chunkDependencies.get(chunkGroup); | ||
if (!deps) chunkDependencies.set(chunkGroup, (deps = [])); | ||
deps.push({ | ||
block: b, | ||
// 2. We store the connection for the block | ||
// to connect it later if needed | ||
blockConnections.get(b).push({ | ||
originChunkGroupInfo: chunkGroupInfo, | ||
chunkGroup: c | ||
@@ -315,3 +317,3 @@ }); | ||
chunkGroup = queueItem.chunkGroup; | ||
const chunkGroupInfo = chunkGroupInfoMap.get(chunkGroup); | ||
chunkGroupInfo = chunkGroupInfoMap.get(chunkGroup); | ||
minAvailableModules = chunkGroupInfo.minAvailableModules; | ||
@@ -593,3 +595,3 @@ skippedItems = chunkGroupInfo.skippedItems; | ||
* @param {Set<DependenciesBlock>} blocksWithNestedBlocks flag for blocks that have nested blocks | ||
* @param {Map<ChunkGroup, ChunkGroupDep[]>} chunkDependencies dependencies for chunk groups | ||
* @param {Map<AsyncDependenciesBlock, BlockChunkGroupConnection[]>} blockConnections connection for blocks | ||
* @param {Map<ChunkGroup, ChunkGroupInfo>} chunkGroupInfoMap mapping from chunk group to available modules | ||
@@ -599,8 +601,5 @@ */ | ||
blocksWithNestedBlocks, | ||
chunkDependencies, | ||
blockConnections, | ||
chunkGroupInfoMap | ||
) => { | ||
/** @type {Set<Module>} */ | ||
let resultingAvailableModules; | ||
/** | ||
@@ -623,45 +622,34 @@ * Helper function to check if all modules of a chunk are available | ||
// For each edge in the basic chunk graph | ||
/** | ||
* @param {ChunkGroupDep} dep the dependency used for filtering | ||
* @returns {boolean} used to filter "edges" (aka Dependencies) that were pointing | ||
* to modules that are already available. Also filters circular dependencies in the chunks graph | ||
*/ | ||
const filterFn = dep => { | ||
const depChunkGroup = dep.chunkGroup; | ||
// TODO is this needed? | ||
if (blocksWithNestedBlocks.has(dep.block)) return true; | ||
if (areModulesAvailable(depChunkGroup, resultingAvailableModules)) { | ||
return false; // break all modules are already available | ||
for (const [block, connections] of blockConnections) { | ||
// 1. Check if connection is needed | ||
// When none of the dependencies need to be connected | ||
// we can skip all of them | ||
// It's not possible to filter each item so it doesn't create inconsistent | ||
// connections and modules can only create one version | ||
// TODO maybe decide this per runtime | ||
if ( | ||
// TODO is this needed? | ||
!blocksWithNestedBlocks.has(block) && | ||
connections.every(({ chunkGroup, originChunkGroupInfo }) => | ||
areModulesAvailable( | ||
chunkGroup, | ||
originChunkGroupInfo.resultingAvailableModules | ||
) | ||
) | ||
) { | ||
continue; | ||
} | ||
return true; | ||
}; | ||
// For all deps, check if chunk groups need to be connected | ||
for (const [chunkGroup, deps] of chunkDependencies) { | ||
if (deps.length === 0) continue; | ||
// 1. Get info from chunk group info map | ||
const info = chunkGroupInfoMap.get(chunkGroup); | ||
resultingAvailableModules = info.resultingAvailableModules; | ||
// 2. Foreach edge | ||
for (let i = 0; i < deps.length; i++) { | ||
const dep = deps[i]; | ||
for (let i = 0; i < connections.length; i++) { | ||
const { chunkGroup, originChunkGroupInfo } = connections[i]; | ||
// Filter inline, rather than creating a new array from `.filter()` | ||
// TODO check if inlining filterFn makes sense here | ||
if (!filterFn(dep)) { | ||
continue; | ||
} | ||
const depChunkGroup = dep.chunkGroup; | ||
const depBlock = dep.block; | ||
// 3. Connect block with chunk | ||
GraphHelpers.connectDependenciesBlockAndChunkGroup(block, chunkGroup); | ||
// 5. Connect block with chunk | ||
GraphHelpers.connectDependenciesBlockAndChunkGroup( | ||
depBlock, | ||
depChunkGroup | ||
// 4. Connect chunk with parent | ||
GraphHelpers.connectChunkGroupParentAndChild( | ||
originChunkGroupInfo.chunkGroup, | ||
chunkGroup | ||
); | ||
// 6. Connect chunk with parent | ||
GraphHelpers.connectChunkGroupParentAndChild(chunkGroup, depChunkGroup); | ||
} | ||
@@ -698,4 +686,4 @@ } | ||
/** @type {Map<ChunkGroup, ChunkGroupDep[]>} */ | ||
const chunkDependencies = new Map(); | ||
/** @type {Map<AsyncDependenciesBlock, BlockChunkGroupConnection[]>} */ | ||
const blockConnections = new Map(); | ||
@@ -717,3 +705,3 @@ /** @type {Set<ChunkGroup>} */ | ||
chunkGroupInfoMap, | ||
chunkDependencies, | ||
blockConnections, | ||
blocksWithNestedBlocks, | ||
@@ -727,3 +715,3 @@ allCreatedChunkGroups | ||
blocksWithNestedBlocks, | ||
chunkDependencies, | ||
blockConnections, | ||
chunkGroupInfoMap | ||
@@ -730,0 +718,0 @@ ); |
@@ -79,3 +79,3 @@ /* | ||
// 4. by cache group index | ||
const indexDiff = a.cacheGroupIndex - b.cacheGroupIndex; | ||
const indexDiff = b.cacheGroupIndex - a.cacheGroupIndex; | ||
if (indexDiff) return indexDiff; | ||
@@ -527,6 +527,10 @@ // 5. by number of modules (to be able to compare by identifier) | ||
} | ||
const oldSize = info.modules.size; | ||
info.modules.add(module); | ||
info.size += module.size(); | ||
if (!info.chunksKeys.has(selectedChunksKey)) { | ||
info.chunksKeys.add(selectedChunksKey); | ||
if (info.modules.size !== oldSize) { | ||
info.size += module.size(); | ||
} | ||
const oldChunksKeysSize = info.chunksKeys.size; | ||
info.chunksKeys.add(selectedChunksKey); | ||
if (oldChunksKeysSize !== info.chunksKeys.size) { | ||
for (const chunk of selectedChunks) { | ||
@@ -533,0 +537,0 @@ info.chunks.add(chunk); |
@@ -359,2 +359,13 @@ /* | ||
}); | ||
this.set( | ||
"resolve.preferAbsolute", | ||
"make", | ||
options => !options.resolve.roots || options.resolve.roots.length === 0 | ||
); | ||
this.set( | ||
"resolve.ignoreRootsErrors", | ||
"make", | ||
options => !options.resolve.roots || options.resolve.roots.length === 0 | ||
); | ||
this.set("resolve.roots", "make", options => [options.context]); | ||
@@ -366,3 +377,2 @@ this.set("resolveLoader", "call", value => Object.assign({}, value)); | ||
this.set("resolveLoader.mainFiles", ["index"]); | ||
this.set("resolveLoader.roots", "make", options => [options.context]); | ||
this.set("resolveLoader.cacheWithContext", "make", options => { | ||
@@ -369,0 +379,0 @@ return ( |
{ | ||
"name": "webpack", | ||
"version": "4.44.1", | ||
"version": "4.46.0", | ||
"author": "Tobias Koppers @sokra", | ||
@@ -16,3 +16,3 @@ "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.", | ||
"chrome-trace-event": "^1.0.2", | ||
"enhanced-resolve": "^4.3.0", | ||
"enhanced-resolve": "^4.5.0", | ||
"eslint-scope": "^4.0.3", | ||
@@ -19,0 +19,0 @@ "json-parse-better-errors": "^1.0.2", |
Sorry, the diff of this file is too big to display
1476315
46237
11
Updatedenhanced-resolve@^4.5.0