-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Use @vercel/nft
to create lambdas
#4969
Conversation
🦋 Changeset detectedLatest commit: 228cf07 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Getting it to work with the v1 API is proving finicky, but since v3 is coming out of beta soon I think we should just revert to CJS output for v1 and count down the days until we can remove it altogether. People who want to use top-level await will need to opt into v3 by setting the Future optimisation: would be good to deduplicate shared dependencies between functions. Not going to worry about that right now though. |
This reverts commit 6f699e6.
Builds are completing successfully with this PR, but the build process on Vercel is then hanging with messages like these:
|
This should be fixed in the next version of |
An alternative to #4967 — fixes #4933.
This is something I've been meaning to look into for a while. By using
@vercel/nft
, we can get a list of all the files a function depends on, and copy them into the function directory rather than relying on a bundler likeesbuild
to bundle everything into a single file.Doing so has a couple of advantages:
sharp
I think continuing to use
esbuild
for Edge Functions is the right strategy, at least for the time being (since these can't use native dependencies anyway).There's some trickery involved in getting this to work — in order for relative imports to continue working, we need to find the common ancestor directory of all dependencies (which could even be outside the workspace, if using linked dependencies) and copy the structure into the lambda, and to support
pnpm
we need special handling for symlinks. It's working, though it feels like quite a lot of grunt work, so I'm not 100% sure I'm doing it right.Todo:
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0