@platformatic/next 2.37.1 → 2.39.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/index.js +31 -0
- package/package.json +6 -6
- package/schema.json +1 -1
package/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
schemaOptions
|
|
13
13
|
} from '@platformatic/basic'
|
|
14
14
|
import { ConfigManager } from '@platformatic/config'
|
|
15
|
+
import { ChildProcess } from 'node:child_process'
|
|
15
16
|
import { once } from 'node:events'
|
|
16
17
|
import { readFile } from 'node:fs/promises'
|
|
17
18
|
import { dirname, resolve as pathResolve } from 'node:path'
|
|
@@ -173,6 +174,8 @@ export class NextStackable extends BaseStackable {
|
|
|
173
174
|
await this.childManager.inject()
|
|
174
175
|
const childPromise = createChildProcessListener()
|
|
175
176
|
|
|
177
|
+
this.#ensurePipeableStreamsInFork()
|
|
178
|
+
|
|
176
179
|
if (this.#nextVersion.major === 14 && this.#nextVersion.minor < 2) {
|
|
177
180
|
await nextDev({
|
|
178
181
|
'--hostname': serverOptions.host,
|
|
@@ -184,6 +187,11 @@ export class NextStackable extends BaseStackable {
|
|
|
184
187
|
}
|
|
185
188
|
|
|
186
189
|
this.#child = await childPromise
|
|
190
|
+
this.#child.stdout.setEncoding('utf8')
|
|
191
|
+
this.#child.stderr.setEncoding('utf8')
|
|
192
|
+
|
|
193
|
+
this.#child.stdout.pipe(process.stdout, { end: false })
|
|
194
|
+
this.#child.stderr.pipe(process.stderr, { end: false })
|
|
187
195
|
} finally {
|
|
188
196
|
await this.childManager.eject()
|
|
189
197
|
}
|
|
@@ -271,6 +279,29 @@ export class NextStackable extends BaseStackable {
|
|
|
271
279
|
|
|
272
280
|
return scripts
|
|
273
281
|
}
|
|
282
|
+
|
|
283
|
+
// In development mode, Next.js starts the dev server using child_process.fork with stdio set to 'inherit'.
|
|
284
|
+
// In order to capture the output, we need to ensure that the streams are pipeable and thus we perform a one-time
|
|
285
|
+
// monkey-patch of the ChildProcess.prototype.spawn method to override stdio[1] and stdio[2] to 'pipe'.
|
|
286
|
+
#ensurePipeableStreamsInFork () {
|
|
287
|
+
const originalSpawn = ChildProcess.prototype.spawn
|
|
288
|
+
|
|
289
|
+
// IMPORTANT: If Next.js code changes this might not work anymore. When this gives error, dig into Next.js code
|
|
290
|
+
// to evaluate the new path and/or if this is still necessary.
|
|
291
|
+
const startServerPath = pathResolve(this.#next, './dist/server/lib/start-server.js')
|
|
292
|
+
|
|
293
|
+
ChildProcess.prototype.spawn = function (options) {
|
|
294
|
+
if (options.args?.[1] === startServerPath) {
|
|
295
|
+
options.stdio[1] = 'pipe'
|
|
296
|
+
options.stdio[2] = 'pipe'
|
|
297
|
+
|
|
298
|
+
// Uninstall the patch
|
|
299
|
+
ChildProcess.prototype.spawn = originalSpawn
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return originalSpawn.call(this, options)
|
|
303
|
+
}
|
|
304
|
+
}
|
|
274
305
|
}
|
|
275
306
|
|
|
276
307
|
/* c8 ignore next 9 */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/next",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.39.0",
|
|
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.
|
|
26
|
+
"@platformatic/basic": "2.39.0",
|
|
27
|
+
"@platformatic/config": "2.39.0",
|
|
28
|
+
"@platformatic/utils": "2.39.0"
|
|
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.39.0",
|
|
45
|
+
"@platformatic/service": "2.39.0"
|
|
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.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/next/2.39.0.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Next.js Stackable",
|
|
5
5
|
"type": "object",
|