Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 793d59a

Browse filesBrowse files
authored
fix(vercel): use tmp directory to clone contents (#3810)
1 parent 6b2720b commit 793d59a
Copy full SHA for 793d59a

3 files changed

+20-3Lines changed: 20 additions & 3 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/module.ts‎

Copy file name to clipboardExpand all lines: src/module.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,8 @@ async function processCollectionItems(nuxt: Nuxt, collections: ResolvedCollectio
332332
for await (const source of collection.source) {
333333
if (source.prepare) {
334334
// @ts-expect-error - `__rootDir` is a private property to store the layer's cwd
335-
const rootDir = collection.__rootDir || nuxt.options.rootDir
335+
const rootDir = (source.repository ? options._remoteSourceRootDir : collection.__rootDir)
336+
|| nuxt.options.rootDir
336337
await source.prepare({ rootDir })
337338
}
338339

Collapse file

‎src/presets/nuxthub.ts‎

Copy file name to clipboardExpand all lines: src/presets/nuxthub.ts
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { mkdir, writeFile } from 'node:fs/promises'
2-
import { resolve } from 'pathe'
1+
import { tmpdir } from 'node:os'
2+
import { mkdir, writeFile, mkdtemp } from 'node:fs/promises'
3+
import { resolve, join } from 'pathe'
34
import { provider } from 'std-env'
45
import { logger } from '../utils/dev'
56
import { definePreset } from '../utils/preset'
@@ -43,6 +44,13 @@ export default definePreset({
4344
else {
4445
await nodePreset.setup?.(options, nuxt, config)
4546
}
47+
48+
if (preset.includes('vercel')) {
49+
// Change remoteSourceRootDir to a temporary directory
50+
// this will prevent conflicts with the Vercel build cache
51+
// @ts-expect-error - `_remoteSourceRootDir` is a private property to store the temporary directory
52+
options._remoteSourceRootDir = options._remoteSourceRootDir || await mkdtemp(join(tmpdir(), 'nuxt-content'))
53+
}
4654
},
4755
async setupNitro(nitroConfig, options) {
4856
const { nuxt } = options as unknown as { nuxt: Nuxt & { options: { hub: { db?: boolean | object, database?: boolean } } } }
Collapse file

‎src/presets/vercel.ts‎

Copy file name to clipboardExpand all lines: src/presets/vercel.ts
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { mkdtemp } from 'node:fs/promises'
2+
import { tmpdir } from 'node:os'
3+
import { join } from 'pathe'
14
import { definePreset } from '../utils/preset'
25
import { logger } from '../utils/dev'
36
import nodePreset from './node'
@@ -13,6 +16,11 @@ export default definePreset({
1316
options.experimental ||= {}
1417
options.experimental.sqliteConnector ||= 'bun'
1518
}
19+
20+
// Change remoteSourceRootDir to a temporary directory
21+
// this will prevent conflicts with the Vercel build cache
22+
// @ts-expect-error - `_remoteSourceRootDir` is a private property to store the temporary directory
23+
options._remoteSourceRootDir = options._remoteSourceRootDir || await mkdtemp(join(tmpdir(), 'nuxt-content'))
1624
},
1725
async setupNitro(nitroConfig) {
1826
const database = nitroConfig.runtimeConfig?.content?.database

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.