@platformatic/next 2.67.0-alpha.1 → 2.67.0-alpha.2
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 +21 -8
- package/lib/loader.js +7 -3
- package/package.json +6 -6
- package/schema.json +1 -1
package/index.js
CHANGED
|
@@ -48,7 +48,10 @@ export class NextStackable extends BaseStackable {
|
|
|
48
48
|
const nextPackage = JSON.parse(await readFile(pathResolve(this.#next, 'package.json'), 'utf-8'))
|
|
49
49
|
this.#nextVersion = parse(nextPackage.version)
|
|
50
50
|
|
|
51
|
-
if (
|
|
51
|
+
if (
|
|
52
|
+
this.#nextVersion.major < 15 ||
|
|
53
|
+
(this.#nextVersion.major <= 15 && this.#nextVersion.minor < 1)
|
|
54
|
+
) {
|
|
52
55
|
await import('./lib/create-context-patch.js')
|
|
53
56
|
}
|
|
54
57
|
|
|
@@ -64,17 +67,13 @@ export class NextStackable extends BaseStackable {
|
|
|
64
67
|
return this.url
|
|
65
68
|
}
|
|
66
69
|
|
|
67
|
-
this.on('config', config => {
|
|
68
|
-
this.#basePath = config.basePath
|
|
69
|
-
})
|
|
70
|
-
|
|
71
70
|
if (this.isProduction) {
|
|
72
71
|
await this.#startProduction(listen)
|
|
73
72
|
} else {
|
|
74
73
|
await this.#startDevelopment(listen)
|
|
75
74
|
}
|
|
76
75
|
|
|
77
|
-
|
|
76
|
+
this._collectMetrics()
|
|
78
77
|
}
|
|
79
78
|
|
|
80
79
|
async stop () {
|
|
@@ -182,6 +181,10 @@ export class NextStackable extends BaseStackable {
|
|
|
182
181
|
async #startDevelopmentNext (serverOptions) {
|
|
183
182
|
const { nextDev } = await importFile(pathResolve(this.#next, './dist/cli/next-dev.js'))
|
|
184
183
|
|
|
184
|
+
this.childManager.on('config', config => {
|
|
185
|
+
this.#basePath = config.basePath
|
|
186
|
+
})
|
|
187
|
+
|
|
185
188
|
try {
|
|
186
189
|
await this.childManager.inject()
|
|
187
190
|
const childPromise = createChildProcessListener()
|
|
@@ -219,8 +222,13 @@ export class NextStackable extends BaseStackable {
|
|
|
219
222
|
if (command) {
|
|
220
223
|
const childManagerScripts = this.#getChildManagerScripts()
|
|
221
224
|
|
|
222
|
-
if (
|
|
223
|
-
|
|
225
|
+
if (
|
|
226
|
+
this.#nextVersion.major < 15 ||
|
|
227
|
+
(this.#nextVersion.major <= 15 && this.#nextVersion.minor < 1)
|
|
228
|
+
) {
|
|
229
|
+
childManagerScripts.push(
|
|
230
|
+
new URL('./lib/create-context-patch.js', import.meta.url)
|
|
231
|
+
)
|
|
224
232
|
}
|
|
225
233
|
return this.startWithCommand(command, loaderUrl, childManagerScripts)
|
|
226
234
|
}
|
|
@@ -259,6 +267,11 @@ export class NextStackable extends BaseStackable {
|
|
|
259
267
|
port: port || 0
|
|
260
268
|
}
|
|
261
269
|
|
|
270
|
+
// Since we are in the same process
|
|
271
|
+
process.once('plt:next:config', config => {
|
|
272
|
+
this.#basePath = config.basePath
|
|
273
|
+
})
|
|
274
|
+
|
|
262
275
|
this.childManager.register()
|
|
263
276
|
const serverPromise = createServerListener(
|
|
264
277
|
(this.isEntrypoint ? serverOptions?.port : undefined) ?? true,
|
package/lib/loader.js
CHANGED
|
@@ -42,8 +42,11 @@ function parseSingleExpression (expr) {
|
|
|
42
42
|
__pltOriginalNextConfig.cacheMaxMemorySize = 0
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
// This is to send the configuraion when Next is executed in a child process
|
|
46
|
-
globalThis.
|
|
45
|
+
// This is to send the configuraion when Next is executed in a child process (development)
|
|
46
|
+
globalThis[Symbol.for('plt.children.itc')]?.notify('config', __pltOriginalNextConfig)
|
|
47
|
+
|
|
48
|
+
// This is to send the configuraion when Next is executed in the same process (production)
|
|
49
|
+
process.emit('plt:next:config', __pltOriginalNextConfig)
|
|
47
50
|
|
|
48
51
|
return __pltOriginalNextConfig;
|
|
49
52
|
}
|
|
@@ -84,7 +87,8 @@ function createEvaluatorWrapperFunction (original) {
|
|
|
84
87
|
}
|
|
85
88
|
`)
|
|
86
89
|
: undefined,
|
|
87
|
-
parseSingleExpression(`globalThis.
|
|
90
|
+
parseSingleExpression(`globalThis[Symbol.for('plt.children.itc')]?.notify('config', ${originalId})`),
|
|
91
|
+
parseSingleExpression(`process.emit('plt:next:config', ${originalId})`),
|
|
88
92
|
returnStatement(identifier(originalId))
|
|
89
93
|
].filter(e => e)
|
|
90
94
|
),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/next",
|
|
3
|
-
"version": "2.67.0-alpha.
|
|
3
|
+
"version": "2.67.0-alpha.2",
|
|
4
4
|
"description": "Platformatic Next.js Stackable",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"iovalkey": "^0.3.0",
|
|
24
24
|
"msgpackr": "^1.11.2",
|
|
25
25
|
"semver": "^7.6.3",
|
|
26
|
-
"@platformatic/
|
|
27
|
-
"@platformatic/
|
|
28
|
-
"@platformatic/utils": "2.67.0-alpha.
|
|
26
|
+
"@platformatic/basic": "2.67.0-alpha.2",
|
|
27
|
+
"@platformatic/config": "2.67.0-alpha.2",
|
|
28
|
+
"@platformatic/utils": "2.67.0-alpha.2"
|
|
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/composer": "2.67.0-alpha.
|
|
45
|
-
"@platformatic/service": "2.67.0-alpha.
|
|
44
|
+
"@platformatic/composer": "2.67.0-alpha.2",
|
|
45
|
+
"@platformatic/service": "2.67.0-alpha.2"
|
|
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.67.0-alpha.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/next/2.67.0-alpha.2.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Next.js Stackable",
|
|
5
5
|
"type": "object",
|