From d34a143e1bf5f27ce3e58e234ca17bc931ef69f6 Mon Sep 17 00:00:00 2001 From: Wesley de Bruijn Date: Fri, 15 Sep 2023 09:26:51 +0200 Subject: [PATCH] fix: move sort to loader to also sort query string --- .../build/webpack/loaders/next-flight-client-entry-loader.ts | 1 - .../src/build/webpack/plugins/flight-client-entry-plugin.ts | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/next/src/build/webpack/loaders/next-flight-client-entry-loader.ts b/packages/next/src/build/webpack/loaders/next-flight-client-entry-loader.ts index ef24afd5a81f8..0be3b6fa2b75c 100644 --- a/packages/next/src/build/webpack/loaders/next-flight-client-entry-loader.ts +++ b/packages/next/src/build/webpack/loaders/next-flight-client-entry-loader.ts @@ -24,7 +24,6 @@ export default function transformSource(this: any) { const code = requests // Filter out CSS files in the SSR compilation .filter((request) => (isServer ? !regexCSS.test(request) : true)) - .sort((a, b) => (regexCSS.test(b) ? 1 : a.localeCompare(b))) .map( (request) => `import(/* webpackMode: "eager" */ ${JSON.stringify(request)})` diff --git a/packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts b/packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts index 2ddf2f9ad87c1..7927f2748752e 100644 --- a/packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts +++ b/packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts @@ -26,6 +26,7 @@ import { getActions, isClientComponentEntryModule, isCSSMod, + regexCSS, } from '../loaders/utils' import { traverseModules, forEachEntryModule } from '../utils' import { normalizePathSep } from '../../../shared/lib/page-path/normalize-path-sep' @@ -668,7 +669,9 @@ export class FlightClientEntryPlugin { let shouldInvalidate = false const loaderOptions: NextFlightClientEntryLoaderOptions = { - modules: clientImports, + modules: clientImports.sort((a, b) => + regexCSS.test(b) ? 1 : a.localeCompare(b) + ), server: false, }