@platformatic/next 3.32.0-alpha.1 → 3.32.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/lib/capability.js CHANGED
@@ -13,7 +13,6 @@ import { ChildProcess } from 'node:child_process'
13
13
  import { once } from 'node:events'
14
14
  import { existsSync } from 'node:fs'
15
15
  import { glob, readFile, writeFile } from 'node:fs/promises'
16
- import { createRequire } from 'node:module'
17
16
  import { dirname, resolve as resolvePath, sep } from 'node:path'
18
17
  import { fileURLToPath } from 'node:url'
19
18
  import { parse, satisfies } from 'semver'
@@ -33,7 +32,6 @@ export class NextCapability extends BaseCapability {
33
32
  #child
34
33
  #server
35
34
  #configModified
36
- #isStandalone
37
35
 
38
36
  constructor (root, config, context) {
39
37
  super('next', version, root, config, context)
@@ -44,20 +42,6 @@ export class NextCapability extends BaseCapability {
44
42
  async init () {
45
43
  await super.init()
46
44
 
47
- if (this.isProduction) {
48
- try {
49
- const buildInfo = JSON.parse(await readFile(resolvePath(this.root, '.platformatic-build.json'), 'utf-8'))
50
-
51
- if (buildInfo.standalone) {
52
- this.#isStandalone = true
53
- this.#nextVersion = parse(buildInfo.version)
54
- }
55
- return
56
- } catch (error) {
57
- // No-op
58
- }
59
- }
60
-
61
45
  // This is needed to avoid Next.js to throw an error when the lockfile is not correct
62
46
  // and the user is using npm but has pnpm in its $PATH.
63
47
  //
@@ -269,10 +253,11 @@ export class NextCapability extends BaseCapability {
269
253
  this.#getChildManagerScripts()
270
254
  )
271
255
 
272
- if (this.#isStandalone) {
256
+ this.verifyOutputDirectory(resolvePath(this.root, '.next'))
257
+
258
+ if (existsSync(resolvePath(this.root, '.next/standalone'))) {
273
259
  return this.#startProductionStandaloneNext()
274
260
  } else {
275
- this.verifyOutputDirectory(resolvePath(this.root, '.next'))
276
261
  return this.#startProductionNext()
277
262
  }
278
263
  }
@@ -315,17 +300,19 @@ export class NextCapability extends BaseCapability {
315
300
  }
316
301
 
317
302
  async #startProductionStandaloneNext () {
303
+ const rootDir = resolvePath(this.root, '.next', 'standalone')
304
+
318
305
  // If built in standalone mode, the generated standalone directory is not on the root of the project but somewhere
319
306
  // inside .next/standalone due to turbopack limitations in determining the root of the project.
320
307
  // In that case we search a server.js next to a .next folder inside the .next /standalone folder.
321
308
  const serverEntrypoints = await Array.fromAsync(
322
- glob(['**/server.js'], { cwd: this.root, ignore: ['node_modules', '**/node_modules/**'] })
309
+ glob(['**/server.js'], { cwd: rootDir, ignore: ['node_modules', '**/node_modules/**'] })
323
310
  )
324
311
 
325
312
  let serverEntrypoint
326
313
  for (const entrypoint of serverEntrypoints) {
327
- if (existsSync(resolvePath(this.root, dirname(entrypoint), '.next'))) {
328
- serverEntrypoint = resolvePath(this.root, entrypoint)
314
+ if (existsSync(resolvePath(rootDir, dirname(entrypoint), '.next'))) {
315
+ serverEntrypoint = resolvePath(rootDir, entrypoint)
329
316
  break
330
317
  }
331
318
  }
@@ -383,9 +370,7 @@ export class NextCapability extends BaseCapability {
383
370
 
384
371
  // This is needed by Next.js standalone server to pick up the correct configuration
385
372
  process.env.__NEXT_PRIVATE_STANDALONE_CONFIG = JSON.stringify(nextConfig)
386
- const require = createRequire(serverEntrypoint)
387
- const serverModule = require('next/dist/server/lib/start-server.js')
388
- const { startServer } = serverModule.default ?? serverModule
373
+ const { startServer } = await importFile(resolvePath(this.#next, './dist/server/lib/start-server.js'))
389
374
 
390
375
  await startServer({
391
376
  dir: dirname(serverEntrypoint),
@@ -465,16 +450,6 @@ export class NextCapability extends BaseCapability {
465
450
  await writeFile(requiredServerFilesPath, JSON.stringify(requiredServerFiles, null, 2))
466
451
  }
467
452
  }
468
-
469
- // This is needed to allow to have a standalone server working correctly
470
- if (existsSync(resolvePath(distDir, 'standalone'))) {
471
- await writeFile(
472
- resolvePath(distDir, 'standalone/.platformatic-build.json'),
473
- JSON.stringify({ standalone: true, version: this.#nextVersion.version }),
474
- 'utf-8'
475
- )
476
- }
477
-
478
453
  return distDir
479
454
  }
480
455
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/next",
3
- "version": "3.32.0-alpha.1",
3
+ "version": "3.32.0",
4
4
  "description": "Platformatic Next.js Capability",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -23,8 +23,8 @@
23
23
  "iovalkey": "^0.3.0",
24
24
  "msgpackr": "^1.11.2",
25
25
  "semver": "^7.6.3",
26
- "@platformatic/basic": "3.32.0-alpha.1",
27
- "@platformatic/foundation": "3.32.0-alpha.1"
26
+ "@platformatic/basic": "3.32.0",
27
+ "@platformatic/foundation": "3.32.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@fastify/reply-from": "^12.0.0",
@@ -40,8 +40,8 @@
40
40
  "next": "^16.0.0",
41
41
  "typescript": "^5.5.4",
42
42
  "ws": "^8.18.0",
43
- "@platformatic/gateway": "3.32.0-alpha.1",
44
- "@platformatic/service": "3.32.0-alpha.1"
43
+ "@platformatic/gateway": "3.32.0",
44
+ "@platformatic/service": "3.32.0"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=22.19.0"
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/next/3.32.0-alpha.1.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/next/3.32.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Next.js Config",
5
5
  "type": "object",