sst 2.0.0-rc.61 → 2.0.0-rc.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import * as lambda from "aws-cdk-lib/aws-lambda";
1
+ import { Function as CdkFunction } from "aws-cdk-lib/aws-lambda";
2
2
  import { SsrSite } from "./SsrSite.js";
3
3
  import { EdgeFunction } from "./EdgeFunction.js";
4
4
  /**
@@ -19,6 +19,6 @@ export declare class AstroSite extends SsrSite {
19
19
  clientBuildVersionedSubDir: string;
20
20
  };
21
21
  protected validateBuildOutput(): void;
22
- protected createFunctionForRegional(): lambda.Function;
22
+ protected createFunctionForRegional(): CdkFunction;
23
23
  protected createFunctionForEdge(): EdgeFunction;
24
24
  }
@@ -1,7 +1,8 @@
1
1
  import fs from "fs";
2
2
  import url from "url";
3
3
  import path from "path";
4
- import * as esbuild from "esbuild";
4
+ import { buildSync } from "esbuild";
5
+ import { Architecture } from "aws-cdk-lib/aws-lambda";
5
6
  import { SsrSite } from "./SsrSite.js";
6
7
  import { Function } from "./Function.js";
7
8
  import { useProject } from "../project.js";
@@ -50,6 +51,7 @@ export class AstroSite extends SsrSite {
50
51
  },
51
52
  environment,
52
53
  ...cdk?.server,
54
+ architecture: cdk?.server?.architecture === Architecture.ARM_64 ? "arm_64" : "x86_64",
53
55
  });
54
56
  fn._disableBind = true;
55
57
  return fn;
@@ -59,7 +61,7 @@ export class AstroSite extends SsrSite {
59
61
  // Create a directory that we will use to create the bundled version
60
62
  // of the "core server build" along with our custom Lamba server handler.
61
63
  const outputPath = path.resolve(path.join(useProject().paths.artifacts, `AstroSiteFunction-${this.node.id}-${this.node.addr}`));
62
- const result = esbuild.buildSync({
64
+ const result = buildSync({
63
65
  entryPoints: [
64
66
  path.join(this.props.path, this.buildConfig.serverBuildOutputFile),
65
67
  ],
@@ -37,7 +37,7 @@ export class NextjsSite extends SsrSite {
37
37
  };
38
38
  }
39
39
  createFunctionForRegional() {
40
- const { timeout, memorySize, permissions, environment } = this.props;
40
+ const { timeout, memorySize, permissions, environment, cdk } = this.props;
41
41
  const ssrFn = new SsrFunction(this, `ServerFunction`, {
42
42
  description: "Server handler for Next.js",
43
43
  bundlePath: path.join(this.props.path, ".open-next", "server-function"),
@@ -46,11 +46,12 @@ export class NextjsSite extends SsrSite {
46
46
  memorySize,
47
47
  permissions,
48
48
  environment,
49
+ ...cdk?.server,
49
50
  });
50
51
  return ssrFn.function;
51
52
  }
52
53
  createImageOptimizationFunctionForRegional() {
53
- const { imageOptimization, path: sitePath, cdk } = this.props;
54
+ const { imageOptimization, path: sitePath } = this.props;
54
55
  return new lambda.Function(this, `ImageFunction`, {
55
56
  description: "Image optimization handler for Next.js",
56
57
  handler: "index.handler",
@@ -64,12 +65,12 @@ export class NextjsSite extends SsrSite {
64
65
  ? typeof imageOptimization.memorySize === "string"
65
66
  ? toCdkSize(imageOptimization.memorySize).toMebibytes()
66
67
  : imageOptimization.memorySize
67
- : 512,
68
+ : 1536,
68
69
  timeout: CdkDuration.seconds(25),
70
+ architecture: lambda.Architecture.ARM_64,
69
71
  environment: {
70
72
  BUCKET_NAME: this.cdk.bucket.bucketName,
71
73
  },
72
- ...cdk?.server,
73
74
  });
74
75
  }
75
76
  createMiddlewareEdgeFunctionForRegional() {
@@ -89,7 +90,7 @@ export class NextjsSite extends SsrSite {
89
90
  bundlePath,
90
91
  handler,
91
92
  timeout: 10,
92
- memorySize: 512,
93
+ memorySize: 128,
93
94
  permissions,
94
95
  environment,
95
96
  format: "esm",
@@ -1,4 +1,4 @@
1
- import * as lambda from "aws-cdk-lib/aws-lambda";
1
+ import { Function as CdkFunction } from "aws-cdk-lib/aws-lambda";
2
2
  import { SsrSite } from "./SsrSite.js";
3
3
  import { EdgeFunction } from "./EdgeFunction.js";
4
4
  /**
@@ -18,6 +18,6 @@ export declare class SolidStartSite extends SsrSite {
18
18
  clientBuildOutputDir: string;
19
19
  clientBuildVersionedSubDir: string;
20
20
  };
21
- protected createFunctionForRegional(): lambda.Function;
21
+ protected createFunctionForRegional(): CdkFunction;
22
22
  protected createFunctionForEdge(): EdgeFunction;
23
23
  }
@@ -1,12 +1,11 @@
1
1
  import fs from "fs";
2
- import url from "url";
3
2
  import path from "path";
4
- import * as esbuild from "esbuild";
3
+ import { buildSync } from "esbuild";
4
+ import { Architecture } from "aws-cdk-lib/aws-lambda";
5
5
  import { SsrSite } from "./SsrSite.js";
6
6
  import { Function } from "./Function.js";
7
7
  import { useProject } from "../project.js";
8
8
  import { EdgeFunction } from "./EdgeFunction.js";
9
- const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
10
9
  /**
11
10
  * The `SolidStartSite` construct is a higher level CDK construct that makes it easy to create a SolidStart app.
12
11
  * @example
@@ -43,6 +42,7 @@ export class SolidStartSite extends SsrSite {
43
42
  },
44
43
  environment,
45
44
  ...cdk?.server,
45
+ architecture: cdk?.server?.architecture === Architecture.ARM_64 ? "arm_64" : "x86_64",
46
46
  });
47
47
  fn._disableBind = true;
48
48
  return fn;
@@ -53,7 +53,7 @@ export class SolidStartSite extends SsrSite {
53
53
  // of the "core server build" along with our custom Lamba server handler.
54
54
  const outputPath = path.resolve(path.join(useProject().paths.artifacts, `SolidStartSiteFunction-${this.node.id}-${this.node.addr}`));
55
55
  // Bundle code
56
- const result = esbuild.buildSync({
56
+ const result = buildSync({
57
57
  entryPoints: [
58
58
  path.join(this.props.path, this.buildConfig.serverBuildOutputFile),
59
59
  ],
@@ -3,14 +3,13 @@ import * as lambda from "aws-cdk-lib/aws-lambda";
3
3
  import { Permissions } from "./util/permission.js";
4
4
  import { Size } from "./util/size.js";
5
5
  import { Duration } from "./util/duration.js";
6
- export interface SsrFunctionProps {
7
- description?: string;
6
+ import { FunctionOptions } from "aws-cdk-lib/aws-lambda";
7
+ export interface SsrFunctionProps extends Omit<FunctionOptions, "memorySize" | "timeout" | "runtime"> {
8
8
  bundlePath: string;
9
9
  handler: string;
10
10
  timeout: number | Duration;
11
11
  memorySize: number | Size;
12
12
  permissions?: Permissions;
13
- environment?: Record<string, string>;
14
13
  }
15
14
  export declare class SsrFunction extends Construct {
16
15
  function: lambda.Function;
@@ -30,7 +30,7 @@ export class SsrFunction extends Construct {
30
30
  attachPermissionsToRole(this.function.role, permissions);
31
31
  }
32
32
  createFunction() {
33
- const { timeout, memorySize, handler, bundlePath, environment } = this.props;
33
+ const { timeout, memorySize, handler, bundlePath } = this.props;
34
34
  // Note: cannot point the bundlePath to the `.open-next/server-function`
35
35
  // b/c the folder contains node_modules. And pnpm node_modules
36
36
  // contains symlinks. CDK cannot zip symlinks correctly.
@@ -53,18 +53,18 @@ export class SsrFunction extends Construct {
53
53
  // Deploy after the code is updated
54
54
  const replacer = this.createLambdaCodeReplacer(asset);
55
55
  const fn = new lambda.Function(this, `ServerFunction`, {
56
- description: this.props.description,
56
+ ...this.props,
57
57
  handler,
58
58
  logRetention: logs.RetentionDays.THREE_DAYS,
59
59
  code: lambda.Code.fromBucket(asset.bucket, asset.s3ObjectKey),
60
60
  runtime: lambda.Runtime.NODEJS_18_X,
61
+ architecture: lambda.Architecture.ARM_64,
61
62
  memorySize: typeof memorySize === "string"
62
63
  ? toCdkSize(memorySize).toMebibytes()
63
64
  : memorySize,
64
65
  timeout: typeof timeout === "string"
65
66
  ? toCdkDuration(timeout)
66
67
  : CdkDuration.seconds(timeout),
67
- environment,
68
68
  });
69
69
  fn.node.addDependency(replacer);
70
70
  return fn;
@@ -159,7 +159,7 @@ export interface SsrSiteProps {
159
159
  */
160
160
  serverRequests?: ICachePolicy;
161
161
  };
162
- server?: Pick<FunctionProps, "vpc" | "vpcSubnets" | "securityGroups" | "allowAllOutbound" | "allowPublicSubnet">;
162
+ server?: Pick<FunctionProps, "vpc" | "vpcSubnets" | "securityGroups" | "allowAllOutbound" | "allowPublicSubnet" | "architecture">;
163
163
  };
164
164
  }
165
165
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sst",
3
- "version": "2.0.0-rc.61",
3
+ "version": "2.0.0-rc.63",
4
4
  "bin": {
5
5
  "sst": "cli/sst.js"
6
6
  },