source: trip-planner-front/node_modules/webpack/lib/dependencies/processExportInfo.js@ 84d0fbb

Last change on this file since 84d0fbb was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const { UsageState } = require("../ExportsInfo");
9
10/** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
11/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
12
13/**
14 * @param {RuntimeSpec} runtime the runtime
15 * @param {string[][]} referencedExports list of referenced exports, will be added to
16 * @param {string[]} prefix export prefix
17 * @param {ExportInfo=} exportInfo the export info
18 * @param {boolean} defaultPointsToSelf when true, using default will reference itself
19 * @param {Set<ExportInfo>} alreadyVisited already visited export info (to handle circular reexports)
20 */
21const 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};
65module.exports = processExportInfo;
Note: See TracBrowser for help on using the repository browser.