@platformatic/vite 2.0.0-alpha.7 → 2.0.0-alpha.9

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 (54) hide show
  1. package/config.d.ts +17 -7
  2. package/eslint.config.js +1 -1
  3. package/index.js +274 -53
  4. package/lib/schema.js +49 -26
  5. package/package.json +12 -11
  6. package/schema.json +66 -31
  7. package/test/fixtures/platformatic-composer/platformatic.composer.json +0 -20
  8. package/test/fixtures/platformatic-composer/platformatic.no-prefix.composer.json +0 -23
  9. package/test/fixtures/platformatic-composer/plugin.js +0 -9
  10. package/test/fixtures/platformatic-service/platformatic.service.json +0 -15
  11. package/test/fixtures/platformatic-service/plugin.js +0 -19
  12. package/test/fixtures/vite/composer-autodetect-prefix/custom.vite.config.js +0 -3
  13. package/test/fixtures/vite/composer-autodetect-prefix/index.html +0 -13
  14. package/test/fixtures/vite/composer-autodetect-prefix/main.js +0 -3
  15. package/test/fixtures/vite/composer-autodetect-prefix/package.json +0 -14
  16. package/test/fixtures/vite/composer-autodetect-prefix/platformatic.application.json +0 -11
  17. package/test/fixtures/vite/composer-autodetect-prefix/platformatic.runtime.json +0 -20
  18. package/test/fixtures/vite/composer-with-prefix/index.html +0 -13
  19. package/test/fixtures/vite/composer-with-prefix/main.js +0 -3
  20. package/test/fixtures/vite/composer-with-prefix/package.json +0 -14
  21. package/test/fixtures/vite/composer-with-prefix/platformatic.application.json +0 -11
  22. package/test/fixtures/vite/composer-with-prefix/platformatic.runtime.json +0 -21
  23. package/test/fixtures/vite/composer-without-prefix/index.html +0 -13
  24. package/test/fixtures/vite/composer-without-prefix/main.js +0 -3
  25. package/test/fixtures/vite/composer-without-prefix/package.json +0 -14
  26. package/test/fixtures/vite/composer-without-prefix/platformatic.application.json +0 -8
  27. package/test/fixtures/vite/composer-without-prefix/platformatic.runtime.json +0 -21
  28. package/test/fixtures/vite/ssr-autodetect-prefix/client/index.html +0 -12
  29. package/test/fixtures/vite/ssr-autodetect-prefix/client/index.js +0 -7
  30. package/test/fixtures/vite/ssr-autodetect-prefix/package.json +0 -15
  31. package/test/fixtures/vite/ssr-autodetect-prefix/platformatic.application.json +0 -11
  32. package/test/fixtures/vite/ssr-autodetect-prefix/platformatic.runtime.json +0 -21
  33. package/test/fixtures/vite/ssr-autodetect-prefix/server.js +0 -35
  34. package/test/fixtures/vite/ssr-autodetect-prefix/vite.config.js +0 -7
  35. package/test/fixtures/vite/ssr-with-prefix/client/index.html +0 -12
  36. package/test/fixtures/vite/ssr-with-prefix/client/index.js +0 -7
  37. package/test/fixtures/vite/ssr-with-prefix/package.json +0 -15
  38. package/test/fixtures/vite/ssr-with-prefix/platformatic.application.json +0 -14
  39. package/test/fixtures/vite/ssr-with-prefix/platformatic.runtime.json +0 -21
  40. package/test/fixtures/vite/ssr-with-prefix/server.js +0 -35
  41. package/test/fixtures/vite/ssr-with-prefix/vite.config.js +0 -7
  42. package/test/fixtures/vite/ssr-without-prefix/client/index.html +0 -12
  43. package/test/fixtures/vite/ssr-without-prefix/client/index.js +0 -7
  44. package/test/fixtures/vite/ssr-without-prefix/package.json +0 -15
  45. package/test/fixtures/vite/ssr-without-prefix/platformatic.application.json +0 -11
  46. package/test/fixtures/vite/ssr-without-prefix/platformatic.runtime.json +0 -21
  47. package/test/fixtures/vite/ssr-without-prefix/server.js +0 -34
  48. package/test/fixtures/vite/ssr-without-prefix/vite.config.js +0 -7
  49. package/test/fixtures/vite/standalone/custom.vite.config.js +0 -3
  50. package/test/fixtures/vite/standalone/index.html +0 -13
  51. package/test/fixtures/vite/standalone/main.js +0 -3
  52. package/test/fixtures/vite/standalone/package.json +0 -15
  53. package/test/fixtures/vite/standalone/platformatic.runtime.json +0 -18
  54. package/test/index.test.js +0 -161
package/config.d.ts CHANGED
@@ -62,6 +62,9 @@ export interface PlatformaticViteStackable {
62
62
  };
63
63
  [k: string]: unknown;
64
64
  };
65
+ loggerInstance?: {
66
+ [k: string]: unknown;
67
+ };
65
68
  serializerOpts?: {
66
69
  schema?: {
67
70
  [k: string]: unknown;
@@ -152,20 +155,27 @@ export interface PlatformaticViteStackable {
152
155
  | string;
153
156
  application?: {
154
157
  basePath?: string;
158
+ outputDirectory?: string;
159
+ include?: string[];
160
+ commands?: {
161
+ install?: string;
162
+ build?: string;
163
+ development?: string;
164
+ production?: string;
165
+ };
155
166
  };
156
167
  vite?: {
157
168
  configFile?: string | boolean;
169
+ devServer?: {
170
+ strict?: boolean;
171
+ };
158
172
  ssr?:
159
173
  | {
174
+ enabled?: boolean;
160
175
  entrypoint: string;
176
+ clientDirectory?: string;
177
+ serverDirectory?: string;
161
178
  }
162
179
  | boolean;
163
180
  };
164
- deploy?: {
165
- include?: string[];
166
- buildCommand?: string;
167
- installCommand?: string;
168
- startCommand?: string;
169
- [k: string]: unknown;
170
- };
171
181
  }
package/eslint.config.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import neostandard from 'neostandard'
2
2
 
3
3
  export default neostandard({
4
- ignores: ['test/tmp/version.js', '**/.vite'],
4
+ ignores: ['**/.vite', '**/dist', '**/tmp']
5
5
  })
package/index.js CHANGED
@@ -1,16 +1,21 @@
1
+ import fastifyStatic from '@fastify/static'
1
2
  import {
2
3
  BaseStackable,
3
4
  transformConfig as basicTransformConfig,
5
+ cleanBasePath,
4
6
  createServerListener,
7
+ ensureTrailingSlash,
5
8
  errors,
6
9
  getServerUrl,
7
10
  importFile,
11
+ resolvePackage,
8
12
  schemaOptions
9
13
  } from '@platformatic/basic'
10
14
  import { ConfigManager } from '@platformatic/config'
11
15
  import { NodeStackable } from '@platformatic/node'
12
- import { readFile } from 'node:fs/promises'
13
- import { createRequire } from 'node:module'
16
+ import fastify from 'fastify'
17
+ import { existsSync } from 'node:fs'
18
+ import { readFile, writeFile } from 'node:fs/promises'
14
19
  import { dirname, resolve } from 'node:path'
15
20
  import { pathToFileURL } from 'node:url'
16
21
  import { satisfies } from 'semver'
@@ -29,7 +34,7 @@ export class ViteStackable extends BaseStackable {
29
34
  }
30
35
 
31
36
  async init () {
32
- this.#vite = dirname(createRequire(this.root).resolve('vite'))
37
+ this.#vite = dirname(resolvePackage(this.root, 'vite'))
33
38
  const vitePackage = JSON.parse(await readFile(resolve(this.#vite, 'package.json'), 'utf-8'))
34
39
 
35
40
  /* c8 ignore next 3 */
@@ -38,20 +43,135 @@ export class ViteStackable extends BaseStackable {
38
43
  }
39
44
  }
40
45
 
41
- async start () {
46
+ async start ({ listen }) {
42
47
  // Make this idempotent
43
48
  if (this.url) {
44
49
  return this.url
45
50
  }
46
51
 
52
+ if (this.isProduction) {
53
+ await this.#startProduction(listen)
54
+ } else {
55
+ await this.#startDevelopment(listen)
56
+ }
57
+ }
58
+
59
+ async stop () {
60
+ if (this.subprocess) {
61
+ return this.stopCommand()
62
+ }
63
+
64
+ return this.#app.close()
65
+ }
66
+
67
+ async build () {
47
68
  const config = this.configManager.current
69
+ const command = config.application.commands.build
70
+ const configFile = config.vite.configFile ? resolve(this.root, config.vite.configFile) : undefined
71
+ let basePath = config.application?.basePath
72
+ ? ensureTrailingSlash(cleanBasePath(config.application?.basePath))
73
+ : undefined
74
+ let outDir
75
+
76
+ if (command) {
77
+ return this.buildWithCommand(command, basePath)
78
+ }
79
+
80
+ await this.init()
81
+ const { build } = await importFile(resolve(this.#vite, 'dist/node/index.js'))
82
+
83
+ await build({
84
+ root: this.root,
85
+ base: basePath,
86
+ mode: 'production',
87
+ configFile,
88
+ logLevel: this.logger.level,
89
+ build: {
90
+ outDir: config.application.outputDirectory
91
+ },
92
+ plugins: [
93
+ {
94
+ name: 'platformatic-build',
95
+ configResolved: config => {
96
+ basePath = ensureTrailingSlash(cleanBasePath(config.base))
97
+ outDir = resolve(this.root, config.build.outDir)
98
+ }
99
+ }
100
+ ]
101
+ })
102
+
103
+ await writeFile(resolve(outDir, '.platformatic-build.json'), JSON.stringify({ basePath }), 'utf-8')
104
+ }
105
+
106
+ /* c8 ignore next 5 */
107
+ async getWatchConfig () {
108
+ return {
109
+ enabled: false
110
+ }
111
+ }
112
+
113
+ // This is only used in production mode
114
+ async inject (injectParams, onInject) {
115
+ const res = await this.#app.inject(injectParams, onInject)
116
+
117
+ /* c8 ignore next 3 */
118
+ if (onInject) {
119
+ return
120
+ }
121
+
122
+ // Since inject might be called from the main thread directly via ITC, let's clean it up
123
+ const { statusCode, headers, body, payload, rawPayload } = res
124
+ return { statusCode, headers, body, payload, rawPayload }
125
+ }
126
+
127
+ getMeta () {
128
+ let composer = { prefix: this.servicePrefix, wantsAbsoluteUrls: true, needsRootRedirect: true }
129
+
130
+ if (this.isProduction) {
131
+ composer = {
132
+ tcp: typeof this.url !== 'undefined',
133
+ url: this.url,
134
+ prefix: (this.subprocessConfig?.base ?? this.#basePath).replace(/(^\/)|(\/$)/g, ''),
135
+ wantsAbsoluteUrls: true,
136
+ needsRootRedirect: true
137
+ }
138
+ } else if (this.url) {
139
+ if (!this.#basePath) {
140
+ const config = this.subprocessConfig ?? this.#app.config
141
+ this.#basePath = config.base.replace(/(^\/)|(\/$)/g, '')
142
+ }
143
+
144
+ composer = {
145
+ tcp: true,
146
+ url: this.url,
147
+ prefix: this.#basePath.replace(/(^\/)|(\/$)/g, ''),
148
+ wantsAbsoluteUrls: true,
149
+ needsRootRedirect: true
150
+ }
151
+ }
152
+
153
+ return { composer }
154
+ }
155
+
156
+ _getVite () {
157
+ return this.#app
158
+ }
159
+
160
+ async #startDevelopment () {
161
+ const config = this.configManager.current
162
+ const command = this.configManager.current.application.commands.development
163
+
164
+ this.#basePath = config.application?.basePath
165
+ ? ensureTrailingSlash(cleanBasePath(config.application?.basePath))
166
+ : undefined
167
+
168
+ if (command) {
169
+ return this.startWithCommand(command)
170
+ }
48
171
 
49
172
  // Prepare options
50
173
  const { hostname, port, https, cors } = this.serverConfig ?? {}
51
- const configFile = config.vite?.configFile ? resolve(this.root, config.vite?.configFile) : undefined
52
- const basePath = config.application?.basePath
53
- ? `/${config.application?.basePath}`.replaceAll(/\/+/g, '/').replace(/\/$/, '')
54
- : undefined
174
+ const configFile = config.vite.configFile ? resolve(this.root, config.vite.configFile) : undefined
55
175
 
56
176
  const serverOptions = {
57
177
  host: hostname || '127.0.0.1',
@@ -60,17 +180,20 @@ export class ViteStackable extends BaseStackable {
60
180
  https,
61
181
  cors,
62
182
  origin: 'http://localhost',
63
- hmr: true
183
+ hmr: true,
184
+ fs: {
185
+ strict: config.vite.devServer.strict
186
+ }
64
187
  }
65
188
 
66
189
  // Require Vite
67
- const serverPromise = createServerListener()
190
+ const serverPromise = createServerListener((this.isEntrypoint ? serverOptions?.port : undefined) ?? true)
68
191
  const { createServer } = await importFile(resolve(this.#vite, 'dist/node/index.js'))
69
192
 
70
193
  // Create the server and listen
71
194
  this.#app = await createServer({
72
195
  root: this.root,
73
- base: basePath,
196
+ base: this.#basePath,
74
197
  mode: 'development',
75
198
  configFile,
76
199
  logLevel: this.logger.level,
@@ -84,47 +207,56 @@ export class ViteStackable extends BaseStackable {
84
207
  this.url = getServerUrl(this.#server)
85
208
  }
86
209
 
87
- async stop () {
88
- return this.#app.close()
89
- }
210
+ async #startProduction (listen) {
211
+ const config = this.configManager.current
212
+ const command = this.configManager.current.application.commands.production
90
213
 
91
- /* c8 ignore next 5 */
92
- async getWatchConfig () {
93
- return {
94
- enabled: false
214
+ this.#basePath = config.application?.basePath
215
+ ? ensureTrailingSlash(cleanBasePath(config.application?.basePath))
216
+ : undefined
217
+
218
+ if (command) {
219
+ return this.startWithCommand(command)
95
220
  }
96
- }
97
221
 
98
- getMeta () {
99
- const deploy = this.configManager.current.deploy
100
- let composer
222
+ if (this.#app && listen) {
223
+ const serverOptions = this.serverConfig
224
+ await this.#app.listen({ host: serverOptions?.hostname || '127.0.0.1', port: serverOptions?.port || 0 })
225
+ this.url = getServerUrl(this.#app.server)
226
+ return this.url
227
+ }
101
228
 
102
- if (this.url) {
103
- if (!this.#basePath) {
104
- this.#basePath = this.#app.config.base.replace(/(^\/)|(\/$)/g, '')
105
- }
229
+ this.#app = fastify({ logger: { level: 'info' } })
106
230
 
107
- composer = {
108
- tcp: true,
109
- url: this.url,
110
- prefix: this.#basePath,
111
- wantsAbsoluteUrls: true
231
+ const outputDirectory = resolve(this.root, config.application.outputDirectory)
232
+ this.verifyOutputDirectory(outputDirectory)
233
+ const buildInfoPath = resolve(outputDirectory, '.platformatic-build.json')
234
+
235
+ if (!this.#basePath && existsSync(buildInfoPath)) {
236
+ try {
237
+ const buildInfo = JSON.parse(await readFile(buildInfoPath, 'utf-8'))
238
+ this.#basePath = buildInfo.basePath
239
+ } catch (e) {
240
+ console.log(e)
112
241
  }
113
242
  }
114
243
 
115
- return { deploy, composer }
116
- }
244
+ await this.#app.register(fastifyStatic, {
245
+ root: outputDirectory,
246
+ prefix: this.#basePath,
247
+ prefixAvoidTrailingSlash: true,
248
+ schemaHide: true
249
+ })
117
250
 
118
- _getVite () {
119
- return this.#app
251
+ await this.#app.ready()
120
252
  }
121
253
  }
122
254
 
123
255
  export class ViteSSRStackable extends NodeStackable {
124
256
  #basePath
125
257
 
126
- constructor (options, root, configManager, entrypoint) {
127
- super(options, root, configManager, entrypoint, true)
258
+ constructor (options, root, configManager) {
259
+ super(options, root, configManager)
128
260
 
129
261
  this.type = 'vite'
130
262
  }
@@ -133,14 +265,15 @@ export class ViteSSRStackable extends NodeStackable {
133
265
  const config = this.configManager.current
134
266
 
135
267
  this.#basePath = config.application?.basePath
136
- ? `/${config.application?.basePath}`.replaceAll(/\/+/g, '/').replace(/\/$/, '')
137
- : ''
268
+ ? ensureTrailingSlash(cleanBasePath(config.application?.basePath))
269
+ : undefined
138
270
 
139
271
  this.registerGlobals({
272
+ id: this.id,
140
273
  // Always use URL to avoid serialization problem in Windows
141
- root: pathToFileURL(this.root),
274
+ root: pathToFileURL(this.root).toString(),
142
275
  basePath: this.#basePath,
143
- logger: { id: this.id, level: this.logger.level }
276
+ logLevel: this.logger.level
144
277
  })
145
278
  }
146
279
 
@@ -151,33 +284,112 @@ export class ViteSSRStackable extends NodeStackable {
151
284
  return this.url
152
285
  }
153
286
 
287
+ const config = this.configManager.current
288
+ const command = config.application.commands[this.isProduction ? 'production' : 'development']
289
+
290
+ if (command) {
291
+ return this.startWithCommand(command)
292
+ }
293
+
294
+ if (this.isProduction) {
295
+ const clientDirectory = config.vite.ssr.clientDirectory
296
+ this.verifyOutputDirectory(
297
+ resolve(this.root, clientDirectory, config.application.outputDirectory, clientDirectory)
298
+ )
299
+ }
300
+
154
301
  await super.start({ listen })
155
302
  await super._listen()
156
303
  }
157
304
 
305
+ async build () {
306
+ const config = this.configManager.current
307
+ const command = config.application.commands.build
308
+ const configFile = config.vite.configFile ? resolve(this.root, config.vite.configFile) : undefined
309
+ let basePath = config.application?.basePath
310
+ ? ensureTrailingSlash(cleanBasePath(config.application?.basePath))
311
+ : undefined
312
+
313
+ if (command) {
314
+ return this.buildWithCommand(command, basePath)
315
+ }
316
+
317
+ const clientDirectory = config.vite.ssr.clientDirectory
318
+ const serverDirectory = config.vite.ssr.serverDirectory
319
+ let clientOutDir = resolve(this.root, clientDirectory, config.application.outputDirectory, clientDirectory)
320
+
321
+ await this.init()
322
+ const vite = dirname(resolvePackage(this.root, 'vite'))
323
+ const { build } = await importFile(resolve(vite, 'dist/node/index.js'))
324
+
325
+ // Build the client
326
+ await build({
327
+ root: resolve(this.root, clientDirectory),
328
+ base: basePath,
329
+ mode: 'production',
330
+ configFile,
331
+ logLevel: this.logger.level,
332
+ build: {
333
+ outDir: clientOutDir,
334
+ ssrManifest: true
335
+ },
336
+ plugins: [
337
+ {
338
+ name: 'platformatic-build',
339
+ configResolved: config => {
340
+ basePath = ensureTrailingSlash(cleanBasePath(config.base))
341
+ clientOutDir = resolve(this.root, clientDirectory, config.build.outDir)
342
+ }
343
+ }
344
+ ]
345
+ })
346
+
347
+ await writeFile(resolve(clientOutDir, '.platformatic-build.json'), JSON.stringify({ basePath }), 'utf-8')
348
+
349
+ // Build the server
350
+ await build({
351
+ root: this.root,
352
+ base: basePath,
353
+ mode: 'production',
354
+ configFile,
355
+ logLevel: this.logger.level,
356
+ build: {
357
+ outDir: resolve(this.root, clientDirectory, config.application.outputDirectory, serverDirectory),
358
+ ssr: resolve(this.root, clientDirectory, 'index.js')
359
+ }
360
+ })
361
+ }
362
+
158
363
  getMeta () {
159
- const deploy = this.configManager.current.deploy
160
- let composer
364
+ let composer = { prefix: this.servicePrefix, wantsAbsoluteUrls: true, needsRootRedirect: true }
161
365
 
162
366
  if (this.url) {
163
367
  if (!this.#basePath) {
164
- this.#basePath = this._getApplication().vite.devServer.config.base.replace(/(^\/)|(\/$)/g, '')
368
+ const application = this._getApplication()
369
+ const config = application.vite.devServer?.config ?? application.vite.config.vite
370
+ this.#basePath = (config.base ?? '').replace(/(^\/)|(\/$)/g, '')
165
371
  }
166
372
 
167
373
  composer = {
168
374
  tcp: true,
169
375
  url: this.url,
170
- prefix: this.#basePath,
171
- wantsAbsoluteUrls: true
376
+ prefix: this.#basePath ?? this.servicePrefix,
377
+ wantsAbsoluteUrls: true,
378
+ needsRootRedirect: true
172
379
  }
173
380
  }
174
381
 
175
- return { deploy, composer }
382
+ return { composer }
383
+ }
384
+
385
+ _findEntrypoint () {
386
+ const config = this.configManager.current.vite ?? {}
387
+ return resolve(this.root, config.ssr.entrypoint)
176
388
  }
177
389
  }
178
390
 
179
391
  /* c8 ignore next 9 */
180
- function transformConfig () {
392
+ export function transformConfig () {
181
393
  if (this.current.watch === undefined) {
182
394
  this.current.watch = { enabled: false }
183
395
  }
@@ -186,8 +398,13 @@ function transformConfig () {
186
398
  this.current.watch = { enabled: this.current.watch || false }
187
399
  }
188
400
 
189
- if (this.current.vite?.ssr === true) {
190
- this.current.vite.ssr = { entrypoint: 'server.js' }
401
+ if (this.current.vite.ssr === true) {
402
+ this.current.vite.ssr = {
403
+ enabled: true,
404
+ entrypoint: 'server.js',
405
+ clientDirectory: 'client',
406
+ serverDirectory: 'server'
407
+ }
191
408
  }
192
409
 
193
410
  basicTransformConfig.call(this)
@@ -199,14 +416,18 @@ export async function buildStackable (opts) {
199
416
  const configManager = new ConfigManager({ schema, source: opts.config ?? {}, schemaOptions, transformConfig })
200
417
  await configManager.parseAndValidate()
201
418
 
202
- // When in SSR mode, we use @platformatic/node
203
- if (configManager.current.vite?.ssr) {
204
- return new ViteSSRStackable(opts, root, configManager, configManager.current.vite.ssr.entrypoint)
419
+ // When in SSR mode, we use ViteSSRStackable, which is a subclass of @platformatic/node
420
+ const viteConfig = configManager.current.vite ?? {}
421
+
422
+ if (viteConfig.ssr?.enabled) {
423
+ return new ViteSSRStackable(opts, root, configManager)
205
424
  }
206
425
 
207
426
  return new ViteStackable(opts, root, configManager)
208
427
  }
209
428
 
429
+ export { schema, schemaComponents } from './lib/schema.js'
430
+
210
431
  export default {
211
432
  configType: 'vite',
212
433
  configManagerConfig: {
package/lib/schema.js CHANGED
@@ -1,9 +1,52 @@
1
- import { schemaComponents } from '@platformatic/basic'
2
- import { schemas as utilsSchema } from '@platformatic/utils'
1
+ import { schemaComponents as basicSchemaComponents } from '@platformatic/basic'
2
+ import { schemaComponents as utilsSchemaComponents } from '@platformatic/utils'
3
3
  import { readFileSync } from 'node:fs'
4
4
 
5
5
  export const packageJson = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf-8'))
6
6
 
7
+ const vite = {
8
+ type: 'object',
9
+ properties: {
10
+ configFile: {
11
+ oneOf: [{ type: 'string' }, { type: 'boolean' }]
12
+ },
13
+ devServer: {
14
+ type: 'object',
15
+ properties: {
16
+ strict: {
17
+ type: 'boolean',
18
+ // This required to avoid showing error users when the node_modules
19
+ // for vite or similar are in some nested parent folders
20
+ default: false
21
+ }
22
+ },
23
+ additionalProperties: false,
24
+ default: {}
25
+ },
26
+ ssr: {
27
+ oneOf: [
28
+ {
29
+ type: 'object',
30
+ properties: {
31
+ enabled: { type: 'boolean' },
32
+ entrypoint: { type: 'string', default: 'server.js' },
33
+ clientDirectory: { type: 'string', default: 'client' },
34
+ serverDirectory: { type: 'string', default: 'server' }
35
+ },
36
+ required: ['entrypoint'],
37
+ additionalProperties: false
38
+ },
39
+ { type: 'boolean' }
40
+ ],
41
+ default: false
42
+ }
43
+ },
44
+ default: {},
45
+ additionalProperties: false
46
+ }
47
+
48
+ export const schemaComponents = { vite }
49
+
7
50
  export const schema = {
8
51
  $id: `https://schemas.platformatic.dev/@platformatic/vite/${packageJson.version}.json`,
9
52
  $schema: 'http://json-schema.org/draft-07/schema#',
@@ -13,30 +56,10 @@ export const schema = {
13
56
  $schema: {
14
57
  type: 'string'
15
58
  },
16
- server: utilsSchema.server,
17
- watch: schemaComponents.watch,
18
- application: schemaComponents.application,
19
- vite: {
20
- type: 'object',
21
- properties: {
22
- configFile: {
23
- oneOf: [{ type: 'string' }, { type: 'boolean' }]
24
- },
25
- ssr: {
26
- oneOf: [
27
- {
28
- type: 'object',
29
- properties: { entrypoint: { type: 'string' } },
30
- required: ['entrypoint'],
31
- additionalProperties: false
32
- },
33
- { type: 'boolean' }
34
- ]
35
- }
36
- },
37
- additionalProperties: false
38
- },
39
- deploy: schemaComponents.deploy
59
+ server: utilsSchemaComponents.server,
60
+ watch: basicSchemaComponents.watch,
61
+ application: basicSchemaComponents.application,
62
+ vite
40
63
  },
41
64
  additionalProperties: false
42
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/vite",
3
- "version": "2.0.0-alpha.7",
3
+ "version": "2.0.0-alpha.9",
4
4
  "description": "Platformatic Vite Stackable",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -15,17 +15,18 @@
15
15
  },
16
16
  "homepage": "https://github.com/platformatic/platformatic#readme",
17
17
  "dependencies": {
18
+ "@fastify/static": "^7.0.4",
19
+ "fastify": "5.0.0-alpha.4",
18
20
  "semver": "^7.6.3",
19
- "@platformatic/config": "2.0.0-alpha.7",
20
- "@platformatic/node": "2.0.0-alpha.7",
21
- "@platformatic/utils": "2.0.0-alpha.7",
22
- "@platformatic/basic": "2.0.0-alpha.7"
21
+ "@platformatic/basic": "2.0.0-alpha.9",
22
+ "@platformatic/config": "2.0.0-alpha.9",
23
+ "@platformatic/utils": "2.0.0-alpha.9",
24
+ "@platformatic/node": "2.0.0-alpha.9"
23
25
  },
24
26
  "devDependencies": {
25
- "@fastify/vite": "^6.0.7",
27
+ "@fastify/vite": "7.0.0-alpha.1",
26
28
  "borp": "^0.17.0",
27
29
  "eslint": "9",
28
- "fastify": "^4.28.1",
29
30
  "json-schema-to-typescript": "^15.0.1",
30
31
  "neostandard": "^0.11.1",
31
32
  "react": "^18.3.1",
@@ -33,12 +34,12 @@
33
34
  "typescript": "^5.5.4",
34
35
  "vite": "^5.4.0",
35
36
  "ws": "^8.18.0",
36
- "@platformatic/composer": "2.0.0-alpha.7",
37
- "@platformatic/service": "2.0.0-alpha.7"
37
+ "@platformatic/service": "2.0.0-alpha.9",
38
+ "@platformatic/composer": "2.0.0-alpha.9"
38
39
  },
39
40
  "scripts": {
40
- "test": "npm run lint && borp --concurrency=1 --timeout=180000",
41
- "coverage": "npm run lint && borp -C -X test -X test/fixtures --concurrency=1 --timeout=180000",
41
+ "test": "npm run lint && borp --concurrency=1 --no-timeout",
42
+ "coverage": "npm run lint && borp -C -X test -X test/fixtures --concurrency=1 --no-timeout",
42
43
  "gen-schema": "node lib/schema.js > schema.json",
43
44
  "gen-types": "json2ts > config.d.ts < schema.json",
44
45
  "build": "pnpm run gen-schema && pnpm run gen-types",