sst 2.1.17 → 2.1.18
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/bootstrap.js +1 -1
- package/cli/commands/bind.js +1 -1
- package/cli/commands/env.js +1 -1
- package/constructs/App.js +3 -3
- package/constructs/AstroSite.js +8 -41
- package/constructs/EdgeFunction.d.ts +19 -21
- package/constructs/EdgeFunction.js +235 -167
- package/constructs/Function.d.ts +1 -1
- package/constructs/Function.js +3 -3
- package/constructs/Job.js +2 -2
- package/constructs/NextjsSite.d.ts +6 -5
- package/constructs/NextjsSite.js +5 -3
- package/constructs/RDS.js +1 -1
- package/constructs/RemixSite.d.ts +2 -3
- package/constructs/RemixSite.js +42 -71
- package/constructs/SolidStartSite.js +8 -41
- package/constructs/SsrFunction.d.ts +9 -6
- package/constructs/SsrFunction.js +61 -50
- package/constructs/SsrSite.d.ts +6 -4
- package/constructs/SsrSite.js +0 -4
- package/constructs/Stack.js +2 -1
- package/node/util/index.js +1 -1
- package/package.json +1 -1
- package/runtime/handlers/node.js +1 -1
- package/sst.mjs +4 -4
- package/support/nodejs-runtime/index.mjs +62 -14629
package/bootstrap.js
CHANGED
package/cli/commands/bind.js
CHANGED
package/cli/commands/env.js
CHANGED
package/constructs/App.js
CHANGED
|
@@ -247,7 +247,7 @@ export class App extends cdk.App {
|
|
|
247
247
|
if (!isSSTConstruct(c)) {
|
|
248
248
|
return;
|
|
249
249
|
}
|
|
250
|
-
if (c instanceof Function && c.
|
|
250
|
+
if (c instanceof Function && c._doNotAllowOthersToBind) {
|
|
251
251
|
return;
|
|
252
252
|
}
|
|
253
253
|
bindParameters(c);
|
|
@@ -370,7 +370,7 @@ export class App extends cdk.App {
|
|
|
370
370
|
if (!isSSTConstruct(c)) {
|
|
371
371
|
return;
|
|
372
372
|
}
|
|
373
|
-
if (c instanceof Function && c.
|
|
373
|
+
if (c instanceof Function && c._doNotAllowOthersToBind) {
|
|
374
374
|
return;
|
|
375
375
|
}
|
|
376
376
|
const className = c.constructor.name;
|
|
@@ -449,7 +449,7 @@ export class App extends cdk.App {
|
|
|
449
449
|
if (!isSSTConstruct(c)) {
|
|
450
450
|
return;
|
|
451
451
|
}
|
|
452
|
-
if (c instanceof Function && c.
|
|
452
|
+
if (c instanceof Function && c._doNotAllowOthersToBind) {
|
|
453
453
|
return;
|
|
454
454
|
}
|
|
455
455
|
const binding = bindType(c);
|
package/constructs/AstroSite.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
|
-
import url from "url";
|
|
3
2
|
import path from "path";
|
|
4
|
-
import { buildSync } from "esbuild";
|
|
5
3
|
import { Architecture } from "aws-cdk-lib/aws-lambda";
|
|
6
4
|
import { SsrSite } from "./SsrSite.js";
|
|
7
5
|
import { Function } from "./Function.js";
|
|
8
|
-
import { useProject } from "../project.js";
|
|
9
6
|
import { EdgeFunction } from "./EdgeFunction.js";
|
|
10
|
-
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
11
7
|
/**
|
|
12
8
|
* The `AstroSite` construct is a higher level CDK construct that makes it easy to create a Astro app.
|
|
13
9
|
* @example
|
|
@@ -36,12 +32,10 @@ export class AstroSite extends SsrSite {
|
|
|
36
32
|
super.validateBuildOutput();
|
|
37
33
|
}
|
|
38
34
|
createFunctionForRegional() {
|
|
39
|
-
const { runtime, memorySize,
|
|
40
|
-
// Create function
|
|
35
|
+
const { runtime, timeout, memorySize, permissions, environment, bind, cdk, } = this.props;
|
|
41
36
|
const fn = new Function(this, `ServerFunction`, {
|
|
42
37
|
description: "Server handler",
|
|
43
38
|
handler: path.join(this.props.path, "dist", "server", "entry.handler"),
|
|
44
|
-
bind,
|
|
45
39
|
logRetention: "three_days",
|
|
46
40
|
runtime,
|
|
47
41
|
memorySize,
|
|
@@ -49,53 +43,26 @@ export class AstroSite extends SsrSite {
|
|
|
49
43
|
nodejs: {
|
|
50
44
|
format: "esm",
|
|
51
45
|
},
|
|
46
|
+
bind,
|
|
52
47
|
environment,
|
|
48
|
+
permissions,
|
|
53
49
|
...cdk?.server,
|
|
54
50
|
architecture: cdk?.server?.architecture === Architecture.ARM_64 ? "arm_64" : "x86_64",
|
|
55
51
|
});
|
|
56
|
-
fn.
|
|
52
|
+
fn._doNotAllowOthersToBind = true;
|
|
57
53
|
return fn;
|
|
58
54
|
}
|
|
59
55
|
createFunctionForEdge() {
|
|
60
|
-
const { runtime, timeout, memorySize, permissions, environment } = this.props;
|
|
61
|
-
// Create a directory that we will use to create the bundled version
|
|
62
|
-
// of the "core server build" along with our custom Lamba server handler.
|
|
63
|
-
const outputPath = path.resolve(path.join(useProject().paths.artifacts, `AstroSiteFunction-${this.node.id}-${this.node.addr}`));
|
|
64
|
-
const result = buildSync({
|
|
65
|
-
entryPoints: [
|
|
66
|
-
path.join(this.props.path, this.buildConfig.serverBuildOutputFile),
|
|
67
|
-
],
|
|
68
|
-
target: "esnext",
|
|
69
|
-
format: "esm",
|
|
70
|
-
platform: "node",
|
|
71
|
-
metafile: true,
|
|
72
|
-
bundle: true,
|
|
73
|
-
write: true,
|
|
74
|
-
allowOverwrite: true,
|
|
75
|
-
outfile: path.join(outputPath, "entry.mjs"),
|
|
76
|
-
banner: {
|
|
77
|
-
js: [
|
|
78
|
-
`import { createRequire as topLevelCreateRequire } from 'module';`,
|
|
79
|
-
`const require = topLevelCreateRequire(import.meta.url);`,
|
|
80
|
-
].join(""),
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
if (result.errors.length > 0) {
|
|
84
|
-
result.errors.forEach((error) => console.error(error));
|
|
85
|
-
throw new Error(`There was a problem bundling the function code for the ${this.id} AstroSite.`);
|
|
86
|
-
}
|
|
87
|
-
// Create package.json
|
|
88
|
-
fs.writeFileSync(path.join(outputPath, "package.json"), `{"type":"module"}`);
|
|
89
|
-
// Create function
|
|
56
|
+
const { runtime, timeout, memorySize, bind, permissions, environment } = this.props;
|
|
90
57
|
return new EdgeFunction(this, `Server`, {
|
|
91
58
|
scopeOverride: this,
|
|
92
|
-
|
|
93
|
-
handler: "entry.handler",
|
|
59
|
+
handler: path.join(this.props.path, "dist", "server", "entry.handler"),
|
|
94
60
|
runtime,
|
|
95
61
|
timeout,
|
|
96
62
|
memorySize,
|
|
97
|
-
|
|
63
|
+
bind,
|
|
98
64
|
environment,
|
|
65
|
+
permissions,
|
|
99
66
|
format: "esm",
|
|
100
67
|
});
|
|
101
68
|
}
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
+
import { BuildOptions } from "esbuild";
|
|
1
2
|
import { Construct, IConstruct } from "constructs";
|
|
2
3
|
import { Role } from "aws-cdk-lib/aws-iam";
|
|
3
|
-
import
|
|
4
|
+
import { IVersion } from "aws-cdk-lib/aws-lambda";
|
|
5
|
+
import { SSTConstruct } from "./Construct.js";
|
|
4
6
|
import { Size } from "./util/size.js";
|
|
5
7
|
import { Duration } from "./util/duration.js";
|
|
6
8
|
import { Permissions } from "./util/permission.js";
|
|
7
9
|
export interface EdgeFunctionProps {
|
|
8
|
-
|
|
10
|
+
bundle?: string;
|
|
9
11
|
handler: string;
|
|
10
|
-
runtime
|
|
12
|
+
runtime: "nodejs14.x" | "nodejs16.x" | "nodejs18.x";
|
|
11
13
|
timeout: number | Duration;
|
|
12
14
|
memorySize: number | Size;
|
|
13
15
|
permissions?: Permissions;
|
|
14
|
-
format: "cjs" | "esm";
|
|
15
16
|
environment?: Record<string, string>;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* changes. When the hirerchical structure changes, the child AWS
|
|
20
|
-
* resources' logical ID will change. And CloudFormation will recreate
|
|
21
|
-
* them.
|
|
22
|
-
*/
|
|
17
|
+
bind?: SSTConstruct[];
|
|
18
|
+
esbuild?: BuildOptions;
|
|
19
|
+
format: "cjs" | "esm";
|
|
23
20
|
scopeOverride?: IConstruct;
|
|
24
21
|
}
|
|
25
22
|
export declare class EdgeFunction extends Construct {
|
|
@@ -27,20 +24,21 @@ export declare class EdgeFunction extends Construct {
|
|
|
27
24
|
functionArn: string;
|
|
28
25
|
private scope;
|
|
29
26
|
private versionId;
|
|
27
|
+
private bindingEnvs;
|
|
30
28
|
private props;
|
|
31
29
|
constructor(scope: Construct, id: string, props: EdgeFunctionProps);
|
|
32
|
-
get currentVersion():
|
|
30
|
+
get currentVersion(): IVersion;
|
|
33
31
|
attachPermissions(permissions: Permissions): void;
|
|
34
|
-
private
|
|
35
|
-
private
|
|
32
|
+
private buildBundle;
|
|
33
|
+
private updateBundleWithEnvWrapper;
|
|
34
|
+
private bind;
|
|
35
|
+
private createCodeAsset;
|
|
36
|
+
private createCodeReplacer;
|
|
36
37
|
private createRole;
|
|
37
|
-
private
|
|
38
|
-
private
|
|
39
|
-
private
|
|
40
|
-
private
|
|
41
|
-
private createVersionCR;
|
|
42
|
-
private getLambdaContentReplaceValues;
|
|
43
|
-
private updateVersionLogicalId;
|
|
38
|
+
private createSingletonBucketInUsEast1;
|
|
39
|
+
private createFunctionInUsEast1;
|
|
40
|
+
private createVersionInUsEast1;
|
|
41
|
+
private getHandlerExtension;
|
|
44
42
|
private trimFromStart;
|
|
45
43
|
private calculateHash;
|
|
46
44
|
}
|