sst 2.1.1 → 2.1.3

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.
@@ -23,4 +23,5 @@ export declare class RemixSite extends SsrSite {
23
23
  private createServerLambdaBundle;
24
24
  protected createFunctionForRegional(): lambda.Function;
25
25
  protected createFunctionForEdge(): EdgeFunction;
26
+ private normalizeRuntime;
26
27
  }
@@ -60,7 +60,7 @@ export class RemixSite extends SsrSite {
60
60
  clientBuildVersionedSubDir: "build",
61
61
  };
62
62
  }
63
- createServerLambdaBundle(wrapperFile) {
63
+ createServerLambdaBundle(wrapperFile, external) {
64
64
  // Create a Lambda@Edge handler for the Remix server bundle.
65
65
  //
66
66
  // Note: Remix does perform their own internal ESBuild process, but it
@@ -96,7 +96,7 @@ export class RemixSite extends SsrSite {
96
96
  bundle: true,
97
97
  target: "node16",
98
98
  platform: "node",
99
- external: ["aws-sdk"],
99
+ external,
100
100
  outfile: path.join(outputPath, "server.js"),
101
101
  // We need to ensure that the polyfills are injected above other code that
102
102
  // will depend on them. Importing them within the top of the lambda code
@@ -112,8 +112,9 @@ export class RemixSite extends SsrSite {
112
112
  return outputPath;
113
113
  }
114
114
  createFunctionForRegional() {
115
- const { runtime, timeout, memorySize, environment, cdk } = this.props;
116
- const bundlePath = this.createServerLambdaBundle("regional-server.js");
115
+ const { runtime: runtimeRaw, timeout, memorySize, environment, cdk, } = this.props;
116
+ const runtime = this.normalizeRuntime(runtimeRaw);
117
+ const bundlePath = this.createServerLambdaBundle("regional-server.js", runtime === "nodejs18.x" ? [] : ["aws-sdk"]);
117
118
  return new lambda.Function(this, `ServerFunction`, {
118
119
  description: "Server handler for Remix",
119
120
  handler: "server.handler",
@@ -138,8 +139,9 @@ export class RemixSite extends SsrSite {
138
139
  });
139
140
  }
140
141
  createFunctionForEdge() {
141
- const { runtime, timeout, memorySize, permissions, environment } = this.props;
142
- const bundlePath = this.createServerLambdaBundle("edge-server.js");
142
+ const { runtime: runtimeRaw, timeout, memorySize, permissions, environment, } = this.props;
143
+ const runtime = this.normalizeRuntime(runtimeRaw);
144
+ const bundlePath = this.createServerLambdaBundle("edge-server.js", runtime === "nodejs18.x" ? [] : ["aws-sdk"]);
143
145
  return new EdgeFunction(this, `Server`, {
144
146
  scopeOverride: this,
145
147
  format: "cjs",
@@ -152,4 +154,7 @@ export class RemixSite extends SsrSite {
152
154
  environment,
153
155
  });
154
156
  }
157
+ normalizeRuntime(runtime) {
158
+ return runtime || "nodejs18.x";
159
+ }
155
160
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sst",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "bin": {
5
5
  "sst": "cli/sst.js"
6
6
  },
@@ -4,7 +4,7 @@
4
4
  import fs from "fs";
5
5
  import url from "url";
6
6
  import path from "path";
7
- import { AssetStaging, DockerImage, FileSystem, } from "aws-cdk-lib";
7
+ import { DockerImage, FileSystem, } from "aws-cdk-lib";
8
8
  const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
9
9
  /**
10
10
  * Dependency files to exclude from the asset hash.
@@ -22,13 +22,6 @@ export function bundle(options) {
22
22
  const stagedir = FileSystem.mkdtemp("python-bundling-");
23
23
  const hasDeps = stageDependencies(entry, stagedir);
24
24
  const hasInstallCommands = stageInstallCommands(installCommands || [], stagedir);
25
- const depsCommand = chain([
26
- hasDeps || hasInstallCommands
27
- ? `rsync -r ${BUNDLER_DEPENDENCIES_CACHE}/. ${AssetStaging.BUNDLING_OUTPUT_DIR}/${outputPathSuffix}`
28
- : "",
29
- `rsync -r . ${AssetStaging.BUNDLING_OUTPUT_DIR}/${outputPathSuffix}`,
30
- ]);
31
- console.log("Commands", depsCommand);
32
25
  // Determine which dockerfile to use. When dependencies are present, we use a
33
26
  // Dockerfile that can create a cacheable layer. We can't use this Dockerfile
34
27
  // if there aren't dependencies or the Dockerfile will complain about missing
@@ -46,19 +39,14 @@ export function bundle(options) {
46
39
  },
47
40
  file: dockerfile,
48
41
  });
49
- image.run({
50
- command: ["bash", "-c", depsCommand],
51
- workingDirectory: AssetStaging.BUNDLING_INPUT_DIR,
52
- volumes: [
53
- {
54
- hostPath: entry,
55
- containerPath: AssetStaging.BUNDLING_INPUT_DIR,
56
- },
57
- {
58
- hostPath: options.out,
59
- containerPath: AssetStaging.BUNDLING_OUTPUT_DIR,
60
- },
61
- ],
42
+ const outputPath = path.join(options.out, outputPathSuffix);
43
+ // Copy dependencies to the bundle if applicable.
44
+ if (hasDeps || hasInstallCommands) {
45
+ image.cp(`${BUNDLER_DEPENDENCIES_CACHE}/.`, outputPath);
46
+ }
47
+ // Copy source code to the bundle.
48
+ fs.cpSync(entry, outputPath, {
49
+ recursive: true,
62
50
  });
63
51
  }
64
52
  /**
@@ -88,6 +76,3 @@ function stageInstallCommands(installCommands, stagedir) {
88
76
  }
89
77
  return found;
90
78
  }
91
- function chain(commands) {
92
- return commands.filter((c) => !!c).join(" && ");
93
- }
package/sst.mjs CHANGED
@@ -1695,7 +1695,7 @@ var init_credentials = __esm({
1695
1695
  Logger.debug("Loading v2 AWS SDK");
1696
1696
  const project = useProject();
1697
1697
  const creds = await useAWSCredentials();
1698
- const chain2 = new CredentialProviderChain([
1698
+ const chain = new CredentialProviderChain([
1699
1699
  () => ({
1700
1700
  ...creds,
1701
1701
  get(cb) {
@@ -1718,7 +1718,7 @@ var init_credentials = __esm({
1718
1718
  secretAccessKey: creds.secretAccessKey
1719
1719
  })
1720
1720
  ]);
1721
- const provider = new SdkProvider(chain2, project.config.region, {
1721
+ const provider = new SdkProvider(chain, project.config.region, {
1722
1722
  maxRetries: 1e4,
1723
1723
  region: project.config.region
1724
1724
  });
@@ -5292,7 +5292,6 @@ import fs13 from "fs";
5292
5292
  import url6 from "url";
5293
5293
  import path13 from "path";
5294
5294
  import {
5295
- AssetStaging,
5296
5295
  DockerImage,
5297
5296
  FileSystem
5298
5297
  } from "aws-cdk-lib";
@@ -5304,11 +5303,6 @@ function bundle(options) {
5304
5303
  installCommands || [],
5305
5304
  stagedir
5306
5305
  );
5307
- const depsCommand = chain([
5308
- hasDeps || hasInstallCommands ? `rsync -r ${BUNDLER_DEPENDENCIES_CACHE}/. ${AssetStaging.BUNDLING_OUTPUT_DIR}/${outputPathSuffix}` : "",
5309
- `rsync -r . ${AssetStaging.BUNDLING_OUTPUT_DIR}/${outputPathSuffix}`
5310
- ]);
5311
- console.log("Commands", depsCommand);
5312
5306
  const dockerfile = hasInstallCommands ? "Dockerfile.custom" : hasDeps ? "Dockerfile.dependencies" : "Dockerfile";
5313
5307
  fs13.copyFileSync(
5314
5308
  path13.join(__dirname2, "../../support/python-runtime", dockerfile),
@@ -5320,19 +5314,12 @@ function bundle(options) {
5320
5314
  },
5321
5315
  file: dockerfile
5322
5316
  });
5323
- image.run({
5324
- command: ["bash", "-c", depsCommand],
5325
- workingDirectory: AssetStaging.BUNDLING_INPUT_DIR,
5326
- volumes: [
5327
- {
5328
- hostPath: entry,
5329
- containerPath: AssetStaging.BUNDLING_INPUT_DIR
5330
- },
5331
- {
5332
- hostPath: options.out,
5333
- containerPath: AssetStaging.BUNDLING_OUTPUT_DIR
5334
- }
5335
- ]
5317
+ const outputPath = path13.join(options.out, outputPathSuffix);
5318
+ if (hasDeps || hasInstallCommands) {
5319
+ image.cp(`${BUNDLER_DEPENDENCIES_CACHE}/.`, outputPath);
5320
+ }
5321
+ fs13.cpSync(entry, outputPath, {
5322
+ recursive: true
5336
5323
  });
5337
5324
  }
5338
5325
  function stageDependencies(entry, stagedir) {
@@ -5358,9 +5345,6 @@ function stageInstallCommands(installCommands, stagedir) {
5358
5345
  }
5359
5346
  return found;
5360
5347
  }
5361
- function chain(commands) {
5362
- return commands.filter((c) => !!c).join(" && ");
5363
- }
5364
5348
  var __dirname2, BUNDLER_DEPENDENCIES_CACHE;
5365
5349
  var init_pythonBundling = __esm({
5366
5350
  "src/runtime/handlers/pythonBundling.ts"() {