@@ -7,7 +7,13 @@ import * as fs from 'node:fs/promises';
77import * as path from 'node:path' ;
88import { sep as posixSep } from 'node:path/posix' ;
99
10- import { getOutExtension , isMjsBuild , mapConcurrently , validatePkgJson } from '../utils/build.mjs' ;
10+ import {
11+ getOutExtension ,
12+ isMjsBuild ,
13+ mapConcurrently ,
14+ validatePkgJson ,
15+ withPerformanceMeasurement ,
16+ } from '../utils/build.mjs' ;
1117
1218/**
1319 * @typedef {Object } Args
@@ -238,7 +244,7 @@ async function writePackageJson({ packageJson, bundles, outputDir, cwd, addTypes
238244 ) ;
239245}
240246
241- export default /** @type {import('yargs').CommandModule<{}, Args> } */ ( {
247+ const command = /** @type {import('yargs').CommandModule<{}, Args> } */ ( {
242248 command : 'build' ,
243249 describe : 'Builds the package for publishing.' ,
244250 builder ( yargs ) {
@@ -375,24 +381,29 @@ export default /** @type {import('yargs').CommandModule<{}, Args>} */ ({
375381
376382 const promises = [ ] ;
377383
378- promises . push (
379- babelMod . babelBuild ( {
380- cwd,
381- sourceDir,
382- outDir : outputDir ,
383- babelRuntimeVersion,
384- hasLargeFiles,
385- bundle,
386- verbose,
387- optimizeClsx :
388- packageJson . dependencies . clsx !== undefined ||
389- packageJson . dependencies . classnames !== undefined ,
390- removePropTypes : packageJson . dependencies [ 'prop-types' ] !== undefined ,
391- pkgVersion : packageJson . version ,
392- ignores : extraIgnores ,
393- outExtension,
394- } ) ,
384+ const markLabel = `build:babel:${ bundle } ` ;
385+ const runBabel = withPerformanceMeasurement (
386+ markLabel ,
387+ async ( ) =>
388+ babelMod . babelBuild ( {
389+ cwd,
390+ sourceDir,
391+ outDir : outputDir ,
392+ babelRuntimeVersion,
393+ hasLargeFiles,
394+ bundle,
395+ verbose,
396+ optimizeClsx :
397+ packageJson . dependencies . clsx !== undefined ||
398+ packageJson . dependencies . classnames !== undefined ,
399+ removePropTypes : packageJson . dependencies [ 'prop-types' ] !== undefined ,
400+ pkgVersion : packageJson . version ,
401+ ignores : extraIgnores ,
402+ outExtension,
403+ } ) ,
404+ { shouldLog : true } ,
395405 ) ;
406+ promises . push ( runBabel ( ) ) ;
396407
397408 if ( buildDir !== outputDir && ! skipBundlePackageJson && ! isMjsBuild ) {
398409 // @TODO - Not needed if the output extension is .mjs. Remove this before PR merge.
@@ -420,23 +431,31 @@ export default /** @type {import('yargs').CommandModule<{}, Args>} */ ({
420431 // js build end
421432
422433 if ( buildTypes ) {
423- const tsMod = await import ( './typescript.mjs' ) ;
424- /**
425- * @type {{type: import('../utils/build.mjs').BundleType, dir: string}[] };
426- */
427- const bundleMap = bundles . map ( ( type ) => ( {
428- type,
429- dir : relativeOutDirs [ type ] ,
430- } ) ) ;
431-
432- await tsMod . createTypes ( {
433- bundles : bundleMap ,
434- srcDir : sourceDir ,
435- cwd,
436- skipTsc,
437- isMjsBuild,
438- buildDir,
439- } ) ;
434+ const tsMarkLabel = 'build:typescript' ;
435+ const runTsc = withPerformanceMeasurement (
436+ tsMarkLabel ,
437+ async ( ) => {
438+ const tsMod = await import ( './typescript.mjs' ) ;
439+ /**
440+ * @type {{type: import('../utils/build.mjs').BundleType, dir: string}[] };
441+ */
442+ const bundleMap = bundles . map ( ( type ) => ( {
443+ type,
444+ dir : relativeOutDirs [ type ] ,
445+ } ) ) ;
446+
447+ await tsMod . createTypes ( {
448+ bundles : bundleMap ,
449+ srcDir : sourceDir ,
450+ cwd,
451+ skipTsc,
452+ isMjsBuild,
453+ buildDir,
454+ } ) ;
455+ } ,
456+ { shouldLog : true } ,
457+ ) ;
458+ await runTsc ( ) ;
440459 }
441460 if ( skipPackageJson ) {
442461 console . log ( 'Skipping package.json generation in the output directory.' ) ;
@@ -464,6 +483,14 @@ export default /** @type {import('yargs').CommandModule<{}, Args>} */ ({
464483 } ,
465484} ) ;
466485
486+ command . handler = withPerformanceMeasurement (
487+ /** @type {string } */ ( command . command ) ,
488+ command . handler ,
489+ { shouldLog : true } ,
490+ ) ;
491+
492+ export default command ;
493+
467494/**
468495 * @param {Object } param0
469496 * @param {string } param0.cwd - The current working directory.
0 commit comments