Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby-adapter-netlify): support monorepos #39005

Conversation

pieh
Copy link
Contributor

@pieh pieh commented Jun 3, 2024

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:

  • 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 a3aa898
  • 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 6efd4bb

The changes can be tested using canary releases:

gatsby@monorepo-support
gatsby-adapter-netlify@monorepo-support

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

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jun 3, 2024
@pieh pieh added topic: adapters Related to Gatsby Adapters and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jun 3, 2024
@pieh pieh force-pushed the michalpiechowiak/fra-552-ssr-error-enoent-no-such-file-or-directory-lstat branch 20 times, most recently from 8c1ca47 to 520635d Compare June 4, 2024 11:06
pieh added 3 commits June 4, 2024 13:38
…onorepo cases will bundle all required files correctly
…ad infer root of 'gatsby' through relative path from entry module and set process.cwd() based on that so rest of utils relying on process.cwd() continue to work in monorepo scenarios
@pieh pieh force-pushed the michalpiechowiak/fra-552-ssr-error-enoent-no-such-file-or-directory-lstat branch from 520635d to aa13fbb Compare June 4, 2024 11:39
@pieh pieh marked this pull request as ready for review June 4, 2024 13:46
serhalp
serhalp previously approved these changes Jul 11, 2024
@pieh pieh merged commit 1a56c34 into master Jul 11, 2024
33 of 35 checks passed
@pieh pieh deleted the michalpiechowiak/fra-552-ssr-error-enoent-no-such-file-or-directory-lstat branch July 11, 2024 17:10
pieh added a commit that referenced this pull request Jul 11, 2024
* test: run e2e adapters in monorepo setup

* fix(gatsby-adapter-netlify): ensure we set includedFilesBasePath so monorepo cases will bundle all required files correctly

* fix(gatsby): don't rely on process.cwd() in lambda for ssr/dsg, instead infer root of 'gatsby' through relative path from entry module and set process.cwd() based on that so rest of utils relying on process.cwd() continue to work in monorepo scenarios

* chore: minor cleanup

* chore: bump caniuse-lite

(cherry picked from commit 1a56c34)
pieh added a commit that referenced this pull request Jul 12, 2024
* test: run e2e adapters in monorepo setup

* fix(gatsby-adapter-netlify): ensure we set includedFilesBasePath so monorepo cases will bundle all required files correctly

* fix(gatsby): don't rely on process.cwd() in lambda for ssr/dsg, instead infer root of 'gatsby' through relative path from entry module and set process.cwd() based on that so rest of utils relying on process.cwd() continue to work in monorepo scenarios

* chore: minor cleanup

* chore: bump caniuse-lite

(cherry picked from commit 1a56c34)

Co-authored-by: Michal Piechowiak <[email protected]>
@pieh
Copy link
Contributor Author

pieh commented Jul 12, 2024

Successfully published:
 - [email protected]
 - [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: adapters Related to Gatsby Adapters
Projects
Status: Published
Development

Successfully merging this pull request may close these issues.

3 participants