From 0a3c711a059f54f53d1f46ef0ef9ddc288a37c80 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Wed, 29 May 2024 14:15:51 +0200 Subject: [PATCH 1/2] Split webpack specific test into separate test suite --- test/e2e/app-dir/rsc-basic/rsc-basic.test.ts | 14 --------- .../app-dir/rsc-webpack-loader/app/layout.js | 12 ++++++++ .../app/loader-rule/a.txt | 0 .../app/loader-rule/page.js | 0 .../app-dir/rsc-webpack-loader/next.config.js | 17 +++++++++++ .../rsc-webpack-loader.test.ts | 30 +++++++++++++++++++ test/turbopack-build-tests-manifest.json | 3 +- test/turbopack-dev-tests-manifest.json | 3 +- 8 files changed, 61 insertions(+), 18 deletions(-) create mode 100644 test/e2e/app-dir/rsc-webpack-loader/app/layout.js rename test/e2e/app-dir/{rsc-basic => rsc-webpack-loader}/app/loader-rule/a.txt (100%) rename test/e2e/app-dir/{rsc-basic => rsc-webpack-loader}/app/loader-rule/page.js (100%) create mode 100644 test/e2e/app-dir/rsc-webpack-loader/next.config.js create mode 100644 test/e2e/app-dir/rsc-webpack-loader/rsc-webpack-loader.test.ts 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 32f9638af9bf0..db618770ae3b0 100644 --- a/test/e2e/app-dir/rsc-basic/rsc-basic.test.ts +++ b/test/e2e/app-dir/rsc-basic/rsc-basic.test.ts @@ -606,20 +606,6 @@ describe('app dir - rsc basics', () => { ) }) - // Skip as Turbopack doesn't support webpack loaders. - ;(process.env.TURBOPACK ? it.skip : it)( - 'should support webpack loader rules', - async () => { - const browser = await next.browser('/loader-rule') - - expect( - await browser.eval( - `window.getComputedStyle(document.querySelector('#red')).color` - ) - ).toBe('rgb(255, 0, 0)') - } - ) - if (isNextStart) { it('should generate edge SSR manifests for Node.js', async () => { const requiredServerFiles = JSON.parse( diff --git a/test/e2e/app-dir/rsc-webpack-loader/app/layout.js b/test/e2e/app-dir/rsc-webpack-loader/app/layout.js new file mode 100644 index 0000000000000..ffb819527ff40 --- /dev/null +++ b/test/e2e/app-dir/rsc-webpack-loader/app/layout.js @@ -0,0 +1,12 @@ +import React from 'react' + +export default function AppLayout({ children }) { + return ( + + + RSC + + {children} + + ) +} diff --git a/test/e2e/app-dir/rsc-basic/app/loader-rule/a.txt b/test/e2e/app-dir/rsc-webpack-loader/app/loader-rule/a.txt similarity index 100% rename from test/e2e/app-dir/rsc-basic/app/loader-rule/a.txt rename to test/e2e/app-dir/rsc-webpack-loader/app/loader-rule/a.txt diff --git a/test/e2e/app-dir/rsc-basic/app/loader-rule/page.js b/test/e2e/app-dir/rsc-webpack-loader/app/loader-rule/page.js similarity index 100% rename from test/e2e/app-dir/rsc-basic/app/loader-rule/page.js rename to test/e2e/app-dir/rsc-webpack-loader/app/loader-rule/page.js diff --git a/test/e2e/app-dir/rsc-webpack-loader/next.config.js b/test/e2e/app-dir/rsc-webpack-loader/next.config.js new file mode 100644 index 0000000000000..dc925a7303fe3 --- /dev/null +++ b/test/e2e/app-dir/rsc-webpack-loader/next.config.js @@ -0,0 +1,17 @@ +module.exports = { + reactStrictMode: true, + onDemandEntries: { + maxInactiveAge: 1000 * 60 * 60, + }, + serverExternalPackages: ['conditional-exports-optout'], + rewrites: async () => { + return { + afterFiles: [ + { + source: '/rewritten-to-edge-dynamic', + destination: '/edge/dynamic', + }, + ], + } + }, +} diff --git a/test/e2e/app-dir/rsc-webpack-loader/rsc-webpack-loader.test.ts b/test/e2e/app-dir/rsc-webpack-loader/rsc-webpack-loader.test.ts new file mode 100644 index 0000000000000..d5df3d633887f --- /dev/null +++ b/test/e2e/app-dir/rsc-webpack-loader/rsc-webpack-loader.test.ts @@ -0,0 +1,30 @@ +import { nextTestSetup } from 'e2e-utils' +;(process.env.TURBOPACK ? describe.skip : describe)( + 'app dir - rsc webpack loader', + () => { + const { next } = nextTestSetup({ + files: __dirname, + dependencies: { + 'styled-components': 'latest', + 'server-only': 'latest', + }, + resolutions: { + '@babel/core': '7.22.18', + '@babel/parser': '7.22.16', + '@babel/types': '7.22.17', + '@babel/traverse': '7.22.18', + }, + }) + + // Skip as Turbopack doesn't support webpack loaders. + it('should support webpack loader rules', async () => { + const browser = await next.browser('/loader-rule') + + expect( + await browser.eval( + `window.getComputedStyle(document.querySelector('#red')).color` + ) + ).toBe('rgb(255, 0, 0)') + }) + } +) diff --git a/test/turbopack-build-tests-manifest.json b/test/turbopack-build-tests-manifest.json index 50ff04f35dcc5..802b83d104124 100644 --- a/test/turbopack-build-tests-manifest.json +++ b/test/turbopack-build-tests-manifest.json @@ -3020,8 +3020,7 @@ ], "pending": [ "app dir - rsc basics should not use bundled react for pages with app", - "app dir - rsc basics should support partial hydration with inlined server data in browser", - "app dir - rsc basics should support webpack loader rules" + "app dir - rsc basics should support partial hydration with inlined server data in browser" ], "flakey": [], "runtimeError": false diff --git a/test/turbopack-dev-tests-manifest.json b/test/turbopack-dev-tests-manifest.json index 781694b98516c..63e4a1519e1e4 100644 --- a/test/turbopack-dev-tests-manifest.json +++ b/test/turbopack-dev-tests-manifest.json @@ -5144,8 +5144,7 @@ "failed": [], "pending": [ "app dir - rsc basics should not use bundled react for pages with app", - "app dir - rsc basics should support partial hydration with inlined server data in browser", - "app dir - rsc basics should support webpack loader rules" + "app dir - rsc basics should support partial hydration with inlined server data in browser" ], "flakey": [], "runtimeError": false From 5b4b759ef7c984a47d3979e28ed9065827a31cfa Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Wed, 29 May 2024 14:44:33 +0200 Subject: [PATCH 2/2] Update manifest --- test/turbopack-build-tests-manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/turbopack-build-tests-manifest.json b/test/turbopack-build-tests-manifest.json index 802b83d104124..bc6f5c8891678 100644 --- a/test/turbopack-build-tests-manifest.json +++ b/test/turbopack-build-tests-manifest.json @@ -2979,8 +2979,7 @@ "runtimeError": false }, "test/e2e/app-dir/rsc-basic/rsc-basic.test.ts": { - "passed": [], - "failed": [ + "passed": [ "app dir - rsc basics next internal shared context should not error if just load next/navigation module in pages/api", "app dir - rsc basics next internal shared context should not error if just load next/router module in app page", "app dir - rsc basics react@experimental should opt into the react@experimental when enabling ppr", @@ -3018,6 +3017,7 @@ "app dir - rsc basics should track client components in dynamic imports", "app dir - rsc basics should use canary react for app" ], + "failed": [], "pending": [ "app dir - rsc basics should not use bundled react for pages with app", "app dir - rsc basics should support partial hydration with inlined server data in browser"