From 3837528cd32ceeabf27e6b71f0dcf2d739b16db7 Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Fri, 22 Sep 2023 12:24:15 +0200 Subject: [PATCH 1/3] Simplify server reference manifest --- .../webpack/plugins/flight-client-entry-plugin.ts | 2 +- test/e2e/app-dir/rsc-basic/rsc-basic.test.ts | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) 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 7927f2748752e..561473df9402d 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 @@ -915,7 +915,7 @@ export class FlightClientEntryPlugin { assets[`${this.assetPrefix}${SERVER_REFERENCE_MANIFEST}.js`] = new sources.RawSource( - `self.__RSC_SERVER_MANIFEST=${JSON.stringify(json)}` + `self.__RSC_SERVER_MANIFEST=${json}` ) as unknown as webpack.sources.RawSource assets[`${this.assetPrefix}${SERVER_REFERENCE_MANIFEST}.json`] = new sources.RawSource(json) as unknown as webpack.sources.RawSource diff --git a/test/e2e/app-dir/rsc-basic/rsc-basic.test.ts b/test/e2e/app-dir/rsc-basic/rsc-basic.test.ts index 849d2389331c8..2fb3439fe635b 100644 --- a/test/e2e/app-dir/rsc-basic/rsc-basic.test.ts +++ b/test/e2e/app-dir/rsc-basic/rsc-basic.test.ts @@ -31,19 +31,16 @@ createNextDescribe( }, ({ next, isNextDev, isNextStart, isTurbopack }) => { if (isNextDev && !isTurbopack) { - // TODO: Fix this test, it no longer uses stringified JSON. - it.skip('should have correct client references keys in manifest', async () => { + it.only('should have correct client references keys in manifest', async () => { await next.render('/') await check(async () => { // Check that the client-side manifest is correct before any requests const clientReferenceManifest = JSON.parse( - JSON.parse( - ( - await next.readFile( - '.next/server/app/page_client-reference-manifest.js' - ) - ).match(/]=(.+)$/)[1] - ) + ( + await next.readFile( + '.next/server/app/page_client-reference-manifest.js' + ) + ).match(/]=(.+)$/)[1] ) const clientModulesNames = Object.keys( clientReferenceManifest.clientModules From 30e446977e37440a9db727031011fe2ff542715e Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Fri, 22 Sep 2023 12:46:25 +0200 Subject: [PATCH 2/3] fix --- test/e2e/app-dir/rsc-basic/rsc-basic.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/app-dir/rsc-basic/rsc-basic.test.ts b/test/e2e/app-dir/rsc-basic/rsc-basic.test.ts index 2fb3439fe635b..819e1a818f9ea 100644 --- a/test/e2e/app-dir/rsc-basic/rsc-basic.test.ts +++ b/test/e2e/app-dir/rsc-basic/rsc-basic.test.ts @@ -31,7 +31,7 @@ createNextDescribe( }, ({ next, isNextDev, isNextStart, isTurbopack }) => { if (isNextDev && !isTurbopack) { - it.only('should have correct client references keys in manifest', async () => { + it('should have correct client references keys in manifest', async () => { await next.render('/') await check(async () => { // Check that the client-side manifest is correct before any requests From 3cfbf595f2ff491969155af8815b6f307d5334c2 Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Sat, 23 Sep 2023 19:43:37 +0200 Subject: [PATCH 3/3] Update packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts --- .../src/build/webpack/plugins/flight-client-entry-plugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 561473df9402d..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 @@ -915,7 +915,7 @@ export class FlightClientEntryPlugin { assets[`${this.assetPrefix}${SERVER_REFERENCE_MANIFEST}.js`] = new sources.RawSource( - `self.__RSC_SERVER_MANIFEST=${json}` + `self.__RSC_SERVER_MANIFEST=${JSON.stringify(json)}` ) as unknown as webpack.sources.RawSource assets[`${this.assetPrefix}${SERVER_REFERENCE_MANIFEST}.json`] = new sources.RawSource(json) as unknown as webpack.sources.RawSource