@platformatic/next 2.67.0-alpha.0 → 2.67.0-alpha.1

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