MCPcopy
hub / github.com/webpack/webpack / processItem

Method processItem

lib/dependencies/WorkerPlugin.js:513–581  ·  view source on GitHub ↗
(item)

Source from the content-addressed store, hash-verified

511 * @param {string} item item
512 */
513 const processItem = (item) => {
514 if (
515 item.startsWith("*") &&
516 item.includes(".") &&
517 item.endsWith("()")
518 ) {
519 const firstDot = item.indexOf(".");
520 const pattern = item.slice(1, firstDot);
521 const itemMembers = item.slice(firstDot + 1, -2);
522
523 parser.hooks.preDeclarator.tap(
524 PLUGIN_NAME,
525 (decl, _statement) => {
526 if (
527 decl.id.type === "Identifier" &&
528 decl.id.name === pattern
529 ) {
530 parser.tagVariable(decl.id.name, WorkerSpecifierTag);
531 return true;
532 }
533 }
534 );
535 parser.hooks.pattern.for(pattern).tap(PLUGIN_NAME, (pattern) => {
536 parser.tagVariable(pattern.name, WorkerSpecifierTag);
537 return true;
538 });
539 parser.hooks.callMemberChain
540 .for(WorkerSpecifierTag)
541 .tap(PLUGIN_NAME, (expression, members) => {
542 if (itemMembers !== members.join(".")) {
543 return;
544 }
545
546 return handleNewWorker(expression);
547 });
548 } else if (item.endsWith("()")) {
549 parser.hooks.call
550 .for(item.slice(0, -2))
551 .tap(PLUGIN_NAME, handleNewWorker);
552 } else {
553 const match = /^(.+?)(\(\))?\s+from\s+(.+)$/.exec(item);
554 if (match) {
555 const ids = match[1].split(".");
556 const call = match[2];
557 const source = match[3];
558 (call ? parser.hooks.call : parser.hooks.new)
559 .for(harmonySpecifierTag)
560 .tap(PLUGIN_NAME, (expr) => {
561 const settings = /** @type {HarmonySettings} */ (
562 parser.currentTagData
563 );
564 if (
565 !settings ||
566 settings.source !== source ||
567 !equals(settings.ids, ids)
568 ) {
569 return;
570 }

Callers

nothing calls this directly

Calls 5

sliceMethod · 0.80
tapMethod · 0.80
tagVariableMethod · 0.80
execMethod · 0.80
splitMethod · 0.80

Tested by

no test coverage detected