-
-
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
Cannot build with .node files and Vercel adapter #1547
Comments
Since I wasn't aware of them, Does this work with |
Building works with |
I wonder if it has anything to do with kit/packages/adapter-vercel/index.js Line 30 in 6372690
|
Looks like esbuild is probably the culprit: evanw/esbuild#1051 Luckily, the issue also has a code snippet for an ESBuild plugin to fix this. Not sure if adding it to the adapter itself is the direction Sveltekit should go, but it would likely work. Alternatively, |
Hitting this issue as well |
Oupsi, let's go for a selfmade linode deploy as always :'( |
Is there a current workaround for this? I can't get
Any help would be appreciated! |
@alteredorange, I couldn't figure out a workaround so I ended up creating a custom serverless function on Vercel. It's very much not ideal, though. |
Did someone find a solution here ? |
Try add a In my case, I'm using Prisma with N-API I have:
see also this comment I posted in Prisma repo. |
@haishanh, with Primsa, did you also have errors during the build step? It looks like the issue you commented on in the Prisma repo didn't experience build-time errors. If you did also get those build-time errors, how'd you fix that? |
Looks like this issue might be resolved once #1732 is merged. |
Same Issue with the netlify-adapter here. |
I haven't tried it yet, but it looks like #1914 is merged and should fix this issue for all the official adapters (except static) |
Did someone try to use |
I'm not having any luck with the vercel adapter and vercel bundles your app into a single binary when it deploys, so we need to get this file on the filesystem alongside it in order for that to work. |
Hey @antony, it seems there is a hacky fix : esbuild config ; but i didn't try yet |
I am not using Vercel adapter but facing this problem as well. I was running svimg on a Codesandbox and it was fine until I updated some packages to try something. Now everything is broken 😖 Even if I set old packages versions in |
I got the .node files to work by rewriting the path in the lambda and copying the .node file to the lambda dir:
However, it looks like once deployed to Vercel's lambda, there is no This seems odd because nextjs uses it. Perhaps @leo can shine some light here - how is next using libvips? Is it possible for us to access it at runtime? UPDATE: As usual, a millisecond after pinging Leo, this now seems to work (essentially, placing the build shared object right next to the .node file and lambda: #!/bin/bash
LAMBDA_DIR=.vercel_build_output/functions/node/render/
cp node_modules/sharp/build/Release/*.node $LAMBDA_DIR
cp node_modules/sharp/vendor/8.11.3/linux-x64/lib/libvips-cpp.so.42 $LAMBDA_DIR
sed -i 's#\.\./build/Release#\.#g' $LAMBDA_DIR/index.js Of course it's a total hack - I'd be interested to know if there was a better way of achieving this. |
Am I correctly understanding that you're in need of a native dependency in the Vercel Build Step? If so, which one exactly and what would it be used for? If you're talking about optimizing images, have you considered using the respective edge network API for that? |
@leo what we'd want, as I understand it, is for Vercel's build step to handle unbundled native dependencies, or somehow provide a way to allow these dependencies to become available to projects. Libraries like sharp dynamically load The fix above makes a manual move of the required files into the lambda dir, which is quite painful to figure out. Didn't know about the edge network API though - that could save me a lot of time in a few places! |
I see. Thanks for clarifying! When using the File System API, Vercel won't do any automatic bundling based on resolving what a Serverless Function needs like we do for our user-facing API. Instead, as described on the documentation page, we just place the file we're provided with directly in the final Lambda, and place any files next to it that were put into the same folder next to that entrypoint file, so that's where you could place them. Does that help? When it comes to this specific case, however, I recommend using the Image Optimization API, as anything else, I think, would be a waste of performance both in the build step and at runtime. |
Hi Leo - Ok so I think this makes sense. If I move the files into the right place, everything seems to work fine. I think the new issue I'm encountering is to do with vite's handing of Thanks for your help! |
@antony my understanding is that's related to ESBuild? Struggling with this at the moment. |
Describe the bug
Cannot build Sveltekit while using Sharp and the Vercel adapter. Sharp works in development. I suspect this issue applies to all dependencies with
.node
files.This seems unrelated to the "error when including packages" question in the FAQ or #737
Logs
To Reproduce
pnpm i sharp
pnpm build
Reproduction repo: https://github.com/Nick-Mazuk/sveltekit-sharp
Expected behavior
Site would build without issues.
Stacktraces
If you have a stack trace to include, we recommend putting inside a
<details>
block for the sake of the thread's readability:Stack trace
Information about your SvelteKit Installation:
Diagnostics
System:
OS: macOS 11.3
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 8.95 GB / 64.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 16.1.0 - ~/.nvm/versions/node/v16.1.0/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 7.11.2 - ~/.nvm/versions/node/v16.1.0/bin/npm
Browsers:
Brave Browser: 90.1.24.86
Firefox: 87.0
Safari: 14.1
npmPackages:
@sveltejs/kit: next => 1.0.0-next.109
svelte: ^3.34.0 => 3.38.2
"@sveltejs/adapter-vercel": "^1.0.0-next.19"
"sharp": "^0.28.3"
Severity
Blocking deployment of new feature.
The text was updated successfully, but these errors were encountered: