UNPKG

@sanpjs/bundler-webpack

Version:

@sanpjs/bundler-webpack

51 lines 1.96 kB
"use strict"; /** * @file 检测产出 * Reference: https://github.com/ecomfe/reskript/blob/master/packages/cli-build/src/inspect/index.ts */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const initialRes_1 = __importDefault(require("./initialRes")); const dupPkg_1 = __importDefault(require("./dupPkg")); const esCheck_1 = __importDefault(require("./esCheck")); const inspect_1 = require("../utils/inspect"); const utils_1 = require("@sanpjs/utils"); const logger = new utils_1.Logger(utils_1.LogLevel.Verbose); const run = async (processors, args) => { const results = await (0, utils_1.pReduce)(processors, async (results, processor) => { const [level, value] = (0, inspect_1.normalizeConfig)(processor.config, processor.defaultValue); if (level === 'off') { return results; } const res = await processor.check(value, { notice: (...msgs) => { logger.info(...msgs); }, report: (...msg) => { logger[level](...msg); } }, args); if (!res) { results.add(level); } return results; }, new Set()); return results; }; exports.default = async (stats, args, bundler) => { const context = bundler.context; const inspectConfigs = context.config.build.inspect; if (!inspectConfigs || Object.keys(inspectConfigs).length === 0) { return; } const { children = [] } = stats?.toJson('normal'); const processors = [ ...(0, initialRes_1.default)(children, inspectConfigs.initialRes), (0, dupPkg_1.default)(children, inspectConfigs.dupPkg, context), (0, esCheck_1.default)(children, inspectConfigs.esCheck) ]; await run(processors, args); }; //# sourceMappingURL=index.js.map