UNPKG

@modern-js/builder

Version:
67 lines (66 loc) 2.54 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var performance_exports = {}; __export(performance_exports, { builderPluginPerformance: () => builderPluginPerformance }); module.exports = __toCommonJS(performance_exports); function applyProfile({ chain, config }) { const { profile } = config.performance; if (!profile) { return; } chain.profile(profile); } const builderPluginPerformance = () => ({ name: "builder-plugin-performance", setup(api) { api.modifyBuilderConfig((builderConfig) => { var _builderConfig_performance; if ((_builderConfig_performance = builderConfig.performance) === null || _builderConfig_performance === void 0 ? void 0 : _builderConfig_performance.profile) { var _builderConfig_performance1; if (!((_builderConfig_performance1 = builderConfig.performance) === null || _builderConfig_performance1 === void 0 ? void 0 : _builderConfig_performance1.bundleAnalyze)) { var _builderConfig; var _performance; (_performance = (_builderConfig = builderConfig).performance) !== null && _performance !== void 0 ? _performance : _builderConfig.performance = {}; builderConfig.performance.bundleAnalyze = { analyzerMode: "disabled", generateStatsFile: true }; } else { builderConfig.performance.bundleAnalyze = { generateStatsFile: true, ...builderConfig.performance.bundleAnalyze || {} }; } } }); api.modifyBundlerChain((chain) => { const config = api.getNormalizedConfig(); applyProfile({ chain, config }); }); } }); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { builderPluginPerformance });