Skip to content

Commit

Permalink
only ignore sharp if it's installed
Browse files Browse the repository at this point in the history
  • Loading branch information
David Bailey committed Feb 2, 2021
1 parent b6c3d9b commit 850219e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/next/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,17 @@ export default async function build(
PAGES_MANIFEST
)

// `sharp` is optional so may not be installed
const ignore: string[] = []
try {
ignore.push(
path.relative(
dir,
path.join(path.dirname(require.resolve('sharp')), '**/*')
)
)
} catch {}

const requiredServerFiles = traceFn(
tracer.startSpan('generate-required-server-files'),
() => ({
Expand All @@ -420,12 +431,7 @@ export default async function build(
]
.filter(nonNullable)
.map((file) => path.join(config.distDir, file)),
ignore: [
path.relative(
dir,
path.join(path.dirname(require.resolve('sharp')), '**/*')
),
],
ignore,
})
)

Expand Down

0 comments on commit 850219e

Please sign in to comment.