diff --git a/packages/next/server/config-schema.ts b/packages/next/server/config-schema.ts index f11b517aef17f..5270491e0a132 100644 --- a/packages/next/server/config-schema.ts +++ b/packages/next/server/config-schema.ts @@ -240,12 +240,6 @@ const configSchema = { appDir: { type: 'boolean', }, - optoutServerComponentsBundle: { - items: { - type: 'string', - }, - type: 'array', - }, browsersListForSwc: { type: 'boolean', }, @@ -326,6 +320,12 @@ const configSchema = { optimisticClientCache: { type: 'boolean', }, + optoutServerComponentsBundle: { + items: { + type: 'string', + }, + type: 'array', + }, outputFileTracingRoot: { minLength: 1, type: 'string', diff --git a/run-tests.js b/run-tests.js index 336298b50183f..de3a31500849e 100644 --- a/run-tests.js +++ b/run-tests.js @@ -223,10 +223,8 @@ async function main() { console.log('Creating Next.js install for isolated tests') const reactVersion = process.env.NEXT_TEST_REACT_VERSION || 'latest' const testStarter = await createNextInstall({ - dependencies: { - react: reactVersion, - 'react-dom': reactVersion, - }, + react: reactVersion, + 'react-dom': reactVersion, }) process.env.NEXT_TEST_STARTER = testStarter } diff --git a/test/e2e/app-dir/rsc-basic.test.ts b/test/e2e/app-dir/rsc-basic.test.ts index 624e7fc4c3bb0..b0757936bf378 100644 --- a/test/e2e/app-dir/rsc-basic.test.ts +++ b/test/e2e/app-dir/rsc-basic.test.ts @@ -38,14 +38,15 @@ describe('app dir - react server components', () => { next = await createNext({ files: new FileRef(path.join(__dirname, './rsc-basic')), dependencies: { - 'styled-components': '6.0.0-beta.2', + 'styled-components': '6.0.0-alpha.5', react: 'experimental', 'react-dom': 'experimental', }, packageJson: { scripts: { - build: 'next build', - dev: 'next dev', + setup: `cp -r ./node_modules_bak/* ./node_modules`, + build: 'yarn setup && next build', + dev: 'yarn setup && next dev', start: 'next start', }, }, diff --git a/test/e2e/app-dir/rsc-basic/node_modules/conditional-exports-optout/index.js b/test/e2e/app-dir/rsc-basic/node_modules_bak/conditional-exports-optout/index.js similarity index 100% rename from test/e2e/app-dir/rsc-basic/node_modules/conditional-exports-optout/index.js rename to test/e2e/app-dir/rsc-basic/node_modules_bak/conditional-exports-optout/index.js diff --git a/test/e2e/app-dir/rsc-basic/node_modules/conditional-exports-optout/index.server.js b/test/e2e/app-dir/rsc-basic/node_modules_bak/conditional-exports-optout/index.server.js similarity index 100% rename from test/e2e/app-dir/rsc-basic/node_modules/conditional-exports-optout/index.server.js rename to test/e2e/app-dir/rsc-basic/node_modules_bak/conditional-exports-optout/index.server.js diff --git a/test/e2e/app-dir/rsc-basic/node_modules/conditional-exports-optout/package.json b/test/e2e/app-dir/rsc-basic/node_modules_bak/conditional-exports-optout/package.json similarity index 100% rename from test/e2e/app-dir/rsc-basic/node_modules/conditional-exports-optout/package.json rename to test/e2e/app-dir/rsc-basic/node_modules_bak/conditional-exports-optout/package.json diff --git a/test/e2e/app-dir/rsc-basic/node_modules/conditional-exports-optout/subpath.js b/test/e2e/app-dir/rsc-basic/node_modules_bak/conditional-exports-optout/subpath.js similarity index 100% rename from test/e2e/app-dir/rsc-basic/node_modules/conditional-exports-optout/subpath.js rename to test/e2e/app-dir/rsc-basic/node_modules_bak/conditional-exports-optout/subpath.js diff --git a/test/e2e/app-dir/rsc-basic/node_modules/conditional-exports-optout/subpath.server.js b/test/e2e/app-dir/rsc-basic/node_modules_bak/conditional-exports-optout/subpath.server.js similarity index 100% rename from test/e2e/app-dir/rsc-basic/node_modules/conditional-exports-optout/subpath.server.js rename to test/e2e/app-dir/rsc-basic/node_modules_bak/conditional-exports-optout/subpath.server.js diff --git a/test/e2e/app-dir/rsc-basic/node_modules/conditional-exports/index.js b/test/e2e/app-dir/rsc-basic/node_modules_bak/conditional-exports/index.js similarity index 100% rename from test/e2e/app-dir/rsc-basic/node_modules/conditional-exports/index.js rename to test/e2e/app-dir/rsc-basic/node_modules_bak/conditional-exports/index.js diff --git a/test/e2e/app-dir/rsc-basic/node_modules/conditional-exports/index.server.js b/test/e2e/app-dir/rsc-basic/node_modules_bak/conditional-exports/index.server.js similarity index 100% rename from test/e2e/app-dir/rsc-basic/node_modules/conditional-exports/index.server.js rename to test/e2e/app-dir/rsc-basic/node_modules_bak/conditional-exports/index.server.js diff --git a/test/e2e/app-dir/rsc-basic/node_modules/conditional-exports/package.json b/test/e2e/app-dir/rsc-basic/node_modules_bak/conditional-exports/package.json similarity index 100% rename from test/e2e/app-dir/rsc-basic/node_modules/conditional-exports/package.json rename to test/e2e/app-dir/rsc-basic/node_modules_bak/conditional-exports/package.json diff --git a/test/e2e/app-dir/rsc-basic/node_modules/conditional-exports/subpath.js b/test/e2e/app-dir/rsc-basic/node_modules_bak/conditional-exports/subpath.js similarity index 100% rename from test/e2e/app-dir/rsc-basic/node_modules/conditional-exports/subpath.js rename to test/e2e/app-dir/rsc-basic/node_modules_bak/conditional-exports/subpath.js diff --git a/test/e2e/app-dir/rsc-basic/node_modules/conditional-exports/subpath.server.js b/test/e2e/app-dir/rsc-basic/node_modules_bak/conditional-exports/subpath.server.js similarity index 100% rename from test/e2e/app-dir/rsc-basic/node_modules/conditional-exports/subpath.server.js rename to test/e2e/app-dir/rsc-basic/node_modules_bak/conditional-exports/subpath.server.js diff --git a/test/e2e/app-dir/rsc-basic/node_modules/non-isomorphic-text/browser.js b/test/e2e/app-dir/rsc-basic/node_modules_bak/non-isomorphic-text/browser.js similarity index 100% rename from test/e2e/app-dir/rsc-basic/node_modules/non-isomorphic-text/browser.js rename to test/e2e/app-dir/rsc-basic/node_modules_bak/non-isomorphic-text/browser.js diff --git a/test/e2e/app-dir/rsc-basic/node_modules/non-isomorphic-text/index.mjs b/test/e2e/app-dir/rsc-basic/node_modules_bak/non-isomorphic-text/index.mjs similarity index 100% rename from test/e2e/app-dir/rsc-basic/node_modules/non-isomorphic-text/index.mjs rename to test/e2e/app-dir/rsc-basic/node_modules_bak/non-isomorphic-text/index.mjs diff --git a/test/e2e/app-dir/rsc-basic/node_modules/non-isomorphic-text/package.json b/test/e2e/app-dir/rsc-basic/node_modules_bak/non-isomorphic-text/package.json similarity index 100% rename from test/e2e/app-dir/rsc-basic/node_modules/non-isomorphic-text/package.json rename to test/e2e/app-dir/rsc-basic/node_modules_bak/non-isomorphic-text/package.json diff --git a/test/e2e/app-dir/rsc-basic/node_modules/random-module-instance/index.js b/test/e2e/app-dir/rsc-basic/node_modules_bak/random-module-instance/index.js similarity index 100% rename from test/e2e/app-dir/rsc-basic/node_modules/random-module-instance/index.js rename to test/e2e/app-dir/rsc-basic/node_modules_bak/random-module-instance/index.js diff --git a/test/e2e/app-dir/rsc-basic/node_modules/random-module-instance/package.json b/test/e2e/app-dir/rsc-basic/node_modules_bak/random-module-instance/package.json similarity index 100% rename from test/e2e/app-dir/rsc-basic/node_modules/random-module-instance/package.json rename to test/e2e/app-dir/rsc-basic/node_modules_bak/random-module-instance/package.json diff --git a/test/e2e/styled-jsx/app/node_modules/my-comps/button.js b/test/e2e/styled-jsx/app/node_modules_bak/my-comps/button.js similarity index 100% rename from test/e2e/styled-jsx/app/node_modules/my-comps/button.js rename to test/e2e/styled-jsx/app/node_modules_bak/my-comps/button.js diff --git a/test/e2e/styled-jsx/index.test.ts b/test/e2e/styled-jsx/index.test.ts index b5b2105e60144..aa22928ece663 100644 --- a/test/e2e/styled-jsx/index.test.ts +++ b/test/e2e/styled-jsx/index.test.ts @@ -13,25 +13,23 @@ function runTest() { beforeAll(async () => { next = await createNext({ files: { - node_modules: new FileRef(path.join(appDir, 'node_modules')), + node_modules_bak: new FileRef(path.join(appDir, 'node_modules_bak')), pages: new FileRef(path.join(appDir, 'pages')), '.npmrc': new FileRef(path.join(appDir, '.npmrc')), }, packageJson: { scripts: { - build: 'next build', - dev: 'next dev', + setup: `cp -r ./node_modules_bak/my-comps ./node_modules;`, + build: `yarn setup && next build`, + dev: `yarn setup && next dev`, start: 'next start', }, }, dependencies: { - // A different version of styled-jsx on user side, - // using a different patch version comparing to the one from next.js - 'styled-jsx': '5.0.0', + 'styled-jsx': '5.0.0', // styled-jsx on user side }, startCommand: 'yarn ' + ((global as any).isNextDev ? 'dev' : 'start'), - buildCommand: 'yarn build', - installCommand: 'yarn', + buildCommand: `yarn build`, }) }) afterAll(() => next.destroy()) diff --git a/test/lib/create-next-install.js b/test/lib/create-next-install.js index 382537a8cc2cf..224cb1824ad0e 100644 --- a/test/lib/create-next-install.js +++ b/test/lib/create-next-install.js @@ -7,12 +7,12 @@ const { randomBytes } = require('crypto') const { linkPackages } = require('../../.github/actions/next-stats-action/src/prepare/repo-setup')() -async function createNextInstall({ +async function createNextInstall( dependencies, installCommand, packageJson = {}, - packageLockPath = '', -}) { + packageLockPath = '' +) { const tmpDir = await fs.realpath(process.env.NEXT_TEST_DIR || os.tmpdir()) const origRepoDir = path.join(__dirname, '../../') const installDir = path.join( diff --git a/test/lib/next-modes/base.ts b/test/lib/next-modes/base.ts index 8bf3a186fa2e1..2e9b7432f9cc4 100644 --- a/test/lib/next-modes/base.ts +++ b/test/lib/next-modes/base.ts @@ -143,30 +143,16 @@ export class NextInstance { ) { await fs.copy(process.env.NEXT_TEST_STARTER, this.testDir) } else if (!skipIsolatedNext) { - this.testDir = await createNextInstall({ - dependencies: finalDependencies, - installCommand: this.installCommand, - packageJson: this.packageJson, - packageLockPath: this.packageLockPath, - }) + this.testDir = await createNextInstall( + finalDependencies, + this.installCommand, + this.packageJson, + this.packageLockPath + ) } require('console').log('created next.js install, writing test files') } - const tempNodeModulesFolder = 'node_modules_bak' - // Merge customized node_modules and installed node_modules. - // Move files[node_modules] to a temporary folder node_modules_back, - // then copy the modules back to node_modules after installation. - const tempNodeModulesPath = path.join(this.testDir, tempNodeModulesFolder) - const nodeModulesDir = path.join(this.testDir, 'node_modules') - const hasNodeModulesDir = - fs.existsSync(nodeModulesDir) && - (await fs.stat(nodeModulesDir)).isDirectory() - if (hasNodeModulesDir) { - // Move node_modules to temp folder - await fs.move(nodeModulesDir, tempNodeModulesPath) - } - if (this.files instanceof FileRef) { // if a FileRef is passed directly to `files` we copy the // entire folder to the test directory @@ -177,7 +163,6 @@ export class NextInstance { `FileRef passed to "files" in "createNext" is not a directory ${this.files.fsPath}` ) } - await fs.copy(this.files.fsPath, this.testDir) } else { for (const filename of Object.keys(this.files)) { @@ -193,12 +178,6 @@ export class NextInstance { } } - if (hasNodeModulesDir) { - // Move node_modules from temp back to origin - await fs.copy(tempNodeModulesPath, nodeModulesDir) - await fs.remove(tempNodeModulesPath) - } - let nextConfigFile = Object.keys(this.files).find((file) => file.startsWith('next.config.') )