Skip to content

Conversation

bernardobelchior
Copy link
Member

Fixes a bug I introduced in #19127.

fs.exists is valid, but fs.promises.exists doesn't exist since fs.exists is deprecated.

Reverting to fs-extra's version for now. I'll look into removing it later.

@bernardobelchior bernardobelchior requested a review from a team August 11, 2025 12:47
@bernardobelchior bernardobelchior added type: bug It doesn't behave as expected. scope: code-infra Changes related to the core-infra product. labels Aug 11, 2025
@mui-bot
Copy link

mui-bot commented Aug 11, 2025

Deploy preview: https://deploy-preview-19132--material-ui-x.netlify.app/

Bundle size report

Bundle Parsed Size Gzip Size
@mui/x-data-grid 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-pro 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-premium 0B(0.00%) 0B(0.00%)
@mui/x-charts 0B(0.00%) 0B(0.00%)
@mui/x-charts-pro 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers-pro 0B(0.00%) 0B(0.00%)
@mui/x-tree-view 0B(0.00%) 0B(0.00%)
@mui/x-tree-view-pro 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against 15cdac7

@bernardobelchior bernardobelchior changed the title [infra] Fix fs-extra removal from formattedTSDemos.js [infra] Fix fs-extra removal from formattedTSDemos script Aug 11, 2025
@brijeshb42
Copy link
Contributor

Will be good to create a followup issue in mui/mui-public to track the removal of fs-extra.

@bernardobelchior
Copy link
Member Author

Will be good to create a followup issue in mui/mui-public to track the removal of fs-extra.

Sounds good. I'll create the issue in a bit.

@@ -90,7 +91,7 @@ const previewOverride = {
async function transpileFile(tsxPath, program, ignoreCache = false) {
const jsPath = tsxPath.replace(/\.tsx?$/, '.js');
try {
if (!ignoreCache && (await fs.promises.exists(jsPath))) {
if (!ignoreCache && (await fse.exists(jsPath))) {
Copy link
Member

@Janpot Janpot Aug 11, 2025

Choose a reason for hiding this comment

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

Consider removing the exists check altogether, .stat already does the same thing

if (!ignoreCache) {
  const ignoreNotFound = (err) => err.code === 'ENOENT' ? null : Promise.reject(err);
  const [jsStat, tsxStat] = await Promise.all([
    fs.promises.stat(jsPath).catch(ignoreNotFound),
    fs.promises.stat(tsxPath).catch(ignoreNotFound),
  ]);
  if (jsStat && tsxStat && jsStat.mtimeMs > tsxStat.mtimeMs) {
    // JavaScript version is newer, skip transpiling
    return TranspileResult.Skipped;
  }
}

or use Promise.allSettled.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I'm aware. Just want to fix this regression asap and I'll take a deeper look into how we can remove fs-extra and exists calls.

@bernardobelchior bernardobelchior merged commit 04af8f3 into mui:master Aug 11, 2025
24 of 25 checks passed
@bernardobelchior bernardobelchior deleted the fix-formatted-ts-demos branch August 11, 2025 14:07
@bernardobelchior
Copy link
Member Author

Will be good to create a followup issue in mui/mui-public to track the removal of fs-extra.

Sounds good. I'll create the issue in a bit.

mui/mui-public#481

@oliviertassinari oliviertassinari added type: regression A bug, but worse, it used to behave as expected. and removed type: bug It doesn't behave as expected. labels Aug 13, 2025
@zannager zannager changed the title [infra] Fix fs-extra removal from formattedTSDemos script [code-infra] Fix fs-extra removal from formattedTSDemos script Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: code-infra Changes related to the core-infra product. type: regression A bug, but worse, it used to behave as expected.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants