cdk-nextjs 0.7.10 → 0.7.12
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 +76 -22
- package/.jsii.tabl.json +1 -1
- package/API.md +59 -3
- package/README.md +2 -2
- package/docs/breaking-changes.md +32 -0
- package/docs/harness-coverage.md +1 -1
- package/docs/next-build-output-guide.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.d.ts +74 -5
- package/lib/nextjs-static-assets.js +276 -41
- package/lib/nextjs-static-assets.test.js +286 -1
- package/lib/root-constructs/nextjs-base-construct.d.ts +5 -4
- package/lib/root-constructs/nextjs-base-construct.js +17 -8
- 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-utils.d.ts +1 -0
- package/lib/runtime/image-utils.js +2 -1
- package/lib/runtime/image-utils.test.js +17 -1
- package/lib/runtime/image.js +47 -33
- package/lib/runtime/image.test.js +47 -26
- package/lib/runtime/lambda.mjs +281 -37
- package/lib/runtime/manifest.d.ts +34 -8
- package/lib/runtime/manifest.js +7 -5
- package/lib/runtime/server.mjs +281 -37
- package/package.json +1 -1
- package/scripts/capture-adapter-fixture.mjs +13 -1
- package/scripts/zero-config-build.mjs +5 -1
package/lib/runtime/server.mjs
CHANGED
|
@@ -25416,7 +25416,7 @@ var require_dist_cjs13 = __commonJS({
|
|
|
25416
25416
|
"node_modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.972.78/node_modules/@aws-sdk/credential-provider-web-identity/dist-cjs/index.js"(exports) {
|
|
25417
25417
|
var { setCredentialFeature: setCredentialFeature2 } = (init_client3(), __toCommonJS(client_exports2));
|
|
25418
25418
|
var { CredentialsProviderError: CredentialsProviderError2, externalDataInterceptor: externalDataInterceptor2 } = (init_config2(), __toCommonJS(config_exports));
|
|
25419
|
-
var { readFileSync:
|
|
25419
|
+
var { readFileSync: readFileSync2 } = __require("node:fs");
|
|
25420
25420
|
var fromWebToken = (init) => async (awsIdentityProperties) => {
|
|
25421
25421
|
init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromWebToken");
|
|
25422
25422
|
const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy, durationSeconds } = init;
|
|
@@ -25457,7 +25457,7 @@ var require_dist_cjs13 = __commonJS({
|
|
|
25457
25457
|
}
|
|
25458
25458
|
const credentials = await fromWebToken({
|
|
25459
25459
|
...init,
|
|
25460
|
-
webIdentityToken: externalDataInterceptor2?.getTokenRecord?.()[webIdentityTokenFile] ??
|
|
25460
|
+
webIdentityToken: externalDataInterceptor2?.getTokenRecord?.()[webIdentityTokenFile] ?? readFileSync2(webIdentityTokenFile, { encoding: "ascii" }),
|
|
25461
25461
|
roleArn,
|
|
25462
25462
|
roleSessionName
|
|
25463
25463
|
})(awsIdentityProperties);
|
|
@@ -35918,7 +35918,7 @@ var require_dist = __commonJS({
|
|
|
35918
35918
|
if (typeof e5 !== "undefined") e5.ab = __dirname + "/";
|
|
35919
35919
|
var t = {};
|
|
35920
35920
|
e5.r(t);
|
|
35921
|
-
e5.d(t, { detectDomainLocale: () => detectDomainLocale2, detectLocale: () => detectLocale2, getAcceptLanguageLocale: () => getAcceptLanguageLocale, getCookieLocale: () => getCookieLocale, normalizeLocalePath: () =>
|
|
35921
|
+
e5.d(t, { detectDomainLocale: () => detectDomainLocale2, detectLocale: () => detectLocale2, getAcceptLanguageLocale: () => getAcceptLanguageLocale, getCookieLocale: () => getCookieLocale, normalizeLocalePath: () => normalizeLocalePath2, resolveRoutes: () => resolveRoutes2, responseToMiddlewareResult: () => responseToMiddlewareResult2 });
|
|
35922
35922
|
function matchesCondition(e6, t8) {
|
|
35923
35923
|
if (e6 === void 0) {
|
|
35924
35924
|
return { matched: false };
|
|
@@ -36117,7 +36117,7 @@ var require_dist = __commonJS({
|
|
|
36117
36117
|
}
|
|
36118
36118
|
return void 0;
|
|
36119
36119
|
}
|
|
36120
|
-
function
|
|
36120
|
+
function normalizeLocalePath2(e6, t8) {
|
|
36121
36121
|
if (!t8 || t8.length === 0) {
|
|
36122
36122
|
return { pathname: e6 };
|
|
36123
36123
|
}
|
|
@@ -36201,7 +36201,7 @@ var require_dist = __commonJS({
|
|
|
36201
36201
|
}
|
|
36202
36202
|
function detectLocale2(e6) {
|
|
36203
36203
|
const { pathname: t8, hostname: n4, cookieHeader: a5, acceptLanguageHeader: s2, i18n: r5 } = e6;
|
|
36204
|
-
const o3 =
|
|
36204
|
+
const o3 = normalizeLocalePath2(t8, r5.locales);
|
|
36205
36205
|
if (o3.detectedLocale) {
|
|
36206
36206
|
return { locale: o3.detectedLocale, pathnameWithoutLocale: o3.pathname, localeInPath: true };
|
|
36207
36207
|
}
|
|
@@ -36486,7 +36486,7 @@ var require_dist = __commonJS({
|
|
|
36486
36486
|
const t9 = f5.hostname;
|
|
36487
36487
|
const a6 = h5.get("cookie") || void 0;
|
|
36488
36488
|
const s4 = h5.get("accept-language") || void 0;
|
|
36489
|
-
const r6 =
|
|
36489
|
+
const r6 = normalizeLocalePath2(e7, l3.locales);
|
|
36490
36490
|
const o4 = !!r6.detectedLocale;
|
|
36491
36491
|
const i6 = detectDomainLocale2(l3.domains, t9);
|
|
36492
36492
|
const c6 = i6?.defaultLocale || l3.defaultLocale;
|
|
@@ -36877,9 +36877,249 @@ var require_dist = __commonJS({
|
|
|
36877
36877
|
}
|
|
36878
36878
|
});
|
|
36879
36879
|
|
|
36880
|
+
// package.json
|
|
36881
|
+
var require_package = __commonJS({
|
|
36882
|
+
"package.json"(exports, module) {
|
|
36883
|
+
module.exports = {
|
|
36884
|
+
name: "cdk-nextjs",
|
|
36885
|
+
description: "Deploy Next.js apps on AWS with CDK",
|
|
36886
|
+
repository: {
|
|
36887
|
+
type: "git",
|
|
36888
|
+
url: "https://github.com/cdklabs/cdk-nextjs.git"
|
|
36889
|
+
},
|
|
36890
|
+
scripts: {
|
|
36891
|
+
build: "pnpm dlx projen build",
|
|
36892
|
+
bump: "pnpm dlx projen bump",
|
|
36893
|
+
"bump:releasable-commits": "pnpm dlx projen bump:releasable-commits",
|
|
36894
|
+
bundle: "pnpm dlx projen bundle",
|
|
36895
|
+
"bundle:adapter/adapter": "pnpm dlx projen bundle:adapter/adapter",
|
|
36896
|
+
"bundle:adapter/adapter:watch": "pnpm dlx projen bundle:adapter/adapter:watch",
|
|
36897
|
+
"bundle:adapter/cache-handler": "pnpm dlx projen bundle:adapter/cache-handler",
|
|
36898
|
+
"bundle:adapter/cache-handler:watch": "pnpm dlx projen bundle:adapter/cache-handler:watch",
|
|
36899
|
+
"bundle:adapter/use-cache-default-handler": "pnpm dlx projen bundle:adapter/use-cache-default-handler",
|
|
36900
|
+
"bundle:adapter/use-cache-default-handler:watch": "pnpm dlx projen bundle:adapter/use-cache-default-handler:watch",
|
|
36901
|
+
"bundle:adapter/use-cache-remote-handler": "pnpm dlx projen bundle:adapter/use-cache-remote-handler",
|
|
36902
|
+
"bundle:adapter/use-cache-remote-handler:watch": "pnpm dlx projen bundle:adapter/use-cache-remote-handler:watch",
|
|
36903
|
+
"bundle:lambdas/post-deploy/post-deploy.lambda": "pnpm dlx projen bundle:lambdas/post-deploy/post-deploy.lambda",
|
|
36904
|
+
"bundle:lambdas/post-deploy/post-deploy.lambda:watch": "pnpm dlx projen bundle:lambdas/post-deploy/post-deploy.lambda:watch",
|
|
36905
|
+
"bundle:lambdas/redeploy-stage/redeploy-stage.lambda": "pnpm dlx projen bundle:lambdas/redeploy-stage/redeploy-stage.lambda",
|
|
36906
|
+
"bundle:lambdas/redeploy-stage/redeploy-stage.lambda:watch": "pnpm dlx projen bundle:lambdas/redeploy-stage/redeploy-stage.lambda:watch",
|
|
36907
|
+
"bundle:nextjs-build/patch-fetch": "pnpm dlx projen bundle:nextjs-build/patch-fetch",
|
|
36908
|
+
"bundle:nextjs-build/patch-fetch:watch": "pnpm dlx projen bundle:nextjs-build/patch-fetch:watch",
|
|
36909
|
+
"bundle:runtime/lambda": "pnpm dlx projen bundle:runtime/lambda",
|
|
36910
|
+
"bundle:runtime/lambda:watch": "pnpm dlx projen bundle:runtime/lambda:watch",
|
|
36911
|
+
"bundle:runtime/server": "pnpm dlx projen bundle:runtime/server",
|
|
36912
|
+
"bundle:runtime/server:watch": "pnpm dlx projen bundle:runtime/server:watch",
|
|
36913
|
+
clobber: "pnpm dlx projen clobber",
|
|
36914
|
+
compat: "pnpm dlx projen compat",
|
|
36915
|
+
compile: "pnpm dlx projen compile",
|
|
36916
|
+
default: "pnpm dlx projen default",
|
|
36917
|
+
docgen: "pnpm dlx projen docgen",
|
|
36918
|
+
eject: "pnpm dlx projen eject",
|
|
36919
|
+
eslint: "pnpm dlx projen eslint",
|
|
36920
|
+
integ: "pnpm dlx projen integ",
|
|
36921
|
+
"integ:update": "pnpm dlx projen integ:update",
|
|
36922
|
+
package: "pnpm dlx projen package",
|
|
36923
|
+
"package-all": "pnpm dlx projen package-all",
|
|
36924
|
+
"package:js": "pnpm dlx projen package:js",
|
|
36925
|
+
"post-compile": "pnpm dlx projen post-compile",
|
|
36926
|
+
"post-upgrade": "pnpm dlx projen post-upgrade",
|
|
36927
|
+
"pre-compile": "pnpm dlx projen pre-compile",
|
|
36928
|
+
release: "pnpm dlx projen release",
|
|
36929
|
+
"rosetta:extract": "pnpm dlx projen rosetta:extract",
|
|
36930
|
+
test: "pnpm dlx projen test",
|
|
36931
|
+
"test:watch": "pnpm dlx projen test:watch",
|
|
36932
|
+
unbump: "pnpm dlx projen unbump",
|
|
36933
|
+
upgrade: "pnpm dlx projen upgrade",
|
|
36934
|
+
"upgrade-cdklabs-projen-project-types": "pnpm dlx projen upgrade-cdklabs-projen-project-types",
|
|
36935
|
+
"upgrade-dev-deps": "pnpm dlx projen upgrade-dev-deps",
|
|
36936
|
+
watch: "pnpm dlx projen watch",
|
|
36937
|
+
projen: "pnpm dlx projen"
|
|
36938
|
+
},
|
|
36939
|
+
author: {
|
|
36940
|
+
name: "Amazon Web Services",
|
|
36941
|
+
email: "aws-cdk-dev@amazon.com",
|
|
36942
|
+
organization: true
|
|
36943
|
+
},
|
|
36944
|
+
devDependencies: {
|
|
36945
|
+
"@aws-cdk/integ-runner": "latest",
|
|
36946
|
+
"@aws-cdk/integ-tests-alpha": "latest",
|
|
36947
|
+
"@aws-crypto/sha256-js": "^5.2.0",
|
|
36948
|
+
"@aws-sdk/client-api-gateway": "^3.1141.0",
|
|
36949
|
+
"@aws-sdk/client-cloudfront": "^3.1141.0",
|
|
36950
|
+
"@aws-sdk/client-dynamodb": "^3.1141.0",
|
|
36951
|
+
"@aws-sdk/client-s3": "^3.1141.0",
|
|
36952
|
+
"@aws-sdk/client-ssm": "^3.1141.0",
|
|
36953
|
+
"@aws-sdk/lib-storage": "^3.1141.0",
|
|
36954
|
+
"@mrgrain/jsii-struct-builder": "^0.7.64",
|
|
36955
|
+
"@next/routing": "16.4.0",
|
|
36956
|
+
"@smithy/signature-v4": "^2.3.0",
|
|
36957
|
+
"@types/aws-lambda": "^8.10.163",
|
|
36958
|
+
"@types/debug": "^4.1.13",
|
|
36959
|
+
"@types/jest": "^29.5.14",
|
|
36960
|
+
"@types/mime-types": "^2.1.4",
|
|
36961
|
+
"@types/node": "^24",
|
|
36962
|
+
"@typescript-eslint/eslint-plugin": "^8",
|
|
36963
|
+
"@typescript-eslint/parser": "^8",
|
|
36964
|
+
"aws-cdk": "^2.1143.0",
|
|
36965
|
+
"aws-cdk-lib": "2.261.0",
|
|
36966
|
+
"cdk-nag": "^2.38.2",
|
|
36967
|
+
"cdklabs-projen-project-types": "^0.6.17",
|
|
36968
|
+
"commit-and-tag-version": "^12",
|
|
36969
|
+
constructs: "10.5.1",
|
|
36970
|
+
debug: "^4.4.3",
|
|
36971
|
+
esbuild: "^0.28.2",
|
|
36972
|
+
eslint: "^9",
|
|
36973
|
+
"eslint-config-prettier": "^9.1.2",
|
|
36974
|
+
"eslint-import-resolver-typescript": "^3.10.1",
|
|
36975
|
+
"eslint-plugin-import": "^2.32.0",
|
|
36976
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
36977
|
+
jest: "^29.7.0",
|
|
36978
|
+
"jest-junit": "^17",
|
|
36979
|
+
jsii: "~6.0.4",
|
|
36980
|
+
"jsii-diff": "^1.140.0",
|
|
36981
|
+
"jsii-docgen": "^10.5.0",
|
|
36982
|
+
"jsii-pacmak": "^1.140.0",
|
|
36983
|
+
"jsii-rosetta": "~5.9.67",
|
|
36984
|
+
"mime-types": "^2.1.35",
|
|
36985
|
+
next: "^16.4.0",
|
|
36986
|
+
prettier: "^3.9.9",
|
|
36987
|
+
projen: "^0.101.6",
|
|
36988
|
+
"ts-jest": "^29.4.14",
|
|
36989
|
+
"ts-node": "^10.9.2",
|
|
36990
|
+
typescript: "^5.9.3",
|
|
36991
|
+
undici: "^6.29.0"
|
|
36992
|
+
},
|
|
36993
|
+
peerDependencies: {
|
|
36994
|
+
"aws-cdk-lib": "^2.261.0",
|
|
36995
|
+
constructs: "^10.5.1"
|
|
36996
|
+
},
|
|
36997
|
+
pnpm: {
|
|
36998
|
+
onlyBuiltDependencies: [
|
|
36999
|
+
"esbuild",
|
|
37000
|
+
"unrs-resolver",
|
|
37001
|
+
"sharp"
|
|
37002
|
+
],
|
|
37003
|
+
overrides: {
|
|
37004
|
+
postcss: "^8.5.23",
|
|
37005
|
+
browserslist: "^4.28.7",
|
|
37006
|
+
"js-yaml@3": "^3.15.1",
|
|
37007
|
+
"js-yaml@4": "^4.3.1",
|
|
37008
|
+
"brace-expansion@1": "^1.1.21",
|
|
37009
|
+
"brace-expansion@5": "^5.0.12",
|
|
37010
|
+
"@babel/core": "^7.29.6",
|
|
37011
|
+
sharp: "^0.35.5",
|
|
37012
|
+
"source-map-js": "^1.2.2"
|
|
37013
|
+
}
|
|
37014
|
+
},
|
|
37015
|
+
keywords: [
|
|
37016
|
+
"aws",
|
|
37017
|
+
"aws-cdk",
|
|
37018
|
+
"cdk",
|
|
37019
|
+
"next",
|
|
37020
|
+
"next.js",
|
|
37021
|
+
"nextjs"
|
|
37022
|
+
],
|
|
37023
|
+
devEngines: {
|
|
37024
|
+
packageManager: {
|
|
37025
|
+
name: "pnpm",
|
|
37026
|
+
version: "10.32.1",
|
|
37027
|
+
onFail: "ignore"
|
|
37028
|
+
}
|
|
37029
|
+
},
|
|
37030
|
+
main: "lib/index.js",
|
|
37031
|
+
license: "Apache-2.0",
|
|
37032
|
+
stability: "stable",
|
|
37033
|
+
publishConfig: {
|
|
37034
|
+
access: "public"
|
|
37035
|
+
},
|
|
37036
|
+
version: "0.7.12",
|
|
37037
|
+
packageManager: "pnpm@10.32.1",
|
|
37038
|
+
jest: {
|
|
37039
|
+
coverageProvider: "v8",
|
|
37040
|
+
testPathIgnorePatterns: [
|
|
37041
|
+
"/node_modules/",
|
|
37042
|
+
"/cdk.out/"
|
|
37043
|
+
],
|
|
37044
|
+
testMatch: [
|
|
37045
|
+
"<rootDir>/@(src|test)/**/*(*.)@(spec|test).ts?(x)",
|
|
37046
|
+
"<rootDir>/@(src|test)/**/__tests__/**/*.ts?(x)",
|
|
37047
|
+
"<rootDir>/@(projenrc)/**/*(*.)@(spec|test).ts?(x)",
|
|
37048
|
+
"<rootDir>/@(projenrc)/**/__tests__/**/*.ts?(x)"
|
|
37049
|
+
],
|
|
37050
|
+
clearMocks: true,
|
|
37051
|
+
collectCoverage: true,
|
|
37052
|
+
coverageReporters: [
|
|
37053
|
+
"json",
|
|
37054
|
+
"lcov",
|
|
37055
|
+
"clover",
|
|
37056
|
+
"cobertura",
|
|
37057
|
+
"text"
|
|
37058
|
+
],
|
|
37059
|
+
coverageDirectory: "coverage",
|
|
37060
|
+
coveragePathIgnorePatterns: [
|
|
37061
|
+
"/node_modules/",
|
|
37062
|
+
"/cdk.out/"
|
|
37063
|
+
],
|
|
37064
|
+
watchPathIgnorePatterns: [
|
|
37065
|
+
"/node_modules/"
|
|
37066
|
+
],
|
|
37067
|
+
reporters: [
|
|
37068
|
+
"default",
|
|
37069
|
+
[
|
|
37070
|
+
"jest-junit",
|
|
37071
|
+
{
|
|
37072
|
+
outputDirectory: "test-reports"
|
|
37073
|
+
}
|
|
37074
|
+
]
|
|
37075
|
+
],
|
|
37076
|
+
transform: {
|
|
37077
|
+
"^.+\\.[t]sx?$": [
|
|
37078
|
+
"ts-jest",
|
|
37079
|
+
{
|
|
37080
|
+
tsconfig: "test/tsconfig.json"
|
|
37081
|
+
}
|
|
37082
|
+
]
|
|
37083
|
+
}
|
|
37084
|
+
},
|
|
37085
|
+
types: "lib/index.d.ts",
|
|
37086
|
+
jsii: {
|
|
37087
|
+
outdir: "dist",
|
|
37088
|
+
targets: {},
|
|
37089
|
+
tsconfig: "tsconfig.json",
|
|
37090
|
+
validateTsconfig: "strict"
|
|
37091
|
+
},
|
|
37092
|
+
exports: {
|
|
37093
|
+
".": {
|
|
37094
|
+
types: "./lib/index.d.ts",
|
|
37095
|
+
import: "./lib/index.js",
|
|
37096
|
+
default: "./lib/index.js"
|
|
37097
|
+
},
|
|
37098
|
+
"./adapter": {
|
|
37099
|
+
import: "./lib/adapter/adapter.mjs",
|
|
37100
|
+
default: "./lib/adapter/adapter.mjs"
|
|
37101
|
+
},
|
|
37102
|
+
"./cache-handler": {
|
|
37103
|
+
import: "./lib/adapter/cache-handler.mjs",
|
|
37104
|
+
default: "./lib/adapter/cache-handler.mjs"
|
|
37105
|
+
},
|
|
37106
|
+
"./cache-handlers/default": {
|
|
37107
|
+
import: "./lib/adapter/use-cache-default-handler.mjs",
|
|
37108
|
+
default: "./lib/adapter/use-cache-default-handler.mjs"
|
|
37109
|
+
},
|
|
37110
|
+
"./cache-handlers/remote": {
|
|
37111
|
+
import: "./lib/adapter/use-cache-remote-handler.mjs",
|
|
37112
|
+
default: "./lib/adapter/use-cache-remote-handler.mjs"
|
|
37113
|
+
}
|
|
37114
|
+
},
|
|
37115
|
+
"//": '~~ Generated by projen. To modify, edit .projenrc.ts and run "pnpm dlx projen".'
|
|
37116
|
+
};
|
|
37117
|
+
}
|
|
37118
|
+
});
|
|
37119
|
+
|
|
36880
37120
|
// src/runtime/server.mts
|
|
36881
37121
|
import { dirname as dirname2 } from "node:path";
|
|
36882
|
-
import { fileURLToPath
|
|
37122
|
+
import { fileURLToPath } from "node:url";
|
|
36883
37123
|
|
|
36884
37124
|
// src/runtime/core.ts
|
|
36885
37125
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
@@ -37547,8 +37787,7 @@ function requestLocale(manifest, url) {
|
|
|
37547
37787
|
const i18n = asI18n(manifest.config.i18n);
|
|
37548
37788
|
if (!i18n) return void 0;
|
|
37549
37789
|
const pathname = withoutPathPrefix(url.pathname, manifest.config.basePath);
|
|
37550
|
-
|
|
37551
|
-
return i18n.locales.find((candidate) => candidate.toLowerCase() === segment) ?? (0, import_routing.detectDomainLocale)(i18n.domains, url.hostname)?.defaultLocale ?? i18n.defaultLocale;
|
|
37790
|
+
return (0, import_routing.normalizeLocalePath)(pathname, i18n.locales).detectedLocale ?? (0, import_routing.detectDomainLocale)(i18n.domains, url.hostname)?.defaultLocale ?? i18n.defaultLocale;
|
|
37552
37791
|
}
|
|
37553
37792
|
|
|
37554
37793
|
// src/runtime/entrypoints.ts
|
|
@@ -38032,9 +38271,8 @@ function padEmptyBody() {
|
|
|
38032
38271
|
}
|
|
38033
38272
|
|
|
38034
38273
|
// src/runtime/image.ts
|
|
38035
|
-
import { readFileSync as readFileSync2 } from "node:fs";
|
|
38036
38274
|
import { isAbsolute as isAbsolutePath, join as join9 } from "node:path";
|
|
38037
|
-
import {
|
|
38275
|
+
import { pathToFileURL } from "node:url";
|
|
38038
38276
|
|
|
38039
38277
|
// src/runtime/image-utils.ts
|
|
38040
38278
|
var import_client_s32 = __toESM(require_dist_cjs16());
|
|
@@ -38072,6 +38310,7 @@ async function fetchFromS3(s32, bucket, url, location, maximumBody) {
|
|
|
38072
38310
|
return {
|
|
38073
38311
|
buffer: Buffer.concat(chunks),
|
|
38074
38312
|
contentType: response.ContentType || null,
|
|
38313
|
+
cacheControl: response.CacheControl || null,
|
|
38075
38314
|
etag: response.ETag || ""
|
|
38076
38315
|
};
|
|
38077
38316
|
}
|
|
@@ -38105,6 +38344,9 @@ function resolveErrorResponse(error2, ImageError) {
|
|
|
38105
38344
|
return { statusCode: 500, message: "Internal Server Error" };
|
|
38106
38345
|
}
|
|
38107
38346
|
|
|
38347
|
+
// src/cdk-nextjs-version.ts
|
|
38348
|
+
var CDK_NEXTJS_VERSION = require_package().version;
|
|
38349
|
+
|
|
38108
38350
|
// src/runtime/next-modules.ts
|
|
38109
38351
|
import { createRequire as createRequire2 } from "node:module";
|
|
38110
38352
|
import { join as join8 } from "node:path";
|
|
@@ -38164,13 +38406,13 @@ var RuntimeImageOptimizer = class {
|
|
|
38164
38406
|
* off.
|
|
38165
38407
|
*/
|
|
38166
38408
|
isEnabled() {
|
|
38167
|
-
|
|
38168
|
-
|
|
38169
|
-
return imagesConfig.loader === "default" && !imagesConfig.unoptimized;
|
|
38409
|
+
const images = manifestImages(this.options.manifest);
|
|
38410
|
+
return images.loader === "default" && !images.unoptimized;
|
|
38170
38411
|
}
|
|
38171
38412
|
async handle(req, res, url, waitUntil) {
|
|
38172
38413
|
this.loaded ??= loadImageRuntime(this.options);
|
|
38173
|
-
const { next, nextConfig
|
|
38414
|
+
const { next, nextConfig } = this.loaded;
|
|
38415
|
+
const imagesConfig = nextConfig.images;
|
|
38174
38416
|
const {
|
|
38175
38417
|
ImageError,
|
|
38176
38418
|
ImageOptimizerCache,
|
|
@@ -38320,7 +38562,10 @@ var RuntimeImageOptimizer = class {
|
|
|
38320
38562
|
return {
|
|
38321
38563
|
buffer: result.buffer,
|
|
38322
38564
|
contentType: result.contentType,
|
|
38323
|
-
|
|
38565
|
+
// The object's own, as `fetchInternalImage` passes on the file's
|
|
38566
|
+
// `Cache-Control`: the optimizer keeps the result for its max-age, a
|
|
38567
|
+
// year for an immutable `_next/static/media` file.
|
|
38568
|
+
cacheControl: result.cacheControl,
|
|
38324
38569
|
// Encoded as for a route's response: `fetchInternalImage` does too.
|
|
38325
38570
|
etag: extractEtag(result.etag, result.buffer)
|
|
38326
38571
|
};
|
|
@@ -38405,9 +38650,8 @@ function newImageResponseCache(ResponseCache) {
|
|
|
38405
38650
|
}
|
|
38406
38651
|
}
|
|
38407
38652
|
function cacheHandlerUrl(distDir, cacheHandler) {
|
|
38408
|
-
const path = cacheHandler.startsWith("file://") ? fileURLToPath(cacheHandler) : cacheHandler;
|
|
38409
38653
|
return pathToFileURL(
|
|
38410
|
-
isAbsolutePath(
|
|
38654
|
+
isAbsolutePath(cacheHandler) ? cacheHandler : join9(distDir, cacheHandler)
|
|
38411
38655
|
).toString();
|
|
38412
38656
|
}
|
|
38413
38657
|
function deferWrites(images, waitUntil) {
|
|
@@ -38427,29 +38671,29 @@ function sendText(res, statusCode, body) {
|
|
|
38427
38671
|
res.setHeader("Content-Type", "text/plain");
|
|
38428
38672
|
res.end(body);
|
|
38429
38673
|
}
|
|
38430
|
-
function
|
|
38674
|
+
function manifestImages(manifest) {
|
|
38675
|
+
if (manifest.cdkNextjsVersion !== CDK_NEXTJS_VERSION) {
|
|
38676
|
+
throw new Error(
|
|
38677
|
+
`The adapter manifest was written by cdk-nextjs ${manifest.cdkNextjsVersion ?? "(unknown)"}, but this runtime is cdk-nextjs ${CDK_NEXTJS_VERSION}. Rebuild the app with this version.`
|
|
38678
|
+
);
|
|
38679
|
+
}
|
|
38680
|
+
return manifest.config.images;
|
|
38681
|
+
}
|
|
38682
|
+
function loadImageRuntime({ manifest }) {
|
|
38431
38683
|
const next = {
|
|
38432
|
-
configShared: nextModule("next/dist/server/config-shared.js"),
|
|
38433
|
-
imageConfig: nextModule("next/dist/shared/lib/image-config.js"),
|
|
38434
38684
|
optimizer: nextModule("next/dist/server/image-optimizer.js"),
|
|
38435
38685
|
serveStatic: nextModule("next/dist/server/serve-static.js")
|
|
38436
38686
|
};
|
|
38437
|
-
const
|
|
38438
|
-
|
|
38439
|
-
|
|
38440
|
-
|
|
38441
|
-
|
|
38442
|
-
|
|
38443
|
-
|
|
38444
|
-
|
|
38445
|
-
return {
|
|
38446
|
-
next,
|
|
38447
|
-
nextConfig,
|
|
38448
|
-
imagesConfig: {
|
|
38449
|
-
...next.imageConfig.imageConfigDefault,
|
|
38450
|
-
...nextConfig.images
|
|
38451
|
-
}
|
|
38687
|
+
const { config } = manifest;
|
|
38688
|
+
const nextConfig = {
|
|
38689
|
+
basePath: config.basePath,
|
|
38690
|
+
assetPrefix: config.assetPrefix,
|
|
38691
|
+
images: manifestImages(manifest),
|
|
38692
|
+
experimental: config.experimental,
|
|
38693
|
+
cacheHandler: config.cacheHandler ?? void 0,
|
|
38694
|
+
cacheMaxMemorySize: config.cacheMaxMemorySize
|
|
38452
38695
|
};
|
|
38696
|
+
return { next, nextConfig };
|
|
38453
38697
|
}
|
|
38454
38698
|
|
|
38455
38699
|
// src/runtime/middleware.ts
|
|
@@ -39702,7 +39946,7 @@ var PORT = Number(process.env.PORT ?? 3e3);
|
|
|
39702
39946
|
var HOSTNAME = process.env.HOSTNAME ?? "0.0.0.0";
|
|
39703
39947
|
async function main() {
|
|
39704
39948
|
const runtime = await loadRuntime(
|
|
39705
|
-
deploymentRootOf(dirname2(
|
|
39949
|
+
deploymentRootOf(dirname2(fileURLToPath(import.meta.url)))
|
|
39706
39950
|
);
|
|
39707
39951
|
const { server, shutdown } = createRuntimeServer(runtime, {
|
|
39708
39952
|
trustCloudFrontProto: process.env.CDK_NEXTJS_TRUST_CLOUDFRONT_PROTO === "1"
|
package/package.json
CHANGED
|
@@ -173,6 +173,10 @@ const __captureAdapter = {
|
|
|
173
173
|
trailingSlash: config.trailingSlash,
|
|
174
174
|
assetPrefix: config.assetPrefix,
|
|
175
175
|
i18n: config.i18n,
|
|
176
|
+
images: config.images,
|
|
177
|
+
experimental: config.experimental,
|
|
178
|
+
cacheHandler: config.cacheHandler,
|
|
179
|
+
cacheMaxMemorySize: config.cacheMaxMemorySize,
|
|
176
180
|
},
|
|
177
181
|
}),
|
|
178
182
|
);
|
|
@@ -308,7 +312,15 @@ function trim(raw, { app, name }) {
|
|
|
308
312
|
distDir: rewrite(raw.distDir),
|
|
309
313
|
nextVersion: raw.nextVersion,
|
|
310
314
|
buildId: raw.buildId,
|
|
311
|
-
|
|
315
|
+
// The adapter's `cacheHandler` and Next's `images.loaderFile` are absolute.
|
|
316
|
+
config: {
|
|
317
|
+
...raw.config,
|
|
318
|
+
cacheHandler: rewrite(raw.config.cacheHandler),
|
|
319
|
+
images: raw.config.images && {
|
|
320
|
+
...raw.config.images,
|
|
321
|
+
loaderFile: rewrite(raw.config.images.loaderFile),
|
|
322
|
+
},
|
|
323
|
+
},
|
|
312
324
|
};
|
|
313
325
|
}
|
|
314
326
|
|
|
@@ -329,7 +329,11 @@ function check(appDir, adapterPath, { label, distDir, buildArgs, forbid }) {
|
|
|
329
329
|
// `output: "standalone"`.
|
|
330
330
|
const adapterDir = join(dist, "cdk-nextjs-adapter");
|
|
331
331
|
const manifest = readJson(join(adapterDir, "manifest.json"));
|
|
332
|
-
|
|
332
|
+
const { version } = readJson(join(repoRoot, "package.json"));
|
|
333
|
+
assert(
|
|
334
|
+
manifest.cdkNextjsVersion === version,
|
|
335
|
+
`manifest stamped cdk-nextjs ${manifest.cdkNextjsVersion}, not ${version}`,
|
|
336
|
+
);
|
|
333
337
|
for (const route of ["/", "/isr/[id]"]) {
|
|
334
338
|
assert(
|
|
335
339
|
manifest.entrypoints[route],
|