MCPcopy
hub / github.com/webpack/webpack / checkModuleLayer

Function checkModuleLayer

lib/optimize/SplitChunksPlugin.js:625–639  ·  view source on GitHub ↗
(test, module)

Source from the content-addressed store, hash-verified

623 * @returns {boolean} true, if the module should be selected
624 */
625const checkModuleLayer = (test, module) => {
626 if (test === undefined) return true;
627 if (typeof test === "function") {
628 return test(module.layer);
629 }
630 if (typeof test === "string") {
631 const layer = module.layer;
632 return test === "" ? !layer : layer ? layer.startsWith(test) : false;
633 }
634 if (test instanceof RegExp) {
635 const layer = module.layer;
636 return layer ? test.test(layer) : false;
637 }
638 return false;
639};
640
641/**
642 * Creates a cache group source.

Callers 1

normalizeCacheGroupsFunction · 0.85

Calls 2

testFunction · 0.50
testMethod · 0.45

Tested by

no test coverage detected