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

Missing manifest.js (Trying to build adapter-lambda myself for a fork) #29

Open JL102 opened 1 year ago

JL102 commented 1 year ago

Hi,

I've forked adapter-lambda because I'd like to implement a feature that would allow me to customize the Lambda handler code, but I'm unable to run the build script. It seems like esbuild is attempting to run serverless.js, which is searching for manifest.js, which does not exist. How do I get the build script to run properly?

> esbuild src/serverless.js --bundle --format=esm --platform=node --external:'../index.*' --external:'../manifest.*' --outfile=files/serverless.js && cp src/shims.js files/shims.js && cp src/router.js files/router.js

 > src/serverless.js:2:25: error: Could not resolve "../manifest.js"
    2 │ import { manifest } from '../manifest.js';
      ╵                          ~~~~~~~~~~~~~~~~
yarbsemaj commented 1 year ago

Hi @JL102 Thank You for your interest in my project! This is an odd one. I have cloned your fork of my repo and have run the command you have listed in your comment without issue. image I may be worth trying npm run build. This is the command that is run before a new version of the package is pushed to the NPM repository and again works on my machine with your fork. image

esbuild should be ignoring manifest.js (as it is with index.js) as they are marked as external in the esbuild arguments. Its a long shot but if you were trying to build on windows the way you input switches into a command may be slightly diffrent (if indeed you are using windows)

For some context, the above screenshot were taken using node 18.10.0 on Linux with esbuild 0.10.0

JL102 commented 1 year ago

@yarbsemaj Ah, that's it, thanks! I would switch to WSL, but due to very complicated reasons related to my Intel Arc GPU, I can't enable it until they update their driver with a bug fix. I created a new build script win-build that just adjusts the commands to work on Windows: https://github.com/yarbsemaj/sveltekit-adapter-lambda/compare/master...JL102:sveltekit-adapter-lambda:master Is it alright if I submit a PR with that?

Edit: Just noticed that package.json is using spaces instead of tabs. Are you using Bun? 😉

yarbsemaj commented 1 year ago

Aha! Glad you got there! :tada: Before i merge your change could you try using docker to perform the build. Id prefer not to have 2 build commands if i can help it.

JL102 commented 1 year ago

Unfortunately Docker needs hardware assisted virtualization to work, and SVM / Hyper-V is what I currently need to disable to get my Intel Arc GPU to work properly.

I updated the build script to work properly on both OSes -- turns out that the quotation marks are not needed. I tested on my laptop which runs Kubuntu. Is this solution acceptable? https://github.com/yarbsemaj/sveltekit-adapter-lambda/commit/2762ded0a6faa17f52d8ee34169f591be8f98acd