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(vercel): rush monorepo support #479

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jamsch
Copy link

@jamsch jamsch commented Dec 11, 2024

Changes

This change uncomments a line used to detect the monorepo root for Rush projects. This change is necessary to include the node modules + correct symlinks as part of the Vercel build.

In a Rush monorepo with the following structure:

.
├── README.md
├── apps
│   ├── admin
│   ├── web
│   └── www
├── common
│   ├── changes
│   ├── config
│   ├── git-hooks
│   ├── pnpm-patches
│   ├── scripts
│   └── temp
├── package.json
├── packages
│   ├── api
│   ├── eslint-config
│   ├── shared
│   ├── test
│   ├── tsconfig
│   ├── types
│   └── ui
├── rush.json
└── tsconfig.base.json

Running the build process in our apps/www folder results in the following structure:

 ._render.func
├── dist
│   └── server
│       ├── _noop-middleware.mjs
│       ├── chunks
│       ├── entry.mjs
│       ├── manifest_Bl2bl94u.mjs
│       ├── pages
│       └── renderers.mjs
├── node_modules
│   ├── @radix-ui
│   │   ├── react-avatar -> ../../../../common/temp/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/@radix-ui/react-avatar
│   │   └── react-select -> ../../../../common/temp/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/@radix-ui/react-select
│   ├── clsx -> ../../../common/temp/node_modules/.pnpm/[email protected]/node_modules/clsx
│   ├── dayjs -> ../../../common/temp/node_modules/.pnpm/[email protected]/node_modules/dayjs
│   ├── react -> ../../../common/temp/node_modules/.pnpm/[email protected]/node_modules/react
│   ├── react-dom -> ../../../common/temp/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom
│   ├── sharp -> ../../../common/temp/node_modules/.pnpm/[email protected]/node_modules/sharp
│   └── tailwind-merge -> ../../../common/temp/node_modules/.pnpm/[email protected]/node_modules/tailwind-merge
├── package.json
└── src
    └── pages
        ├── [...path].astro
        ├── aboutus.astro
        ├── help.astro
        ├── index.astro
        ├── pricing.astro
        └── reviews.astro

Which resolves in incorrect symlinks, as well as no node_modules sources copied in to the .vercel folder.

If deployed to Vercel, it results in the following error:

Screenshot 2024-12-11 at 4 27 16 PM

After the fix, the project structure uses the monorepo root:

.
└── _render.func
    ├── apps
    │   └── www
    │       ├── dist
    │       │   └── server
    │       │       ├── _noop-middleware.mjs
    │       │       ├── chunks
    │       ├── node_modules
    │       │   ├── @radix-ui
    │       │   │   ├── react-avatar -> ../../../../common/temp/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/@radix-ui/react-avatar
    │       │   │   └── react-select -> ../../../../common/temp/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/@radix-ui/react-select
    │       │   ├── clsx -> ../../../common/temp/node_modules/.pnpm/[email protected]/node_modules/clsx
    │       │   ├── dayjs -> ../../../common/temp/node_modules/.pnpm/[email protected]/node_modules/dayjs
    │       │   ├── react -> ../../../common/temp/node_modules/.pnpm/[email protected]/node_modules/react
    │       │   ├── react-dom -> ../../../common/temp/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom
    │       │   ├── sharp -> ../../../common/temp/node_modules/.pnpm/[email protected]/node_modules/sharp
    │       │   └── tailwind-merge -> ../../../common/temp/node_modules/.pnpm/[email protected]/node_modules/tailwind-merge
    │       └── src
    │           └── pages
    │               ├── [...path].astro
    │               ├── aboutus.astro
    │               ├── help.astro
    │               ├── index.astro
    │               ├── pricing.astro
    │               └── reviews.astro
    ├── common
    │   └── temp
    │       └── node_modules
    │          └── .pnpm (all of our dependencies here)
    └── package.json

Testing

Testing was done manually on a Vercel account. I highly doubt before this users were able to run Astro on their monorepos.

Docs

Nothing of note

Copy link

changeset-bot bot commented Dec 11, 2024

🦋 Changeset detected

Latest commit: af81c7e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
Name Type
@astrojs/vercel Patch
@test/astro-vercel-basic Patch
@test/astro-vercel-image Patch
@test/vercel-isr Patch
@test/vercel-max-duration Patch
@test/vercel-edge-middleware-with-edge-file Patch
@test/vercel-edge-middleware-without-edge-file Patch
@test/astro-vercel-no-output Patch
@test/astro-vercel-prerendered-error-pages Patch
@test/astro-vercel-redirects-serverless Patch
@test/astro-vercel-redirects Patch
@test/vercel-server-islands Patch
@test/astro-vercel-serverless-prerender Patch
@test/astro-vercel-serverless-with-dynamic-routes Patch
@test/astro-vercel-static-assets Patch
@test/astro-vercel-static Patch
@test/vercel-streaming Patch
@test/astro-vercel-with-web-analytics-enabled-output-as-static Patch
vercel-hosted-astro-project Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: vercel Related to Vercel adapter (scope) label Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: vercel Related to Vercel adapter (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants