MCPcopy
hub / github.com/webpack/webpack / chunkCondition

Method chunkCondition

lib/ExternalModule.js:840–853  ·  view source on GitHub ↗

* Returns true if the module can be placed in the chunk. * @param {Chunk} chunk the chunk which condition should be checked * @param {Compilation} compilation the compilation * @returns {boolean} true if the module can be placed in the chunk

(chunk, compilation)

Source from the content-addressed store, hash-verified

838 * @returns {boolean} true if the module can be placed in the chunk
839 */
840 chunkCondition(chunk, compilation) {
841 const { chunkCondition } = ExternalModule.getCompilationHooks(compilation);
842 const condition = chunkCondition.call(chunk, compilation);
843 if (condition !== undefined) return condition;
844
845 const type = this._resolveExternalType(this.externalType);
846
847 // For `import()` externals, keep them in the initial chunk to avoid loading
848 // them asynchronously twice and to improve runtime performance.
849 if (["css-import", "module"].includes(type)) {
850 return true;
851 }
852 return compilation.chunkGraph.getNumberOfEntryModules(chunk) > 0;
853 }
854
855 /**
856 * Returns the unique identifier used to reference this module.

Callers

nothing calls this directly

Calls 4

_resolveExternalTypeMethod · 0.95
getCompilationHooksMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected