[ReactFlightWebpackPlugin] Add support for .mjs file extension (#33028)

## Summary
Our builds generate files with a `.mjs` file extension. These are
currently filtered out by `ReactFlightWebpackPlugin` so I am updating it
to support this file extension.

This fixes https://github.com/facebook/react/issues/33155

## How did you test this change?
I built the plugin with this change and used `yalc` to test it in my
project. I confirmed the expected files now show up in
`react-client-manifest.json`
This commit is contained in:
Jenny Steele 2025-05-12 18:16:15 -07:00 committed by GitHub
parent 5d04d73274
commit 2bcf06b692
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -277,8 +277,14 @@ export default class ReactFlightWebpackPlugin {
chunkGroup.chunks.forEach(function (c) {
// eslint-disable-next-line no-for-of-loops/no-for-of-loops
for (const file of c.files) {
if (!file.endsWith('.js')) return;
if (file.endsWith('.hot-update.js')) return;
if (!(file.endsWith('.js') || file.endsWith('.mjs'))) {
return;
}
if (
file.endsWith('.hot-update.js') ||
file.endsWith('.hot-update.mjs')
)
return;
chunks.push(c.id, file);
break;
}