@platformatic/vite 3.0.0-rc.2 → 3.0.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/lib/capability.js CHANGED
@@ -15,13 +15,14 @@ import fastify from 'fastify'
15
15
  import { existsSync } from 'node:fs'
16
16
  import { readFile, writeFile } from 'node:fs/promises'
17
17
  import { dirname, resolve } from 'node:path'
18
- import { satisfies } from 'semver'
18
+ import { parse, satisfies } from 'semver'
19
19
  import { version } from './schema.js'
20
20
 
21
- const supportedVersions = '^5.0.0'
21
+ const supportedVersions = ['^5.0.0', '^6.0.0', '^7.0.0']
22
22
 
23
23
  export class ViteCapability extends BaseCapability {
24
24
  #vite
25
+ #viteVersion
25
26
  #app
26
27
  #server
27
28
  #basePath
@@ -38,9 +39,16 @@ export class ViteCapability extends BaseCapability {
38
39
  }
39
40
 
40
41
  this.#vite = dirname(resolvePackage(this.root, 'vite'))
42
+
43
+ // In Vite 6, module resolving changed, adjust it
44
+ if (!existsSync(resolve(this.#vite, 'dist/node/index.js'))) {
45
+ this.#vite = resolve(this.#vite, '../..')
46
+ }
47
+
41
48
  const vitePackage = JSON.parse(await readFile(resolve(this.#vite, 'package.json'), 'utf-8'))
49
+ this.#viteVersion = parse(vitePackage.version)
42
50
 
43
- if (!satisfies(vitePackage.version, supportedVersions)) {
51
+ if (!supportedVersions.some(v => satisfies(vitePackage.version, v))) {
44
52
  throw new errors.UnsupportedVersion('vite', vitePackage.version, supportedVersions)
45
53
  }
46
54
  }
@@ -65,9 +73,10 @@ export class ViteCapability extends BaseCapability {
65
73
 
66
74
  if (this.childManager) {
67
75
  return this.stopCommand()
76
+ } else if (this.#app) {
77
+ // This is needed if the capability was subclassed
78
+ return this.#app.close()
68
79
  }
69
-
70
- return this.#app.close()
71
80
  }
72
81
 
73
82
  async build () {
@@ -338,7 +347,13 @@ export class ViteSSRCapability extends NodeCapability {
338
347
  let clientOutDir = resolve(this.root, clientDirectory, config.application.outputDirectory, clientDirectory)
339
348
 
340
349
  await this.init()
341
- const vite = dirname(resolvePackage(this.root, 'vite'))
350
+
351
+ let vite = dirname(resolvePackage(this.root, 'vite'))
352
+ // In Vite 6, module resolving changed, adjust it
353
+ if (!existsSync(resolve(vite, 'dist/node/index.js'))) {
354
+ vite = resolve(vite, '../..')
355
+ }
356
+
342
357
  const { build } = await importFile(resolve(vite, 'dist/node/index.js'))
343
358
 
344
359
  // Build the client
@@ -387,8 +402,7 @@ export class ViteSSRCapability extends NodeCapability {
387
402
 
388
403
  getMeta () {
389
404
  const vite = this._getApplication()?.vite
390
- const config = vite?.devServer?.config ?? vite?.config.vite
391
- const applicationBasePath = config?.base
405
+ const applicationBasePath = vite?.config?.base
392
406
 
393
407
  const gateway = {
394
408
  tcp: typeof this.url !== 'undefined',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/vite",
3
- "version": "3.0.0-rc.2",
3
+ "version": "3.0.1",
4
4
  "description": "Platformatic Vite Capability",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -18,12 +18,11 @@
18
18
  "@fastify/static": "^8.0.0",
19
19
  "fastify": "^5.0.0",
20
20
  "semver": "^7.6.3",
21
- "@platformatic/basic": "3.0.0-rc.2",
22
- "@platformatic/foundation": "3.0.0-rc.2",
23
- "@platformatic/node": "3.0.0-rc.2"
21
+ "@platformatic/basic": "3.0.1",
22
+ "@platformatic/foundation": "3.0.1",
23
+ "@platformatic/node": "3.0.1"
24
24
  },
25
25
  "devDependencies": {
26
- "@fastify/vite": "^7.0.1",
27
26
  "cleaner-spec-reporter": "^0.5.0",
28
27
  "eslint": "9",
29
28
  "json-schema-to-typescript": "^15.0.1",
@@ -31,10 +30,10 @@
31
30
  "react": "^19.1.0",
32
31
  "react-dom": "^19.1.0",
33
32
  "typescript": "^5.5.4",
34
- "vite": "^5.4.0",
33
+ "vite": "^7.1.4",
35
34
  "ws": "^8.18.0",
36
- "@platformatic/gateway": "3.0.0-rc.2",
37
- "@platformatic/service": "3.0.0-rc.2"
35
+ "@platformatic/gateway": "3.0.1",
36
+ "@platformatic/service": "3.0.1"
38
37
  },
39
38
  "engines": {
40
39
  "node": ">=22.18.0"
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/vite/3.0.0-rc.2.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/vite/3.0.1.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Vite Config",
5
5
  "type": "object",