MCPcopy
hub / github.com/webpack/webpack / isOptional

Method isOptional

lib/Module.js:831–844  ·  view source on GitHub ↗

* Checks whether this module is optional. * @param {ModuleGraph} moduleGraph the module graph * @returns {boolean} true, if the module is optional

(moduleGraph)

Source from the content-addressed store, hash-verified

829 * @returns {boolean} true, if the module is optional
830 */
831 isOptional(moduleGraph) {
832 let hasConnections = false;
833 for (const r of moduleGraph.getIncomingConnections(this)) {
834 if (
835 !r.dependency ||
836 !r.dependency.optional ||
837 !r.isTargetActive(undefined)
838 ) {
839 return false;
840 }
841 hasConnections = true;
842 }
843 return hasConnections;
844 }
845
846 /**
847 * Checks whether this module is accessible in chunk.

Callers 6

optionalMethod · 0.95
_getSourceDataMethod · 0.80
updateHashMethod · 0.80
renderMethod · 0.80
externalsRequireArrayMethod · 0.80

Calls 2

isTargetActiveMethod · 0.80

Tested by

no test coverage detected