-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat: deploy / adapter / AWS Lambda #48
base: main
Are you sure you want to change the base?
feat: deploy / adapter / AWS Lambda #48
Conversation
|
@lazarv the adapter is ready but I need help with these small problems:
Example Error from
when
|
The problem is not related to NODE_ENV, it's the additional bundling by ˋsstˋ which fails with imports not represented in the node_module folder. I will try to find an option to switch off bundling |
Hi @aheissenberger! I will implement / refactor what you have right now in the AWS adapter to be able to just provide a function which creates a Hattip handler / middleware, so it's easier to create handlers for different platforms, like Node.js, AWS, etc. But I can't promise when I'll have time to do it. I tried to deploy to AWS lambda using Serverless Framework v3 and v4, but neither worked. Your test run works, but there were issues with the deployments. Using v3 it creates a handler which calls the specified function handler, but it's implemented using CommonJS which can't call ESM. With v4 I had other module resolution issues. Could you please provide a working |
@lazarv I am finished and suggest to move any kind of optimization regarding configuration of deployment frameworks to its own PRs Currently your methods in core do not copy any source map files which is fine for me as I upload them directly to sentry but I suggest to add an option which allows to define if the source maps should be included in the output for the adapter. regarding slow startup time: Have you ever looked at the startup time of your server? The current startup time for a lambda is |
@aheissenberger this is great! As soon as you think this is ready to go, just mark it ready for review and it's good to go!
I went through all of them, everything works! My only concern is about the SST deployment as it doesn't use CloudFront to serve all the static files from an S3 bucket, but every request is handled by the lambda, which is very suboptimal.
The build can get the information from the configuration that it's needed to copy source maps or not, an enhancement for later for sure.
I think this is a future task and should be implemented at SST like in the case of Remix or Next.js with support from react-server's side.
This is a performance issue around loading the configuration files. If
I think that bundling is almost impossible right now because how client components and server actions are resolved and imported on-demand. It could result in shrinking the size a bit regarding the dependencies in |
I have added a first version of a sst stack for react-server which supports s3 for static assets. Last step will be to add optional lambda streaming. |
@lazarv any idea why the Here is a list sorted by size: |
Again, because of configuration. That module needs special attention from my side and I'll fix the performance and dependency issues around it this weekend. Regarding patching SST with a symlink, can you move that into the adapter package and add Pulumi as an optional peer dependency? Also that "master" file needs some cleanup, like removing unused import comment and fixing TanStack Start link. I'll check out what's needed to make dev mode work. If you could move the instructions from the readme into the docs that would be awesome! |
The symlink is only a hack to allow me to test the stack - I am not experienced with sst framework at all and the documentation on how to develop a stack outside the repository does not exist. Currently all frameworks exist directly in the sst repository which is cool in the long run but currently as things still move a little bit problematic. I have asked on discord on how to handle this case. I will upgrade the docs to include the content of the readme. |
I was able to significantly reduce the startup time with changes regarding configuration and static file handling. On the main branch before the changes the docs started locally in ~265ms for me in production mode. After the changes this is down to ~72-75ms. This configuration handling change also removes the You will need to change the import at https://github.com/aheissenberger/react-server/blob/feat/adapter/aws-lambda/packages/react-server-adapter-aws/libs/create-handler.mjs#L1 to use https://github.com/lazarv/react-server/blob/main/packages/react-server/config/prebuilt.mjs. This way it's loading a prebuilt version of the configuration much faster than using glob in development mode. |
@lazarv I try to find a setup with AWS CDK for the AWS CloudFront & AWS Lambda Setup to handle Routing for static und dynamic routes. I have tried the following setups: A) static top level folder strategy (tested/ old implementation )
Problems:
B) Static File Lookup-Table (implemented)
Problems:
C) Edge Routing (not impemented)
Problems:
Generell Problems
Solution C) is a long term goal but the problem exists with other cloud providers. Currently I will try to fix the existing problems with B). The solution with Sample App: |
I would suggest the following approach:
Right now the routing manifest for the file-system based router only exists as a virtual module at Also keep in mind that while it seems that the file-system based router will be the most used, it's not the only way to create apps with react-server. When you have a single entrypoint handling all the rendering, you can still specify static routes in Your better choice is to use the list of static files instead, as you have it using Please let me know if I missed something! |
I do not like https://d53oahuh7w7td.cloudfront.net/ (Variation B) is now working with caching (overcaching) in cloudfront. |
@lazarv I have different deployment commands based on the toolkit (cdk, sst, serverless framework) used to deploy. Currently the I would either need this optional to be a function called with the adapterOptions or being called after the deployment adapter process is finished to show the correct deployment command. |
Fixes handling the `deploy` CLI argument in the build action adapter handler addressing #101. Adds handling `deploy` property of an adapter implementation when the value of `deploy` is a function. See more in the docs at https://react-server.dev/deploy/api#define-the-adapter-handler. Implements feature request at #48 (comment)
Now you can use a function as the I think you can now remove the temporary file for framework detection, you'll also get the return value of the |
Adapter to deploy to AWS Lambda. Wraps the hattip middleware with a AWS Lambda specific handler.
fix #30
Status with different Deployment Frameworks:
/create-logger.mjs
and cannot handle the native libs forfsevents
andlightningcss