@platformatic/next 2.44.1 → 2.44.3
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/index.js +18 -1
- package/lib/create-context-patch.js +31 -0
- package/package.json +6 -6
- package/schema.json +1 -1
package/index.js
CHANGED
|
@@ -40,6 +40,13 @@ export class NextStackable extends BaseStackable {
|
|
|
40
40
|
const nextPackage = JSON.parse(await readFile(pathResolve(this.#next, 'package.json'), 'utf-8'))
|
|
41
41
|
this.#nextVersion = parse(nextPackage.version)
|
|
42
42
|
|
|
43
|
+
if (
|
|
44
|
+
this.#nextVersion.major < 15 ||
|
|
45
|
+
(this.#nextVersion.major <= 15 && this.#nextVersion.minor < 1)
|
|
46
|
+
) {
|
|
47
|
+
await import('./lib/create-context-patch.js')
|
|
48
|
+
}
|
|
49
|
+
|
|
43
50
|
/* c8 ignore next 3 */
|
|
44
51
|
if (!supportedVersions.some(v => satisfies(nextPackage.version, v))) {
|
|
45
52
|
throw new errors.UnsupportedVersion('next', nextPackage.version, supportedVersions)
|
|
@@ -205,7 +212,17 @@ export class NextStackable extends BaseStackable {
|
|
|
205
212
|
this.#basePath = config.application?.basePath ? cleanBasePath(config.application?.basePath) : ''
|
|
206
213
|
|
|
207
214
|
if (command) {
|
|
208
|
-
|
|
215
|
+
const childManagerScripts = this.#getChildManagerScripts()
|
|
216
|
+
|
|
217
|
+
if (
|
|
218
|
+
this.#nextVersion.major < 15 ||
|
|
219
|
+
(this.#nextVersion.major <= 15 && this.#nextVersion.minor < 1)
|
|
220
|
+
) {
|
|
221
|
+
childManagerScripts.push(
|
|
222
|
+
new URL('./lib/create-context-patch.js', import.meta.url)
|
|
223
|
+
)
|
|
224
|
+
}
|
|
225
|
+
return this.startWithCommand(command, loaderUrl, childManagerScripts)
|
|
209
226
|
}
|
|
210
227
|
|
|
211
228
|
this.childManager = new ChildManager({
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { createRequire } from 'node:module'
|
|
4
|
+
import { getGlobalDispatcher } from 'undici'
|
|
5
|
+
|
|
6
|
+
// Next.js runs middlewares in it's own patched vm context. So the global dispatcher in
|
|
7
|
+
// the middleware context is different from a service global dispatcher. This
|
|
8
|
+
// method sets a service global dispatcher after next.js defines it's own version of
|
|
9
|
+
// fetch function.
|
|
10
|
+
export function patchVmCreateContext () {
|
|
11
|
+
const _require = createRequire(process.cwd())
|
|
12
|
+
const vm = _require('node:vm')
|
|
13
|
+
|
|
14
|
+
const originalCreateContext = vm.createContext
|
|
15
|
+
vm.createContext = (contextObject, opts) => {
|
|
16
|
+
const globalDispatcher = getGlobalDispatcher()
|
|
17
|
+
const context = originalCreateContext(contextObject, opts)
|
|
18
|
+
queueMicrotask(() => {
|
|
19
|
+
if (contextObject.fetch === undefined) return
|
|
20
|
+
|
|
21
|
+
const originalFetch = contextObject.fetch
|
|
22
|
+
contextObject.fetch = (input, init = {}) => {
|
|
23
|
+
init.dispatcher = globalDispatcher
|
|
24
|
+
return originalFetch(input, init)
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
return context
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
patchVmCreateContext()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/next",
|
|
3
|
-
"version": "2.44.
|
|
3
|
+
"version": "2.44.3",
|
|
4
4
|
"description": "Platformatic Next.js Stackable",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"iovalkey": "^0.2.1",
|
|
24
24
|
"msgpackr": "^1.11.2",
|
|
25
25
|
"semver": "^7.6.3",
|
|
26
|
-
"@platformatic/
|
|
27
|
-
"@platformatic/
|
|
28
|
-
"@platformatic/utils": "2.44.
|
|
26
|
+
"@platformatic/basic": "2.44.3",
|
|
27
|
+
"@platformatic/config": "2.44.3",
|
|
28
|
+
"@platformatic/utils": "2.44.3"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@fastify/reply-from": "^12.0.0",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"react-dom": "^18.3.1",
|
|
42
42
|
"typescript": "^5.5.4",
|
|
43
43
|
"ws": "^8.18.0",
|
|
44
|
-
"@platformatic/
|
|
45
|
-
"@platformatic/
|
|
44
|
+
"@platformatic/composer": "2.44.3",
|
|
45
|
+
"@platformatic/service": "2.44.3"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"test": "npm run lint && borp --concurrency=1 --no-timeout",
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/next/2.44.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/next/2.44.3.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Next.js Stackable",
|
|
5
5
|
"type": "object",
|