Hi everyone,
Since the Gatsby team is now part of Netlify, I wanted to bring an architectural and security-focused question to this community, as it involves the core compilation pipeline of Gatsby sites.
I am currently working on hardening our Gatsby projects against npm supply-chain risks. Following security frameworks, we want to disable install-time lifecycle scripts globally by setting ignore-scripts=true in our .npmrc. To allow necessary packages to function without introducing blind risks, we are leveraging @lavamoat/allow-scripts to implement a strict script allowlist.
The Challenge
In a standard Gatsby setup, the installation phase fails because sharp (via gatsby-plugin-sharp) requires lifecycle scripts to fetch or compile its native binaries (libvips).
While explicitly adding sharp to our allowlist unblocks local development, we want to ensure this architecture is resilient, cross-platform, and optimized before scaling it across multiple production pipelines—whether they run on Netlify, AWS S3, or standard Docker containers.
Since the experts on Gatsby’s build mechanics are here, I would love to get your insights on these platform-agnostic questions:
-
Gatsby Ecosystem Dependencies: Beyond
sharp, are there other official or common Gatsby plugins/dependencies that hiddenly rely on install/postinstall scripts to function or compile correctly? -
Deterministic Binary Caching: When deploying to serverless environments or stateless CI/CD runners, does overriding scripts via tools like
@lavamoat/allow-scriptsclash with standard npm/yarn/pnpm caching strategies for pre-compiled binaries? -
Best Practices for Hardening: Is there a recommended approach or a community allowlist recognized by the Gatsby team for running fully hardened builds without breaking image processing?
I appreciate any guidance or architectural best practices you can share on this!
Here is a discussion I opened on GitHub and a minimal implementation for replication if that helps.
Thanks in advance.