MCPcopy
hub / github.com/webpack/webpack / shouldPreventParsing

Method shouldPreventParsing

lib/NormalModule.js:1719–1742  ·  view source on GitHub ↗

* @param {undefined | NoParse} noParseRule no parse rule * @param {string} request request * @returns {boolean} check if module should not be parsed, returns "true" if the module should !not! be parsed, returns "false" if the module !must! be parsed

(noParseRule, request)

Source from the content-addressed store, hash-verified

1717 * @returns {boolean} check if module should not be parsed, returns "true" if the module should !not! be parsed, returns "false" if the module !must! be parsed
1718 */
1719 shouldPreventParsing(noParseRule, request) {
1720 // if no noParseRule exists, return false
1721 // the module !must! be parsed.
1722 if (!noParseRule) {
1723 return false;
1724 }
1725
1726 // we only have one rule to check
1727 if (!Array.isArray(noParseRule)) {
1728 // returns "true" if the module is !not! to be parsed
1729 return this.applyNoParseRule(noParseRule, request);
1730 }
1731
1732 for (let i = 0; i < noParseRule.length; i++) {
1733 const rule = noParseRule[i];
1734 // early exit on first truthy match
1735 // this module is !not! to be parsed
1736 if (this.applyNoParseRule(rule, request)) {
1737 return true;
1738 }
1739 }
1740 // no match found, so this module !should! be parsed
1741 return false;
1742 }
1743
1744 /**
1745 * @param {Compilation} compilation compilation

Callers 2

buildMethod · 0.95

Calls 2

applyNoParseRuleMethod · 0.95
isArrayMethod · 0.80

Tested by

no test coverage detected