Skip to content

Conversation

@brijeshb42
Copy link
Contributor

@brijeshb42 brijeshb42 commented Sep 11, 2025

to each relevant sub-command. And some cleanup.

Removed copy-files command since all repos are now migrated.

Removed markFn and measureFn functions and wrapped their functionality
in a single HOC withPerformanceMeasurement.

@brijeshb42 brijeshb42 requested a review from a team September 11, 2025 13:36
@brijeshb42 brijeshb42 added the scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd). label Sep 11, 2025
@mui-bot
Copy link

mui-bot commented Sep 11, 2025

Bundle size report

Bundle Parsed size Gzip size
@base-ui-components/react 0B(0.00%) 0B(0.00%)

Details of bundle changes


await Promise.all(promises);
console.log(
`✅ Built "${bundle}" with babel in ${(measureFn(markLabel).duration / 1000).toFixed(3)}s.`,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handy to see when comparing the new build tools transpilation times.

* @typedef {import('yargs').CommandModule<{}, any>} CommandModule
*/

const commands = {
Copy link
Member

@Janpot Janpot Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a huge fan of this style, it's such an arbitrary way of separating the different commands, and it makes the logic in this file hard to understand.

How do you feel about instead we create a function that we can use to wrap a command handler function and just in each command file that we want this output on we wrap their handler function?

import withCmdMeasure from './withCmdMeasure'

export default {
  command: 'argos-push',
  handler: withCmdMeasure(async (argv) => {
    // ...
  })
}

I suppose in the wrapper we can read the command name from argv._[o].

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would also work. I don't have during opinions here.
This is something I thought of previously.

Copy link
Member

@Janpot Janpot Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the way it's currently done is a bit of an anti-pattern.

@oliviertassinari oliviertassinari temporarily deployed to log-perf-measurement - mui-tools-public PR #687 September 11, 2025 17:27 — with Render Destroyed
@oliviertassinari oliviertassinari temporarily deployed to log-perf-measurement - mui-tools-public PR #687 September 11, 2025 17:29 — with Render Destroyed
@oliviertassinari oliviertassinari temporarily deployed to log-perf-measurement - mui-tools-public PR #687 September 11, 2025 17:31 — with Render Destroyed
@oliviertassinari oliviertassinari temporarily deployed to log-perf-measurement - mui-tools-public PR #687 September 11, 2025 17:33 — with Render Destroyed
to each relevant sub-command.

Removed markFn and measureFn functions and wrapped their functionality
in a single HOC `withPerformanceMeasurement`.
@oliviertassinari oliviertassinari temporarily deployed to log-perf-measurement - mui-tools-public PR #687 September 12, 2025 04:19 — with Render Destroyed
}

export default /** @type {import('yargs').CommandModule<{}, Args>} */ ({
const command = /** @type {import('yargs').CommandModule<{}, Args>} */ ({
Copy link
Member

@Janpot Janpot Sep 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const command = /** @type {import('yargs').CommandModule<{}, Args>} */ ({
export default /** @type {import('yargs').CommandModule<{}, Args>} */ ({

I really would like to keep this simple and have a function that only wraps the handler, something we can add/remove like a middleware without imposing changes on how these command modules are structured. It's not important enough as a feature to be so visually present in our source code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with handler: withPerformanceMeasurement(label, async (args) => {}) is that args's type does not get detected automatically the way it is when its just handler: async (args) => {}.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should do the trick

// ./types.d.ts
import { CommandModule } from 'yargs';
export type CommandHandler<T> = CommandModule<{}, T>['handler'];
export type HandlerMiddleware = <T>(handler: CommandHandler<T>) => CommandHandler<T>;
// ./myCommand.mjs
/**
 * @type {import('./types').HandlerMiddleware}
 */
function withMiddleware(handler) {
  return async (argv) => {
    await handler(argv);
  };
}

// ...

  handler: withMiddleware(async (argv) => {

Copy link
Contributor Author

@brijeshb42 brijeshb42 Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll pick this up again later. Not happy with the type inference that I've added.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Sep 15, 2025
@github-actions
Copy link

This pull request has been inactive for 30 days. Please remove the stale label or leave a comment to keep it open. Otherwise, it will be closed in 15 days.

@github-actions github-actions bot added the stale Inactive for 7 days (issues) or 30 days (PRs); closed after 5 or 15 more days if no update. label Oct 15, 2025
Comment on lines +96 to +98
performance.clearMarks(startMark);
performance.clearMarks(endMark);
performance.clearMeasures(label);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why clear the marks? Isn't it helpful when profiling?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lastMeasurement already gets the measured value. So clearing after usage. These scripts are not really meant to be profiled to be studied for tiny perf improvements. So clearing it.

@github-actions github-actions bot removed the stale Inactive for 7 days (issues) or 30 days (PRs); closed after 5 or 15 more days if no update. label Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: out-of-date The pull request has merge conflicts and can't be merged. scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants