@jsenv/core 40.1.2 → 40.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,7 @@
1
1
  import { parseHtml, injectHtmlNodeAsEarlyAsPossible, createHtmlNode, stringifyHtmlAst, applyBabelPlugins, generateUrlForInlineContent, parseJsWithAcorn, visitHtmlNodes, analyzeScriptNode, getHtmlNodeText, getHtmlNodeAttribute, getHtmlNodePosition, getUrlForContentInsideHtml, setHtmlNodeAttributes, setHtmlNodeText, parseCssUrls, getHtmlNodeAttributePosition, parseSrcSet, removeHtmlNodeText, parseJsUrls, getUrlForContentInsideJs, analyzeLinkNode, injectJsenvScript, findHtmlNode, removeHtmlNode, insertHtmlNodeAfter } from "@jsenv/ast";
2
- import { startMonitoringCpuUsage, startMonitoringMemoryUsage } from "@jsenv/os-metrics";
3
2
  import { memoryUsage } from "node:process";
4
3
  import { readFileSync, existsSync, readdirSync, lstatSync, realpathSync } from "node:fs";
5
- import { lookupPackageDirectory$1 as lookupPackageDirectory, registerDirectoryLifecycle$1 as registerDirectoryLifecycle, urlToRelativeUrl$1 as urlToRelativeUrl, createDetailedMessage$1 as createDetailedMessage, stringifyUrlSite$1 as stringifyUrlSite, generateContentFrame$1 as generateContentFrame, validateResponseIntegrity$1 as validateResponseIntegrity, urlIsInsideOf$1 as urlIsInsideOf, ensureWindowsDriveLetter$1 as ensureWindowsDriveLetter, setUrlFilename$1 as setUrlFilename, moveUrl$1 as moveUrl, getCallerPosition$1 as getCallerPosition, urlToBasename$1 as urlToBasename, urlToExtension$1 as urlToExtension, asSpecifierWithoutSearch$1 as asSpecifierWithoutSearch, asUrlWithoutSearch$1 as asUrlWithoutSearch, injectQueryParamsIntoSpecifier$1 as injectQueryParamsIntoSpecifier, bufferToEtag$1 as bufferToEtag, isFileSystemPath$1 as isFileSystemPath, urlToPathname$1 as urlToPathname, setUrlBasename$1 as setUrlBasename, urlToFileSystemPath$1 as urlToFileSystemPath, writeFileSync$1 as writeFileSync, createLogger$1 as createLogger, URL_META$1 as URL_META, applyNodeEsmResolution$1 as applyNodeEsmResolution, RUNTIME_COMPAT$1 as RUNTIME_COMPAT, normalizeUrl$1 as normalizeUrl, ANSI$1 as ANSI, CONTENT_TYPE$1 as CONTENT_TYPE, urlToFilename$1 as urlToFilename, DATA_URL$1 as DATA_URL, normalizeImportMap$1 as normalizeImportMap, composeTwoImportMaps$1 as composeTwoImportMaps, resolveImport$1 as resolveImport, JS_QUOTES$1 as JS_QUOTES, defaultLookupPackageScope$1 as defaultLookupPackageScope, defaultReadPackageJson$1 as defaultReadPackageJson, readCustomConditionsFromProcessArgs$1 as readCustomConditionsFromProcessArgs, readEntryStatSync$1 as readEntryStatSync, ensurePathnameTrailingSlash$1 as ensurePathnameTrailingSlash, compareFileUrls$1 as compareFileUrls, applyFileSystemMagicResolution$1 as applyFileSystemMagicResolution, getExtensionsToTry$1 as getExtensionsToTry, setUrlExtension$1 as setUrlExtension, jsenvPluginTranspilation$1 as jsenvPluginTranspilation, renderTable, humanizeFileSize, humanizeDuration, renderDetails, renderBigSection, distributePercentages, humanizeMemory, comparePathnames, UNICODE, escapeRegexpSpecialChars, injectQueryParamIntoSpecifierWithoutEncoding, renderUrlOrRelativeUrlFilename, assertAndNormalizeDirectoryUrl$1 as assertAndNormalizeDirectoryUrl, Abort, raceProcessTeardownEvents, inferRuntimeCompatFromClosestPackage, browserDefaultRuntimeCompat, nodeDefaultRuntimeCompat, clearDirectorySync, createTaskLog$1 as createTaskLog, jsenvPluginBundling, jsenvPluginMinification, ensureEmptyDirectory, jsenvPluginJsModuleFallback, createDynamicLog } from "../jsenv_core_packages.js";
4
+ import { lookupPackageDirectory$1 as lookupPackageDirectory, registerDirectoryLifecycle$1 as registerDirectoryLifecycle, urlToRelativeUrl$1 as urlToRelativeUrl, createDetailedMessage$1 as createDetailedMessage, stringifyUrlSite$1 as stringifyUrlSite, generateContentFrame$1 as generateContentFrame, validateResponseIntegrity$1 as validateResponseIntegrity, urlIsInsideOf$1 as urlIsInsideOf, ensureWindowsDriveLetter$1 as ensureWindowsDriveLetter, setUrlFilename$1 as setUrlFilename, moveUrl$1 as moveUrl, getCallerPosition$1 as getCallerPosition, urlToBasename$1 as urlToBasename, urlToExtension$1 as urlToExtension, asSpecifierWithoutSearch$1 as asSpecifierWithoutSearch, asUrlWithoutSearch$1 as asUrlWithoutSearch, injectQueryParamsIntoSpecifier$1 as injectQueryParamsIntoSpecifier, bufferToEtag$1 as bufferToEtag, isFileSystemPath$1 as isFileSystemPath, urlToPathname$1 as urlToPathname, setUrlBasename$1 as setUrlBasename, urlToFileSystemPath$1 as urlToFileSystemPath, writeFileSync$1 as writeFileSync, createLogger$1 as createLogger, URL_META$1 as URL_META, applyNodeEsmResolution$1 as applyNodeEsmResolution, RUNTIME_COMPAT$1 as RUNTIME_COMPAT, normalizeUrl$1 as normalizeUrl, ANSI$1 as ANSI, CONTENT_TYPE$1 as CONTENT_TYPE, urlToFilename$1 as urlToFilename, DATA_URL$1 as DATA_URL, normalizeImportMap$1 as normalizeImportMap, composeTwoImportMaps$1 as composeTwoImportMaps, resolveImport$1 as resolveImport, JS_QUOTES$1 as JS_QUOTES, defaultLookupPackageScope$1 as defaultLookupPackageScope, defaultReadPackageJson$1 as defaultReadPackageJson, readCustomConditionsFromProcessArgs$1 as readCustomConditionsFromProcessArgs, readEntryStatSync$1 as readEntryStatSync, ensurePathnameTrailingSlash$1 as ensurePathnameTrailingSlash, compareFileUrls$1 as compareFileUrls, applyFileSystemMagicResolution$1 as applyFileSystemMagicResolution, getExtensionsToTry$1 as getExtensionsToTry, setUrlExtension$1 as setUrlExtension, jsenvPluginTranspilation$1 as jsenvPluginTranspilation, renderDetails, humanizeDuration, humanizeFileSize, renderTable, renderBigSection, distributePercentages, humanizeMemory, comparePathnames, UNICODE, escapeRegexpSpecialChars, injectQueryParamIntoSpecifierWithoutEncoding, renderUrlOrRelativeUrlFilename, assertAndNormalizeDirectoryUrl$1 as assertAndNormalizeDirectoryUrl, Abort, raceProcessTeardownEvents, startMonitoringCpuUsage, startMonitoringMemoryUsage, inferRuntimeCompatFromClosestPackage, browserDefaultRuntimeCompat, nodeDefaultRuntimeCompat, clearDirectorySync, createTaskLog$1 as createTaskLog, jsenvPluginBundling, jsenvPluginMinification, ensureEmptyDirectory, jsenvPluginJsModuleFallback, createDynamicLog } from "../jsenv_core_packages.js";
6
5
  import { pathToFileURL } from "node:url";
7
6
  import { generateSourcemapFileUrl, createMagicSource, composeTwoSourcemaps, generateSourcemapDataUrl, SOURCEMAP } from "@jsenv/sourcemap";
8
7
  import { performance } from "node:perf_hooks";
@@ -2626,7 +2625,7 @@ const shouldHandleSourcemap = (urlInfo) => {
2626
2625
  };
2627
2626
 
2628
2627
  const inlineContentClientFileUrl = new URL(
2629
- "./client/inline_content.js",
2628
+ "../client/inline_content/inline_content.js",
2630
2629
  import.meta.url,
2631
2630
  ).href;
2632
2631
 
@@ -3674,7 +3673,7 @@ const jsenvPluginInlining = () => {
3674
3673
 
3675
3674
  const jsenvPluginHtmlSyntaxErrorFallback = () => {
3676
3675
  const htmlSyntaxErrorFileUrl = import.meta.resolve(
3677
- "./client/html_syntax_error.html",
3676
+ "../client/html_syntax_error/html_syntax_error.html",
3678
3677
  );
3679
3678
 
3680
3679
  return {
@@ -6029,7 +6028,7 @@ return {
6029
6028
 
6030
6029
 
6031
6030
  const htmlFileUrlForDirectory = import.meta.resolve(
6032
- "./client/directory_listing.html",
6031
+ "../client/directory_listing/directory_listing.html",
6033
6032
  );
6034
6033
 
6035
6034
  const jsenvPluginDirectoryListing = ({
@@ -7390,7 +7389,7 @@ const htmlNodeCanHotReload = (node) => {
7390
7389
 
7391
7390
  const jsenvPluginImportMetaHot = () => {
7392
7391
  const importMetaHotClientFileUrl = import.meta.resolve(
7393
- "./client/import_meta_hot.js",
7392
+ "../client/import_meta_hot/import_meta_hot.js",
7394
7393
  );
7395
7394
 
7396
7395
  return {
@@ -7502,7 +7501,7 @@ import.meta.hot = createImportMetaHot(import.meta.url);
7502
7501
  };
7503
7502
 
7504
7503
  const jsenvPluginAutoreloadClient = () => {
7505
- const autoreloadClientFileUrl = import.meta.resolve("./client/autoreload.js");
7504
+ const autoreloadClientFileUrl = import.meta.resolve("../client/autoreload/autoreload.js");
7506
7505
 
7507
7506
  return {
7508
7507
  name: "jsenv:autoreload_client",
@@ -8021,7 +8020,7 @@ const jsenvPluginRibbon = ({
8021
8020
  rootDirectoryUrl,
8022
8021
  htmlInclude = "/**/*.html",
8023
8022
  }) => {
8024
- const ribbonClientFileUrl = import.meta.resolve("./client/ribbon.js");
8023
+ const ribbonClientFileUrl = import.meta.resolve("../client/ribbon/ribbon.js");
8025
8024
  const associations = URL_META.resolveAssociations(
8026
8025
  {
8027
8026
  ribbon: {
@@ -8216,6 +8215,7 @@ const humanizeProcessMemoryUsage = (value) => {
8216
8215
  return humanizeMemory(value, { short: true, decimals: 0 });
8217
8216
  };
8218
8217
  const renderBuildDoneLog = ({
8218
+ entryPointArray,
8219
8219
  duration,
8220
8220
  buildFileContents,
8221
8221
  processCpuUsage,
@@ -8224,84 +8224,15 @@ const renderBuildDoneLog = ({
8224
8224
  const buildContentReport = createBuildContentReport(buildFileContents);
8225
8225
 
8226
8226
  let title = "";
8227
- let content = "";
8228
8227
  const lines = [];
8229
8228
 
8230
- const filesWrittenCount = buildContentReport.total.count;
8231
- if (filesWrittenCount === 1) {
8232
- title = `1 file written`;
8229
+ const entryPointCount = entryPointArray.length;
8230
+ if (entryPointCount === 1) {
8231
+ title = `build done`;
8233
8232
  } else {
8234
- title = `${filesWrittenCount} files written`;
8235
- const keys = Object.keys(buildContentReport);
8236
- const rows = [];
8237
- let y = 0;
8238
- let highestPercentage = 0;
8239
- let highestPercentageY = 0;
8240
- for (const key of keys) {
8241
- if (key === "sourcemaps") {
8242
- continue;
8243
- }
8244
- if (key === "total") {
8245
- continue;
8246
- }
8247
- const { count, size, percentage } = buildContentReport[key];
8248
- if (count === 0) {
8249
- continue;
8250
- }
8251
- const row = [
8252
- {
8253
- value: key,
8254
- borderTop: {},
8255
- borderBottom: {},
8256
- },
8257
- {
8258
- value: count,
8259
- borderTop: {},
8260
- borderBottom: {},
8261
- },
8262
- {
8263
- value: size,
8264
- format: "size",
8265
- borderTop: {},
8266
- borderBottom: {},
8267
- },
8268
- {
8269
- value: percentage,
8270
- format: "percentage",
8271
- unit: "%",
8272
- borderTop: {},
8273
- borderBottom: {},
8274
- },
8275
- ];
8276
- if (percentage > highestPercentage) {
8277
- highestPercentage = percentage;
8278
- highestPercentageY = y;
8279
- }
8280
- rows.push(row);
8281
- y++;
8282
- }
8283
- if (rows.length > 1) {
8284
- const rowWithHighestPercentage = rows[highestPercentageY];
8285
- for (const cell of rowWithHighestPercentage) {
8286
- cell.bold = true;
8287
- }
8288
- const table = renderTable(rows, {
8289
- borderCollapse: true,
8290
- ansi: true,
8291
- });
8292
- content += table;
8293
- content += "\n";
8294
- }
8233
+ title = `build done (${entryPointCount} entry points)`;
8295
8234
  }
8296
8235
 
8297
- let sizeLine = `total size: `;
8298
- sizeLine += humanizeFileSize(buildContentReport.total.size);
8299
- lines.push(sizeLine);
8300
-
8301
- let durationLine = `duration: `;
8302
- durationLine += humanizeDuration(duration, { short: true });
8303
- lines.push(durationLine);
8304
-
8305
8236
  // cpu usage
8306
8237
  let cpuUsageLine = "cpu: ";
8307
8238
  cpuUsageLine += `${humanizeProcessCpuUsage(processCpuUsage.end)}`;
@@ -8322,7 +8253,86 @@ const renderBuildDoneLog = ({
8322
8253
  });
8323
8254
  lines.push(memoryUsageLine);
8324
8255
 
8325
- content += lines.join("\n");
8256
+ // duration
8257
+ let durationLine = `duration: `;
8258
+ durationLine += humanizeDuration(duration, { short: true });
8259
+ lines.push(durationLine);
8260
+
8261
+ // content
8262
+ let filesLine = `content: `;
8263
+ const filesWrittenCount = buildContentReport.total.count;
8264
+ if (filesWrittenCount === 1) {
8265
+ filesLine += "1 file";
8266
+ } else {
8267
+ filesLine += `${filesWrittenCount} files`;
8268
+ }
8269
+ filesLine += " (";
8270
+ filesLine += humanizeFileSize(buildContentReport.total.size);
8271
+ filesLine += ")";
8272
+ lines.push(filesLine);
8273
+
8274
+ // file repartition
8275
+ const keys = Object.keys(buildContentReport);
8276
+ const rows = [];
8277
+ let y = 0;
8278
+ let highestPercentage = 0;
8279
+ let highestPercentageY = 0;
8280
+ for (const key of keys) {
8281
+ if (key === "sourcemaps") {
8282
+ continue;
8283
+ }
8284
+ if (key === "total") {
8285
+ continue;
8286
+ }
8287
+ const { count, size, percentage } = buildContentReport[key];
8288
+ if (count === 0) {
8289
+ continue;
8290
+ }
8291
+ const row = [
8292
+ {
8293
+ value: key,
8294
+ borderTop: {},
8295
+ borderBottom: {},
8296
+ },
8297
+ {
8298
+ value: count,
8299
+ borderTop: {},
8300
+ borderBottom: {},
8301
+ },
8302
+ {
8303
+ value: size,
8304
+ format: "size",
8305
+ borderTop: {},
8306
+ borderBottom: {},
8307
+ },
8308
+ {
8309
+ value: percentage,
8310
+ format: "percentage",
8311
+ unit: "%",
8312
+ borderTop: {},
8313
+ borderBottom: {},
8314
+ },
8315
+ ];
8316
+ if (percentage > highestPercentage) {
8317
+ highestPercentage = percentage;
8318
+ highestPercentageY = y;
8319
+ }
8320
+ rows.push(row);
8321
+ y++;
8322
+ }
8323
+ if (rows.length > 1) {
8324
+ const rowWithHighestPercentage = rows[highestPercentageY];
8325
+ for (const cell of rowWithHighestPercentage) {
8326
+ cell.bold = true;
8327
+ }
8328
+ const table = renderTable(rows, {
8329
+ borderCollapse: true,
8330
+ ansi: true,
8331
+ });
8332
+ lines.push(table);
8333
+ }
8334
+
8335
+ const content = lines.join("\n");
8326
8336
  return `${renderBigSection({
8327
8337
  title,
8328
8338
  content,
@@ -10496,6 +10506,7 @@ const build = async ({
10496
10506
  processMemoryUsageMonitoring.end();
10497
10507
 
10498
10508
  return renderBuildDoneLog({
10509
+ entryPointArray,
10499
10510
  duration,
10500
10511
  buildFileContents,
10501
10512
  processCpuUsage: processCpuUsageMonitoring.info,
@@ -9,6 +9,8 @@ import { parseJsUrls, parseHtml, visitHtmlNodes, analyzeScriptNode, getHtmlNodeA
9
9
  import { createMagicSource, composeTwoSourcemaps, sourcemapConverter } from "@jsenv/sourcemap";
10
10
  import { createRequire } from "node:module";
11
11
  import { convertJsModuleToJsClassic, systemJsClientFileUrlDefault } from "@jsenv/js-module-fallback";
12
+ import { cpus, totalmem, freemem } from "node:os";
13
+ import { cpuUsage, memoryUsage } from "node:process";
12
14
 
13
15
  /*
14
16
  * data:[<mediatype>][;base64],<data>
@@ -6698,7 +6700,7 @@ const injectAstAfterImport$1 = (programPath, ast) => {
6698
6700
  };
6699
6701
 
6700
6702
  const newStylesheetClientFileUrl$1 = new URL(
6701
- "./client/new_stylesheet.js",
6703
+ "./client/new_stylesheet/new_stylesheet.js",
6702
6704
  import.meta.url,
6703
6705
  ).href;
6704
6706
 
@@ -6856,7 +6858,7 @@ const getImportAttributes$1 = (importNode) => {
6856
6858
  };
6857
6859
 
6858
6860
  const regeneratorRuntimeClientFileUrl$1 = new URL(
6859
- "./client/regenerator_runtime.js",
6861
+ "./client/regenerator_runtime/regenerator_runtime.js",
6860
6862
  import.meta.url,
6861
6863
  ).href;
6862
6864
 
@@ -14355,6 +14357,253 @@ const getExtensionsToTry = (magicExtensions, importer) => {
14355
14357
  return Array.from(extensionsSet.values());
14356
14358
  };
14357
14359
 
14360
+ const startMeasuringTotalCpuUsage = () => {
14361
+ let previousCpuArray = cpus();
14362
+ let previousMs = Date.now();
14363
+ let previousCpuUsage = cpuUsage();
14364
+
14365
+ const overall = {
14366
+ inactive: 100,
14367
+ active: 0,
14368
+ system: 0,
14369
+ user: 0,
14370
+ };
14371
+ const thisProcess = {
14372
+ active: 0,
14373
+ system: 0,
14374
+ user: 0,
14375
+ };
14376
+ const details = previousCpuArray.map(() => {
14377
+ return {
14378
+ inactive: 100,
14379
+ active: 0,
14380
+ system: 0,
14381
+ user: 0,
14382
+ };
14383
+ });
14384
+
14385
+ const samples = [];
14386
+ const interval = setInterval(() => {
14387
+ let cpuArray = cpus();
14388
+ const ms = Date.now();
14389
+ const ellapsedMs = ms - previousMs;
14390
+ const cpuUsageSampleArray = [];
14391
+ let overallSystemMs = 0;
14392
+ let overallUserMs = 0;
14393
+ let overallInactiveMs = 0;
14394
+ let overallActiveMs = 0;
14395
+ let overallMsEllapsed = 0;
14396
+ let index = 0;
14397
+ for (const cpu of cpuArray) {
14398
+ const previousCpuTimes = previousCpuArray[index].times;
14399
+ const cpuTimes = cpu.times;
14400
+ const systemMs = cpuTimes.sys - previousCpuTimes.sys;
14401
+ const userMs = cpuTimes.user - previousCpuTimes.user;
14402
+ const activeMs = systemMs + userMs;
14403
+ const inactiveMs = ellapsedMs - activeMs;
14404
+ const cpuUsageSample = {
14405
+ inactive: inactiveMs / ellapsedMs,
14406
+ active: activeMs / ellapsedMs,
14407
+ system: systemMs / ellapsedMs,
14408
+ user: userMs / ellapsedMs,
14409
+ };
14410
+ cpuUsageSampleArray.push(cpuUsageSample);
14411
+
14412
+ overallSystemMs += systemMs;
14413
+ overallUserMs += userMs;
14414
+ overallInactiveMs += inactiveMs;
14415
+ overallActiveMs += activeMs;
14416
+ overallMsEllapsed += ellapsedMs;
14417
+ index++;
14418
+ }
14419
+ const overallUsageSample = {
14420
+ inactive: overallInactiveMs / overallMsEllapsed,
14421
+ active: overallActiveMs / overallMsEllapsed,
14422
+ system: overallSystemMs / overallMsEllapsed,
14423
+ user: overallUserMs / overallMsEllapsed,
14424
+ };
14425
+ previousCpuArray = cpuArray;
14426
+ previousMs = ms;
14427
+
14428
+ const processCpuUsage = cpuUsage();
14429
+ const thisProcessSystemMs = Math.round(
14430
+ (processCpuUsage.system - previousCpuUsage.system) / 1000,
14431
+ );
14432
+ const thisProcessUserMs = Math.round(
14433
+ (processCpuUsage.user - previousCpuUsage.user) / 1000,
14434
+ );
14435
+ previousCpuUsage = processCpuUsage;
14436
+
14437
+ const thisProcessActiveMs = thisProcessSystemMs + thisProcessUserMs;
14438
+ const thisProcessInactiveMs = overallMsEllapsed - thisProcessActiveMs;
14439
+ const thisProcessSample = {
14440
+ inactive: thisProcessInactiveMs / overallMsEllapsed,
14441
+ active: thisProcessActiveMs / overallMsEllapsed,
14442
+ system: thisProcessSystemMs / overallMsEllapsed,
14443
+ user: thisProcessUserMs / overallMsEllapsed,
14444
+ };
14445
+ samples.push({
14446
+ cpuUsageSampleArray,
14447
+ overallUsageSample,
14448
+ thisProcessSample,
14449
+ });
14450
+ if (samples.length === 10) {
14451
+ {
14452
+ let index = 0;
14453
+ for (const detail of details) {
14454
+ let systemSum = 0;
14455
+ let userSum = 0;
14456
+ let inactiveSum = 0;
14457
+ let activeSum = 0;
14458
+ for (const sample of samples) {
14459
+ const { cpuUsageSampleArray } = sample;
14460
+ const cpuUsageSample = cpuUsageSampleArray[index];
14461
+ inactiveSum += cpuUsageSample.inactive;
14462
+ activeSum += cpuUsageSample.active;
14463
+ systemSum += cpuUsageSample.system;
14464
+ userSum += cpuUsageSample.user;
14465
+ }
14466
+ Object.assign(detail, {
14467
+ inactive: inactiveSum / samples.length,
14468
+ active: activeSum / samples.length,
14469
+ system: systemSum / samples.length,
14470
+ user: userSum / samples.length,
14471
+ });
14472
+ index++;
14473
+ }
14474
+ }
14475
+ {
14476
+ let overallSystemSum = 0;
14477
+ let overallUserSum = 0;
14478
+ let overallInactiveSum = 0;
14479
+ let overallActiveSum = 0;
14480
+ for (const sample of samples) {
14481
+ const { overallUsageSample } = sample;
14482
+ overallSystemSum += overallUsageSample.system;
14483
+ overallUserSum += overallUsageSample.user;
14484
+ overallInactiveSum += overallUsageSample.inactive;
14485
+ overallActiveSum += overallUsageSample.active;
14486
+ }
14487
+ Object.assign(overall, {
14488
+ inactive: overallInactiveSum / samples.length,
14489
+ active: overallActiveSum / samples.length,
14490
+ system: overallSystemSum / samples.length,
14491
+ user: overallUserSum / samples.length,
14492
+ });
14493
+ }
14494
+ {
14495
+ let thisProcessSystemSum = 0;
14496
+ let thisProcessUserSum = 0;
14497
+ let thisProcessInactiveSum = 0;
14498
+ let thisProcessActiveSum = 0;
14499
+ for (const sample of samples) {
14500
+ const { thisProcessSample } = sample;
14501
+ thisProcessSystemSum += thisProcessSample.system;
14502
+ thisProcessUserSum += thisProcessSample.user;
14503
+ thisProcessInactiveSum += thisProcessSample.inactive;
14504
+ thisProcessActiveSum += thisProcessSample.active;
14505
+ }
14506
+ Object.assign(thisProcess, {
14507
+ inactive: thisProcessInactiveSum / samples.length,
14508
+ active: thisProcessActiveSum / samples.length,
14509
+ system: thisProcessSystemSum / samples.length,
14510
+ user: thisProcessUserSum / samples.length,
14511
+ });
14512
+ }
14513
+ samples.length = 0;
14514
+ }
14515
+ }, 15);
14516
+ interval.unref();
14517
+
14518
+ return {
14519
+ overall,
14520
+ thisProcess,
14521
+ details,
14522
+ stop: () => {
14523
+ clearInterval(interval);
14524
+ },
14525
+ };
14526
+ };
14527
+
14528
+ const startMonitoringMetric = (measure) => {
14529
+ const metrics = [];
14530
+ const takeMeasure = () => {
14531
+ const value = measure();
14532
+ metrics.push(value);
14533
+ return value;
14534
+ };
14535
+
14536
+ const info = {
14537
+ start: takeMeasure(),
14538
+ min: null,
14539
+ max: null,
14540
+ median: null,
14541
+ end: null,
14542
+ };
14543
+ return {
14544
+ info,
14545
+ measure: takeMeasure,
14546
+ end: () => {
14547
+ info.end = takeMeasure();
14548
+ metrics.sort((a, b) => a - b);
14549
+ info.min = metrics[0];
14550
+ info.max = metrics[metrics.length - 1];
14551
+ info.median = medianFromSortedArray(metrics);
14552
+ metrics.length = 0;
14553
+ },
14554
+ };
14555
+ };
14556
+
14557
+ const medianFromSortedArray = (array) => {
14558
+ const length = array.length;
14559
+ const isOdd = length % 2 === 1;
14560
+ if (isOdd) {
14561
+ const medianNumberIndex = (length - 1) / 2;
14562
+ const medianNumber = array[medianNumberIndex];
14563
+ return medianNumber;
14564
+ }
14565
+ const rightMiddleNumberIndex = length / 2;
14566
+ const leftMiddleNumberIndex = rightMiddleNumberIndex - 1;
14567
+ const leftMiddleNumber = array[leftMiddleNumberIndex];
14568
+ const rightMiddleNumber = array[rightMiddleNumberIndex];
14569
+ const medianNumber = (leftMiddleNumber + rightMiddleNumber) / 2;
14570
+ return medianNumber;
14571
+ };
14572
+
14573
+ // https://gist.github.com/GaetanoPiazzolla/c40e1ebb9f709d091208e89baf9f4e00
14574
+
14575
+
14576
+ const startMonitoringCpuUsage = () => {
14577
+ const cpuUsage = startMeasuringTotalCpuUsage();
14578
+ const processCpuUsageMonitoring = startMonitoringMetric(() => {
14579
+ return cpuUsage.thisProcess.active;
14580
+ });
14581
+ const osCpuUsageMonitoring = startMonitoringMetric(() => {
14582
+ return cpuUsage.overall.active;
14583
+ });
14584
+ const result = [processCpuUsageMonitoring, osCpuUsageMonitoring];
14585
+ result.stop = cpuUsage.stop;
14586
+ return result;
14587
+ };
14588
+
14589
+ const startMonitoringMemoryUsage = () => {
14590
+ const processMemoryUsageMonitoring = startMonitoringMetric(() => {
14591
+ return memoryUsage().rss;
14592
+ });
14593
+ const osMemoryUsageMonitoring = startMonitoringMetric(() => {
14594
+ const total = totalmem();
14595
+ const free = freemem();
14596
+ return total - free;
14597
+ });
14598
+ const stop = () => {
14599
+ processMemoryUsageMonitoring.stop();
14600
+ osMemoryUsageMonitoring.stop();
14601
+ };
14602
+ const result = [processMemoryUsageMonitoring, osMemoryUsageMonitoring];
14603
+ result.stop = stop;
14604
+ return result;
14605
+ };
14606
+
14358
14607
  const fileUrlConverter = {
14359
14608
  asFilePath: (fileUrl) => {
14360
14609
  const filePath = urlToFileSystemPath(fileUrl);
@@ -14891,7 +15140,22 @@ const rollupPluginJsenv = ({
14891
15140
  const dynamicImportUrl = getOriginalUrl(
14892
15141
  dynamicImportRollupFileInfo,
14893
15142
  );
14894
- const rollupSpecifier = `./${dynamicImportRollupFileInfo.fileName}`;
15143
+ const importerBuildUrl = new URL(
15144
+ rollupFileInfo.fileName,
15145
+ buildDirectoryUrl,
15146
+ ).href;
15147
+ const urlToImport = new URL(
15148
+ dynamicImportRollupFileInfo.fileName,
15149
+ buildDirectoryUrl,
15150
+ ).href;
15151
+ const specifierRelative = urlToRelativeUrl(
15152
+ urlToImport,
15153
+ importerBuildUrl,
15154
+ );
15155
+ const rollupSpecifier =
15156
+ specifierRelative[0] === "."
15157
+ ? specifierRelative
15158
+ : `./${specifierRelative}`;
14895
15159
  specifierToUrlMap.set(rollupSpecifier, dynamicImportUrl);
14896
15160
  }
14897
15161
  }
@@ -16802,7 +17066,7 @@ const injectAstAfterImport = (programPath, ast) => {
16802
17066
  };
16803
17067
 
16804
17068
  const newStylesheetClientFileUrl = new URL(
16805
- "./client/new_stylesheet.js",
17069
+ "./client/new_stylesheet/new_stylesheet.js",
16806
17070
  import.meta.url,
16807
17071
  ).href;
16808
17072
 
@@ -16960,7 +17224,7 @@ const getImportAttributes = (importNode) => {
16960
17224
  };
16961
17225
 
16962
17226
  const regeneratorRuntimeClientFileUrl = new URL(
16963
- "./client/regenerator_runtime.js",
17227
+ "./client/regenerator_runtime/regenerator_runtime.js",
16964
17228
  import.meta.url,
16965
17229
  ).href;
16966
17230
 
@@ -23413,4 +23677,4 @@ const assertAndNormalizeDirectoryUrl = (
23413
23677
  return value;
23414
23678
  };
23415
23679
 
23416
- export { ANSI$2 as ANSI, ANSI$1, Abort$1 as Abort, Abort as Abort$1, CONTENT_TYPE$1 as CONTENT_TYPE, CONTENT_TYPE as CONTENT_TYPE$1, DATA_URL$1 as DATA_URL, DATA_URL as DATA_URL$1, JS_QUOTES$1 as JS_QUOTES, JS_QUOTES as JS_QUOTES$1, RUNTIME_COMPAT$1 as RUNTIME_COMPAT, RUNTIME_COMPAT as RUNTIME_COMPAT$1, UNICODE$1 as UNICODE, URL_META$1 as URL_META, URL_META as URL_META$1, applyFileSystemMagicResolution$1 as applyFileSystemMagicResolution, applyFileSystemMagicResolution as applyFileSystemMagicResolution$1, applyNodeEsmResolution$1 as applyNodeEsmResolution, applyNodeEsmResolution as applyNodeEsmResolution$1, asSpecifierWithoutSearch$1 as asSpecifierWithoutSearch, asSpecifierWithoutSearch as asSpecifierWithoutSearch$1, asUrlWithoutSearch$1 as asUrlWithoutSearch, asUrlWithoutSearch as asUrlWithoutSearch$1, assertAndNormalizeDirectoryUrl$2 as assertAndNormalizeDirectoryUrl, assertAndNormalizeDirectoryUrl$1, assertAndNormalizeDirectoryUrl as assertAndNormalizeDirectoryUrl$2, browserDefaultRuntimeCompat, bufferToEtag$1 as bufferToEtag, bufferToEtag as bufferToEtag$1, clearDirectorySync, compareFileUrls$1 as compareFileUrls, compareFileUrls as compareFileUrls$1, comparePathnames, composeTwoImportMaps$1 as composeTwoImportMaps, composeTwoImportMaps as composeTwoImportMaps$1, createDetailedMessage$3 as createDetailedMessage, createDetailedMessage$1, createDynamicLog$1 as createDynamicLog, createLogger$2 as createLogger, createLogger$1, createLogger as createLogger$2, createTaskLog$2 as createTaskLog, createTaskLog$1, createTaskLog as createTaskLog$2, defaultLookupPackageScope$1 as defaultLookupPackageScope, defaultLookupPackageScope as defaultLookupPackageScope$1, defaultReadPackageJson$1 as defaultReadPackageJson, defaultReadPackageJson as defaultReadPackageJson$1, distributePercentages, ensureEmptyDirectory, ensurePathnameTrailingSlash$2 as ensurePathnameTrailingSlash, ensurePathnameTrailingSlash$1, ensureWindowsDriveLetter$1 as ensureWindowsDriveLetter, ensureWindowsDriveLetter as ensureWindowsDriveLetter$1, escapeRegexpSpecialChars, generateContentFrame$1 as generateContentFrame, generateContentFrame as generateContentFrame$1, getCallerPosition$1 as getCallerPosition, getCallerPosition as getCallerPosition$1, getExtensionsToTry$1 as getExtensionsToTry, getExtensionsToTry as getExtensionsToTry$1, humanizeDuration$1 as humanizeDuration, humanizeFileSize, humanizeMemory, inferRuntimeCompatFromClosestPackage, injectQueryParamIntoSpecifierWithoutEncoding, injectQueryParamsIntoSpecifier$1 as injectQueryParamsIntoSpecifier, injectQueryParamsIntoSpecifier as injectQueryParamsIntoSpecifier$1, isFileSystemPath$2 as isFileSystemPath, isFileSystemPath$1, jsenvPluginBundling, jsenvPluginJsModuleFallback, jsenvPluginMinification, jsenvPluginTranspilation$1 as jsenvPluginTranspilation, jsenvPluginTranspilation as jsenvPluginTranspilation$1, lookupPackageDirectory$1 as lookupPackageDirectory, lookupPackageDirectory as lookupPackageDirectory$1, memoizeByFirstArgument, moveUrl$1 as moveUrl, moveUrl as moveUrl$1, nodeDefaultRuntimeCompat, normalizeImportMap$1 as normalizeImportMap, normalizeImportMap as normalizeImportMap$1, normalizeUrl$1 as normalizeUrl, normalizeUrl as normalizeUrl$1, raceProcessTeardownEvents$1 as raceProcessTeardownEvents, raceProcessTeardownEvents as raceProcessTeardownEvents$1, readCustomConditionsFromProcessArgs$1 as readCustomConditionsFromProcessArgs, readCustomConditionsFromProcessArgs as readCustomConditionsFromProcessArgs$1, readEntryStatSync$1 as readEntryStatSync, readEntryStatSync as readEntryStatSync$1, registerDirectoryLifecycle$1 as registerDirectoryLifecycle, registerDirectoryLifecycle as registerDirectoryLifecycle$1, renderBigSection, renderDetails, renderTable, renderUrlOrRelativeUrlFilename, resolveImport$1 as resolveImport, resolveImport as resolveImport$1, setUrlBasename$1 as setUrlBasename, setUrlBasename as setUrlBasename$1, setUrlExtension$1 as setUrlExtension, setUrlExtension as setUrlExtension$1, setUrlFilename$1 as setUrlFilename, setUrlFilename as setUrlFilename$1, stringifyUrlSite$1 as stringifyUrlSite, stringifyUrlSite as stringifyUrlSite$1, urlIsInsideOf$1 as urlIsInsideOf, urlIsInsideOf as urlIsInsideOf$1, urlToBasename$1 as urlToBasename, urlToBasename as urlToBasename$1, urlToExtension$4 as urlToExtension, urlToExtension$2 as urlToExtension$1, urlToExtension as urlToExtension$2, urlToFileSystemPath$1 as urlToFileSystemPath, urlToFileSystemPath as urlToFileSystemPath$1, urlToFilename$3 as urlToFilename, urlToFilename$1, urlToPathname$4 as urlToPathname, urlToPathname$2 as urlToPathname$1, urlToPathname as urlToPathname$2, urlToRelativeUrl$1 as urlToRelativeUrl, urlToRelativeUrl as urlToRelativeUrl$1, validateResponseIntegrity$1 as validateResponseIntegrity, validateResponseIntegrity as validateResponseIntegrity$1, writeFileSync$1 as writeFileSync, writeFileSync as writeFileSync$1 };
23680
+ export { ANSI$2 as ANSI, ANSI$1, Abort$1 as Abort, Abort as Abort$1, CONTENT_TYPE$1 as CONTENT_TYPE, CONTENT_TYPE as CONTENT_TYPE$1, DATA_URL$1 as DATA_URL, DATA_URL as DATA_URL$1, JS_QUOTES$1 as JS_QUOTES, JS_QUOTES as JS_QUOTES$1, RUNTIME_COMPAT$1 as RUNTIME_COMPAT, RUNTIME_COMPAT as RUNTIME_COMPAT$1, UNICODE$1 as UNICODE, URL_META$1 as URL_META, URL_META as URL_META$1, applyFileSystemMagicResolution$1 as applyFileSystemMagicResolution, applyFileSystemMagicResolution as applyFileSystemMagicResolution$1, applyNodeEsmResolution$1 as applyNodeEsmResolution, applyNodeEsmResolution as applyNodeEsmResolution$1, asSpecifierWithoutSearch$1 as asSpecifierWithoutSearch, asSpecifierWithoutSearch as asSpecifierWithoutSearch$1, asUrlWithoutSearch$1 as asUrlWithoutSearch, asUrlWithoutSearch as asUrlWithoutSearch$1, assertAndNormalizeDirectoryUrl$2 as assertAndNormalizeDirectoryUrl, assertAndNormalizeDirectoryUrl$1, assertAndNormalizeDirectoryUrl as assertAndNormalizeDirectoryUrl$2, browserDefaultRuntimeCompat, bufferToEtag$1 as bufferToEtag, bufferToEtag as bufferToEtag$1, clearDirectorySync, compareFileUrls$1 as compareFileUrls, compareFileUrls as compareFileUrls$1, comparePathnames, composeTwoImportMaps$1 as composeTwoImportMaps, composeTwoImportMaps as composeTwoImportMaps$1, createDetailedMessage$3 as createDetailedMessage, createDetailedMessage$1, createDynamicLog$1 as createDynamicLog, createLogger$2 as createLogger, createLogger$1, createLogger as createLogger$2, createTaskLog$2 as createTaskLog, createTaskLog$1, createTaskLog as createTaskLog$2, defaultLookupPackageScope$1 as defaultLookupPackageScope, defaultLookupPackageScope as defaultLookupPackageScope$1, defaultReadPackageJson$1 as defaultReadPackageJson, defaultReadPackageJson as defaultReadPackageJson$1, distributePercentages, ensureEmptyDirectory, ensurePathnameTrailingSlash$2 as ensurePathnameTrailingSlash, ensurePathnameTrailingSlash$1, ensureWindowsDriveLetter$1 as ensureWindowsDriveLetter, ensureWindowsDriveLetter as ensureWindowsDriveLetter$1, escapeRegexpSpecialChars, generateContentFrame$1 as generateContentFrame, generateContentFrame as generateContentFrame$1, getCallerPosition$1 as getCallerPosition, getCallerPosition as getCallerPosition$1, getExtensionsToTry$1 as getExtensionsToTry, getExtensionsToTry as getExtensionsToTry$1, humanizeDuration$1 as humanizeDuration, humanizeFileSize, humanizeMemory, inferRuntimeCompatFromClosestPackage, injectQueryParamIntoSpecifierWithoutEncoding, injectQueryParamsIntoSpecifier$1 as injectQueryParamsIntoSpecifier, injectQueryParamsIntoSpecifier as injectQueryParamsIntoSpecifier$1, isFileSystemPath$2 as isFileSystemPath, isFileSystemPath$1, jsenvPluginBundling, jsenvPluginJsModuleFallback, jsenvPluginMinification, jsenvPluginTranspilation$1 as jsenvPluginTranspilation, jsenvPluginTranspilation as jsenvPluginTranspilation$1, lookupPackageDirectory$1 as lookupPackageDirectory, lookupPackageDirectory as lookupPackageDirectory$1, memoizeByFirstArgument, moveUrl$1 as moveUrl, moveUrl as moveUrl$1, nodeDefaultRuntimeCompat, normalizeImportMap$1 as normalizeImportMap, normalizeImportMap as normalizeImportMap$1, normalizeUrl$1 as normalizeUrl, normalizeUrl as normalizeUrl$1, raceProcessTeardownEvents$1 as raceProcessTeardownEvents, raceProcessTeardownEvents as raceProcessTeardownEvents$1, readCustomConditionsFromProcessArgs$1 as readCustomConditionsFromProcessArgs, readCustomConditionsFromProcessArgs as readCustomConditionsFromProcessArgs$1, readEntryStatSync$1 as readEntryStatSync, readEntryStatSync as readEntryStatSync$1, registerDirectoryLifecycle$1 as registerDirectoryLifecycle, registerDirectoryLifecycle as registerDirectoryLifecycle$1, renderBigSection, renderDetails, renderTable, renderUrlOrRelativeUrlFilename, resolveImport$1 as resolveImport, resolveImport as resolveImport$1, setUrlBasename$1 as setUrlBasename, setUrlBasename as setUrlBasename$1, setUrlExtension$1 as setUrlExtension, setUrlExtension as setUrlExtension$1, setUrlFilename$1 as setUrlFilename, setUrlFilename as setUrlFilename$1, startMonitoringCpuUsage, startMonitoringMemoryUsage, stringifyUrlSite$1 as stringifyUrlSite, stringifyUrlSite as stringifyUrlSite$1, urlIsInsideOf$1 as urlIsInsideOf, urlIsInsideOf as urlIsInsideOf$1, urlToBasename$1 as urlToBasename, urlToBasename as urlToBasename$1, urlToExtension$4 as urlToExtension, urlToExtension$2 as urlToExtension$1, urlToExtension as urlToExtension$2, urlToFileSystemPath$1 as urlToFileSystemPath, urlToFileSystemPath as urlToFileSystemPath$1, urlToFilename$3 as urlToFilename, urlToFilename$1, urlToPathname$4 as urlToPathname, urlToPathname$2 as urlToPathname$1, urlToPathname as urlToPathname$2, urlToRelativeUrl$1 as urlToRelativeUrl, urlToRelativeUrl as urlToRelativeUrl$1, validateResponseIntegrity$1 as validateResponseIntegrity, validateResponseIntegrity as validateResponseIntegrity$1, writeFileSync$1 as writeFileSync, writeFileSync as writeFileSync$1 };
@@ -2666,7 +2666,7 @@ const shouldHandleSourcemap = (urlInfo) => {
2666
2666
  };
2667
2667
 
2668
2668
  const inlineContentClientFileUrl = new URL(
2669
- "./client/inline_content.js",
2669
+ "../client/inline_content/inline_content.js",
2670
2670
  import.meta.url,
2671
2671
  ).href;
2672
2672
 
@@ -3379,7 +3379,7 @@ const inferUrlInfoType = (urlInfo) => {
3379
3379
 
3380
3380
  const jsenvPluginHtmlSyntaxErrorFallback = () => {
3381
3381
  const htmlSyntaxErrorFileUrl = import.meta.resolve(
3382
- "./client/html_syntax_error.html",
3382
+ "../client/html_syntax_error/html_syntax_error.html",
3383
3383
  );
3384
3384
 
3385
3385
  return {
@@ -5734,7 +5734,7 @@ return {
5734
5734
 
5735
5735
 
5736
5736
  const htmlFileUrlForDirectory = import.meta.resolve(
5737
- "./client/directory_listing.html",
5737
+ "../client/directory_listing/directory_listing.html",
5738
5738
  );
5739
5739
 
5740
5740
  const jsenvPluginDirectoryListing = ({
@@ -7430,7 +7430,7 @@ const htmlNodeCanHotReload = (node) => {
7430
7430
 
7431
7431
  const jsenvPluginImportMetaHot = () => {
7432
7432
  const importMetaHotClientFileUrl = import.meta.resolve(
7433
- "./client/import_meta_hot.js",
7433
+ "../client/import_meta_hot/import_meta_hot.js",
7434
7434
  );
7435
7435
 
7436
7436
  return {
@@ -7542,7 +7542,7 @@ import.meta.hot = createImportMetaHot(import.meta.url);
7542
7542
  };
7543
7543
 
7544
7544
  const jsenvPluginAutoreloadClient = () => {
7545
- const autoreloadClientFileUrl = import.meta.resolve("./client/autoreload.js");
7545
+ const autoreloadClientFileUrl = import.meta.resolve("../client/autoreload/autoreload.js");
7546
7546
 
7547
7547
  return {
7548
7548
  name: "jsenv:autoreload_client",
@@ -8061,7 +8061,7 @@ const jsenvPluginRibbon = ({
8061
8061
  rootDirectoryUrl,
8062
8062
  htmlInclude = "/**/*.html",
8063
8063
  }) => {
8064
- const ribbonClientFileUrl = import.meta.resolve("./client/ribbon.js");
8064
+ const ribbonClientFileUrl = import.meta.resolve("../client/ribbon/ribbon.js");
8065
8065
  const associations = URL_META.resolveAssociations(
8066
8066
  {
8067
8067
  ribbon: {
@@ -8253,7 +8253,7 @@ const getCorePlugins = ({
8253
8253
 
8254
8254
 
8255
8255
  const serverEventsClientFileUrl = new URL(
8256
- "./client/server_events_client.js",
8256
+ "../client/server_events/server_events_client.js",
8257
8257
  import.meta.url,
8258
8258
  ).href;
8259
8259
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "40.1.2",
3
+ "version": "40.1.4",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -85,7 +85,7 @@
85
85
  "@jsenv/integrity": "0.0.2",
86
86
  "@jsenv/js-module-fallback": "1.4.5",
87
87
  "@jsenv/node-esm-resolution": "1.2.0",
88
- "@jsenv/plugin-bundling": "2.8.7",
88
+ "@jsenv/plugin-bundling": "2.8.8",
89
89
  "@jsenv/plugin-minification": "1.6.2",
90
90
  "@jsenv/plugin-supervisor": "1.6.12",
91
91
  "@jsenv/plugin-transpilation": "1.5.9",
@@ -364,6 +364,7 @@ export const build = async ({
364
364
  processMemoryUsageMonitoring.end();
365
365
 
366
366
  return renderBuildDoneLog({
367
+ entryPointArray,
367
368
  duration,
368
369
  buildFileContents,
369
370
  processCpuUsage: processCpuUsageMonitoring.info,
@@ -29,6 +29,7 @@ const humanizeProcessMemoryUsage = (value) => {
29
29
  return humanizeMemory(value, { short: true, decimals: 0 });
30
30
  };
31
31
  export const renderBuildDoneLog = ({
32
+ entryPointArray,
32
33
  duration,
33
34
  buildFileContents,
34
35
  processCpuUsage,
@@ -37,84 +38,15 @@ export const renderBuildDoneLog = ({
37
38
  const buildContentReport = createBuildContentReport(buildFileContents);
38
39
 
39
40
  let title = "";
40
- let content = "";
41
41
  const lines = [];
42
42
 
43
- const filesWrittenCount = buildContentReport.total.count;
44
- if (filesWrittenCount === 1) {
45
- title = `1 file written`;
43
+ const entryPointCount = entryPointArray.length;
44
+ if (entryPointCount === 1) {
45
+ title = `build done`;
46
46
  } else {
47
- title = `${filesWrittenCount} files written`;
48
- const keys = Object.keys(buildContentReport);
49
- const rows = [];
50
- let y = 0;
51
- let highestPercentage = 0;
52
- let highestPercentageY = 0;
53
- for (const key of keys) {
54
- if (key === "sourcemaps") {
55
- continue;
56
- }
57
- if (key === "total") {
58
- continue;
59
- }
60
- const { count, size, percentage } = buildContentReport[key];
61
- if (count === 0) {
62
- continue;
63
- }
64
- const row = [
65
- {
66
- value: key,
67
- borderTop: {},
68
- borderBottom: {},
69
- },
70
- {
71
- value: count,
72
- borderTop: {},
73
- borderBottom: {},
74
- },
75
- {
76
- value: size,
77
- format: "size",
78
- borderTop: {},
79
- borderBottom: {},
80
- },
81
- {
82
- value: percentage,
83
- format: "percentage",
84
- unit: "%",
85
- borderTop: {},
86
- borderBottom: {},
87
- },
88
- ];
89
- if (percentage > highestPercentage) {
90
- highestPercentage = percentage;
91
- highestPercentageY = y;
92
- }
93
- rows.push(row);
94
- y++;
95
- }
96
- if (rows.length > 1) {
97
- const rowWithHighestPercentage = rows[highestPercentageY];
98
- for (const cell of rowWithHighestPercentage) {
99
- cell.bold = true;
100
- }
101
- const table = renderTable(rows, {
102
- borderCollapse: true,
103
- ansi: true,
104
- });
105
- content += table;
106
- content += "\n";
107
- }
47
+ title = `build done (${entryPointCount} entry points)`;
108
48
  }
109
49
 
110
- let sizeLine = `total size: `;
111
- sizeLine += humanizeFileSize(buildContentReport.total.size);
112
- lines.push(sizeLine);
113
-
114
- let durationLine = `duration: `;
115
- durationLine += humanizeDuration(duration, { short: true });
116
- lines.push(durationLine);
117
-
118
50
  // cpu usage
119
51
  let cpuUsageLine = "cpu: ";
120
52
  cpuUsageLine += `${humanizeProcessCpuUsage(processCpuUsage.end)}`;
@@ -135,7 +67,86 @@ export const renderBuildDoneLog = ({
135
67
  });
136
68
  lines.push(memoryUsageLine);
137
69
 
138
- content += lines.join("\n");
70
+ // duration
71
+ let durationLine = `duration: `;
72
+ durationLine += humanizeDuration(duration, { short: true });
73
+ lines.push(durationLine);
74
+
75
+ // content
76
+ let filesLine = `content: `;
77
+ const filesWrittenCount = buildContentReport.total.count;
78
+ if (filesWrittenCount === 1) {
79
+ filesLine += "1 file";
80
+ } else {
81
+ filesLine += `${filesWrittenCount} files`;
82
+ }
83
+ filesLine += " (";
84
+ filesLine += humanizeFileSize(buildContentReport.total.size);
85
+ filesLine += ")";
86
+ lines.push(filesLine);
87
+
88
+ // file repartition
89
+ const keys = Object.keys(buildContentReport);
90
+ const rows = [];
91
+ let y = 0;
92
+ let highestPercentage = 0;
93
+ let highestPercentageY = 0;
94
+ for (const key of keys) {
95
+ if (key === "sourcemaps") {
96
+ continue;
97
+ }
98
+ if (key === "total") {
99
+ continue;
100
+ }
101
+ const { count, size, percentage } = buildContentReport[key];
102
+ if (count === 0) {
103
+ continue;
104
+ }
105
+ const row = [
106
+ {
107
+ value: key,
108
+ borderTop: {},
109
+ borderBottom: {},
110
+ },
111
+ {
112
+ value: count,
113
+ borderTop: {},
114
+ borderBottom: {},
115
+ },
116
+ {
117
+ value: size,
118
+ format: "size",
119
+ borderTop: {},
120
+ borderBottom: {},
121
+ },
122
+ {
123
+ value: percentage,
124
+ format: "percentage",
125
+ unit: "%",
126
+ borderTop: {},
127
+ borderBottom: {},
128
+ },
129
+ ];
130
+ if (percentage > highestPercentage) {
131
+ highestPercentage = percentage;
132
+ highestPercentageY = y;
133
+ }
134
+ rows.push(row);
135
+ y++;
136
+ }
137
+ if (rows.length > 1) {
138
+ const rowWithHighestPercentage = rows[highestPercentageY];
139
+ for (const cell of rowWithHighestPercentage) {
140
+ cell.bold = true;
141
+ }
142
+ const table = renderTable(rows, {
143
+ borderCollapse: true,
144
+ ansi: true,
145
+ });
146
+ lines.push(table);
147
+ }
148
+
149
+ const content = lines.join("\n");
139
150
  return `${renderBigSection({
140
151
  title,
141
152
  content,