DSG/SSR handler was making some assumptions about how it's being mounted in serverless that were not correct when site deployed to Netlify is part of monorepo:
functions configuration - includedFiles in particular was not working due to base directory assuming root of repo and hence those files were not being bundled (it did bundle some things due to regular import tracking, but not all required things when static analisys would not catch some files) - fixed with https://github.com/gatsbyjs/gatsby/pull/39005/commits/a3aa898c6fb3ceac4ea75ba4b4e8e25f5b03f369
serverless structure for monorepos is a bit different than for single-site repos and so gatsby's .cache directory for monorepo is not in <cwd>/.cache and instead is in <cwd>/<package_path>/.cache - instead of using <cwd> to figure out directory it now goes other way around by resolving directory locations by resolving directories relative to main function entry point module - fixed with https://github.com/gatsbyjs/gatsby/pull/39005/commits/6efd4bb13f938242fcf70cde3f6e2ba2f3d824c8
Added workflow that run adapters e2e tests with fixture using monorepo setup (first commit is just added monorepo test setup showing it failing lots of adapters e2e test and remaining commits fixed the problems making it pass).
Description
DSG/SSR handler was making some assumptions about how it's being mounted in serverless that were not correct when site deployed to Netlify is part of monorepo:
includedFiles
in particular was not working due to base directory assuming root of repo and hence those files were not being bundled (it did bundle some things due to regular import tracking, but not all required things when static analisys would not catch some files) - fixed with https://github.com/gatsbyjs/gatsby/pull/39005/commits/a3aa898c6fb3ceac4ea75ba4b4e8e25f5b03f369.cache
directory for monorepo is not in<cwd>/.cache
and instead is in<cwd>/<package_path>/.cache
- instead of using<cwd>
to figure out directory it now goes other way around by resolving directory locations by resolving directories relative to main function entry point module - fixed with https://github.com/gatsbyjs/gatsby/pull/39005/commits/6efd4bb13f938242fcf70cde3f6e2ba2f3d824c8The changes can be tested using canary releases:
Tests
Added workflow that run adapters e2e tests with fixture using monorepo setup (first commit is just added monorepo test setup showing it failing lots of adapters e2e test and remaining commits fixed the problems making it pass).
Related Issues
Fixes https://linear.app/netlify/issue/FRA-552/ssr-error-enoent-no-such-file-or-directory-lstat-vartaskcachedata-on