From f0cf832e1d0c8544c36aa8b310960885a11a847c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Markb=C3=A5ge?= Date: Tue, 7 Feb 2023 12:09:29 -0500 Subject: [PATCH] Update Flight Fixture to "use client" instead of .client.js (#26118) This updates the Flight fixture to support the new ESM loaders in newer versions of Node.js. It also uses native fetch since react-fetch is gone now. (This part requires Node 18 to run the fixture.) I also updated everything to use the `"use client"` convention instead of file name based convention. The biggest hack here is that the Webpack plugin now just writes every `.js` file in the manifest. This needs to be more scoped. In practice, this new convention effectively requires you to traverse the server graph first to find the actual used files. This is enough to at least run our own fixture though. I didn't update the "blocks" fixture. More details in each commit message. --- fixtures/flight-browser/index.html | 8 +- fixtures/flight/config/webpack.config.js | 9 +- fixtures/flight/loader/index.js | 30 ++- .../flight/server/{cli.server.js => cli.js} | 2 +- .../server/{handler.server.js => handler.js} | 4 +- fixtures/flight/server/package.json | 2 +- fixtures/flight/src/{App.server.js => App.js} | 12 +- .../src/{Counter.client.js => Counter.js} | 2 + fixtures/flight/src/Counter2.client.js | 1 - fixtures/flight/src/Counter2.js | 3 + .../src/{ShowMore.client.js => ShowMore.js} | 2 + .../src/ReactFlightWebpackNodeLoader.js | 233 +++++++++++------- .../src/ReactFlightWebpackNodeRegister.js | 71 +++--- .../src/ReactFlightWebpackPlugin.js | 4 +- .../src/__tests__/utils/WebpackMock.js | 16 +- scripts/rollup/bundles.js | 19 +- 16 files changed, 247 insertions(+), 171 deletions(-) rename fixtures/flight/server/{cli.server.js => cli.js} (97%) rename fixtures/flight/server/{handler.server.js => handler.js} (89%) rename fixtures/flight/src/{App.server.js => App.js} (56%) rename fixtures/flight/src/{Counter.client.js => Counter.js} (94%) delete mode 100644 fixtures/flight/src/Counter2.client.js create mode 100644 fixtures/flight/src/Counter2.js rename fixtures/flight/src/{ShowMore.client.js => ShowMore.js} (95%) diff --git a/fixtures/flight-browser/index.html b/fixtures/flight-browser/index.html index 927a0556d5328..5b16a2809c7a1 100644 --- a/fixtures/flight-browser/index.html +++ b/fixtures/flight-browser/index.html @@ -20,7 +20,7 @@

Flight Example

- +