@platformatic/vite 2.2.2-alpha.1 → 2.3.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.
Files changed (3) hide show
  1. package/index.js +28 -3
  2. package/package.json +7 -7
  3. package/schema.json +1 -1
package/index.js CHANGED
@@ -150,6 +150,14 @@ export class ViteStackable extends BaseStackable {
150
150
  ? ensureTrailingSlash(cleanBasePath(config.application?.basePath))
151
151
  : undefined
152
152
 
153
+ this.registerGlobals({
154
+ id: this.id,
155
+ // Always use URL to avoid serialization problem in Windows
156
+ root: pathToFileURL(this.root).toString(),
157
+ basePath: this.#basePath,
158
+ logLevel: this.logger.level
159
+ })
160
+
153
161
  if (command) {
154
162
  return this.startWithCommand(command)
155
163
  }
@@ -203,6 +211,13 @@ export class ViteStackable extends BaseStackable {
203
211
  ? ensureTrailingSlash(cleanBasePath(config.application?.basePath))
204
212
  : undefined
205
213
 
214
+ this.registerGlobals({
215
+ id: this.id,
216
+ // Always use URL to avoid serialization problem in Windows
217
+ root: pathToFileURL(this.root).toString(),
218
+ basePath: this.#basePath,
219
+ logLevel: this.logger.level
220
+ })
206
221
  if (command) {
207
222
  return this.startWithCommand(command)
208
223
  }
@@ -285,9 +300,19 @@ export class ViteSSRStackable extends NodeStackable {
285
300
 
286
301
  if (this.isProduction) {
287
302
  const clientDirectory = config.vite.ssr.clientDirectory
288
- this.verifyOutputDirectory(
289
- resolve(this.root, clientDirectory, config.application.outputDirectory, clientDirectory)
290
- )
303
+ const clientOutDir = resolve(this.root, clientDirectory, config.application.outputDirectory, clientDirectory)
304
+
305
+ this.verifyOutputDirectory(clientOutDir)
306
+
307
+ const buildInfoPath = resolve(clientOutDir, '.platformatic-build.json')
308
+ if (!this.#basePath && existsSync(buildInfoPath)) {
309
+ try {
310
+ const buildInfo = JSON.parse(await readFile(buildInfoPath, 'utf-8'))
311
+ this.#basePath = buildInfo.basePath
312
+ } catch (e) {
313
+ console.log(e)
314
+ }
315
+ }
291
316
  }
292
317
 
293
318
  await super.start({ listen })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/vite",
3
- "version": "2.2.2-alpha.1",
3
+ "version": "2.3.1",
4
4
  "description": "Platformatic Vite Stackable",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -18,10 +18,10 @@
18
18
  "@fastify/static": "^8.0.0",
19
19
  "fastify": "^5.0.0",
20
20
  "semver": "^7.6.3",
21
- "@platformatic/basic": "2.2.2-alpha.1",
22
- "@platformatic/utils": "2.2.2-alpha.1",
23
- "@platformatic/config": "2.2.2-alpha.1",
24
- "@platformatic/node": "2.2.2-alpha.1"
21
+ "@platformatic/basic": "2.3.1",
22
+ "@platformatic/config": "2.3.1",
23
+ "@platformatic/utils": "2.3.1",
24
+ "@platformatic/node": "2.3.1"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@fastify/vite": "^7.0.1",
@@ -34,8 +34,8 @@
34
34
  "typescript": "^5.5.4",
35
35
  "vite": "^5.4.0",
36
36
  "ws": "^8.18.0",
37
- "@platformatic/service": "2.2.2-alpha.1",
38
- "@platformatic/composer": "2.2.2-alpha.1"
37
+ "@platformatic/composer": "2.3.1",
38
+ "@platformatic/service": "2.3.1"
39
39
  },
40
40
  "scripts": {
41
41
  "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/vite/2.2.2-alpha.1.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/vite/2.3.1.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Vite Stackable",
5
5
  "type": "object",