Unverified Commit 070239e6 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Revert "Merge e2e test node_modules (#40926)" (#40974)

This reverts commit b508fef2.

Fixes: https://github.com/vercel/next.js/actions/runs/3139454323/jobs/5100342131

We aren't able to modify the filesystem for E2E deployments so this reverts the change introduced in the above PR to ensure deployment tests are able to run correctly with custom `node_modules`. 
parent 91f0a7c6
......@@ -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',
......
......@@ -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
}
......
......@@ -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',
},
},
......
......@@ -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())
......
......@@ -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(
......
......@@ -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.')
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment