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

perf(netlify): handle dependency tracing for SSR function #296

Merged
merged 11 commits into from
Jun 27, 2024
Merged

Conversation

ascorbic
Copy link
Contributor

@ascorbic ascorbic commented Jun 21, 2024

Changes

Currently this adapter relies on the Netlify build process to bundle and trace the SSR functions. This can be slow, particularly when there are a large number of generated chunks from content collections. This PR changes the adapter to handle its own tracing using @vercel/nft. This is already done in the @astrojs/vercel, so I've mostly taken the code from there and adapted it a bit. Once we've done that we can tell Netlify to not bundle the generated function. For context, the astro.build site was taking over 6 minutes to bundle before this. With this PR, the bundling takes 6 seconds

See https://app.netlify.com/teams/ascorbic/builds/667d304a908d450008617d30 for an example build

Testing

Docs

Copy link

changeset-bot bot commented Jun 21, 2024

🦋 Changeset detected

Latest commit: f5fa01e

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

This PR includes changesets to release 2 packages
Name Type
@astrojs/netlify Patch
@test/netlify-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

Copy link
Contributor

Invalid command. Expected: "/preview "

@ascorbic
Copy link
Contributor Author

!preview netlify-nft

Copy link
Contributor

Snapshots have been released for the following packages:

  • @astrojs/netlify@experimental--netlify-nft
Publish Log
🦋  warn ===============================IMPORTANT!===============================
🦋  warn Packages will be released under the experimental--netlify-nft tag
🦋  warn ----------------------------------------------------------------------
🦋  info npm info @astrojs/cloudflare
🦋  info npm info @astrojs/netlify
🦋  warn @astrojs/cloudflare is not being published because version 10.4.2 is already published on npm
🦋  info @astrojs/netlify is being published because our local version (0.0.0-netlify-nft-20240621164746) has not been published on npm
🦋  info Publishing "@astrojs/netlify" at "0.0.0-netlify-nft-20240621164746"
🦋  success packages published successfully:
🦋  @astrojs/netlify@0.0.0-netlify-nft-20240621164746
🦋  Creating git tag...
🦋  New tag:  @astrojs/netlify@0.0.0-netlify-nft-20240621164746
Build Log

> root@0.0.0 build /home/runner/work/adapters/adapters
> turbo run build --filter="@astrojs/*"

• Packages in scope: @astrojs/cloudflare, @astrojs/netlify, @astrojs/test-utils
• Running build in 3 packages
• Remote caching disabled
::group::@astrojs/netlify:build
cache miss, executing 8d88ba60eb0326ab

> @astrojs/netlify@0.0.0-netlify-nft-20240621164746 build /home/runner/work/adapters/adapters/packages/netlify
> tsc

::endgroup::
::group::@astrojs/cloudflare:build
cache miss, executing 87f9ce230dd80047

> @astrojs/cloudflare@10.4.2 build /home/runner/work/adapters/adapters/packages/cloudflare
> tsc

::endgroup::

 Tasks:    2 successful, 2 total
Cached:    0 cached, 2 total
  Time:    3.705s 

@ascorbic ascorbic changed the title perf: take over function tracing perf(netlify): take over function tracing Jun 27, 2024
@ascorbic ascorbic changed the title perf(netlify): take over function tracing perf(netlify): handle dependency tracing for SSR function Jun 27, 2024
@ascorbic
Copy link
Contributor Author

!preview netlify-nft

Copy link
Contributor

Snapshots have been released for the following packages:

  • @astrojs/netlify@experimental--netlify-nft
Publish Log
🦋  warn ===============================IMPORTANT!===============================
🦋  warn Packages will be released under the experimental--netlify-nft tag
🦋  warn ----------------------------------------------------------------------
🦋  info npm info @astrojs/cloudflare
🦋  info npm info @astrojs/netlify
🦋  warn @astrojs/cloudflare is not being published because version 11.0.1 is already published on npm
🦋  info @astrojs/netlify is being published because our local version (0.0.0-netlify-nft-20240627091118) has not been published on npm
🦋  info Publishing "@astrojs/netlify" at "0.0.0-netlify-nft-20240627091118"
🦋  success packages published successfully:
🦋  @astrojs/netlify@0.0.0-netlify-nft-20240627091118
🦋  Creating git tag...
🦋  New tag:  @astrojs/netlify@0.0.0-netlify-nft-20240627091118
Build Log

> root@0.0.0 build /home/runner/work/adapters/adapters
> turbo run build --filter="@astrojs/*"

• Packages in scope: @astrojs/cloudflare, @astrojs/netlify, @astrojs/test-utils
• Running build in 3 packages
• Remote caching disabled
::group::@astrojs/netlify:build
cache miss, executing 34842d97b0e58606

> @astrojs/netlify@0.0.0-netlify-nft-20240627091118 build /home/runner/work/adapters/adapters/packages/netlify
> tsc

::endgroup::
::group::@astrojs/cloudflare:build
cache miss, executing 984452774e18a17a

> @astrojs/cloudflare@11.0.1 build /home/runner/work/adapters/adapters/packages/cloudflare
> tsc

::endgroup::

 Tasks:    2 successful, 2 total
Cached:    0 cached, 2 total
  Time:    3.843s 

@ascorbic ascorbic marked this pull request as ready for review June 27, 2024 09:25
.changeset/thick-kids-sing.md Outdated Show resolved Hide resolved
packages/netlify/src/lib/nft.ts Outdated Show resolved Hide resolved
packages/netlify/src/index.ts Outdated Show resolved Hide resolved
@ascorbic ascorbic requested a review from ematipico June 27, 2024 10:09
@ascorbic
Copy link
Contributor Author

WINDOWS PATHS 😱

@ascorbic ascorbic merged commit 8a00cad into main Jun 27, 2024
8 checks passed
@ascorbic ascorbic deleted the nft-bundling branch June 27, 2024 11:50
@github-actions github-actions bot mentioned this pull request Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants