-
Notifications
You must be signed in to change notification settings - Fork 0
[code-infra] Accomodate build requirements from mui-x #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: wip-mjs
Are you sure you want to change the base?
Conversation
brijeshb42
commented
Jul 17, 2025
- I have followed (at least) the PR section of the contributing guide.
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
'--ignore', | ||
// Need to put these patterns in quotes otherwise they might be evaluated by the used terminal. | ||
`"${ignore.join('","')}"`, | ||
...babelFlags, |
There was a problem hiding this comment.
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).
scripts/build.mjs
Outdated
); | ||
} else if (babelRuntimeVersion === 'catalog:') { | ||
// resolve the version from the given package | ||
const { stdout: listedBabelRuntime } = await exec('pnpm list "@babel/runtime" --json'); |
There was a problem hiding this comment.
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:
.
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
8fffd51
to
c3b4b50
Compare
} 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'); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this 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
c3b4b50
to
ad869b4
Compare