sst 2.19.1 → 2.20.0

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.
@@ -19,7 +19,8 @@ export type CronMetadata = ExtractMetadata<Cron>;
19
19
  import type { EventBus } from "./EventBus.js";
20
20
  export type EventBusMetadata = ExtractMetadata<EventBus>;
21
21
  import type { Function as Fn } from "./Function.js";
22
- export type FunctionMetadata = ExtractMetadata<Fn>;
22
+ import type { SsrFunction } from "./SsrFunction.js";
23
+ export type FunctionMetadata = ExtractMetadata<Fn> | ExtractMetadata<SsrFunction>;
23
24
  import type { KinesisStream } from "./KinesisStream.js";
24
25
  export type KinesisStreamMetadata = ExtractMetadata<KinesisStream>;
25
26
  import type { NextjsSite as SlsNextjsSite } from "./deprecated/NextjsSite.js";
@@ -20,7 +20,8 @@ export interface SsrFunctionProps extends Omit<FunctionOptions, "memorySize" | "
20
20
  copyFiles?: FunctionCopyFilesProps[];
21
21
  logRetention?: RetentionDays;
22
22
  }
23
- export declare class SsrFunction extends Construct {
23
+ export declare class SsrFunction extends Construct implements SSTConstruct {
24
+ readonly id: string;
24
25
  function: CdkFunction;
25
26
  private assetReplacer;
26
27
  private assetReplacerPolicy;
@@ -41,4 +42,16 @@ export declare class SsrFunction extends Construct {
41
42
  private buildAssetFromBundle;
42
43
  private updateCodeReplacer;
43
44
  private updateFunction;
45
+ /** @internal */
46
+ getConstructMetadata(): {
47
+ type: "Function";
48
+ data: {
49
+ arn: string;
50
+ handler: string;
51
+ localId: string;
52
+ secrets: string[];
53
+ };
54
+ };
55
+ /** @internal */
56
+ getFunctionBinding(): undefined;
44
57
  }
@@ -20,12 +20,14 @@ const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
20
20
  // Construct
21
21
  /////////////////////
22
22
  export class SsrFunction extends Construct {
23
+ id;
23
24
  function;
24
25
  assetReplacer;
25
26
  assetReplacerPolicy;
26
27
  props;
27
28
  constructor(scope, id, props) {
28
29
  super(scope, id);
30
+ this.id = id;
29
31
  this.props = {
30
32
  ...props,
31
33
  environment: props.environment || {},
@@ -202,4 +204,20 @@ export class SsrFunction extends Construct {
202
204
  };
203
205
  code.bindToResource(cfnFunction);
204
206
  }
207
+ /** @internal */
208
+ getConstructMetadata() {
209
+ return {
210
+ type: "Function",
211
+ data: {
212
+ arn: this.functionArn,
213
+ handler: this.props.handler,
214
+ localId: this.node.addr,
215
+ secrets: [],
216
+ },
217
+ };
218
+ }
219
+ /** @internal */
220
+ getFunctionBinding() {
221
+ return undefined;
222
+ }
205
223
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "sst",
4
- "version": "2.19.1",
4
+ "version": "2.20.0",
5
5
  "bin": {
6
6
  "sst": "cli/sst.js"
7
7
  },
@@ -66,7 +66,7 @@
66
66
  "cross-spawn": "^7.0.3",
67
67
  "dendriform-immer-patch-optimiser": "^2.1.0",
68
68
  "dotenv": "^16.0.3",
69
- "esbuild": "0.16.13",
69
+ "esbuild": "0.18.11",
70
70
  "express": "^4.18.2",
71
71
  "fast-jwt": "^1.6.1",
72
72
  "get-port": "^6.1.2",
@@ -26,7 +26,7 @@ export const useNodeHandler = Context.memo(async () => {
26
26
  .relative(project.paths.root, input.file)
27
27
  .split(path.sep)
28
28
  .join(path.posix.sep);
29
- return Boolean(result.metafile?.inputs[relative]);
29
+ return Boolean(result.last.metafile?.inputs[relative]);
30
30
  },
31
31
  canHandle: (input) => input.startsWith("nodejs"),
32
32
  startWorker: async (input) => {
@@ -89,9 +89,12 @@ export const useNodeHandler = Context.memo(async () => {
89
89
  .relative(input.out, target.replace(extension, parsed.ext))
90
90
  .split(path.sep)
91
91
  .join(path.posix.sep);
92
- if (exists?.rebuild) {
93
- const result = await exists.rebuild();
94
- cache[input.functionID] = result;
92
+ if (exists) {
93
+ const result = await exists.ctx.rebuild();
94
+ cache[input.functionID] = {
95
+ ctx: exists.ctx,
96
+ last: result,
97
+ };
95
98
  return {
96
99
  type: "success",
97
100
  handler,
@@ -146,7 +149,8 @@ export const useNodeHandler = Context.memo(async () => {
146
149
  ...override,
147
150
  };
148
151
  try {
149
- const result = await esbuild.build(options);
152
+ const ctx = await esbuild.context(options);
153
+ const result = await ctx.rebuild();
150
154
  // Install node_modules
151
155
  const installPackages = [
152
156
  ...(nodejs.install || []),
@@ -202,7 +206,10 @@ export const useNodeHandler = Context.memo(async () => {
202
206
  }
203
207
  catch { }
204
208
  }
205
- cache[input.functionID] = result;
209
+ cache[input.functionID] = {
210
+ ctx,
211
+ last: result,
212
+ };
206
213
  return {
207
214
  type: "success",
208
215
  handler,