1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | "use strict";
|
7 |
|
8 | const { UsageState } = require("../ExportsInfo");
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | const processExportInfo = (
|
22 | runtime,
|
23 | referencedExports,
|
24 | prefix,
|
25 | exportInfo,
|
26 | defaultPointsToSelf = false,
|
27 | alreadyVisited = new Set()
|
28 | ) => {
|
29 | if (!exportInfo) {
|
30 | referencedExports.push(prefix);
|
31 | return;
|
32 | }
|
33 | const used = exportInfo.getUsed(runtime);
|
34 | if (used === UsageState.Unused) return;
|
35 | if (alreadyVisited.has(exportInfo)) {
|
36 | referencedExports.push(prefix);
|
37 | return;
|
38 | }
|
39 | alreadyVisited.add(exportInfo);
|
40 | if (
|
41 | used !== UsageState.OnlyPropertiesUsed ||
|
42 | !exportInfo.exportsInfo ||
|
43 | exportInfo.exportsInfo.otherExportsInfo.getUsed(runtime) !==
|
44 | UsageState.Unused
|
45 | ) {
|
46 | alreadyVisited.delete(exportInfo);
|
47 | referencedExports.push(prefix);
|
48 | return;
|
49 | }
|
50 | const exportsInfo = exportInfo.exportsInfo;
|
51 | for (const exportInfo of exportsInfo.orderedExports) {
|
52 | processExportInfo(
|
53 | runtime,
|
54 | referencedExports,
|
55 | defaultPointsToSelf && exportInfo.name === "default"
|
56 | ? prefix
|
57 | : prefix.concat(exportInfo.name),
|
58 | exportInfo,
|
59 | false,
|
60 | alreadyVisited
|
61 | );
|
62 | }
|
63 | alreadyVisited.delete(exportInfo);
|
64 | };
|
65 | module.exports = processExportInfo;
|