From 260c3c990f8c4caa5ec7e52493c253a7f172492e Mon Sep 17 00:00:00 2001 From: Jorrit Schippers Date: Mon, 4 Jan 2021 13:21:40 +0100 Subject: [PATCH 1/2] Add test job to run tests without sharp --- .github/workflows/build_test_deploy.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml index 176952e1e6a65c..0836dfcbdd9981 100644 --- a/.github/workflows/build_test_deploy.yml +++ b/.github/workflows/build_test_deploy.yml @@ -105,6 +105,26 @@ jobs: - run: xvfb-run node run-tests.js --timings -g ${{ matrix.group }}/6 -c 3 if: ${{needs.build.outputs.docsChange != 'docs only change'}} + testIntegrationWithoutSharp: + name: Test Integration (without sharp) + runs-on: ubuntu-latest + needs: testIntegration + env: + NEXT_TELEMETRY_DISABLED: 1 + NEXT_TEST_JOB: 1 + HEADLESS: true + steps: + - uses: actions/cache@v2 + id: restore-build + with: + path: ./* + key: ${{ github.sha }} + + # TODO: remove after we fix watchpack watching too much + - run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p + - run: rm -rf node_modules/sharp + - run: xvfb-run node run-tests.js --timings test/integration/cli/test/index.test.js -c 3 + testElectron: name: Test Electron runs-on: ubuntu-latest From 6e1af65158369f02e88239678e6055e1ca1b9613 Mon Sep 17 00:00:00 2001 From: Jorrit Schippers Date: Wed, 3 Feb 2021 09:30:35 +0100 Subject: [PATCH 2/2] Check for exceptions while resolving path to sharp --- packages/next/build/index.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/next/build/index.ts b/packages/next/build/index.ts index 0ca466995703f5..33a8cbc68bbbc5 100644 --- a/packages/next/build/index.ts +++ b/packages/next/build/index.ts @@ -395,6 +395,15 @@ export default async function build( PAGES_MANIFEST ) + // Sharp is optional. + let sharpPath: string | null = null + try { + sharpPath = path.relative( + dir, + path.join(path.dirname(require.resolve('sharp')), '**/*') + ) + } catch (e) {} + const requiredServerFiles = traceFn( tracer.startSpan('generate-required-server-files'), () => ({ @@ -420,12 +429,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: [sharpPath].filter(nonNullable), }) )