From 2bcf06b69254cad6f7e702bf7d65c4f30478668c Mon Sep 17 00:00:00 2001 From: Jenny Steele Date: Mon, 12 May 2025 18:16:15 -0700 Subject: [PATCH] [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` --- .../src/ReactFlightWebpackPlugin.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/react-server-dom-webpack/src/ReactFlightWebpackPlugin.js b/packages/react-server-dom-webpack/src/ReactFlightWebpackPlugin.js index 816b9f2a73185..59723c903f642 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightWebpackPlugin.js +++ b/packages/react-server-dom-webpack/src/ReactFlightWebpackPlugin.js @@ -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; }