-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[adapter-vercel] Page visits return 500: INTERNAL_SERVER_ERROR
possibly due to missing modules that are marked as external
for esbuild
#4247
Comments
This seems unlikely to me to be a performance enhancement if you're doing it at runtime. I'd recommend doing it only during prerendering as demonstrated here: https://kit.svelte.dev/docs/migrating#integrations-html-minifier |
Hey @benmccann Thank you for sharing that snippet! I've realized that minifying all HTML responses may not be ideal. import { Handle } from '@sveltejs/kit';
import { sequence } from '@sveltejs/kit/hooks';
import { minify } from 'html-minifier';
import { prerendering } from '$app/env';
const minifyHtml: Handle = async ({ event, resolve }) =>
await resolve(event, {
transformPage: ({ html }) =>
prerendering
? minify(html, {
collapseBooleanAttributes: true,
collapseWhitespace: true,
decodeEntities: true,
minifyCSS: true,
minifyJS: true,
removeAttributeQuotes: true,
removeComments: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
sortAttributes: true,
sortClassName: true
})
: html
});
export const handle = sequence(minifyHtml); Now, prerendered pages are minified as expected and work flawlessly! Unfortunately, the issue still exists, and pages that are not prerendered return My guess is that packages that don't work well with Is there a way to bundle these dependencies for Thank you again for your help with this issue! |
Did you get anywhere with this? I have the same issue, an "external" dependency not found, using sveltekit/vercel/pnpm. In my case I'm external-ising svg2img which loads a .node file (unsupported by esbuild afaik). Also of possible importance - I'm getting this problem in an endpoint. |
This will hopefully be fixed by #4969 |
Going to assume this was fixed by #4969 and close it — feel free to open a new issue if it's still happening with current versions of everything |
I can confirm that this issue is resolved! |
Describe the bug
When using a module that doesn't play well with
esbuild
, (eg:html-minifier
), deploying to Vercel is technically successful but results in failing page visits.In my case, I've used the
html-minifier
package to write a simplehandle
hook that minifieshtml
.The deploys were previously showing warnings that certain relative paths needed to be marked as
external
foresbuild
.All of these warnings had ties to
uglify-js
, a dependency ofhtml-minifier
.These warnings disappeared when
html-minifier
was marked asexternal
Reproduction
Here is a link to a reproduction.
Here are the steps I took to create the reproduction:
html-minifier
and create a simplehandle
hook that minifieshtml
.At this point, I got the following warnings on Vercel:
Warnings on Vercel deployment log
adapter-vercel
and specifyhtml-minifier
as anexternal
module.Logs
Here's an example log for functions that are invoked when a user visits the deployed site:
System Info
Severity
blocking an upgrade
Additional Information
pnpm
as my package managerI think I might be missing some configuration.
Any help is appreciated!
Thank you for your time!
The text was updated successfully, but these errors were encountered: