Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure swc dep is copied for isolated tests #31462

Merged
merged 1 commit into from Nov 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions test/lib/create-next-install.js
Expand Up @@ -11,6 +11,25 @@ async function createNextInstall(dependencies) {
const installDir = path.join(tmpDir, `next-install-${Date.now()}`)
const tmpRepoDir = path.join(tmpDir, `next-repo-${Date.now()}`)

// ensure swc binary is present in the native folder if
// not already built
for (const folder of await fs.readdir(
path.join(origRepoDir, 'node_modules/@next')
)) {
if (folder.startsWith('swc-')) {
const swcPkgPath = path.join(origRepoDir, 'node_modules/@next', folder)
await fs.copy(
swcPkgPath,
path.join(origRepoDir, 'packages/next/native'),
{
filter: (item) =>
item === swcPkgPath ||
(item.endsWith('.node') && !fs.pathExistsSync(item)),
}
)
}
}

for (const item of ['package.json', 'yarn.lock', 'packages']) {
await fs.copy(path.join(origRepoDir, item), path.join(tmpRepoDir, item), {
filter: (item) => {
Expand All @@ -23,6 +42,7 @@ async function createNextInstall(dependencies) {
},
})
}

const pkgPaths = await linkPackages(tmpRepoDir)

await fs.ensureDir(installDir)
Expand Down