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

Use temp repo copy while linking packages #28301

Merged
merged 3 commits into from Aug 19, 2021
Merged
Changes from 1 commit
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
21 changes: 10 additions & 11 deletions scripts/trace-next-server.js
Expand Up @@ -18,10 +18,18 @@ const MAX_UNCOMPRESSED_SIZE = 2.5 * 1000 * 1000
// version so isn't pre-traced
async function main() {
const tmpdir = os.tmpdir()
const repoDir = path.join(__dirname, '..')
const origRepoDir = path.join(__dirname, '..')
const repoDir = path.join(tmpdir, `tmp-next-${Date.now()}`)
const workDir = path.join(tmpdir, `trace-next-${Date.now()}`)

await fs.copy(origRepoDir, repoDir, {
filter: (item) => {
return !item.includes('node_modules')
},
})

console.log('using workdir', workDir)
console.log('using repoDir', repoDir)
ijjk marked this conversation as resolved.
Show resolved Hide resolved
await fs.ensureDir(workDir)

const pkgPaths = await linkPackages(repoDir)
Expand All @@ -48,16 +56,6 @@ async function main() {
},
})

// remove temporary package packs
pkgPaths.forEach((packagePath) => {
fs.unlinkSync(packagePath)
})
// remove changes to package.json files from packing
await execa('git', ['checkout', '.'], {
cwd: repoDir,
stdio: ['ignore', 'inherit', 'inherit'],
})

const nextServerPath = path.join(
workDir,
'node_modules/next/dist/server/next-server.js'
Expand Down Expand Up @@ -119,6 +117,7 @@ async function main() {
})
)
await fs.remove(workDir)
await fs.remove(repoDir)

console.timeEnd(traceLabel)

Expand Down