sst 2.33.4 → 2.34.1
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.
- package/constructs/AstroSite.d.ts +3 -31
- package/constructs/AstroSite.js +5 -18
- package/constructs/NextjsSite.d.ts +24 -2
- package/constructs/NextjsSite.js +24 -1
- package/constructs/RemixSite.d.ts +12 -1
- package/constructs/RemixSite.js +1 -0
- package/constructs/SolidStartSite.d.ts +12 -1
- package/constructs/SolidStartSite.js +1 -0
- package/constructs/SsrSite.d.ts +3 -5
- package/constructs/SsrSite.js +10 -13
- package/constructs/SvelteKitSite.d.ts +14 -2
- package/constructs/SvelteKitSite.js +7 -1
- package/package.json +2 -2
|
@@ -1,34 +1,6 @@
|
|
|
1
1
|
import { SsrSite, SsrSiteNormalizedProps, SsrSiteProps } from "./SsrSite.js";
|
|
2
2
|
import { AllowedMethods } from "aws-cdk-lib/aws-cloudfront";
|
|
3
3
|
import { Construct } from "constructs";
|
|
4
|
-
export interface AstroSiteProps extends SsrSiteProps {
|
|
5
|
-
regional?: SsrSiteProps["regional"] & {
|
|
6
|
-
/**
|
|
7
|
-
* List all routes that will be handling non-GET requests. For example, routes like form submissions, logins, and API endpoints.
|
|
8
|
-
*
|
|
9
|
-
* Route patterns are case sensitive. And the following wildcard characters can be used:
|
|
10
|
-
* - "*" matches 0 or more characters.
|
|
11
|
-
* - "?" matches exactly 1 character.
|
|
12
|
-
*
|
|
13
|
-
* Matched routes will be handled directly by the server function.
|
|
14
|
-
* @deprecated Define `serverRoutes` in `astro.config.mjs` instead.
|
|
15
|
-
* @default true
|
|
16
|
-
* @example
|
|
17
|
-
* ```js
|
|
18
|
-
* regional: {
|
|
19
|
-
* serverRoutes: [
|
|
20
|
-
* "feedback", // Feedback page which requires POST method
|
|
21
|
-
* "login", // Login page which requires POST method
|
|
22
|
-
* "user/*", // Directory of user routes which are all SSR
|
|
23
|
-
* "api/*" // Directory of API endpoints which require all methods
|
|
24
|
-
* ]
|
|
25
|
-
* }
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
serverRoutes?: string[];
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
type AstroSiteNormalizedProps = AstroSiteProps & SsrSiteNormalizedProps;
|
|
32
4
|
/**
|
|
33
5
|
* The `AstroSite` construct is a higher level CDK construct that makes it easy to create a Astro app.
|
|
34
6
|
* @example
|
|
@@ -41,8 +13,8 @@ type AstroSiteNormalizedProps = AstroSiteProps & SsrSiteNormalizedProps;
|
|
|
41
13
|
* ```
|
|
42
14
|
*/
|
|
43
15
|
export declare class AstroSite extends SsrSite {
|
|
44
|
-
props:
|
|
45
|
-
constructor(scope: Construct, id: string, props?:
|
|
16
|
+
props: SsrSiteNormalizedProps;
|
|
17
|
+
constructor(scope: Construct, id: string, props?: SsrSiteProps);
|
|
46
18
|
private static getBuildMeta;
|
|
47
19
|
private static getCFRoutingFunction;
|
|
48
20
|
protected plan(): {
|
|
@@ -77,6 +49,7 @@ export declare class AstroSite extends SsrSite {
|
|
|
77
49
|
fallbackOriginName: string;
|
|
78
50
|
fallbackStatusCodes?: number[] | undefined;
|
|
79
51
|
}>;
|
|
52
|
+
edge: boolean;
|
|
80
53
|
behaviors: {
|
|
81
54
|
cacheType: "server" | "static";
|
|
82
55
|
pattern?: string | undefined;
|
|
@@ -107,4 +80,3 @@ export declare class AstroSite extends SsrSite {
|
|
|
107
80
|
type: "AstroSite";
|
|
108
81
|
};
|
|
109
82
|
}
|
|
110
|
-
export {};
|
package/constructs/AstroSite.js
CHANGED
|
@@ -19,9 +19,6 @@ export class AstroSite extends SsrSite {
|
|
|
19
19
|
super(scope, id, {
|
|
20
20
|
...props,
|
|
21
21
|
typesPath: props?.typesPath ?? "src",
|
|
22
|
-
regional: {
|
|
23
|
-
...props?.regional,
|
|
24
|
-
},
|
|
25
22
|
});
|
|
26
23
|
}
|
|
27
24
|
static getBuildMeta(filePath) {
|
|
@@ -65,20 +62,22 @@ export class AstroSite extends SsrSite {
|
|
|
65
62
|
// End AstroSite CF Routing Function`;
|
|
66
63
|
}
|
|
67
64
|
plan() {
|
|
68
|
-
const { path: sitePath
|
|
65
|
+
const { path: sitePath } = this.props;
|
|
69
66
|
const buildMeta = AstroSite.getBuildMeta(join(sitePath, "dist", BUILD_META_FILE_NAME));
|
|
70
67
|
const isStatic = buildMeta.outputMode === "static";
|
|
68
|
+
const edge = buildMeta.deploymentStrategy === "edge";
|
|
71
69
|
const serverConfig = {
|
|
72
70
|
description: "Server handler for Astro",
|
|
73
71
|
handler: join(sitePath, "dist", "server", "entry.handler"),
|
|
74
72
|
};
|
|
75
73
|
const plan = {
|
|
74
|
+
edge,
|
|
76
75
|
cloudFrontFunctions: {
|
|
77
76
|
serverCfFunction: {
|
|
78
77
|
constructId: "CloudFrontFunction",
|
|
79
78
|
injections: [
|
|
80
79
|
this.useCloudFrontFunctionHostHeaderInjection(),
|
|
81
|
-
|
|
80
|
+
AstroSite.getCFRoutingFunction(buildMeta),
|
|
82
81
|
],
|
|
83
82
|
},
|
|
84
83
|
},
|
|
@@ -120,18 +119,6 @@ export class AstroSite extends SsrSite {
|
|
|
120
119
|
: item,
|
|
121
120
|
origin: "staticsServer",
|
|
122
121
|
})));
|
|
123
|
-
plan.behaviors.push({
|
|
124
|
-
cacheType: "server",
|
|
125
|
-
cfFunction: "serverCfFunction",
|
|
126
|
-
edgeFunction: "edgeServer",
|
|
127
|
-
origin: "staticsServer",
|
|
128
|
-
}, ...readdirSync(join(sitePath, buildMeta.clientBuildOutputDir)).map((item) => ({
|
|
129
|
-
cacheType: "static",
|
|
130
|
-
pattern: statSync(join(sitePath, buildMeta.clientBuildOutputDir, item)).isDirectory()
|
|
131
|
-
? `${item}/*`
|
|
132
|
-
: item,
|
|
133
|
-
origin: "staticsServer",
|
|
134
|
-
})));
|
|
135
122
|
}
|
|
136
123
|
else {
|
|
137
124
|
if (isStatic) {
|
|
@@ -163,7 +150,7 @@ export class AstroSite extends SsrSite {
|
|
|
163
150
|
cacheType: "static",
|
|
164
151
|
pattern: `${buildMeta.clientBuildVersionedSubDir}/*`,
|
|
165
152
|
origin: "staticsServer",
|
|
166
|
-
}, ...
|
|
153
|
+
}, ...buildMeta.serverRoutes?.map((route) => ({
|
|
167
154
|
cacheType: "server",
|
|
168
155
|
pattern: route,
|
|
169
156
|
origin: "regionalServer",
|
|
@@ -28,6 +28,11 @@ export interface NextjsSiteProps extends Omit<SsrSiteProps, "nodejs"> {
|
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
30
|
logging?: "combined" | "per-route";
|
|
31
|
+
/**
|
|
32
|
+
* The server function is deployed to Lambda in a single region. Alternatively, you can enable this option to deploy to Lambda@Edge.
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
edge?: boolean;
|
|
31
36
|
imageOptimization?: {
|
|
32
37
|
/**
|
|
33
38
|
* The amount of memory in MB allocated for image optimization function.
|
|
@@ -128,6 +133,7 @@ export declare class NextjsSite extends SsrSite {
|
|
|
128
133
|
private appPathRoutesManifest?;
|
|
129
134
|
private appPathsManifest?;
|
|
130
135
|
private pagesManifest?;
|
|
136
|
+
private prerenderManifest?;
|
|
131
137
|
constructor(scope: Construct, id: string, props?: NextjsSiteProps);
|
|
132
138
|
static buildDefaultServerCachePolicyProps(): CachePolicyProps;
|
|
133
139
|
protected plan(bucket: Bucket): {
|
|
@@ -143,7 +149,14 @@ export declare class NextjsSite extends SsrSite {
|
|
|
143
149
|
function: {
|
|
144
150
|
layers: import("aws-cdk-lib/aws-lambda").ILayerVersion[] | undefined;
|
|
145
151
|
handler: string;
|
|
146
|
-
bundle?: string | undefined;
|
|
152
|
+
bundle?: string | undefined; /**
|
|
153
|
+
* OpenNext version for building the Next.js site.
|
|
154
|
+
* @default Latest OpenNext version
|
|
155
|
+
* @example
|
|
156
|
+
* ```js
|
|
157
|
+
* openNextVersion: "2.2.4",
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
147
160
|
runtime?: "nodejs14.x" | "nodejs16.x" | "nodejs18.x" | undefined;
|
|
148
161
|
timeout?: number | `${number} second` | `${number} seconds` | `${number} minute` | `${number} minutes` | `${number} hour` | `${number} hours` | `${number} day` | `${number} days` | undefined;
|
|
149
162
|
memorySize?: number | `${number} MB` | `${number} GB` | undefined;
|
|
@@ -240,7 +253,14 @@ export declare class NextjsSite extends SsrSite {
|
|
|
240
253
|
function: {
|
|
241
254
|
layers: import("aws-cdk-lib/aws-lambda").ILayerVersion[] | undefined;
|
|
242
255
|
handler: string;
|
|
243
|
-
bundle?: string | undefined;
|
|
256
|
+
bundle?: string | undefined; /**
|
|
257
|
+
* OpenNext version for building the Next.js site.
|
|
258
|
+
* @default Latest OpenNext version
|
|
259
|
+
* @example
|
|
260
|
+
* ```js
|
|
261
|
+
* openNextVersion: "2.2.4",
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
244
264
|
runtime?: "nodejs14.x" | "nodejs16.x" | "nodejs18.x" | undefined;
|
|
245
265
|
timeout?: number | `${number} second` | `${number} seconds` | `${number} minute` | `${number} minutes` | `${number} hour` | `${number} hours` | `${number} day` | `${number} days` | undefined;
|
|
246
266
|
memorySize?: number | `${number} MB` | `${number} GB` | undefined;
|
|
@@ -300,6 +320,7 @@ export declare class NextjsSite extends SsrSite {
|
|
|
300
320
|
streaming: boolean | undefined;
|
|
301
321
|
} | undefined;
|
|
302
322
|
};
|
|
323
|
+
edge: boolean;
|
|
303
324
|
behaviors: {
|
|
304
325
|
cacheType: "server" | "static";
|
|
305
326
|
pattern?: string | undefined;
|
|
@@ -345,6 +366,7 @@ export declare class NextjsSite extends SsrSite {
|
|
|
345
366
|
private useAppPathRoutesManifest;
|
|
346
367
|
private useAppPathsManifest;
|
|
347
368
|
private usePagesManifest;
|
|
369
|
+
private usePrerenderManifest;
|
|
348
370
|
private getBuildId;
|
|
349
371
|
private getSourcemapForAppRoute;
|
|
350
372
|
private getSourcemapForPagesRoute;
|
package/constructs/NextjsSite.js
CHANGED
|
@@ -18,8 +18,9 @@ import { VisibleError } from "../error.js";
|
|
|
18
18
|
import { Asset } from "aws-cdk-lib/aws-s3-assets";
|
|
19
19
|
import { useFunctions } from "./Function.js";
|
|
20
20
|
import { useDeferredTasks } from "./deferred_task.js";
|
|
21
|
+
import { Logger } from "../logger.js";
|
|
21
22
|
const LAYER_VERSION = "2";
|
|
22
|
-
const DEFAULT_OPEN_NEXT_VERSION = "2.
|
|
23
|
+
const DEFAULT_OPEN_NEXT_VERSION = "2.3.0";
|
|
23
24
|
const DEFAULT_CACHE_POLICY_ALLOWED_HEADERS = [
|
|
24
25
|
"accept",
|
|
25
26
|
"rsc",
|
|
@@ -44,6 +45,7 @@ export class NextjsSite extends SsrSite {
|
|
|
44
45
|
appPathRoutesManifest;
|
|
45
46
|
appPathsManifest;
|
|
46
47
|
pagesManifest;
|
|
48
|
+
prerenderManifest;
|
|
47
49
|
constructor(scope, id, props) {
|
|
48
50
|
const streaming = props?.experimental?.streaming ?? false;
|
|
49
51
|
const disableDynamoDBCache = props?.experimental?.disableDynamoDBCache ?? false;
|
|
@@ -92,6 +94,7 @@ export class NextjsSite extends SsrSite {
|
|
|
92
94
|
});
|
|
93
95
|
this.removeSourcemaps();
|
|
94
96
|
return this.validatePlan({
|
|
97
|
+
edge: edge ?? false,
|
|
95
98
|
cloudFrontFunctions: {
|
|
96
99
|
serverCfFunction: {
|
|
97
100
|
constructId: "CloudFrontFunction",
|
|
@@ -264,12 +267,17 @@ export class NextjsSite extends SsrSite {
|
|
|
264
267
|
table.grantReadWriteData(server.role);
|
|
265
268
|
const dynamodbProviderPath = path.join(sitePath, ".open-next", "dynamodb-provider");
|
|
266
269
|
if (fs.existsSync(dynamodbProviderPath)) {
|
|
270
|
+
// Provision 128MB of memory for every 4,000 prerendered routes,
|
|
271
|
+
// 1GB per 40,000, up to 10GB. This tends to use ~70% of the memory
|
|
272
|
+
// provisioned when testing.
|
|
273
|
+
const prerenderedRouteCount = Object.keys(this.usePrerenderManifest()?.routes ?? {}).length;
|
|
267
274
|
const insertFn = new CdkFunction(this, "RevalidationInsertFunction", {
|
|
268
275
|
description: "Next.js revalidation data insert",
|
|
269
276
|
handler: "index.handler",
|
|
270
277
|
code: Code.fromAsset(dynamodbProviderPath),
|
|
271
278
|
runtime: Runtime.NODEJS_18_X,
|
|
272
279
|
timeout: CdkDuration.minutes(15),
|
|
280
|
+
memorySize: Math.min(10240, Math.max(128, Math.ceil(prerenderedRouteCount / 4000) * 128)),
|
|
273
281
|
initialPolicy: [
|
|
274
282
|
new PolicyStatement({
|
|
275
283
|
actions: [
|
|
@@ -473,6 +481,21 @@ export class NextjsSite extends SsrSite {
|
|
|
473
481
|
return {};
|
|
474
482
|
}
|
|
475
483
|
}
|
|
484
|
+
usePrerenderManifest() {
|
|
485
|
+
if (this.prerenderManifest)
|
|
486
|
+
return this.prerenderManifest;
|
|
487
|
+
const { path: sitePath } = this.props;
|
|
488
|
+
try {
|
|
489
|
+
const content = fs
|
|
490
|
+
.readFileSync(path.join(sitePath, ".next/prerender-manifest.json"))
|
|
491
|
+
.toString();
|
|
492
|
+
this.prerenderManifest = JSON.parse(content);
|
|
493
|
+
return this.prerenderManifest;
|
|
494
|
+
}
|
|
495
|
+
catch (e) {
|
|
496
|
+
Logger.debug("Failed to load prerender-manifest.json", e);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
476
499
|
getBuildId() {
|
|
477
500
|
const { path: sitePath } = this.props;
|
|
478
501
|
return fs.readFileSync(path.join(sitePath, ".next/BUILD_ID")).toString();
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import { SsrSite } from "./SsrSite.js";
|
|
1
|
+
import { SsrSite, SsrSiteNormalizedProps, SsrSiteProps } from "./SsrSite.js";
|
|
2
|
+
export interface RemixSiteProps extends SsrSiteProps {
|
|
3
|
+
/**
|
|
4
|
+
* The server function is deployed to Lambda in a single region. Alternatively, you can enable this option to deploy to Lambda@Edge.
|
|
5
|
+
* @default false
|
|
6
|
+
*/
|
|
7
|
+
edge?: boolean;
|
|
8
|
+
}
|
|
9
|
+
type RemixSiteNormalizedProps = RemixSiteProps & SsrSiteNormalizedProps;
|
|
2
10
|
/**
|
|
3
11
|
* The `RemixSite` construct is a higher level CDK construct that makes it easy to create a Remix app.
|
|
4
12
|
*
|
|
@@ -13,6 +21,7 @@ import { SsrSite } from "./SsrSite.js";
|
|
|
13
21
|
* ```
|
|
14
22
|
*/
|
|
15
23
|
export declare class RemixSite extends SsrSite {
|
|
24
|
+
props: RemixSiteNormalizedProps;
|
|
16
25
|
protected plan(): {
|
|
17
26
|
cloudFrontFunctions?: {
|
|
18
27
|
serverCfFunction: {
|
|
@@ -65,6 +74,7 @@ export declare class RemixSite extends SsrSite {
|
|
|
65
74
|
};
|
|
66
75
|
} | undefined;
|
|
67
76
|
};
|
|
77
|
+
edge: boolean;
|
|
68
78
|
behaviors: {
|
|
69
79
|
cacheType: "server" | "static";
|
|
70
80
|
pattern?: string | undefined;
|
|
@@ -97,3 +107,4 @@ export declare class RemixSite extends SsrSite {
|
|
|
97
107
|
type: "RemixSite";
|
|
98
108
|
};
|
|
99
109
|
}
|
|
110
|
+
export {};
|
package/constructs/RemixSite.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import { SsrSite } from "./SsrSite.js";
|
|
1
|
+
import { SsrSite, SsrSiteNormalizedProps, SsrSiteProps } from "./SsrSite.js";
|
|
2
|
+
export interface SolidStartSiteProps extends SsrSiteProps {
|
|
3
|
+
/**
|
|
4
|
+
* The server function is deployed to Lambda in a single region. Alternatively, you can enable this option to deploy to Lambda@Edge.
|
|
5
|
+
* @default false
|
|
6
|
+
*/
|
|
7
|
+
edge?: boolean;
|
|
8
|
+
}
|
|
9
|
+
type SolidStartSiteNormalizedProps = SolidStartSiteProps & SsrSiteNormalizedProps;
|
|
2
10
|
/**
|
|
3
11
|
* The `SolidStartSite` construct is a higher level CDK construct that makes it easy to create a SolidStart app.
|
|
4
12
|
* @example
|
|
@@ -11,6 +19,7 @@ import { SsrSite } from "./SsrSite.js";
|
|
|
11
19
|
* ```
|
|
12
20
|
*/
|
|
13
21
|
export declare class SolidStartSite extends SsrSite {
|
|
22
|
+
props: SolidStartSiteNormalizedProps;
|
|
14
23
|
protected plan(): {
|
|
15
24
|
cloudFrontFunctions?: {
|
|
16
25
|
serverCfFunction: {
|
|
@@ -47,6 +56,7 @@ export declare class SolidStartSite extends SsrSite {
|
|
|
47
56
|
};
|
|
48
57
|
} | undefined;
|
|
49
58
|
};
|
|
59
|
+
edge: boolean;
|
|
50
60
|
behaviors: {
|
|
51
61
|
cacheType: "server" | "static";
|
|
52
62
|
pattern?: string | undefined;
|
|
@@ -77,3 +87,4 @@ export declare class SolidStartSite extends SsrSite {
|
|
|
77
87
|
type: "SolidStartSite";
|
|
78
88
|
};
|
|
79
89
|
}
|
|
90
|
+
export {};
|
package/constructs/SsrSite.d.ts
CHANGED
|
@@ -111,11 +111,6 @@ export interface SsrSiteProps {
|
|
|
111
111
|
* ```
|
|
112
112
|
*/
|
|
113
113
|
customDomain?: string | SsrDomainProps;
|
|
114
|
-
/**
|
|
115
|
-
* The SSR function is deployed to Lambda in a single region. Alternatively, you can enable this option to deploy to Lambda@Edge.
|
|
116
|
-
* @default false
|
|
117
|
-
*/
|
|
118
|
-
edge?: boolean;
|
|
119
114
|
/**
|
|
120
115
|
* The execution timeout in seconds for SSR function.
|
|
121
116
|
* @default 10 seconds
|
|
@@ -406,6 +401,7 @@ export declare abstract class SsrSite extends Construct implements SSTConstruct
|
|
|
406
401
|
protected bucket: Bucket;
|
|
407
402
|
protected serverFunction?: EdgeFunction | SsrFunction;
|
|
408
403
|
private serverFunctionForDev?;
|
|
404
|
+
private edge?;
|
|
409
405
|
private distribution;
|
|
410
406
|
constructor(scope: Construct, id: string, rawProps?: SsrSiteProps);
|
|
411
407
|
protected static buildDefaultServerCachePolicyProps(allowedHeaders: string[]): CachePolicyProps;
|
|
@@ -460,6 +456,7 @@ export declare abstract class SsrSite extends Construct implements SSTConstruct
|
|
|
460
456
|
cloudFrontFunctions?: CloudFrontFunctions;
|
|
461
457
|
edgeFunctions?: EdgeFunctions;
|
|
462
458
|
origins: Origins;
|
|
459
|
+
edge: boolean;
|
|
463
460
|
behaviors: {
|
|
464
461
|
cacheType: "server" | "static";
|
|
465
462
|
pattern?: string;
|
|
@@ -479,6 +476,7 @@ export declare abstract class SsrSite extends Construct implements SSTConstruct
|
|
|
479
476
|
cloudFrontFunctions?: CloudFrontFunctions | undefined;
|
|
480
477
|
edgeFunctions?: EdgeFunctions | undefined;
|
|
481
478
|
origins: Origins;
|
|
479
|
+
edge: boolean;
|
|
482
480
|
behaviors: {
|
|
483
481
|
cacheType: "server" | "static";
|
|
484
482
|
pattern?: string;
|
package/constructs/SsrSite.js
CHANGED
|
@@ -49,6 +49,7 @@ export class SsrSite extends Construct {
|
|
|
49
49
|
bucket;
|
|
50
50
|
serverFunction;
|
|
51
51
|
serverFunctionForDev;
|
|
52
|
+
edge;
|
|
52
53
|
distribution;
|
|
53
54
|
constructor(scope, id, rawProps) {
|
|
54
55
|
super(scope, rawProps?.cdk?.id || id);
|
|
@@ -70,10 +71,9 @@ export class SsrSite extends Construct {
|
|
|
70
71
|
const app = scope.node.root;
|
|
71
72
|
const stack = Stack.of(this);
|
|
72
73
|
const self = this;
|
|
73
|
-
const { path: sitePath, typesPath, buildCommand, runtime, timeout, memorySize,
|
|
74
|
+
const { path: sitePath, typesPath, buildCommand, runtime, timeout, memorySize, regional, dev, assets, nodejs, permissions, environment, bind, customDomain, invalidation, warm, cdk, } = props;
|
|
74
75
|
this.doNotDeploy = !stack.isActive || (app.mode === "dev" && !dev?.deploy);
|
|
75
76
|
validateSiteExists();
|
|
76
|
-
validateTimeout();
|
|
77
77
|
validateDeprecatedFileOptions();
|
|
78
78
|
writeTypesFile(typesPath);
|
|
79
79
|
useSites().add(stack.stackName, id, this.constructor.name, props);
|
|
@@ -94,6 +94,7 @@ export class SsrSite extends Construct {
|
|
|
94
94
|
// Build app
|
|
95
95
|
buildApp();
|
|
96
96
|
const plan = this.plan(bucket);
|
|
97
|
+
validateTimeout();
|
|
97
98
|
// Create CloudFront
|
|
98
99
|
const cfFunctions = createCloudFrontFunctions();
|
|
99
100
|
const edgeFunctions = createEdgeFunctions();
|
|
@@ -104,12 +105,8 @@ export class SsrSite extends Construct {
|
|
|
104
105
|
createWarmer();
|
|
105
106
|
this.bucket = bucket;
|
|
106
107
|
this.distribution = distribution;
|
|
107
|
-
this.serverFunction =
|
|
108
|
-
|
|
109
|
-
? ssrFunctions[0]
|
|
110
|
-
: Object.values(edgeFunctions).length > 0
|
|
111
|
-
? Object.values(edgeFunctions)[0]
|
|
112
|
-
: undefined;
|
|
108
|
+
this.serverFunction = ssrFunctions[0] ?? Object.values(edgeFunctions)[0];
|
|
109
|
+
this.edge = plan.edge;
|
|
113
110
|
app.registerTypes(this);
|
|
114
111
|
function validateSiteExists() {
|
|
115
112
|
if (!fs.existsSync(sitePath)) {
|
|
@@ -120,10 +117,10 @@ export class SsrSite extends Construct {
|
|
|
120
117
|
const num = typeof timeout === "number"
|
|
121
118
|
? timeout
|
|
122
119
|
: toCdkDuration(timeout).toSeconds();
|
|
123
|
-
const limit = edge ? 30 : 180;
|
|
120
|
+
const limit = plan.edge ? 30 : 180;
|
|
124
121
|
if (num > limit) {
|
|
125
|
-
throw new VisibleError(edge
|
|
126
|
-
? `In the "${id}" construct, timeout must be less than or equal to 30 seconds when the
|
|
122
|
+
throw new VisibleError(plan.edge
|
|
123
|
+
? `In the "${id}" construct, timeout must be less than or equal to 30 seconds when deploying to the edge.`
|
|
127
124
|
: `In the "${id}" construct, timeout must be less than or equal to 180 seconds.`);
|
|
128
125
|
}
|
|
129
126
|
}
|
|
@@ -213,7 +210,7 @@ export class SsrSite extends Construct {
|
|
|
213
210
|
// need to handle warming multiple functions.
|
|
214
211
|
if (!warm)
|
|
215
212
|
return;
|
|
216
|
-
if (warm && edge) {
|
|
213
|
+
if (warm && plan.edge) {
|
|
217
214
|
throw new VisibleError(`In the "${id}" Site, warming is currently supported only for the regional mode.`);
|
|
218
215
|
}
|
|
219
216
|
if (ssrFunctions.length === 0)
|
|
@@ -836,7 +833,7 @@ function handler(event) {
|
|
|
836
833
|
runtime: this.props.runtime,
|
|
837
834
|
customDomainUrl: this.customDomainUrl,
|
|
838
835
|
url: this.url,
|
|
839
|
-
edge: this.
|
|
836
|
+
edge: this.edge,
|
|
840
837
|
server: (this.serverFunctionForDev || this.serverFunction)
|
|
841
838
|
?.functionArn,
|
|
842
839
|
secrets: (this.props.bind || [])
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import { SsrSite } from "./SsrSite.js";
|
|
1
|
+
import { SsrSite, SsrSiteNormalizedProps, SsrSiteProps } from "./SsrSite.js";
|
|
2
|
+
import { Construct } from "constructs";
|
|
3
|
+
export interface SvelteKitSiteProps extends SsrSiteProps {
|
|
4
|
+
/**
|
|
5
|
+
* The server function is deployed to Lambda in a single region. Alternatively, you can enable this option to deploy to Lambda@Edge.
|
|
6
|
+
* @default false
|
|
7
|
+
*/
|
|
8
|
+
edge?: boolean;
|
|
9
|
+
}
|
|
10
|
+
type SvelteKitSiteNormalizedProps = SvelteKitSiteProps & SsrSiteNormalizedProps;
|
|
2
11
|
/**
|
|
3
12
|
* The `SvelteKitSite` construct is a higher level CDK construct that makes it easy to create a SvelteKit app.
|
|
4
13
|
* @example
|
|
@@ -11,7 +20,8 @@ import { SsrSite } from "./SsrSite.js";
|
|
|
11
20
|
* ```
|
|
12
21
|
*/
|
|
13
22
|
export declare class SvelteKitSite extends SsrSite {
|
|
14
|
-
|
|
23
|
+
props: SvelteKitSiteNormalizedProps;
|
|
24
|
+
constructor(scope: Construct, id: string, props?: SvelteKitSiteProps);
|
|
15
25
|
protected plan(): {
|
|
16
26
|
cloudFrontFunctions?: {
|
|
17
27
|
serverCfFunction: {
|
|
@@ -79,6 +89,7 @@ export declare class SvelteKitSite extends SsrSite {
|
|
|
79
89
|
};
|
|
80
90
|
} | undefined;
|
|
81
91
|
};
|
|
92
|
+
edge: boolean;
|
|
82
93
|
behaviors: {
|
|
83
94
|
cacheType: "server" | "static";
|
|
84
95
|
pattern?: string | undefined;
|
|
@@ -109,3 +120,4 @@ export declare class SvelteKitSite extends SsrSite {
|
|
|
109
120
|
type: "SvelteKitSite";
|
|
110
121
|
};
|
|
111
122
|
}
|
|
123
|
+
export {};
|
|
@@ -13,7 +13,12 @@ import { SsrSite } from "./SsrSite.js";
|
|
|
13
13
|
* ```
|
|
14
14
|
*/
|
|
15
15
|
export class SvelteKitSite extends SsrSite {
|
|
16
|
-
|
|
16
|
+
constructor(scope, id, props) {
|
|
17
|
+
super(scope, id, {
|
|
18
|
+
...props,
|
|
19
|
+
typesPath: props?.typesPath ?? "src",
|
|
20
|
+
});
|
|
21
|
+
}
|
|
17
22
|
plan() {
|
|
18
23
|
const { path: sitePath, edge } = this.props;
|
|
19
24
|
const serverDir = ".svelte-kit/svelte-kit-sst/server";
|
|
@@ -39,6 +44,7 @@ export class SvelteKitSite extends SsrSite {
|
|
|
39
44
|
],
|
|
40
45
|
};
|
|
41
46
|
return this.validatePlan({
|
|
47
|
+
edge: edge ?? false,
|
|
42
48
|
buildId: JSON.parse(fs
|
|
43
49
|
.readFileSync(path.join(sitePath, clientDir, "_app/version.json"))
|
|
44
50
|
.toString()).version,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"sideEffects": false,
|
|
3
3
|
"name": "sst",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.34.1",
|
|
5
5
|
"bin": {
|
|
6
6
|
"sst": "cli/sst.js"
|
|
7
7
|
},
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"tsx": "^3.12.1",
|
|
125
125
|
"typescript": "^5.2.2",
|
|
126
126
|
"vitest": "^0.33.0",
|
|
127
|
-
"astro-sst": "2.
|
|
127
|
+
"astro-sst": "2.34.1"
|
|
128
128
|
},
|
|
129
129
|
"peerDependencies": {
|
|
130
130
|
"@sls-next/lambda-at-edge": "^3.7.0"
|