@platformatic/next 3.37.0 → 3.38.0
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/config.d.ts +2 -0
- package/index.js +39 -14
- package/lib/caching/valkey-common.js +1 -1
- package/lib/schema.js +20 -0
- package/package.json +5 -5
- package/schema.json +21 -1
package/config.d.ts
CHANGED
|
@@ -650,10 +650,12 @@ export interface PlatformaticNextJsConfig {
|
|
|
650
650
|
useExperimentalAdapter?: boolean;
|
|
651
651
|
};
|
|
652
652
|
cache?: {
|
|
653
|
+
enabled?: boolean | string;
|
|
653
654
|
adapter: "redis" | "valkey";
|
|
654
655
|
url: string;
|
|
655
656
|
prefix?: string;
|
|
656
657
|
cacheComponents?: boolean;
|
|
657
658
|
maxTTL?: number | string;
|
|
659
|
+
ignoreNextConfig?: boolean | string;
|
|
658
660
|
};
|
|
659
661
|
}
|
package/index.js
CHANGED
|
@@ -20,6 +20,43 @@ export function getAdapterPath () {
|
|
|
20
20
|
return resolvePath(import.meta.dirname, 'lib', 'adapter.js')
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
function enhanceNextCacheConfig (nextConfig, modifications) {
|
|
24
|
+
const { config, nextVersion, logger } = globalThis.platformatic
|
|
25
|
+
|
|
26
|
+
if (!config.cache?.adapter || config.cache?.enabled === false) return
|
|
27
|
+
|
|
28
|
+
const existingCacheHandlers = typeof nextConfig.cacheHandler !== 'undefined' || typeof nextConfig.cacheHandlers?.default !== 'undefined'
|
|
29
|
+
if (existingCacheHandlers) {
|
|
30
|
+
if (!config.cache.ignoreNextConfig) {
|
|
31
|
+
return logger.warn('Next.js cache handlers are already defined in next.config.js. Skipping cache configuration.')
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const cacheComponentsConflict = typeof config.cache?.cacheComponents !== 'undefined' && typeof nextConfig.cacheComponents !== 'undefined' && config.cache?.cacheComponents !== nextConfig.cacheComponents
|
|
36
|
+
if (cacheComponentsConflict) {
|
|
37
|
+
if (!config.cache.ignoreNextConfig) {
|
|
38
|
+
return logger.warn('Platformatic and Next.js Cache Components configs are conflicting. Skipping cache configuration.')
|
|
39
|
+
}
|
|
40
|
+
nextConfig.cacheComponents = config.cache?.cacheComponents
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (config.cache?.cacheComponents || nextConfig.cacheComponents) {
|
|
44
|
+
if (nextVersion.major <= 15) {
|
|
45
|
+
return logger.warn('Next.js Cache Components are only supported in Next.js 16 and above. Skipping cache configuration.')
|
|
46
|
+
}
|
|
47
|
+
nextConfig.cacheComponents = true
|
|
48
|
+
nextConfig.cacheHandler = getCacheHandlerPath('null-isr')
|
|
49
|
+
nextConfig.cacheHandlers = { default: getCacheHandlerPath(`${config.cache.adapter}-components`) }
|
|
50
|
+
nextConfig.cacheMaxMemorySize = 0
|
|
51
|
+
modifications.push(['componentsCache', config.cache.adapter])
|
|
52
|
+
} else {
|
|
53
|
+
delete nextConfig.cacheHandlers
|
|
54
|
+
nextConfig.cacheHandler = getCacheHandlerPath(`${config.cache.adapter}-isr`)
|
|
55
|
+
nextConfig.cacheMaxMemorySize = 0
|
|
56
|
+
modifications.push(['isrCache', config.cache.adapter])
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
23
60
|
export async function enhanceNextConfig (nextConfig, ...args) {
|
|
24
61
|
// This is to avoid https://github.com/vercel/next.js/issues/76981
|
|
25
62
|
Headers.prototype[Symbol.for('nodejs.util.inspect.custom')] = undefined
|
|
@@ -28,7 +65,7 @@ export async function enhanceNextConfig (nextConfig, ...args) {
|
|
|
28
65
|
nextConfig = await nextConfig(...args)
|
|
29
66
|
}
|
|
30
67
|
|
|
31
|
-
const { basePath, config
|
|
68
|
+
const { basePath, config } = globalThis.platformatic
|
|
32
69
|
|
|
33
70
|
if (typeof nextConfig.basePath === 'undefined') {
|
|
34
71
|
nextConfig.basePath = basePath
|
|
@@ -36,19 +73,7 @@ export async function enhanceNextConfig (nextConfig, ...args) {
|
|
|
36
73
|
|
|
37
74
|
const modifications = []
|
|
38
75
|
|
|
39
|
-
|
|
40
|
-
if (nextVersion.major > 15 && config.cache?.cacheComponents && typeof nextConfig.cacheComponents === 'undefined') {
|
|
41
|
-
nextConfig.cacheComponents = true
|
|
42
|
-
nextConfig.cacheHandler = getCacheHandlerPath('null-isr')
|
|
43
|
-
nextConfig.cacheHandlers = { default: getCacheHandlerPath(`${config.cache.adapter}-components`) }
|
|
44
|
-
nextConfig.cacheMaxMemorySize = 0
|
|
45
|
-
modifications.push(['componentsCache', config.cache.adapter])
|
|
46
|
-
} else if (typeof nextConfig.cacheHandler === 'undefined') {
|
|
47
|
-
nextConfig.cacheHandler = getCacheHandlerPath(`${config.cache.adapter}-isr`)
|
|
48
|
-
nextConfig.cacheMaxMemorySize = 0
|
|
49
|
-
modifications.push(['isrCache', config.cache.adapter])
|
|
50
|
-
}
|
|
51
|
-
}
|
|
76
|
+
enhanceNextCacheConfig(nextConfig, modifications)
|
|
52
77
|
|
|
53
78
|
if (config.next?.trailingSlash && typeof nextConfig.trailingSlash === 'undefined') {
|
|
54
79
|
nextConfig.trailingSlash = true
|
package/lib/schema.js
CHANGED
|
@@ -9,6 +9,16 @@ export const version = packageJson.version
|
|
|
9
9
|
export const cache = {
|
|
10
10
|
type: 'object',
|
|
11
11
|
properties: {
|
|
12
|
+
enabled: {
|
|
13
|
+
anyOf: [
|
|
14
|
+
{
|
|
15
|
+
type: 'boolean'
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
type: 'string'
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
},
|
|
12
22
|
adapter: {
|
|
13
23
|
type: 'string',
|
|
14
24
|
enum: ['redis', 'valkey']
|
|
@@ -33,6 +43,16 @@ export const cache = {
|
|
|
33
43
|
type: 'string'
|
|
34
44
|
}
|
|
35
45
|
]
|
|
46
|
+
},
|
|
47
|
+
ignoreNextConfig: {
|
|
48
|
+
anyOf: [
|
|
49
|
+
{
|
|
50
|
+
type: 'boolean'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
type: 'string'
|
|
54
|
+
}
|
|
55
|
+
]
|
|
36
56
|
}
|
|
37
57
|
},
|
|
38
58
|
required: ['adapter', 'url'],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/next",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.38.0",
|
|
4
4
|
"description": "Platformatic Next.js Capability",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"iovalkey": "^0.3.0",
|
|
24
24
|
"msgpackr": "^1.11.2",
|
|
25
25
|
"semver": "^7.6.3",
|
|
26
|
-
"@platformatic/basic": "3.
|
|
27
|
-
"@platformatic/foundation": "3.
|
|
26
|
+
"@platformatic/basic": "3.38.0",
|
|
27
|
+
"@platformatic/foundation": "3.38.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@fastify/reply-from": "^12.0.0",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"next": "^16.0.0",
|
|
41
41
|
"typescript": "^5.5.4",
|
|
42
42
|
"ws": "^8.18.0",
|
|
43
|
-
"@platformatic/
|
|
44
|
-
"@platformatic/
|
|
43
|
+
"@platformatic/service": "3.38.0",
|
|
44
|
+
"@platformatic/gateway": "3.38.0"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=22.19.0"
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/next/3.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/next/3.38.0.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Next.js Config",
|
|
5
5
|
"type": "object",
|
|
@@ -2380,6 +2380,16 @@
|
|
|
2380
2380
|
"cache": {
|
|
2381
2381
|
"type": "object",
|
|
2382
2382
|
"properties": {
|
|
2383
|
+
"enabled": {
|
|
2384
|
+
"anyOf": [
|
|
2385
|
+
{
|
|
2386
|
+
"type": "boolean"
|
|
2387
|
+
},
|
|
2388
|
+
{
|
|
2389
|
+
"type": "string"
|
|
2390
|
+
}
|
|
2391
|
+
]
|
|
2392
|
+
},
|
|
2383
2393
|
"adapter": {
|
|
2384
2394
|
"type": "string",
|
|
2385
2395
|
"enum": [
|
|
@@ -2407,6 +2417,16 @@
|
|
|
2407
2417
|
"type": "string"
|
|
2408
2418
|
}
|
|
2409
2419
|
]
|
|
2420
|
+
},
|
|
2421
|
+
"ignoreNextConfig": {
|
|
2422
|
+
"anyOf": [
|
|
2423
|
+
{
|
|
2424
|
+
"type": "boolean"
|
|
2425
|
+
},
|
|
2426
|
+
{
|
|
2427
|
+
"type": "string"
|
|
2428
|
+
}
|
|
2429
|
+
]
|
|
2410
2430
|
}
|
|
2411
2431
|
},
|
|
2412
2432
|
"required": [
|