@platformatic/next 2.67.0-alpha.1 → 2.67.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 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 (this.#nextVersion.major < 15 || (this.#nextVersion.major <= 15 && this.#nextVersion.minor < 1)) {
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
- await this._collectMetrics()
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 (this.#nextVersion.major < 15 || (this.#nextVersion.major <= 15 && this.#nextVersion.minor < 1)) {
223
- childManagerScripts.push(new URL('./lib/create-context-patch.js', import.meta.url))
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.platformatic.notifyConfig(__pltOriginalNextConfig)
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.platformatic.notifyConfig(${originalId})`),
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.1",
3
+ "version": "2.67.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.3.0",
24
24
  "msgpackr": "^1.11.2",
25
25
  "semver": "^7.6.3",
26
- "@platformatic/config": "2.67.0-alpha.1",
27
- "@platformatic/basic": "2.67.0-alpha.1",
28
- "@platformatic/utils": "2.67.0-alpha.1"
26
+ "@platformatic/basic": "2.67.0",
27
+ "@platformatic/config": "2.67.0",
28
+ "@platformatic/utils": "2.67.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/composer": "2.67.0-alpha.1",
45
- "@platformatic/service": "2.67.0-alpha.1"
44
+ "@platformatic/composer": "2.67.0",
45
+ "@platformatic/service": "2.67.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.67.0-alpha.1.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/next/2.67.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Next.js Stackable",
5
5
  "type": "object",