Giter Site home page Giter Site logo

yarbsemaj / sveltekit-adapter-lambda Goto Github PK

View Code? Open in Web Editor NEW
74.0 5.0 17.0 390 KB

An adapter to build a SvelteKit app into a lambda ready for deployment with lambda proxy via the Serverless Framework.

Home Page: https://www.npmjs.com/package/@yarbsemaj/adapter-lambda

License: MIT License

JavaScript 100.00%
sveltekit sveltekit-adapter lambda aws-lambda aws serverless cloudformation cloudfront

sveltekit-adapter-lambda's Introduction

adapter-lambda for SvelteKit

An adapter to build a SvelteKit app into a lambda ready for deployment with lambda proxy via the Serverless framework.

Installation

npm install --save-dev @yarbsemaj/adapter-lambda

Usage

In your svelte.config.js configure the adapter as bellow;

import preprocess from 'svelte-preprocess'; //Optional
import serverless from '@yarbsemaj/adapter-lambda';

/** @type {import('@sveltejs/kit').Config} */
const config = {
  preprocess: preprocess(), //Optional

  kit: {
    adapter: serverless(),
  },

};

export default config;

Copy serverless.yml from the root of this repo to the root of your project, make sure to change the service name.

After building your app run sls deploy to deploy code to AWS using the build tool serverless.

Your app can then be accessed via the CloudFront distribution created as a part of the stack.

Static Assets and precompiled pages

To server static assets and precompiled pages this adapter makes use of S3. In order to route traffic the correct destination a Lambda@edge fuction is used to perfrom a origin rewrite to redirect traffic to the S3 Bucket.

Infrastructure Diagram

Infra

Help! I'm getting an error while building or serving my app.

Please raise an issue on Github, and I will be happy to issue a fix.

Versions

Adapter Version Sveltekit Version
1.1.x 1.22.0 (Official)
1.x.x 1.0.0 (Official)
0.12.x 1.0.0-next.433
0.11.x 1.0.0-next.401
0.10.x 1.0.0-next.380
0.9.x 1.0.0-next.348
0.6.x - 0.8.x 1.0.0-next.301
0.5.x 1.0.0-next.286
0.3.x - 0.4.x 1.0.0-next.286
0.2.x 1.0.0-next.239
0.1.x 1.0.0-next.169

sveltekit-adapter-lambda's People

Contributors

blindestman avatar jblack96 avatar nboehret avatar sonnyfishback avatar yarbsemaj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sveltekit-adapter-lambda's Issues

v1.0.0

Hi @yarbsemaj, Thanks for offering this. I had the same idea for a lambda sveltekit adapter and was happy to see you had already made some progress on one.

My question is, How close is this adapter to v1 public release? What can I do to help? I'd like to get involved.

Content-Type of javascript files stored on s3 are returned with a Content-Type of text/html

Hello,

I am getting an issue where my .js files are being blocked because they are returned with a Content-Type of text/html.

Here is the error log from Firefox:

Loading module from “https://22dj4azkgiqjznhqjiwors7tze0qoira.lambda-url.us-east-1.on.aws/_app/immutable/start-f4d7d7b9.js” was blocked because of a disallowed MIME type (“text/html”).

This is weird as the Content-Type is correctly set in s3. Here is the info from it:

METADATA: 
  Type: System defined
  Key: Content-Type
  Value: application/javascript

HTML files seem to be loading fine though. My guess is that the adapter may be looking at the MIME type, and not finding any and defaulting to text/html instead of looking at the Content-Type, however this is just and intuition and I haven't been able to confirm it by checking the code for the moment.

Does this seem like a user error or a software error?

Thank you for your time!

Pascal V.

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

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';
      ╵                          ~~~~~~~~~~~~~~~~

Serverless/SvelteKit/Lambda@Edge CSRF

I have a fully working local SvelteKit app that uses form actions, which POST to the server side, and respond accordingly.

This works locally 100% fine, but after deployment using this adapter and serverless-plugin-cloudfront-lambda-edge using any form actions responds with the '403 -Forbidden, 'Cross-site POST form submissions are forbidden'.

It appears as though you can modify SvelteKit to ignore CSRF by adding a configuration options to originCheck: false, which works, but then gives me 404 /login not found, strict-origin-when-cross-origin..

I ned to find a way to add the ORIGIN to the adapter-lambda or configuration somehow I think?

Failed to load resource: the server responded with a status of 404 (Not Found)

Hello,

Thanks for making an amazing adapter!

I managed to get a deployment working by switching the runtime to 16.x but none of the static assets seemed to be working. I looked into the lambda@edge logs and it seemed that in router.js when comparing the uri of the request with the static_default values of the site that the slashes were not the same. Specifically the static_default slashes were \\ and the uri was /.

Is this an error that others have encountered or is my setup wrong?

My serverless.yml if that is needed.

org: [ORG]
app: [APP]
service: '[APP]'

frameworkVersion: "3"

plugins:
  - '@silvermine/serverless-plugin-cloudfront-lambda-edge'
  - serverless-s3-deploy

provider:
  name: aws
  runtime: nodejs16.x
  region: us-east-1 #Lambda@Edge must be deployed in us-east-1
  stage: ${opt:stage, 'dev'}

package:
  individually: true
  exclude:
    - ./**
  include:
    - build/server/**
    - build/edge/**

custom:
  assets:
    auto: true
    targets:
      - bucket: 
          Ref: StaticAssets
        files:
          - source: ./build/assets/
            globs: 
              - '**'
            empty: true
            headers:
              CacheControl: max-age=31104000
          - source: ./build/prerendered/
            globs: 
              - '**'
            empty: true
            headers:
              CacheControl: max-age=60


functions:
  #SSR Function
  svelte:
    handler: build/server/serverless.handler
    memorySize: 256
    timeout: 15
    url: true

  #Router Function
  cfLambda:
    handler: build/edge/router.handler
    memorySize: 128
    timeout: 1
    lambdaAtEdge:
      distribution: 'WebsiteDistribution'
      eventType: origin-request

resources:
  Resources:
    StaticAssets:
      Type: AWS::S3::Bucket
      Properties:
        AccessControl: PublicRead
        BucketName: ${self:provider.stage}-${self:service}-static-assets

    StaticAssetsS3BucketPolicy:
      Type: AWS::S3::BucketPolicy
      Properties:
        Bucket:
          Ref: StaticAssets
        PolicyDocument:
          Statement:
            - Sid: PublicReadGetObject
              Effect: Allow
              Principal: "*"
              Action:
                - s3:GetObject
              Resource:
                Fn::Join: ["", ["arn:aws:s3:::", { "Ref": "StaticAssets" }, "/*"]]

    WebsiteDistribution:
      Type: 'AWS::CloudFront::Distribution'
      Properties:
        DistributionConfig:
          Origins:
            -
              DomainName: !Select [2, !Split ["/", !GetAtt ["SvelteLambdaFunctionUrl", "FunctionUrl"]]]
              Id: default
              OriginCustomHeaders: 
                #Lambda@edge does not support ENV vars, so instead we have to pass in a customHeaders.
                -
                  HeaderName: 's3-host'
                  HeaderValue: '${self:provider.stage}-${self:service}-static-assets.s3.amazonaws.com'
              CustomOriginConfig:
                HTTPPort: 80
                HTTPSPort: 443
                OriginProtocolPolicy: 'https-only'
          Enabled: true
          Comment: '${self:service}_${self:provider.stage}'
          DefaultCacheBehavior:
            TargetOriginId: default
            Compress: true
            AllowedMethods:
              - DELETE
              - GET
              - HEAD
              - OPTIONS
              - PATCH
              - POST
              - PUT
            CachedMethods:
              - GET
              - HEAD
              - OPTIONS
            ForwardedValues:
              Cookies:
                Forward: all
              QueryString: True
            ViewerProtocolPolicy: 'redirect-to-https'

Multiple `set-cookie` headers from endpoints returned as single value

Currently set-cookie header with multiple value (array) is being returned as comma separated single value.
Browsers can't interpret it correctly and only sets first value before comma in browser cookie.

adapter-netlify (code) seems to solve this by returning multivalued set-cookie header without joining it into single value.

Will it be possible for this adapter to support this in similar way?

Edit: Added Reproduction
This endpoint:

export function get() {
  return {
    headers: {
      'set-cookie': [
        'accesstoken=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly;',
        'refreshtoken=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly;'
      ]
    }
  }
}

produces the following headers:

set-cookie: accesstoken=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly, refreshtoken=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly

but it should produce:

set-cookie: accesstoken=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly
set-cookie: refreshtoken=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly

Update to 401+

Hey @yarbsemaj

I recently updated to 401 and made code changes to handle the import { env } from '$env/dynamic/private'; for environment variables. Wondering if you can update the project to accommodate?

Thank you for your help. This is a great project to work with.

Best,

Nick

Build errors

Hi,
Thanks for making this adapter, I'd love to use it.

I have a very simple Sveltekit app that only has endpoints, no assets or anything static.
When I try to build it with your adapter I get the following build error:
`

Using adapter-serverless
Cannot read properties of undefined (reading 'log')
at adapt (/workspace/crm-backend-sveltekit-aws-lambda/node_modules/@yarbsemaj/adapter-lambda/index.js:27:21)
at adapt (file:///workspace/crm-backend-sveltekit-aws-lambda/node_modules/@sveltejs/kit/dist/chunks/index5.js:740:8)
at file:///workspace/crm-backend-sveltekit-aws-lambda/node_modules/@sveltejs/kit/dist/cli.js:994:11`

The app works without problems with 'svelte-kit dev" and using the Cloudflare adapter it also runs without issues on Cloudflare Workers.

You can find the repo here : https://github.com/NagurasDemoApp/crm-backend-sveltekit-aws-lambda

If you open the repo with this link https://gitpod.io/#https://github.com/NagurasDemoApp/crm-backend-sveltekit-aws-lambda you wil get a VSCode instance in the browser and can look at the error by doing a build in the integrated terminal from VSCode.

If you run the app in dev mode you can test if it's working by opening the the file login.http in the folder http-tests.
On the top line you should see "Send Request". By clicking on that line, it will send a request to the app and you will see a return.
Works a bit like Postman by using this extension (which will be available already if you open the repo via Gitpod.

Thanks.

+page and +layout will break the current adapter

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")

Streaming endpoints

I'm getting a 502 (bad gateway) when calling my serverless function (API endpoint) that has a streaming response:

src/routes/api/soap/format.ts

...
export const POST: RequestHandler = async ({ request }) => {
  response = await openai.createChatCompletion({
      model: model,
      messages: [{ role: 'user', content: prompt }],
      stream: true,
    }, { responseType: 'stream' }
  );

  const customReadable = new ReadableStream({
    start(controller) {
      response.data.on('data', (data: Buffer) => {
        // ...etc
      });
    }
  });
  
  return new Response(customReadable, {
    headers: { 'Content-Type': 'text/html; charset=utf-8' },
  });
  ...

This works locally. Any idea what needs to be adjusted on CloudFront or Lambda to allow for streaming output?

Deploy Error: CREATE_FAILED: StaticAssets (AWS::S3::Bucket)

SvelteKit: 1.0.0-next.348
@yarbsemaj/adapter-lambda: 0.9.1

Copied serverless.yml as is from this repo to root directory.
Build was successful however I'm getting Error: CREATE_FAILED: StaticAssets (AWS::S3::Bucket) on deploy.
Tried removing everything (serverless remove) and deploying again but same error.

Here are some logs if it helps:

λ serverless deploy --verbose
Running "serverless" from node_modules

Deploying sveltekit-app to stage dev (us-east-1)

Packaging
Excluding development dependencies for function "svelte"
Excluding development dependencies for function "cfLambda"
Updated Lambda assume role policy to allow Lambda@Edge to assume the role
Added "origin-request" Lambda@Edge association for version "CfLambdaLambdaVersion9d8whyATJFrfutff6mjOifOMyJ8rhrJ2DIVrLuh1i8" to distribution "WebsiteDistribution"
Retrieving CloudFormation stack
Creating CloudFormation stack
Creating new change set
Waiting for new change set to be created
Change Set did not reach desired state, retrying
Executing created change set
  CREATE_IN_PROGRESS - AWS::CloudFormation::Stack - sveltekit-app-dev
  CREATE_IN_PROGRESS - AWS::S3::Bucket - ServerlessDeploymentBucket
  CREATE_IN_PROGRESS - AWS::S3::Bucket - ServerlessDeploymentBucket
  CREATE_COMPLETE - AWS::S3::Bucket - ServerlessDeploymentBucket
  CREATE_IN_PROGRESS - AWS::S3::BucketPolicy - ServerlessDeploymentBucketPolicy
  CREATE_IN_PROGRESS - AWS::S3::BucketPolicy - ServerlessDeploymentBucketPolicy
  CREATE_COMPLETE - AWS::S3::BucketPolicy - ServerlessDeploymentBucketPolicy
  CREATE_COMPLETE - AWS::CloudFormation::Stack - sveltekit-app-dev
Uploading
Uploading CloudFormation file to S3                                                                                                   
Uploading State file to S3                                                                                                            
Uploading service svelte.zip file to S3 (102.52 kB)                                                                                   
Uploading service cfLambda.zip file to S3 (102.52 kB)                                                                                 
Updating CloudFormation stack                                                                                                         
Creating new change set                                                                                                               
Waiting for new change set to be created                                                                                              
Change Set did not reach desired state, retrying                                                                                      
Executing created change set                                                                                                          
  UPDATE_IN_PROGRESS - AWS::CloudFormation::Stack - sveltekit-app-dev                                                                 
  CREATE_IN_PROGRESS - AWS::S3::Bucket - StaticAssets                                                                                 
  CREATE_IN_PROGRESS - AWS::IAM::Role - IamRoleLambdaExecution                                                                        
  CREATE_IN_PROGRESS - AWS::Logs::LogGroup - SvelteLogGroup                                                                           
  CREATE_IN_PROGRESS - AWS::Logs::LogGroup - CfLambdaLogGroup                                                                         
  CREATE_FAILED - AWS::S3::Bucket - StaticAssets                                                                                      
  CREATE_FAILED - AWS::Logs::LogGroup - SvelteLogGroup                                                                                
  CREATE_FAILED - AWS::IAM::Role - IamRoleLambdaExecution                                                                             
  CREATE_FAILED - AWS::Logs::LogGroup - CfLambdaLogGroup                                                                              
  UPDATE_ROLLBACK_IN_PROGRESS - AWS::CloudFormation::Stack - sveltekit-app-dev                                                        
  UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS - AWS::CloudFormation::Stack - sveltekit-app-dev                                       
  DELETE_COMPLETE - AWS::S3::Bucket - StaticAssets                                                                                    
  DELETE_COMPLETE - AWS::Logs::LogGroup - SvelteLogGroup                                                                              
  DELETE_IN_PROGRESS - AWS::IAM::Role - IamRoleLambdaExecution                                                                        
  DELETE_COMPLETE - AWS::Logs::LogGroup - CfLambdaLogGroup                                                                            
  DELETE_COMPLETE - AWS::IAM::Role - IamRoleLambdaExecution                                                                           
  UPDATE_ROLLBACK_COMPLETE - AWS::CloudFormation::Stack - sveltekit-app-dev                                                           
                                                                                                                                      
× Stack sveltekit-app-dev failed to deploy (116s)                                                                                     
Environment: win32, node 16.15.1, framework 3.19.0 (local) 3.19.0v (global), plugin 6.2.2, SDK 4.3.2                                  
Credentials: Local, "default" profile                                                                                                 
Docs:        docs.serverless.com                                                                                                      
Support:     forum.serverless.com                                                                                                     
Bugs:        github.com/serverless/serverless/issues                                                                                  
                                                                                                                                      
Error:                                                                                                                                
CREATE_FAILED: StaticAssets (AWS::S3::Bucket)                                                                                         
dev-sveltekit-app-static-assets already exists                                                                                        
                                                                                                                                      
View the full error: https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stack/detail?stackId=arn%3Aaws%3Acloudformation%3Aus-east-1%3A306836384016%3Astack%2Fsveltekit-app-dev%2F2922b930-f3e3-11ec-8f77-0ecff273accf
                                                                                                                                      
1 deprecation found: run 'serverless doctor' for more details

image

403 -Forbidden, Cross-site POST form submissions are forbidden

I'm attempting to call my Sveltekit endpoint /api/voice/answer_call from Twilio (this is a web hook that responds to Twilio's phone call) and am getting Cross-site POST form submissions are forbidden

How can I allow CORS?

I've added the following to my endpoint:

		headers: {
			'Content-Type': 'text/xml',
			"Access-Control-Allow-Origin": "*", // Allows all domains
			"Access-Control-Allow-Methods": "OPTIONS,POST,GET",
			"Access-Control-Allow-Headers": "Content-Type,Authorization",
			"Access-Control-Allow-Credentials": "true" // Only if your endpoint requires credentials
		},

I've also ensured CloudFront is not stripping these headers. I'm guessing the issue is with Lambda@Edge not forwarding these headers?

Creating variable outside handler function in SSR code

First, this library rocks. Super impressive and I'm excited to get going with it.

To adopt, I will need a server-side cache in the lambda across lambda invocations. This is easy in a lambda. Just define a variable outside your handler function. How would I achieve it?

let html; // this is reused between invocations
const loadHtml = async () => {
  if (!html) {
    // load HTML from somewhere
    // this is only run during cold start and then cached
  }
  return html
}
module.exports.handler = async (event) => {
  return {
    statusCode: 200,
    body: await loadHtml(),
    headers: {
      'content-type': 'text/html; charset=UTF-8'
    }
  }
}

Feature: Option to use standard lambda instead of lambda@edge for router

Hey James,

Thanks for creating this library!

It's my first time using the serverless framework, but your example has helped me to get started and deploy my app via serverless 😎.

One thing I want to try to avoid is to deploy my stack to us-east-1 due to data compliance. However, it doesn't currently seem possible as the router has direct reference to CloudFront, and also enforces the use of custom headers. As you're aware, lambda@edge is only deployable to us-east-1 and as such I'd like to decouple from it, if possible.

I'm thinking of having an option in the adapter, which allows us to toggle the use of the router using lambda@edge, or standard lambda:

// svelte.config.js
import serverless from "@yarbsemaj/adapter-lambda";

/** @type {import('@sveltejs/kit').Config} */
const config = {
    kit: {
        adapter: serverless({
            edgeRouter: false // default true to avoid a breaking change
        })
    }
};

export default config;

I'm happy to start looking into this and attempting to provide a PR if you think it's achievable.

Moving away from Lambda Edge or towards it.

I've been thinking more about improving the costs of the system, and I think it's probably best to remove the lambda edge router.
The edge router is used to tell CloudFront to get the static files from s3.
The problem however is that lambda edge is expensive and will now be triggered for every missed cache hit.
And because SSR pages can't be cached we trigger the lambda edge function for no reason.
Plus we don't gain any speed benefit by using the edge because SSR is still happening on a normal lambda function.

We could just move the lambda edge router functionality to the normal lambda that is doing SSR right now.
The lambda just needs to get the static assets from s3 when necessary and return it with proper caching headers for CloudFront.
If the request isn't for a static asset we just do the normal SSR stuff.

This approach should reduce costs even more.
What do you think?

Issue with superagent-proxy

I'm trying to use this plugin, but get:

error during build:
Error: Build failed with 1 error:
../../node_modules/rest-facade/src/Client.js:38:12: error: Could not resolve "superagent-proxy" (mark it as external to exclude it from the bundle)

Do you know what could cause this?

Seems to work if I add "superagent-proxy": "3.0.0" to dependencies 😅

Minimum IAM permissions required along with Roles/User

I would be great if someone could give Group/User/Roles permissions required so that we can attach them to the User profile used for deployment.
In our organization, we have to submit the requirements to the DevOps team first and there are no IAM permissions mentioned in this adapter which causes confusion and wastes time.

@yarbsemaj, If you have the minimum permissions required then please post them on README.md or add in the repository. I would love to contribute as I had to deploy it as a sample app on my AWS account first and then forward those permissions to our DevOps team. Those permissions are not very clean as at some points I gave full access to resources or actions using *, which is not advised.

No matching export error during build

Hello, first off thanks for your work on this adapter! However, I wanted to bring the following issue to your attention.

Steps to reproduce:

  1. We created a brand new SvelteKit project this morning
  2. Created a basic wrapping layout (for nav/styles) and added a second "about" us route
  3. Followed your setup instructions in your README.md

I've shared the repo publicly if you want to pull and test directly:
https://github.com/Brain-Bones/bb-svelte-example

The issue:
When we npm run build we receive the following errors and are unsure how to proceed.

❯ npm run build

> [email protected] build /Users/chris/Development/prototypes/bb-website/bb-svelte-example
> svelte-kit build

vite v2.8.5 building for production...
✓ 14 modules transformed.
.svelte-kit/output/client/_app/manifest.json                       1.35 KiB
.svelte-kit/output/client/_app/pages/__layout.svelte-240b0057.js   1.57 KiB / gzip: 0.84 KiB
.svelte-kit/output/client/_app/error.svelte-7f250a32.js            1.56 KiB / gzip: 0.75 KiB
.svelte-kit/output/client/_app/pages/index.svelte-d976cce2.js      0.56 KiB / gzip: 0.36 KiB
.svelte-kit/output/client/_app/pages/about.svelte-7594c2ed.js      0.54 KiB / gzip: 0.36 KiB
.svelte-kit/output/client/_app/chunks/vendor-f8218414.js           7.29 KiB / gzip: 3.00 KiB
.svelte-kit/output/client/_app/start-4b5c06b5.js                   23.55 KiB / gzip: 8.03 KiB
vite v2.8.5 building SSR bundle for production...
✓ 12 modules transformed.
.svelte-kit/output/server/manifest.json                      1.03 KiB
.svelte-kit/output/server/index.js                           64.07 KiB
.svelte-kit/output/server/entries/pages/__layout.svelte.js   0.57 KiB
.svelte-kit/output/server/entries/pages/error.svelte.js      0.72 KiB
.svelte-kit/output/server/entries/pages/index.svelte.js      0.25 KiB
.svelte-kit/output/server/entries/pages/about.svelte.js      0.24 KiB
.svelte-kit/output/server/chunks/index-2dc61825.js           2.29 KiB

Run npm run preview to preview your production build locally.

> Using adapter-serverless
 > build/index.js:637:14: warning: This dynamic import will not be bundled because the argument is not a string literal (use "import().catch()" to silence this warning)
    637 │   csp_ready = import(name).then((crypto2) => {
        ╵               ~~~~~~

 > build/server/shims.js:1:35: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Headers"
    1 │ ...t { fetch, Response, Request, Headers } from '@sveltejs/kit/instal...
      ╵                                  ~~~~~~~

 > build/server/shims.js:1:26: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Request"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                           ~~~~~~~

 > build/server/shims.js:1:16: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Response"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                 ~~~~~~~~

 > build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵          ~~~~~

 > build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵          ~~~~~

 > build/server/shims.js:1:16: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Response"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                 ~~~~~~~~

 > build/server/shims.js:1:26: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Request"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                           ~~~~~~~

 > build/server/shims.js:1:35: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Headers"
    1 │ ...t { fetch, Response, Request, Headers } from '@sveltejs/kit/instal...
      ╵                                  ~~~~~~~

 > build/server/shims.js:1:35: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Headers"
    1 │ ...t { fetch, Response, Request, Headers } from '@sveltejs/kit/instal...
      ╵                                  ~~~~~~~

 > build/server/shims.js:1:26: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Request"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                           ~~~~~~~

 > build/server/shims.js:1:16: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Response"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                 ~~~~~~~~

 > build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵          ~~~~~

 > build/server/shims.js:1:35: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Headers"
    1 │ ...t { fetch, Response, Request, Headers } from '@sveltejs/kit/instal...
      ╵                                  ~~~~~~~

 > build/server/shims.js:1:26: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Request"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                           ~~~~~~~

 > build/server/shims.js:1:16: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Response"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                 ~~~~~~~~

 > build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵          ~~~~~

 > build/server/shims.js:1:35: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Headers"
    1 │ ...t { fetch, Response, Request, Headers } from '@sveltejs/kit/instal...
      ╵                                  ~~~~~~~

 > build/server/shims.js:1:26: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Request"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                           ~~~~~~~

 > build/server/shims.js:1:16: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Response"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                 ~~~~~~~~

 > build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵          ~~~~~

 > build/server/shims.js:1:35: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Headers"
    1 │ ...t { fetch, Response, Request, Headers } from '@sveltejs/kit/instal...
      ╵                                  ~~~~~~~

 > build/server/shims.js:1:26: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Request"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                           ~~~~~~~

 > build/server/shims.js:1:16: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Response"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                 ~~~~~~~~

 > build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵          ~~~~~

 > build/server/shims.js:1:35: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Headers"
    1 │ ...t { fetch, Response, Request, Headers } from '@sveltejs/kit/instal...
      ╵                                  ~~~~~~~

 > build/server/shims.js:1:26: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Request"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                           ~~~~~~~

 > build/server/shims.js:1:16: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Response"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                 ~~~~~~~~

 > build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵          ~~~~~

 > build/server/shims.js:1:35: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Headers"
    1 │ ...t { fetch, Response, Request, Headers } from '@sveltejs/kit/instal...
      ╵                                  ~~~~~~~

 > build/server/shims.js:1:26: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Request"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                           ~~~~~~~

 > build/server/shims.js:1:16: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Response"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                 ~~~~~~~~

 > build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵          ~~~~~

 > build/server/shims.js:1:35: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Headers"
    1 │ ...t { fetch, Response, Request, Headers } from '@sveltejs/kit/instal...
      ╵                                  ~~~~~~~

 > build/server/shims.js:1:26: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Request"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                           ~~~~~~~

 > build/server/shims.js:1:16: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Response"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                 ~~~~~~~~

 > build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵          ~~~~~

 > build/server/shims.js:1:35: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Headers"
    1 │ ...t { fetch, Response, Request, Headers } from '@sveltejs/kit/instal...
      ╵                                  ~~~~~~~

 > build/server/shims.js:1:26: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Request"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                           ~~~~~~~

 > build/server/shims.js:1:16: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Response"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                 ~~~~~~~~

 > build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵          ~~~~~

 > build/server/shims.js:1:35: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Headers"
    1 │ ...t { fetch, Response, Request, Headers } from '@sveltejs/kit/instal...
      ╵                                  ~~~~~~~

 > build/server/shims.js:1:26: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Request"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                           ~~~~~~~

 > build/server/shims.js:1:16: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Response"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                 ~~~~~~~~

 > build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵          ~~~~~

 > build/server/shims.js:1:35: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Headers"
    1 │ ...t { fetch, Response, Request, Headers } from '@sveltejs/kit/instal...
      ╵                                  ~~~~~~~

 > build/server/shims.js:1:26: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Request"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                           ~~~~~~~

 > build/server/shims.js:1:16: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Response"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                 ~~~~~~~~

 > build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵          ~~~~~

 > build/server/shims.js:1:35: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Headers"
    1 │ ...t { fetch, Response, Request, Headers } from '@sveltejs/kit/instal...
      ╵                                  ~~~~~~~

 > build/server/shims.js:1:26: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Request"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                           ~~~~~~~

 > build/server/shims.js:1:16: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Response"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                 ~~~~~~~~

 > build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵          ~~~~~

 > build/server/shims.js:1:35: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Headers"
    1 │ ...t { fetch, Response, Request, Headers } from '@sveltejs/kit/instal...
      ╵                                  ~~~~~~~

 > build/server/shims.js:1:26: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Request"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                           ~~~~~~~

 > build/server/shims.js:1:16: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "Response"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵                 ~~~~~~~~

 > build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
    1 │ export { fetch, Response, Request, Headers } from '@sveltejs/kit/inst...
      ╵          ~~~~~

> Build failed with 56 errors:
build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
...
build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
build/server/shims.js:1:9: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "fetch"
...
    at failureErrorWithLog (/Users/chris/Development/prototypes/bb-website/bb-svelte-example/node_modules/esbuild/lib/main.js:1275:15)
    at buildResponseToResult (/Users/chris/Development/prototypes/bb-website/bb-svelte-example/node_modules/esbuild/lib/main.js:964:32)
    at /Users/chris/Development/prototypes/bb-website/bb-svelte-example/node_modules/esbuild/lib/main.js:1057:20
    at /Users/chris/Development/prototypes/bb-website/bb-svelte-example/node_modules/esbuild/lib/main.js:576:9
    at handleIncomingPacket (/Users/chris/Development/prototypes/bb-website/bb-svelte-example/node_modules/esbuild/lib/main.js:665:9)
    at readFromStdout (/Users/chris/Development/prototypes/bb-website/bb-svelte-example/node_modules/esbuild/lib/main.js:543:7)
    at runServiceSync (/Users/chris/Development/prototypes/bb-website/bb-svelte-example/node_modules/esbuild/lib/main.js:1591:3)
    at Object.buildSync (/Users/chris/Development/prototypes/bb-website/bb-svelte-example/node_modules/esbuild/lib/main.js:1407:3)
    at adapt (/Users/chris/Development/prototypes/bb-website/bb-svelte-example/node_modules/@yarbsemaj/adapter-lambda/index.js:51:15)
    at adapt (file:///Users/chris/Development/prototypes/bb-website/bb-svelte-example/node_modules/@sveltejs/kit/dist/chunks/index5.js:890:8)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `svelte-kit build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/chris/.npm/_logs/2022-02-28T19_15_50_865Z-debug.log
❯ code .
❯ 
❯ git pull
Already up to date.

How does SSR function gets triggered?

First of all, neat stuff you created there! 🤩

I am trying to implement it using Pulumi instead of serverless (still quite new to all of it).

I managed to upload prerendered and assets to s3, create a cloudfront distribution and connect it with the edge function. Working so far ✅

Now I wanted to deploy the SSR function (build/server/serverless.handler). I just wonder though, how and when this function gets triggered? I see you create an URL for it (serverless.yml:51), so I assume its called via an http request (?) but this url of course doesn't exist at build time of the svelte app. Your blog entry indicated an api gateway in between, though can't see you defining it in your serverless.yml.

Would you be so kind to point me into the right direction?

Dependencies loaded in serverless.js even when SSR is off for those pages

Hi,

I noticed that in my app, which loads the library html5-qrcode in a CSR-only page, html5-qrcode is included in the bundle.

Steps to reproduce:

  1. npm create svelte@latest my-app
  2. inside my-app.... npm install
  3. npm install html5-qrcode @yarbsemaj/adapter-lambda
  4. add adapter-lambda to svelte.config.js
  5. create src/routes/qrcode/+page.server.ts:
export const ssr = false;
  1. create src/routes/qrcode/page.svelte with a minimum reproducible example of my qrcode page:
<div id="reader" bind:this={reader} />

<script lang="ts">
	import { onMount } from 'svelte';
	import { Html5Qrcode, Html5QrcodeSupportedFormats as Formats } from 'html5-qrcode';
	
	let html5QrCode: Html5Qrcode;
	let scanning = false;
	let reader: HTMLDivElement;

	async function startCamera() {
		if (html5QrCode && !scanning ) {
			console.log('Starting camera');
			try {
				await html5QrCode.start(
					{ facingMode: 'environment' },
					{
						fps: 20
					},
					(data => {
						console.log(data);
					}),
					(errorMessage) => {}
				);
				scanning = true;
			} catch (err) {
				scanning = false;
				console.error(err);
			}
		}
	}

	onMount(() => {

		reader.setAttribute('width', '1000px');
		reader.setAttribute('height', '1000px');

		html5QrCode = new Html5Qrcode('reader', {
			formatsToSupport: [Formats.QR_CODE],
			verbose: true
			// useBarCodeDetectorIfSupported: true,
		});

		startCamera();
	});
</script>
  1. npm run build -> the serverless.js bundle includes html5-qrcode, even though the page shouldn't be rendered on the server.

It seems like html5-qrcode is being included due to this code chunk:

var init_page_svelte2 = __esm({
  "build/entries/pages/qrcode/_page.svelte.js"() {
    "use strict";
    init_shims();
    init_chunks();
    import_html5_qrcode = __toESM(require_cjs(), 1);
    Page2 = create_ssr_component(($$result, $$props, $$bindings, slots) => {
      let reader;
      return `<div id="reader"${add_attribute("this", reader, 0)}></div>`;
    });
  }
});

in which require_cjs is the entry point for html5-qrcode. Any idea why qrcode/_page.svelte.js is being loaded despite ssr being off for that page? It'd be nice to keep the bundle size down by not including libraries that are only loaded on CSR-only pages.

Error: writeStatic has been removed.

Hi @yarbsemaj,

it seems that since vite 3 the build process is throwing the following error:

> Using adapter-serverless
error during build:
Error: writeStatic has been removed. Please ensure you are using the latest version of adapter-serverless

Thx
Stefan

app.js no longer exists?

SvelteKit : 1.0.0-next.281

app.js is no longer output by build.
I believe it is now index.js

App class has also been renamed to Server.

App class render function has been renamed to respond.

Implementing a serverless solution in AWS: Static S3, CloudFront & Lambda

Hi!

I already have an app that is distributed via CloudFront (from a static S3 bucket). I mostly get data from an API Gateway / Lambda + DynamoDB backend and I format the responses with some javascript on the client side.

But it turns out I'll need some extra server-side rendering functionality. I'm looking if I could use your project in my solution. I already have a set up CI/CD environment, so I'm basically asking how can I figure out which files should go into an S3 bucket and if you have any idea how to set up the SSR via Lambda or Lambda@Edge?

Or is there another solution you'd recommend?

Thanks.

Failure to build

Thanks for the adapter. Unfortunately it's not working for me right now. I'm not sure what information to provide as I'm still new to SvelteKit, but I'm running Node v18.13.0 and whenever I run npm run build with this set up as described in the readme, I get the following error:

> Using adapter-serverless
 > node_modules/undici/lib/websocket/connection.js:5:35: error: Could not resolve "diagnostics_channel" (mark it as external to exclude it from the bundle)
    5 │ const diagnosticsChannel = require('diagnostics_channel')
      ╵                                    ~~~~~~~~~~~~~~~~~~~~~

 > node_modules/undici/lib/websocket/receiver.js:4:35: error: Could not resolve "diagnostics_channel" (mark it as external to exclude it from the bundle)
    4 │ const diagnosticsChannel = require('diagnostics_channel')
      ╵                                    ~~~~~~~~~~~~~~~~~~~~~

error during build:
Error: Build failed with 2 errors:
node_modules/undici/lib/websocket/connection.js:5:35: error: Could not resolve "diagnostics_channel" (mark it as external to exclude it from the bundle)
node_modules/undici/lib/websocket/receiver.js:4:35: error: Could not resolve "diagnostics_channel" (mark it as external to exclude it from the bundle)
    at failureErrorWithLog (node_modules/@yarbsemaj/adapter-lambda/node_modules/esbuild/lib/main.js:1275:15)
    at buildResponseToResult (node_modules/@yarbsemaj/adapter-lambda/node_modules/esbuild/lib/main.js:964:32)
    at node_modules/@yarbsemaj/adapter-lambda/node_modules/esbuild/lib/main.js:1057:20
    at node_modules/@yarbsemaj/adapter-lambda/node_modules/esbuild/lib/main.js:576:9
    at handleIncomingPacket (node_modules/@yarbsemaj/adapter-lambda/node_modules/esbuild/lib/main.js:665:9)
    at readFromStdout (node_modules/@yarbsemaj/adapter-lambda/node_modules/esbuild/lib/main.js:543:7)
    at runServiceSync (node_modules/@yarbsemaj/adapter-lambda/node_modules/esbuild/lib/main.js:1591:3)
    at Object.buildSync (node_modules/@yarbsemaj/adapter-lambda/node_modules/esbuild/lib/main.js:1407:3)
    at adapt (node_modules/@yarbsemaj/adapter-lambda/index.js:49:15)
    at adapt (node_modules/@sveltejs/kit/src/core/adapt/index.js:28:8)

I'm happy to help fix this in any way I can

Building fails.

When building I get the following error.

build/server/_serverless.js:2:21: error: Could not resolve "../index.js"

node_modules not included in the function code uploads

Hiya,

When uploading with serverless deploy (and/or with serverless deploy function --function svelte && serverless deploy function --function cfLambda && serverless s3deploy), it seems that it doesn't include node_modules in the uploaded content. This leads to all of my imported modules failing to load.

Example: (this is my database utilities package)
image

Is there something I can do during the build step to get node_modules included in the build output? Does esbuild support some sort of tree shaking where it includes only the dependencies that are needed?

no such file or directory, scandir 'build/prerendered'

Hi, thank you for this solution.

i was running into a problem were build process displays an error.

ENOENT: no such file or directory, scandir 'build/prerendered'

it came from @yarbsemaj/adapter-lambda/index.js
const prerendered_directory = join(out, 'prerendered');

The solution was to add export const prerender = true; to one of my pages. For example index.svelte
https://kit.svelte.dev/docs/page-options#prerender. The prerender folder is missing if i don`t do that. This is why the build fails.

Is it possible to make this voluntarily in a future Version of this adapter?

Many Thanks and happy coding
Cheers Peter

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.