sst 2.39.10 → 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/constructs/NextjsSite.js +69 -33
- package/package.json +2 -2
package/constructs/NextjsSite.js
CHANGED
|
@@ -78,7 +78,7 @@ export class NextjsSite extends SsrSite {
|
|
|
78
78
|
});
|
|
79
79
|
this.handleMissingSourcemap();
|
|
80
80
|
if (this.isPerRouteLoggingEnabled()) {
|
|
81
|
-
this.disableDefaultLogging();
|
|
81
|
+
//this.disableDefaultLogging();
|
|
82
82
|
this.uploadSourcemaps();
|
|
83
83
|
}
|
|
84
84
|
if (!props.experimental.disableIncrementalCache) {
|
|
@@ -359,36 +359,56 @@ export class NextjsSite extends SsrSite {
|
|
|
359
359
|
if (this._routes)
|
|
360
360
|
return this._routes;
|
|
361
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
|
+
});
|
|
362
409
|
this._routes = [
|
|
363
|
-
...[...
|
|
364
|
-
|
|
365
|
-
const cwRoute = NextjsSite.buildCloudWatchRouteName(page);
|
|
366
|
-
const cwHash = NextjsSite.buildCloudWatchRouteHash(page);
|
|
367
|
-
const sourcemapPath = this.getSourcemapForAppRoute(page) ||
|
|
368
|
-
this.getSourcemapForPagesRoute(page);
|
|
369
|
-
return {
|
|
370
|
-
route: page,
|
|
371
|
-
regex,
|
|
372
|
-
logGroupPath: `/${cwHash}${cwRoute}`,
|
|
373
|
-
sourcemapPath: sourcemapPath,
|
|
374
|
-
sourcemapKey: cwHash,
|
|
375
|
-
};
|
|
376
|
-
})
|
|
377
|
-
.sort((a, b) => a.route.localeCompare(b.route)),
|
|
378
|
-
...(routesManifest.dataRoutes || [])
|
|
379
|
-
.map(({ page, dataRouteRegex }) => {
|
|
380
|
-
const routeDisplayName = page.endsWith("/")
|
|
381
|
-
? `/_next/data/BUILD_ID${page}index.json`
|
|
382
|
-
: `/_next/data/BUILD_ID${page}.json`;
|
|
383
|
-
const cwRoute = NextjsSite.buildCloudWatchRouteName(routeDisplayName);
|
|
384
|
-
const cwHash = NextjsSite.buildCloudWatchRouteHash(page);
|
|
385
|
-
return {
|
|
386
|
-
route: routeDisplayName,
|
|
387
|
-
regex: dataRouteRegex,
|
|
388
|
-
logGroupPath: `/${cwHash}${cwRoute}`,
|
|
389
|
-
};
|
|
390
|
-
})
|
|
391
|
-
.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)),
|
|
392
412
|
];
|
|
393
413
|
return this._routes;
|
|
394
414
|
}
|
|
@@ -410,6 +430,15 @@ export class NextjsSite extends SsrSite {
|
|
|
410
430
|
}
|
|
411
431
|
}
|
|
412
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
|
+
// }
|
|
413
442
|
if (this.appPathRoutesManifest)
|
|
414
443
|
return this.appPathRoutesManifest;
|
|
415
444
|
const { path: sitePath } = this.props;
|
|
@@ -472,10 +501,17 @@ export class NextjsSite extends SsrSite {
|
|
|
472
501
|
useServerFunctionPerRouteLoggingInjection() {
|
|
473
502
|
return `
|
|
474
503
|
if (event.rawPath) {
|
|
475
|
-
const routeData = ${JSON.stringify(
|
|
476
|
-
|
|
504
|
+
const routeData = ${JSON.stringify(
|
|
505
|
+
// @ts-expect-error
|
|
506
|
+
this.useRoutes().map(({ regexMatch, prefixMatch, logGroupPath }) => ({
|
|
507
|
+
regex: regexMatch,
|
|
508
|
+
prefix: prefixMatch,
|
|
477
509
|
logGroupPath,
|
|
478
|
-
})))}.find(({ 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
|
+
});
|
|
479
515
|
if (routeData) {
|
|
480
516
|
console.log("::sst::" + JSON.stringify({
|
|
481
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.
|
|
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.
|
|
123
|
+
"astro-sst": "2.39.11",
|
|
124
124
|
"async": "^3.2.4",
|
|
125
125
|
"tsx": "^3.12.1",
|
|
126
126
|
"typescript": "^5.2.2",
|