yarbsemaj / sveltekit-adapter-lambda

An adapter to build a SvelteKit app into a lambda ready for deployment with lambda proxy via the Serverless Framework or CDK.
https://www.npmjs.com/package/@yarbsemaj/adapter-lambda
MIT License
77 stars 16 forks source link

+page and +layout will break the current adapter #18

Closed ScriptedAdventure closed 2 years ago

ScriptedAdventure commented 2 years ago

Sveltekit changed to using +page and +layout files. As I just converted my application to the latest version, I found that +page css files and +layout css files are not loaded correctly as s3 doesn't support "+" in the uri.

Instead, the plus sign is converted to a "%2b".

One simple fix would be to change the uri in the router.js: request.uri = uri.replace("+", "%2b")

nickmenow commented 2 years ago

See https://github.com/sveltejs/kit/issues/5843 and https://github.com/vitejs/vite/pull/9737 This is likely a vite build issue/bug you are experiencing and not this adapter.

yarbsemaj commented 2 years ago

@philippschladitz This is a bug in svelte/vite, + is considered a reserved character in a URL.

souravjamwal77 commented 2 years ago

Hi @yarbsemaj how do I resolve this issue? We migrated to the new Sveltekit routing system and nothing is working and it's Friday. Please if someone could help me out.

yarbsemaj commented 2 years ago

Hi @souravjamwal77 Unfortunately, for a proper fix, You need to wait for the next vite release where this bug has been addressed. Alternatively, this commenter has written a vite plugin that will fix the issue in the meantime https://github.com/sveltejs/kit/issues/5843#issuecomment-1220222362

souravjamwal77 commented 2 years ago

Hi @yarbsemaj I'm getting below errors after the successful deployment. What am I doing wrong?

{
    "errorType": "TypeError",
    "errorMessage": "Cannot read properties of null (reading 'handleError')",
    "stack": [
        "TypeError: Cannot read properties of null (reading 'handleError')",
        "    at Object.handle_error (/var/task/build/server/serverless.js:17138:28)",
        "    at respond (/var/task/build/server/serverless.js:17094:13)"
    ]
}
yarbsemaj commented 2 years ago

Hi @souravjamwal77 This looks to be an issue related to a svelte change introduced 3 days ago, I have published a new adapter (v0.12.0) that fixes this issue.

It should now be possible to deploy and use the latest sveltekit version.