MCPcopy
hub / github.com/webpack/webpack / printExportsInfoToSource

Function printExportsInfoToSource

lib/ModuleInfoHeaderPlugin.js:55–149  ·  view source on GitHub ↗
(
	source,
	indent,
	exportsInfo,
	moduleGraph,
	requestShortener,
	alreadyPrinted = new Set()
)

Source from the content-addressed store, hash-verified

53 * @returns {void}
54 */
55const printExportsInfoToSource = (
56 source,
57 indent,
58 exportsInfo,
59 moduleGraph,
60 requestShortener,
61 alreadyPrinted = new Set()
62) => {
63 const otherExportsInfo = exportsInfo.otherExportsInfo;
64
65 let alreadyPrintedExports = 0;
66
67 // determine exports to print
68 /** @type {ExportInfo[]} */
69 const printedExports = [];
70 for (const exportInfo of exportsInfo.orderedExports) {
71 if (!alreadyPrinted.has(exportInfo)) {
72 alreadyPrinted.add(exportInfo);
73 printedExports.push(exportInfo);
74 } else {
75 alreadyPrintedExports++;
76 }
77 }
78 let showOtherExports = false;
79 if (!alreadyPrinted.has(otherExportsInfo)) {
80 alreadyPrinted.add(otherExportsInfo);
81 showOtherExports = true;
82 } else {
83 alreadyPrintedExports++;
84 }
85
86 // print the exports
87 for (const exportInfo of printedExports) {
88 const target = exportInfo.getTarget(moduleGraph);
89 source.add(
90 `${Template.toComment(
91 `${indent}export ${JSON.stringify(exportInfo.name).slice(
92 1,
93 -1
94 )} [${exportInfo.getProvidedInfo()}] [${exportInfo.getUsedInfo()}] [${exportInfo.getRenameInfo()}]${
95 target
96 ? ` -> ${target.module.readableIdentifier(requestShortener)}${
97 target.export
98 ? ` .${target.export
99 .map((e) => JSON.stringify(e).slice(1, -1))
100 .join(".")}`
101 : ""
102 }`
103 : ""
104 }`
105 )}\n`
106 );
107 if (exportInfo.exportsInfo) {
108 printExportsInfoToSource(
109 source,
110 `${indent} `,
111 exportInfo.exportsInfo,
112 moduleGraph,

Callers 1

applyMethod · 0.85

Calls 11

getTargetMethod · 0.80
toCommentMethod · 0.80
sliceMethod · 0.80
getProvidedInfoMethod · 0.80
getUsedInfoMethod · 0.80
getRenameInfoMethod · 0.80
hasMethod · 0.45
addMethod · 0.45
pushMethod · 0.45
readableIdentifierMethod · 0.45
getUsedMethod · 0.45

Tested by

no test coverage detected