sst 2.39.9 → 2.39.11

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 CHANGED
@@ -20,7 +20,7 @@ const CDK_STACK_NAME = "CDKToolkit";
20
20
  const SST_STACK_NAME = "SSTBootstrap";
21
21
  const OUTPUT_VERSION = "Version";
22
22
  const OUTPUT_BUCKET = "BucketName";
23
- const LATEST_VERSION = "7.2";
23
+ const LATEST_VERSION = "7.3";
24
24
  const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
25
25
  export const useBootstrap = lazy(async () => {
26
26
  Logger.debug("Initializing bootstrap context");
@@ -61,7 +61,7 @@ export interface JobProps {
61
61
  architecture?: "x86_64" | "arm_64";
62
62
  /**
63
63
  * The runtime environment for the job.
64
- * @default "nodejs"
64
+ * @default "nodejs18.x"
65
65
  * @example
66
66
  * ```js
67
67
  * new Job(stack, "MyJob", {
@@ -70,7 +70,7 @@ export interface JobProps {
70
70
  * })
71
71
  *```
72
72
  */
73
- runtime?: "nodejs" | "container";
73
+ runtime?: "nodejs" | "nodejs16.x" | "nodejs18.x" | "nodejs20.x" | "container";
74
74
  /**
75
75
  * For "nodejs" runtime, point to the entry point and handler function.
76
76
  * Of the format: `/path/to/file.function`.
package/constructs/Job.js CHANGED
@@ -275,11 +275,23 @@ export class Job extends Construct {
275
275
  const code = AssetCode.fromAsset(result.out);
276
276
  const codeConfig = code.bind(this);
277
277
  const project = this.job.node.defaultChild;
278
+ const dockerImageMap = {
279
+ arm_64: {
280
+ nodejs: "amazon/aws-lambda-nodejs:16.2023.07.13.14",
281
+ "nodejs16.x": "amazon/aws-lambda-nodejs:16.2023.07.13.14",
282
+ "nodejs18.x": "amazon/aws-lambda-nodejs:18.2023.12.14.13",
283
+ "nodejs20.x": "amazon/aws-lambda-nodejs:20.2023.12.14.13",
284
+ },
285
+ x86_64: {
286
+ nodejs: "amazon/aws-lambda-nodejs:16",
287
+ "nodejs16.x": "amazon/aws-lambda-nodejs:16",
288
+ "nodejs18.x": "amazon/aws-lambda-nodejs:18",
289
+ "nodejs20.x": "amazon/aws-lambda-nodejs:20",
290
+ },
291
+ };
278
292
  const image = LinuxBuildImage.fromDockerRegistry(
279
293
  // ARM images can be found here https://hub.docker.com/r/amazon/aws-lambda-nodejs
280
- architecture === "arm_64"
281
- ? "amazon/aws-lambda-nodejs:16.2023.07.13.14"
282
- : "amazon/aws-lambda-nodejs:16");
294
+ dockerImageMap[architecture ?? "x86_64"][runtime ?? "nodejs18.x"]);
283
295
  project.environment = {
284
296
  ...project.environment,
285
297
  type: architecture === "arm_64" ? "ARM_CONTAINER" : "LINUX_CONTAINER",
@@ -43,6 +43,19 @@ export interface NextjsSiteProps extends Omit<SsrSiteProps, "nodejs"> {
43
43
  */
44
44
  memorySize?: number | Size;
45
45
  };
46
+ openNext?: {
47
+ /**
48
+ * Specify a custom build output path for cases when running OpenNext from
49
+ * a monorepo with decentralized build output. This is passed to the
50
+ * `--build-output-path` flag of OpenNext.
51
+ * @default Default build output path
52
+ * @example
53
+ * ```js
54
+ * buildOutputPath: "dist/apps/example-app"
55
+ * ```
56
+ */
57
+ buildOutputPath?: string;
58
+ };
46
59
  experimental?: {
47
60
  /**
48
61
  * Enable streaming. Currently an experimental feature in OpenNext.
@@ -63,6 +63,9 @@ export class NextjsSite extends SsrSite {
63
63
  "--yes",
64
64
  `open-next@${props?.openNextVersion ?? DEFAULT_OPEN_NEXT_VERSION}`,
65
65
  "build",
66
+ ...(props.openNext?.buildOutputPath
67
+ ? ["--build-output-path", props.openNext.buildOutputPath]
68
+ : []),
66
69
  ...(props.experimental.streaming ? ["--streaming"] : []),
67
70
  ...(props.experimental.disableDynamoDBCache
68
71
  ? ["--dangerously-disable-dynamodb-cache"]
@@ -75,7 +78,7 @@ export class NextjsSite extends SsrSite {
75
78
  });
76
79
  this.handleMissingSourcemap();
77
80
  if (this.isPerRouteLoggingEnabled()) {
78
- this.disableDefaultLogging();
81
+ //this.disableDefaultLogging();
79
82
  this.uploadSourcemaps();
80
83
  }
81
84
  if (!props.experimental.disableIncrementalCache) {
@@ -356,36 +359,56 @@ export class NextjsSite extends SsrSite {
356
359
  if (this._routes)
357
360
  return this._routes;
358
361
  const routesManifest = this.useRoutesManifest();
362
+ const appPathRoutesManifest = this.useAppPathRoutesManifest();
363
+ const dynamicAndStaticRoutes = [
364
+ ...routesManifest.dynamicRoutes,
365
+ ...routesManifest.staticRoutes,
366
+ ].map(({ page, regex }) => {
367
+ const cwRoute = NextjsSite.buildCloudWatchRouteName(page);
368
+ const cwHash = NextjsSite.buildCloudWatchRouteHash(page);
369
+ const sourcemapPath = this.getSourcemapForAppRoute(page) ||
370
+ this.getSourcemapForPagesRoute(page);
371
+ return {
372
+ route: page,
373
+ regexMatch: regex,
374
+ logGroupPath: `/${cwHash}${cwRoute}`,
375
+ sourcemapPath: sourcemapPath,
376
+ sourcemapKey: cwHash,
377
+ };
378
+ });
379
+ // Some app routes are not in the routes manifest, so we need to add them
380
+ // ie. app/api/route.ts => IS NOT in the routes manifest
381
+ // app/items/[slug]/route.ts => IS in the routes manifest (dynamicRoutes)
382
+ const appRoutes = Object.values(appPathRoutesManifest)
383
+ .filter((page) => routesManifest.dynamicRoutes.every((route) => route.page !== page) &&
384
+ routesManifest.staticRoutes.every((route) => route.page !== page))
385
+ .map((page) => {
386
+ const cwRoute = NextjsSite.buildCloudWatchRouteName(page);
387
+ const cwHash = NextjsSite.buildCloudWatchRouteHash(page);
388
+ const sourcemapPath = this.getSourcemapForAppRoute(page);
389
+ return {
390
+ route: page,
391
+ prefixMatch: page,
392
+ logGroupPath: `/${cwHash}${cwRoute}`,
393
+ sourcemapPath: sourcemapPath,
394
+ sourcemapKey: cwHash,
395
+ };
396
+ });
397
+ const dataRoutes = (routesManifest.dataRoutes || []).map(({ page, dataRouteRegex }) => {
398
+ const routeDisplayName = page.endsWith("/")
399
+ ? `/_next/data/BUILD_ID${page}index.json`
400
+ : `/_next/data/BUILD_ID${page}.json`;
401
+ const cwRoute = NextjsSite.buildCloudWatchRouteName(routeDisplayName);
402
+ const cwHash = NextjsSite.buildCloudWatchRouteHash(page);
403
+ return {
404
+ route: routeDisplayName,
405
+ regexMatch: dataRouteRegex,
406
+ logGroupPath: `/${cwHash}${cwRoute}`,
407
+ };
408
+ });
359
409
  this._routes = [
360
- ...[...routesManifest.dynamicRoutes, ...routesManifest.staticRoutes]
361
- .map(({ page, regex }) => {
362
- const cwRoute = NextjsSite.buildCloudWatchRouteName(page);
363
- const cwHash = NextjsSite.buildCloudWatchRouteHash(page);
364
- const sourcemapPath = this.getSourcemapForAppRoute(page) ||
365
- this.getSourcemapForPagesRoute(page);
366
- return {
367
- route: page,
368
- regex,
369
- logGroupPath: `/${cwHash}${cwRoute}`,
370
- sourcemapPath: sourcemapPath,
371
- sourcemapKey: cwHash,
372
- };
373
- })
374
- .sort((a, b) => a.route.localeCompare(b.route)),
375
- ...(routesManifest.dataRoutes || [])
376
- .map(({ page, dataRouteRegex }) => {
377
- const routeDisplayName = page.endsWith("/")
378
- ? `/_next/data/BUILD_ID${page}index.json`
379
- : `/_next/data/BUILD_ID${page}.json`;
380
- const cwRoute = NextjsSite.buildCloudWatchRouteName(routeDisplayName);
381
- const cwHash = NextjsSite.buildCloudWatchRouteHash(page);
382
- return {
383
- route: routeDisplayName,
384
- regex: dataRouteRegex,
385
- logGroupPath: `/${cwHash}${cwRoute}`,
386
- };
387
- })
388
- .sort((a, b) => a.route.localeCompare(b.route)),
410
+ ...[...dynamicAndStaticRoutes, ...appRoutes].sort((a, b) => a.route.localeCompare(b.route)),
411
+ ...dataRoutes.sort((a, b) => a.route.localeCompare(b.route)),
389
412
  ];
390
413
  return this._routes;
391
414
  }
@@ -407,6 +430,15 @@ export class NextjsSite extends SsrSite {
407
430
  }
408
431
  }
409
432
  useAppPathRoutesManifest() {
433
+ // Example
434
+ // {
435
+ // "/_not-found": "/_not-found",
436
+ // "/page": "/",
437
+ // "/favicon.ico/route": "/favicon.ico",
438
+ // "/api/route": "/api", <- app/api/route.js
439
+ // "/api/sub/route": "/api/sub", <- app/api/sub/route.js
440
+ // "/items/[slug]/route": "/items/[slug]" <- app/items/[slug]/route.js
441
+ // }
410
442
  if (this.appPathRoutesManifest)
411
443
  return this.appPathRoutesManifest;
412
444
  const { path: sitePath } = this.props;
@@ -469,10 +501,17 @@ export class NextjsSite extends SsrSite {
469
501
  useServerFunctionPerRouteLoggingInjection() {
470
502
  return `
471
503
  if (event.rawPath) {
472
- const routeData = ${JSON.stringify(this.useRoutes().map(({ regex, logGroupPath }) => ({
473
- regex,
504
+ const routeData = ${JSON.stringify(
505
+ // @ts-expect-error
506
+ this.useRoutes().map(({ regexMatch, prefixMatch, logGroupPath }) => ({
507
+ regex: regexMatch,
508
+ prefix: prefixMatch,
474
509
  logGroupPath,
475
- })))}.find(({ regex }) => event.rawPath.match(new RegExp(regex)));
510
+ })))}.find(({ regex, prefix }) => {
511
+ if (regex) return event.rawPath.match(new RegExp(regex));
512
+ if (prefix) return event.rawPath === prefix || (event.rawPath === prefix + "/");
513
+ return false;
514
+ });
476
515
  if (routeData) {
477
516
  console.log("::sst::" + JSON.stringify({
478
517
  action:"log.split",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "sst",
4
- "version": "2.39.9",
4
+ "version": "2.39.11",
5
5
  "bin": {
6
6
  "sst": "cli/sst.js"
7
7
  },
@@ -120,7 +120,7 @@
120
120
  "@types/ws": "^8.5.3",
121
121
  "@types/yargs": "^17.0.13",
122
122
  "archiver": "^5.3.1",
123
- "astro-sst": "2.39.9",
123
+ "astro-sst": "2.39.11",
124
124
  "async": "^3.2.4",
125
125
  "tsx": "^3.12.1",
126
126
  "typescript": "^5.2.2",