Skip to content

Conversation

brijeshb42
Copy link

'--ignore',
// Need to put these patterns in quotes otherwise they might be evaluated by the used terminal.
`"${ignore.join('","')}"`,
...babelFlags,
Copy link
Author

@brijeshb42 brijeshb42 Jul 17, 2025

Choose a reason for hiding this comment

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

Not the best approach but works in the short term (allows babel to copy css files in the same directory structure to the output path).

);
} else if (babelRuntimeVersion === 'catalog:') {
// resolve the version from the given package
const { stdout: listedBabelRuntime } = await exec('pnpm list "@babel/runtime" --json');
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe we should just do this altogether instead of reading the version from package.json? Then we can forget about checking for catalog:.

Copy link
Author

Choose a reason for hiding this comment

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

What do you mean by altogether ?

Copy link
Owner

@Janpot Janpot Jul 17, 2025

Choose a reason for hiding this comment

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

I meant we don't need to actually check for catalog: but alwaus resolve the version with pnpm list.

But now that I'm thinking about it, the X method of resolving the catalog is wrong. We don't want the resolved version that's installed at that moment in X, we want the version range as defined in pnpm-workspace.yaml. This is important, because our users may potentially have an older @babel/runtime installed than us. The correct way would be to read it from pnpm-workspace.yaml instead.

Copy link
Author

Choose a reason for hiding this comment

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

I checked the output and it actually outputs what specified in pnpm-workspace.yaml without the ^.
So I don't see the issue here because our packages already specify the minimum required version (which is also what's used in babel transform).
In this case, the output of pnpm list "@babel/runtime" --json is -

[
  {
    "name": "@mui/x-charts",
    "version": "8.8.0",
    "path": "/Users/brijesh/projects/mui/mui-x/packages/x-charts",
    "private": false,
    "dependencies": {
      "@babel/runtime": {
        "from": "@babel/runtime",
        "version": "7.27.6",
        "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.27.6.tgz",
        "path": "/Users/brijesh/projects/mui/mui-x/node_modules/.pnpm/@[email protected]/node_modules/@babel/runtime"
      }
    }
  }
]

And in catalog -

catalog:
  '@babel/runtime': ^7.27.6

Are you referring to the case when we specify ^7.27.6 in catalog but the actual version installed is ^7.27.8 due to renovate ?

Copy link
Owner

@Janpot Janpot Jul 17, 2025

Choose a reason for hiding this comment

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

Are you referring to the case when we specify ^7.27.6 in catalog but the actual version installed is ^7.27.8 due to renovate ?

Yes, exactly that! e.g. someone dedupes or recreates our lockfile, and the package updates without updating the range specifier. We would set 7.27.8 for the babel plugin which potentially makes it use helpers that are not available in 7.27.6, which one of our users may have installed due to the semver range ^7.27.6. Resulting in errors in their bundles that we wouldn't see in our repo. Instead if we supply ^7.27.6 to the plugin, it would only use helpers that are compatible with that whole version range. (cc @LukasTy)

Copy link
Author

Choose a reason for hiding this comment

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

Done.

* Allow passing of extra flags to the babel-cli
* Check existence of package files (like license, changelogs etc) before
copying them.
@brijeshb42 brijeshb42 force-pushed the infra-sync-x-build branch from 8fffd51 to c3b4b50 Compare July 17, 2025 11:41
} else if (babelRuntimeVersion === 'catalog:') {
// resolve the version from the given package
// outputs the pnpm-workspace.yaml config as json
const { stdout: configStdout } = await exec('pnpm config list --json');
Copy link
Owner

Choose a reason for hiding this comment

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

Love this. Just one more thing, perhaps we should move the following check

if (!babelRuntimeVersion) {
    throw new Error(
      'package.json needs to have a dependency on `@babel/runtime` when building with `@babel/plugin-transform-runtime`.',
    );
  }

underneath? Just in case for some reason whatsoever pnpmWorkspaceConfig.catalog['@babel/runtime']; is undefined

Copy link
Author

Choose a reason for hiding this comment

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

Done. I've moved the PR to material-ui since I figured there are no conflicts with your mjs file PR - mui#46551

Copy link
Owner

@Janpot Janpot left a comment

Choose a reason for hiding this comment

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

Great, just move the babelRuntimeVersion check under the catalog logic so we capture all cases where it can be undefined

@brijeshb42 brijeshb42 force-pushed the infra-sync-x-build branch from c3b4b50 to ad869b4 Compare July 17, 2025 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants