cdk-nextjs 0.7.10 → 0.7.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/.jsii +3 -3
- package/README.md +1 -1
- package/docs/harness-coverage.md +1 -1
- package/docs/nextjs-private-apis.md +128 -0
- package/lib/adapter/adapter.mjs +276 -24
- package/lib/adapter/build-outputs.d.ts +1 -1
- package/lib/adapter/build-outputs.js +29 -13
- package/lib/adapter/build-outputs.test.js +35 -7
- package/lib/adapter/cache-handler.d.ts +1 -1
- package/lib/adapter/cache-handler.js +1 -1
- package/lib/adapter/cache-kinds.d.ts +12 -1
- package/lib/adapter/cache-kinds.js +16 -4
- package/lib/adapter/init-cache.js +7 -7
- package/lib/adapter/local-file-cache-handler.d.ts +1 -1
- package/lib/adapter/local-file-cache-handler.js +1 -1
- package/lib/adapter/memory-cache-handler.d.ts +2 -2
- package/lib/adapter/memory-cache-handler.js +1 -1
- package/lib/adapter/s3-cache-handler.d.ts +2 -2
- package/lib/adapter/s3-cache-handler.js +1 -1
- package/lib/adapter/use-cache-common.d.ts +1 -1
- package/lib/adapter/use-cache-common.js +1 -1
- package/lib/adapter/use-cache-common.test.js +1 -1
- package/lib/adapter/use-cache-default-handler.d.ts +1 -1
- package/lib/adapter/use-cache-default-handler.js +1 -1
- package/lib/adapter/use-cache-handlers.test.js +1 -1
- package/lib/adapter/use-cache-remote-handler.d.ts +1 -1
- package/lib/adapter/use-cache-remote-handler.js +1 -1
- package/lib/cdk-nextjs-version.d.ts +10 -0
- package/lib/cdk-nextjs-version.js +15 -0
- package/lib/nextjs-api.js +1 -1
- package/lib/nextjs-build/nextjs-build.js +7 -6
- package/lib/nextjs-build/nextjs-build.test.js +16 -3
- package/lib/nextjs-cache.js +1 -1
- package/lib/nextjs-compute/nextjs-containers.js +1 -1
- package/lib/nextjs-compute/nextjs-functions.js +1 -1
- package/lib/nextjs-distribution.js +5 -5
- package/lib/nextjs-post-deploy.js +1 -1
- package/lib/nextjs-static-assets.js +1 -1
- package/lib/root-constructs/nextjs-base-construct.js +1 -1
- package/lib/root-constructs/nextjs-global-containers.js +1 -1
- package/lib/root-constructs/nextjs-global-functions.js +1 -1
- package/lib/root-constructs/nextjs-regional-containers.js +1 -1
- package/lib/root-constructs/nextjs-regional-functions.js +1 -1
- package/lib/runtime/core.test.js +17 -8
- package/lib/runtime/dispatch.js +4 -5
- package/lib/runtime/image.js +43 -32
- package/lib/runtime/image.test.js +27 -26
- package/lib/runtime/lambda.mjs +276 -36
- package/lib/runtime/manifest.d.ts +34 -8
- package/lib/runtime/manifest.js +7 -5
- package/lib/runtime/server.mjs +276 -36
- package/package.json +1 -1
- package/scripts/capture-adapter-fixture.mjs +13 -1
- package/scripts/zero-config-build.mjs +5 -1
package/lib/adapter/adapter.mjs
CHANGED
|
@@ -792,9 +792,250 @@ var require_src = __commonJS({
|
|
|
792
792
|
}
|
|
793
793
|
});
|
|
794
794
|
|
|
795
|
+
// package.json
|
|
796
|
+
var require_package = __commonJS({
|
|
797
|
+
"package.json"(exports, module) {
|
|
798
|
+
module.exports = {
|
|
799
|
+
name: "cdk-nextjs",
|
|
800
|
+
description: "Deploy Next.js apps on AWS with CDK",
|
|
801
|
+
repository: {
|
|
802
|
+
type: "git",
|
|
803
|
+
url: "https://github.com/cdklabs/cdk-nextjs.git"
|
|
804
|
+
},
|
|
805
|
+
scripts: {
|
|
806
|
+
build: "pnpm dlx projen build",
|
|
807
|
+
bump: "pnpm dlx projen bump",
|
|
808
|
+
"bump:releasable-commits": "pnpm dlx projen bump:releasable-commits",
|
|
809
|
+
bundle: "pnpm dlx projen bundle",
|
|
810
|
+
"bundle:adapter/adapter": "pnpm dlx projen bundle:adapter/adapter",
|
|
811
|
+
"bundle:adapter/adapter:watch": "pnpm dlx projen bundle:adapter/adapter:watch",
|
|
812
|
+
"bundle:adapter/cache-handler": "pnpm dlx projen bundle:adapter/cache-handler",
|
|
813
|
+
"bundle:adapter/cache-handler:watch": "pnpm dlx projen bundle:adapter/cache-handler:watch",
|
|
814
|
+
"bundle:adapter/use-cache-default-handler": "pnpm dlx projen bundle:adapter/use-cache-default-handler",
|
|
815
|
+
"bundle:adapter/use-cache-default-handler:watch": "pnpm dlx projen bundle:adapter/use-cache-default-handler:watch",
|
|
816
|
+
"bundle:adapter/use-cache-remote-handler": "pnpm dlx projen bundle:adapter/use-cache-remote-handler",
|
|
817
|
+
"bundle:adapter/use-cache-remote-handler:watch": "pnpm dlx projen bundle:adapter/use-cache-remote-handler:watch",
|
|
818
|
+
"bundle:lambdas/post-deploy/post-deploy.lambda": "pnpm dlx projen bundle:lambdas/post-deploy/post-deploy.lambda",
|
|
819
|
+
"bundle:lambdas/post-deploy/post-deploy.lambda:watch": "pnpm dlx projen bundle:lambdas/post-deploy/post-deploy.lambda:watch",
|
|
820
|
+
"bundle:lambdas/redeploy-stage/redeploy-stage.lambda": "pnpm dlx projen bundle:lambdas/redeploy-stage/redeploy-stage.lambda",
|
|
821
|
+
"bundle:lambdas/redeploy-stage/redeploy-stage.lambda:watch": "pnpm dlx projen bundle:lambdas/redeploy-stage/redeploy-stage.lambda:watch",
|
|
822
|
+
"bundle:nextjs-build/patch-fetch": "pnpm dlx projen bundle:nextjs-build/patch-fetch",
|
|
823
|
+
"bundle:nextjs-build/patch-fetch:watch": "pnpm dlx projen bundle:nextjs-build/patch-fetch:watch",
|
|
824
|
+
"bundle:runtime/lambda": "pnpm dlx projen bundle:runtime/lambda",
|
|
825
|
+
"bundle:runtime/lambda:watch": "pnpm dlx projen bundle:runtime/lambda:watch",
|
|
826
|
+
"bundle:runtime/server": "pnpm dlx projen bundle:runtime/server",
|
|
827
|
+
"bundle:runtime/server:watch": "pnpm dlx projen bundle:runtime/server:watch",
|
|
828
|
+
clobber: "pnpm dlx projen clobber",
|
|
829
|
+
compat: "pnpm dlx projen compat",
|
|
830
|
+
compile: "pnpm dlx projen compile",
|
|
831
|
+
default: "pnpm dlx projen default",
|
|
832
|
+
docgen: "pnpm dlx projen docgen",
|
|
833
|
+
eject: "pnpm dlx projen eject",
|
|
834
|
+
eslint: "pnpm dlx projen eslint",
|
|
835
|
+
integ: "pnpm dlx projen integ",
|
|
836
|
+
"integ:update": "pnpm dlx projen integ:update",
|
|
837
|
+
package: "pnpm dlx projen package",
|
|
838
|
+
"package-all": "pnpm dlx projen package-all",
|
|
839
|
+
"package:js": "pnpm dlx projen package:js",
|
|
840
|
+
"post-compile": "pnpm dlx projen post-compile",
|
|
841
|
+
"post-upgrade": "pnpm dlx projen post-upgrade",
|
|
842
|
+
"pre-compile": "pnpm dlx projen pre-compile",
|
|
843
|
+
release: "pnpm dlx projen release",
|
|
844
|
+
"rosetta:extract": "pnpm dlx projen rosetta:extract",
|
|
845
|
+
test: "pnpm dlx projen test",
|
|
846
|
+
"test:watch": "pnpm dlx projen test:watch",
|
|
847
|
+
unbump: "pnpm dlx projen unbump",
|
|
848
|
+
upgrade: "pnpm dlx projen upgrade",
|
|
849
|
+
"upgrade-cdklabs-projen-project-types": "pnpm dlx projen upgrade-cdklabs-projen-project-types",
|
|
850
|
+
"upgrade-dev-deps": "pnpm dlx projen upgrade-dev-deps",
|
|
851
|
+
watch: "pnpm dlx projen watch",
|
|
852
|
+
projen: "pnpm dlx projen"
|
|
853
|
+
},
|
|
854
|
+
author: {
|
|
855
|
+
name: "Amazon Web Services",
|
|
856
|
+
email: "aws-cdk-dev@amazon.com",
|
|
857
|
+
organization: true
|
|
858
|
+
},
|
|
859
|
+
devDependencies: {
|
|
860
|
+
"@aws-cdk/integ-runner": "latest",
|
|
861
|
+
"@aws-cdk/integ-tests-alpha": "latest",
|
|
862
|
+
"@aws-crypto/sha256-js": "^5.2.0",
|
|
863
|
+
"@aws-sdk/client-api-gateway": "^3.1141.0",
|
|
864
|
+
"@aws-sdk/client-cloudfront": "^3.1141.0",
|
|
865
|
+
"@aws-sdk/client-dynamodb": "^3.1141.0",
|
|
866
|
+
"@aws-sdk/client-s3": "^3.1141.0",
|
|
867
|
+
"@aws-sdk/client-ssm": "^3.1141.0",
|
|
868
|
+
"@aws-sdk/lib-storage": "^3.1141.0",
|
|
869
|
+
"@mrgrain/jsii-struct-builder": "^0.7.64",
|
|
870
|
+
"@next/routing": "16.4.0",
|
|
871
|
+
"@smithy/signature-v4": "^2.3.0",
|
|
872
|
+
"@types/aws-lambda": "^8.10.163",
|
|
873
|
+
"@types/debug": "^4.1.13",
|
|
874
|
+
"@types/jest": "^29.5.14",
|
|
875
|
+
"@types/mime-types": "^2.1.4",
|
|
876
|
+
"@types/node": "^24",
|
|
877
|
+
"@typescript-eslint/eslint-plugin": "^8",
|
|
878
|
+
"@typescript-eslint/parser": "^8",
|
|
879
|
+
"aws-cdk": "^2.1143.0",
|
|
880
|
+
"aws-cdk-lib": "2.261.0",
|
|
881
|
+
"cdk-nag": "^2.38.2",
|
|
882
|
+
"cdklabs-projen-project-types": "^0.6.17",
|
|
883
|
+
"commit-and-tag-version": "^12",
|
|
884
|
+
constructs: "10.5.1",
|
|
885
|
+
debug: "^4.4.3",
|
|
886
|
+
esbuild: "^0.28.2",
|
|
887
|
+
eslint: "^9",
|
|
888
|
+
"eslint-config-prettier": "^9.1.2",
|
|
889
|
+
"eslint-import-resolver-typescript": "^3.10.1",
|
|
890
|
+
"eslint-plugin-import": "^2.32.0",
|
|
891
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
892
|
+
jest: "^29.7.0",
|
|
893
|
+
"jest-junit": "^17",
|
|
894
|
+
jsii: "~6.0.4",
|
|
895
|
+
"jsii-diff": "^1.140.0",
|
|
896
|
+
"jsii-docgen": "^10.5.0",
|
|
897
|
+
"jsii-pacmak": "^1.140.0",
|
|
898
|
+
"jsii-rosetta": "~5.9.67",
|
|
899
|
+
"mime-types": "^2.1.35",
|
|
900
|
+
next: "^16.4.0",
|
|
901
|
+
prettier: "^3.9.9",
|
|
902
|
+
projen: "^0.101.6",
|
|
903
|
+
"ts-jest": "^29.4.14",
|
|
904
|
+
"ts-node": "^10.9.2",
|
|
905
|
+
typescript: "^5.9.3",
|
|
906
|
+
undici: "^6.29.0"
|
|
907
|
+
},
|
|
908
|
+
peerDependencies: {
|
|
909
|
+
"aws-cdk-lib": "^2.261.0",
|
|
910
|
+
constructs: "^10.5.1"
|
|
911
|
+
},
|
|
912
|
+
pnpm: {
|
|
913
|
+
onlyBuiltDependencies: [
|
|
914
|
+
"esbuild",
|
|
915
|
+
"unrs-resolver",
|
|
916
|
+
"sharp"
|
|
917
|
+
],
|
|
918
|
+
overrides: {
|
|
919
|
+
postcss: "^8.5.23",
|
|
920
|
+
browserslist: "^4.28.7",
|
|
921
|
+
"js-yaml@3": "^3.15.1",
|
|
922
|
+
"js-yaml@4": "^4.3.1",
|
|
923
|
+
"brace-expansion@1": "^1.1.21",
|
|
924
|
+
"brace-expansion@5": "^5.0.12",
|
|
925
|
+
"@babel/core": "^7.29.6",
|
|
926
|
+
sharp: "^0.35.5",
|
|
927
|
+
"source-map-js": "^1.2.2"
|
|
928
|
+
}
|
|
929
|
+
},
|
|
930
|
+
keywords: [
|
|
931
|
+
"aws",
|
|
932
|
+
"aws-cdk",
|
|
933
|
+
"cdk",
|
|
934
|
+
"next",
|
|
935
|
+
"next.js",
|
|
936
|
+
"nextjs"
|
|
937
|
+
],
|
|
938
|
+
devEngines: {
|
|
939
|
+
packageManager: {
|
|
940
|
+
name: "pnpm",
|
|
941
|
+
version: "10.32.1",
|
|
942
|
+
onFail: "ignore"
|
|
943
|
+
}
|
|
944
|
+
},
|
|
945
|
+
main: "lib/index.js",
|
|
946
|
+
license: "Apache-2.0",
|
|
947
|
+
stability: "stable",
|
|
948
|
+
publishConfig: {
|
|
949
|
+
access: "public"
|
|
950
|
+
},
|
|
951
|
+
version: "0.7.11",
|
|
952
|
+
packageManager: "pnpm@10.32.1",
|
|
953
|
+
jest: {
|
|
954
|
+
coverageProvider: "v8",
|
|
955
|
+
testPathIgnorePatterns: [
|
|
956
|
+
"/node_modules/",
|
|
957
|
+
"/cdk.out/"
|
|
958
|
+
],
|
|
959
|
+
testMatch: [
|
|
960
|
+
"<rootDir>/@(src|test)/**/*(*.)@(spec|test).ts?(x)",
|
|
961
|
+
"<rootDir>/@(src|test)/**/__tests__/**/*.ts?(x)",
|
|
962
|
+
"<rootDir>/@(projenrc)/**/*(*.)@(spec|test).ts?(x)",
|
|
963
|
+
"<rootDir>/@(projenrc)/**/__tests__/**/*.ts?(x)"
|
|
964
|
+
],
|
|
965
|
+
clearMocks: true,
|
|
966
|
+
collectCoverage: true,
|
|
967
|
+
coverageReporters: [
|
|
968
|
+
"json",
|
|
969
|
+
"lcov",
|
|
970
|
+
"clover",
|
|
971
|
+
"cobertura",
|
|
972
|
+
"text"
|
|
973
|
+
],
|
|
974
|
+
coverageDirectory: "coverage",
|
|
975
|
+
coveragePathIgnorePatterns: [
|
|
976
|
+
"/node_modules/",
|
|
977
|
+
"/cdk.out/"
|
|
978
|
+
],
|
|
979
|
+
watchPathIgnorePatterns: [
|
|
980
|
+
"/node_modules/"
|
|
981
|
+
],
|
|
982
|
+
reporters: [
|
|
983
|
+
"default",
|
|
984
|
+
[
|
|
985
|
+
"jest-junit",
|
|
986
|
+
{
|
|
987
|
+
outputDirectory: "test-reports"
|
|
988
|
+
}
|
|
989
|
+
]
|
|
990
|
+
],
|
|
991
|
+
transform: {
|
|
992
|
+
"^.+\\.[t]sx?$": [
|
|
993
|
+
"ts-jest",
|
|
994
|
+
{
|
|
995
|
+
tsconfig: "test/tsconfig.json"
|
|
996
|
+
}
|
|
997
|
+
]
|
|
998
|
+
}
|
|
999
|
+
},
|
|
1000
|
+
types: "lib/index.d.ts",
|
|
1001
|
+
jsii: {
|
|
1002
|
+
outdir: "dist",
|
|
1003
|
+
targets: {},
|
|
1004
|
+
tsconfig: "tsconfig.json",
|
|
1005
|
+
validateTsconfig: "strict"
|
|
1006
|
+
},
|
|
1007
|
+
exports: {
|
|
1008
|
+
".": {
|
|
1009
|
+
types: "./lib/index.d.ts",
|
|
1010
|
+
import: "./lib/index.js",
|
|
1011
|
+
default: "./lib/index.js"
|
|
1012
|
+
},
|
|
1013
|
+
"./adapter": {
|
|
1014
|
+
import: "./lib/adapter/adapter.mjs",
|
|
1015
|
+
default: "./lib/adapter/adapter.mjs"
|
|
1016
|
+
},
|
|
1017
|
+
"./cache-handler": {
|
|
1018
|
+
import: "./lib/adapter/cache-handler.mjs",
|
|
1019
|
+
default: "./lib/adapter/cache-handler.mjs"
|
|
1020
|
+
},
|
|
1021
|
+
"./cache-handlers/default": {
|
|
1022
|
+
import: "./lib/adapter/use-cache-default-handler.mjs",
|
|
1023
|
+
default: "./lib/adapter/use-cache-default-handler.mjs"
|
|
1024
|
+
},
|
|
1025
|
+
"./cache-handlers/remote": {
|
|
1026
|
+
import: "./lib/adapter/use-cache-remote-handler.mjs",
|
|
1027
|
+
default: "./lib/adapter/use-cache-remote-handler.mjs"
|
|
1028
|
+
}
|
|
1029
|
+
},
|
|
1030
|
+
"//": '~~ Generated by projen. To modify, edit .projenrc.ts and run "pnpm dlx projen".'
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1033
|
+
});
|
|
1034
|
+
|
|
795
1035
|
// src/adapter/adapter.mts
|
|
1036
|
+
var import_debug2 = __toESM(require_src(), 1);
|
|
796
1037
|
import { join as join3 } from "node:path";
|
|
797
|
-
import { fileURLToPath } from "node:url";
|
|
1038
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
798
1039
|
|
|
799
1040
|
// src/adapter/build-outputs.ts
|
|
800
1041
|
import { existsSync, lstatSync, realpathSync } from "node:fs";
|
|
@@ -809,6 +1050,7 @@ import {
|
|
|
809
1050
|
} from "node:fs/promises";
|
|
810
1051
|
import { createRequire } from "node:module";
|
|
811
1052
|
import { dirname, join, relative, resolve, sep as sep2 } from "node:path";
|
|
1053
|
+
import { fileURLToPath } from "node:url";
|
|
812
1054
|
|
|
813
1055
|
// src/adapter/cache-utils.ts
|
|
814
1056
|
import { createHash } from "node:crypto";
|
|
@@ -970,7 +1212,6 @@ function headerTags(value) {
|
|
|
970
1212
|
var INIT_CACHE_TAG_MANIFEST = "_cdk-nextjs-tag-manifest.json";
|
|
971
1213
|
|
|
972
1214
|
// src/runtime/manifest.ts
|
|
973
|
-
var ADAPTER_MANIFEST_VERSION = 1;
|
|
974
1215
|
var ADAPTER_DIR_NAME = "cdk-nextjs-adapter";
|
|
975
1216
|
var STAGING_DIR_NAME = "app";
|
|
976
1217
|
var GROUPS_DIR_NAME = "groups";
|
|
@@ -1685,6 +1926,9 @@ function withBasePath(path, basePath) {
|
|
|
1685
1926
|
return path === "/" ? basePath || "/" : `${basePath}${path}`;
|
|
1686
1927
|
}
|
|
1687
1928
|
|
|
1929
|
+
// src/cdk-nextjs-version.ts
|
|
1930
|
+
var CDK_NEXTJS_VERSION = require_package().version;
|
|
1931
|
+
|
|
1688
1932
|
// src/utils/deployment-build-id.ts
|
|
1689
1933
|
function deploymentBuildId(manifest) {
|
|
1690
1934
|
const { deploymentId } = manifest.config;
|
|
@@ -1697,11 +1941,7 @@ var RUNTIME_NEXT_MODULES = [
|
|
|
1697
1941
|
"next/dist/server/serve-static.js",
|
|
1698
1942
|
"next/dist/server/lib/router-utils/instrumentation-globals.external.js"
|
|
1699
1943
|
];
|
|
1700
|
-
var IMAGE_NEXT_MODULES = [
|
|
1701
|
-
"next/dist/server/config-shared.js",
|
|
1702
|
-
"next/dist/shared/lib/image-config.js",
|
|
1703
|
-
"next/dist/server/image-optimizer.js"
|
|
1704
|
-
];
|
|
1944
|
+
var IMAGE_NEXT_MODULES = ["next/dist/server/image-optimizer.js"];
|
|
1705
1945
|
var NEXT_FILE_TRACER = "next/dist/compiled/@vercel/nft";
|
|
1706
1946
|
async function writeBuildOutputs(ctx, options = {}) {
|
|
1707
1947
|
const adapterDir = join(ctx.distDir, ADAPTER_DIR_NAME);
|
|
@@ -1800,7 +2040,7 @@ function buildAdapterManifest(ctx, options = {}) {
|
|
|
1800
2040
|
}
|
|
1801
2041
|
) : void 0;
|
|
1802
2042
|
const manifest = {
|
|
1803
|
-
|
|
2043
|
+
cdkNextjsVersion: CDK_NEXTJS_VERSION,
|
|
1804
2044
|
buildId: ctx.buildId,
|
|
1805
2045
|
relativeProjectDir: toPosix(relative(repoRoot, ctx.projectDir)),
|
|
1806
2046
|
config: {
|
|
@@ -1814,7 +2054,11 @@ function buildAdapterManifest(ctx, options = {}) {
|
|
|
1814
2054
|
deploymentId: (ctx.config.deploymentId ?? "").replace(
|
|
1815
2055
|
/[^A-Za-z0-9_-]/g,
|
|
1816
2056
|
"-"
|
|
1817
|
-
)
|
|
2057
|
+
),
|
|
2058
|
+
images: ctx.config.images,
|
|
2059
|
+
experimental: JSON.parse(JSON.stringify(ctx.config.experimental ?? {})),
|
|
2060
|
+
cacheHandler: distRelativeCacheHandler(ctx),
|
|
2061
|
+
cacheMaxMemorySize: ctx.config.cacheMaxMemorySize
|
|
1818
2062
|
},
|
|
1819
2063
|
routing: ctx.routing,
|
|
1820
2064
|
pathnames,
|
|
@@ -2090,6 +2334,12 @@ function buildMiddleware(repoRoot, middleware) {
|
|
|
2090
2334
|
filePath: toPosix(relative(repoRoot, middleware.filePath))
|
|
2091
2335
|
};
|
|
2092
2336
|
}
|
|
2337
|
+
function distRelativeCacheHandler(ctx) {
|
|
2338
|
+
const { cacheHandler } = ctx.config;
|
|
2339
|
+
if (!cacheHandler) return null;
|
|
2340
|
+
const path = cacheHandler.startsWith("file://") ? fileURLToPath(cacheHandler) : cacheHandler;
|
|
2341
|
+
return toPosix(relative(ctx.distDir, resolve(ctx.projectDir, path)));
|
|
2342
|
+
}
|
|
2093
2343
|
var STAGING_CONCURRENCY = 32;
|
|
2094
2344
|
async function stageFiles(staging, stagingDir) {
|
|
2095
2345
|
const planned = [...staging];
|
|
@@ -2228,20 +2478,23 @@ import { existsSync as existsSync2 } from "node:fs";
|
|
|
2228
2478
|
import { mkdir as mkdir2, readFile, writeFile as writeFile2 } from "node:fs/promises";
|
|
2229
2479
|
import { createRequire as createRequire2 } from "node:module";
|
|
2230
2480
|
import { dirname as dirname2, join as join2 } from "node:path";
|
|
2231
|
-
import { CachedRouteKind as CachedRouteKind2 } from "next/dist/server/response-cache/index.js";
|
|
2232
2481
|
|
|
2233
2482
|
// src/adapter/cache-kinds.ts
|
|
2234
|
-
|
|
2483
|
+
var CACHED_ROUTE_KIND = {
|
|
2484
|
+
APP_PAGE: "APP_PAGE",
|
|
2485
|
+
APP_ROUTE: "APP_ROUTE",
|
|
2486
|
+
PAGES: "PAGES"
|
|
2487
|
+
};
|
|
2235
2488
|
function cacheKindResolver(outputs) {
|
|
2236
2489
|
const kindById = /* @__PURE__ */ new Map();
|
|
2237
2490
|
for (const { id } of outputs.pages) {
|
|
2238
|
-
kindById.set(id,
|
|
2491
|
+
kindById.set(id, CACHED_ROUTE_KIND.PAGES);
|
|
2239
2492
|
}
|
|
2240
2493
|
for (const { id } of outputs.appPages) {
|
|
2241
|
-
kindById.set(id,
|
|
2494
|
+
kindById.set(id, CACHED_ROUTE_KIND.APP_PAGE);
|
|
2242
2495
|
}
|
|
2243
2496
|
for (const { id } of outputs.appRoutes) {
|
|
2244
|
-
kindById.set(id,
|
|
2497
|
+
kindById.set(id, CACHED_ROUTE_KIND.APP_ROUTE);
|
|
2245
2498
|
}
|
|
2246
2499
|
return (variants) => {
|
|
2247
2500
|
const source = variants.html ?? variants.rsc ?? variants.data ?? variants.segments[0];
|
|
@@ -2279,7 +2532,7 @@ async function writeInitCache(ctx, cacheDir) {
|
|
|
2279
2532
|
continue;
|
|
2280
2533
|
}
|
|
2281
2534
|
let cacheEntry;
|
|
2282
|
-
if (kind ===
|
|
2535
|
+
if (kind === CACHED_ROUTE_KIND.APP_PAGE) {
|
|
2283
2536
|
const html = (await readPrerender(htmlPrerender))?.toString();
|
|
2284
2537
|
if (!html) {
|
|
2285
2538
|
debug(`SKIP: No HTML content for APP_PAGE ${basePath}`);
|
|
@@ -2293,7 +2546,7 @@ async function writeInitCache(ctx, cacheDir) {
|
|
|
2293
2546
|
cacheEntry = {
|
|
2294
2547
|
lastModified: Date.now(),
|
|
2295
2548
|
value: {
|
|
2296
|
-
kind:
|
|
2549
|
+
kind: CACHED_ROUTE_KIND.APP_PAGE,
|
|
2297
2550
|
html,
|
|
2298
2551
|
rscData,
|
|
2299
2552
|
headers,
|
|
@@ -2305,7 +2558,7 @@ async function writeInitCache(ctx, cacheDir) {
|
|
|
2305
2558
|
status: htmlPrerender?.fallback?.initialStatus
|
|
2306
2559
|
}
|
|
2307
2560
|
};
|
|
2308
|
-
} else if (kind ===
|
|
2561
|
+
} else if (kind === CACHED_ROUTE_KIND.APP_ROUTE) {
|
|
2309
2562
|
const body = await readPrerender(htmlPrerender);
|
|
2310
2563
|
if (!body) {
|
|
2311
2564
|
debug(`SKIP: No body content for APP_ROUTE ${basePath}`);
|
|
@@ -2315,13 +2568,13 @@ async function writeInitCache(ctx, cacheDir) {
|
|
|
2315
2568
|
cacheEntry = {
|
|
2316
2569
|
lastModified: Date.now(),
|
|
2317
2570
|
value: {
|
|
2318
|
-
kind:
|
|
2571
|
+
kind: CACHED_ROUTE_KIND.APP_ROUTE,
|
|
2319
2572
|
body,
|
|
2320
2573
|
headers,
|
|
2321
2574
|
status: htmlPrerender?.fallback?.initialStatus || 200
|
|
2322
2575
|
}
|
|
2323
2576
|
};
|
|
2324
|
-
} else if (kind ===
|
|
2577
|
+
} else if (kind === CACHED_ROUTE_KIND.PAGES) {
|
|
2325
2578
|
const initialStatus = htmlPrerender?.fallback?.initialStatus;
|
|
2326
2579
|
if (initialStatus !== void 0 && initialStatus !== 200) {
|
|
2327
2580
|
debug(
|
|
@@ -2338,7 +2591,7 @@ async function writeInitCache(ctx, cacheDir) {
|
|
|
2338
2591
|
cacheEntry = {
|
|
2339
2592
|
lastModified: Date.now(),
|
|
2340
2593
|
value: {
|
|
2341
|
-
kind:
|
|
2594
|
+
kind: CACHED_ROUTE_KIND.PAGES,
|
|
2342
2595
|
html,
|
|
2343
2596
|
pageData: pageDataJson ? JSON.parse(pageDataJson) : {},
|
|
2344
2597
|
// Both `undefined`, which is what `FileSystemCache` hands back for
|
|
@@ -2418,7 +2671,6 @@ async function getSegmentData(segmentPrerenders) {
|
|
|
2418
2671
|
}
|
|
2419
2672
|
|
|
2420
2673
|
// src/adapter/adapter.mts
|
|
2421
|
-
var import_debug2 = __toESM(require_src(), 1);
|
|
2422
2674
|
var debug2 = (0, import_debug2.default)("cdk-nextjs:adapter");
|
|
2423
2675
|
var adapter = {
|
|
2424
2676
|
name: "cdk-nextjs-adapter",
|
|
@@ -2433,7 +2685,7 @@ var adapter = {
|
|
|
2433
2685
|
// says as much itself, immediately above the `onBuildComplete` call:
|
|
2434
2686
|
// "in the future `output: standalone` might not be allowed if an adapter
|
|
2435
2687
|
// with `onBuildComplete` is configured."
|
|
2436
|
-
cacheHandler: config.cacheHandler ? config.cacheHandler :
|
|
2688
|
+
cacheHandler: config.cacheHandler ? config.cacheHandler : fileURLToPath2(import.meta.resolve("cdk-nextjs/cache-handler")),
|
|
2437
2689
|
cacheHandlers: useCacheHandlers(config.cacheHandlers),
|
|
2438
2690
|
images: {
|
|
2439
2691
|
...config.images,
|
|
@@ -2482,8 +2734,8 @@ function assertSupportedNextVersion(nextVersion) {
|
|
|
2482
2734
|
function useCacheHandlers(configured) {
|
|
2483
2735
|
return {
|
|
2484
2736
|
...configured,
|
|
2485
|
-
default: configured?.default ||
|
|
2486
|
-
remote: configured?.remote ||
|
|
2737
|
+
default: configured?.default || fileURLToPath2(import.meta.resolve("cdk-nextjs/cache-handlers/default")),
|
|
2738
|
+
remote: configured?.remote || fileURLToPath2(import.meta.resolve("cdk-nextjs/cache-handlers/remote"))
|
|
2487
2739
|
};
|
|
2488
2740
|
}
|
|
2489
2741
|
export {
|