UNPKG

bonsai-analyzer

Version:
68 lines (51 loc) 2.24 kB
"use strict"; var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = fullModuleData; var _getChunkModules = _interopRequireDefault(require("./getChunkModules")); var _getEntryHierarchy = _interopRequireDefault(require("./getEntryHierarchy")); var _getExtendedModulesById = _interopRequireWildcard(require("./getExtendedModulesById")); var _getModulesById = _interopRequireDefault(require("./getModulesById")); var _getParentChunks = _interopRequireDefault(require("./getParentChunks")); var _splitUnreachableModules = _interopRequireDefault(require("./splitUnreachableModules")); function fullModuleData(stats, selectedChunkId, blacklistedModuleIds) { const chunksByParent = (0, _getEntryHierarchy.default)(stats); if (selectedChunkId === null || selectedChunkId === undefined) { return { moduleData: null, extendedModules: [], chunksByParent: chunksByParent.children, parentChunks: null }; } const parentChunks = (0, _getParentChunks.default)(chunksByParent, selectedChunkId); const modules = (0, _getChunkModules.default)(stats, parentChunks); if (!modules) { return { moduleData: null, extendedModules: [], chunksByParent: chunksByParent.children, parentChunks: parentChunks }; } const extendedModulesById = (0, _getExtendedModulesById.default)(modules); if (!extendedModulesById) { return { moduleData: null, extendedModules: [], chunksByParent: chunksByParent.children, parentChunks: parentChunks }; } const splitModules = (0, _splitUnreachableModules.default)(extendedModulesById, blacklistedModuleIds); // $FlowFixMe: flow thinks `values()` returns an `Array<mixed>` here const extendedModules = splitModules ? Object.values((0, _getExtendedModulesById.calculateModuleSizes)((0, _getModulesById.default)(splitModules.included))) : []; return { moduleData: splitModules, extendedModules: extendedModules, chunksByParent: chunksByParent.children, parentChunks: parentChunks }; }