@platformatic/vite 2.0.0-alpha.6 → 2.0.0-alpha.8

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 +14 -0
  2. package/eslint.config.js +1 -1
  3. package/index.js +294 -52
  4. package/lib/schema.js +51 -27
  5. package/package.json +11 -10
  6. package/schema.json +63 -4
  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
@@ -152,12 +152,26 @@ export interface PlatformaticViteStackable {
152
152
  | string;
153
153
  application?: {
154
154
  basePath?: string;
155
+ outputDirectory?: string;
156
+ include?: string[];
157
+ commands?: {
158
+ install?: string;
159
+ build?: string;
160
+ development?: string;
161
+ production?: string;
162
+ };
155
163
  };
156
164
  vite?: {
157
165
  configFile?: string | boolean;
166
+ devServer?: {
167
+ strict?: boolean;
168
+ };
158
169
  ssr?:
159
170
  | {
171
+ enabled?: boolean;
160
172
  entrypoint: string;
173
+ clientDirectory?: string;
174
+ serverDirectory?: string;
161
175
  }
162
176
  | boolean;
163
177
  };
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,8 +1,21 @@
1
- import { BaseStackable, createServerListener, errors, getServerUrl, importFile } from '@platformatic/basic'
1
+ import fastifyStatic from '@fastify/static'
2
+ import {
3
+ BaseStackable,
4
+ transformConfig as basicTransformConfig,
5
+ cleanBasePath,
6
+ createServerListener,
7
+ ensureTrailingSlash,
8
+ errors,
9
+ getServerUrl,
10
+ importFile,
11
+ resolvePackage,
12
+ schemaOptions
13
+ } from '@platformatic/basic'
2
14
  import { ConfigManager } from '@platformatic/config'
3
15
  import { NodeStackable } from '@platformatic/node'
4
- import { readFile } from 'node:fs/promises'
5
- import { createRequire } from 'node:module'
16
+ import fastify from 'fastify'
17
+ import { existsSync } from 'node:fs'
18
+ import { readFile, writeFile } from 'node:fs/promises'
6
19
  import { dirname, resolve } from 'node:path'
7
20
  import { pathToFileURL } from 'node:url'
8
21
  import { satisfies } from 'semver'
@@ -21,7 +34,7 @@ export class ViteStackable extends BaseStackable {
21
34
  }
22
35
 
23
36
  async init () {
24
- this.#vite = dirname(createRequire(this.root).resolve('vite'))
37
+ this.#vite = dirname(resolvePackage(this.root, 'vite'))
25
38
  const vitePackage = JSON.parse(await readFile(resolve(this.#vite, 'package.json'), 'utf-8'))
26
39
 
27
40
  /* c8 ignore next 3 */
@@ -30,20 +43,135 @@ export class ViteStackable extends BaseStackable {
30
43
  }
31
44
  }
32
45
 
33
- async start () {
46
+ async start ({ listen }) {
34
47
  // Make this idempotent
35
48
  if (this.url) {
36
49
  return this.url
37
50
  }
38
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 () {
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 () {
39
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
+ }
40
171
 
41
172
  // Prepare options
42
173
  const { hostname, port, https, cors } = this.serverConfig ?? {}
43
- const configFile = config.vite?.configFile ? resolve(this.root, config.vite?.configFile) : undefined
44
- const basePath = config.application?.basePath
45
- ? `/${config.application?.basePath}`.replaceAll(/\/+/g, '/').replace(/\/$/, '')
46
- : undefined
174
+ const configFile = config.vite.configFile ? resolve(this.root, config.vite.configFile) : undefined
47
175
 
48
176
  const serverOptions = {
49
177
  host: hostname || '127.0.0.1',
@@ -52,17 +180,20 @@ export class ViteStackable extends BaseStackable {
52
180
  https,
53
181
  cors,
54
182
  origin: 'http://localhost',
55
- hmr: true
183
+ hmr: true,
184
+ fs: {
185
+ strict: config.vite.devServer.strict
186
+ }
56
187
  }
57
188
 
58
189
  // Require Vite
59
- const serverPromise = createServerListener()
190
+ const serverPromise = createServerListener((this.isEntrypoint ? serverOptions?.port : undefined) ?? true)
60
191
  const { createServer } = await importFile(resolve(this.#vite, 'dist/node/index.js'))
61
192
 
62
193
  // Create the server and listen
63
194
  this.#app = await createServer({
64
195
  root: this.root,
65
- base: basePath,
196
+ base: this.#basePath,
66
197
  mode: 'development',
67
198
  configFile,
68
199
  logLevel: this.logger.level,
@@ -76,42 +207,56 @@ export class ViteStackable extends BaseStackable {
76
207
  this.url = getServerUrl(this.#server)
77
208
  }
78
209
 
79
- async stop () {
80
- return this.#app.close()
81
- }
210
+ async #startProduction (listen) {
211
+ const config = this.configManager.current
212
+ const command = this.configManager.current.application.commands.production
82
213
 
83
- /* c8 ignore next 5 */
84
- async getWatchConfig () {
85
- return {
86
- 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)
87
220
  }
88
- }
89
221
 
90
- getMeta () {
91
- if (!this.#basePath) {
92
- this.#basePath = this.#app.config.base.replace(/(^\/)|(\/$)/g, '')
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
93
227
  }
94
228
 
95
- return {
96
- composer: {
97
- tcp: true,
98
- url: this.url,
99
- prefix: this.#basePath,
100
- wantsAbsoluteUrls: true
229
+ this.#app = fastify({ logger: { level: 'info' } })
230
+
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)
101
241
  }
102
242
  }
103
- }
104
243
 
105
- _getVite () {
106
- return this.#app
244
+ await this.#app.register(fastifyStatic, {
245
+ root: outputDirectory,
246
+ prefix: this.#basePath,
247
+ prefixAvoidTrailingSlash: true,
248
+ schemaHide: true
249
+ })
250
+
251
+ await this.#app.ready()
107
252
  }
108
253
  }
109
254
 
110
255
  export class ViteSSRStackable extends NodeStackable {
111
256
  #basePath
112
257
 
113
- constructor (options, root, configManager, entrypoint) {
114
- super(options, root, configManager, entrypoint, true)
258
+ constructor (options, root, configManager) {
259
+ super(options, root, configManager)
115
260
 
116
261
  this.type = 'vite'
117
262
  }
@@ -120,14 +265,15 @@ export class ViteSSRStackable extends NodeStackable {
120
265
  const config = this.configManager.current
121
266
 
122
267
  this.#basePath = config.application?.basePath
123
- ? `/${config.application?.basePath}`.replaceAll(/\/+/g, '/').replace(/\/$/, '')
124
- : ''
268
+ ? ensureTrailingSlash(cleanBasePath(config.application?.basePath))
269
+ : undefined
125
270
 
126
271
  this.registerGlobals({
272
+ id: this.id,
127
273
  // Always use URL to avoid serialization problem in Windows
128
- root: pathToFileURL(this.root),
274
+ root: pathToFileURL(this.root).toString(),
129
275
  basePath: this.#basePath,
130
- logger: { id: this.id, level: this.logger.level }
276
+ logLevel: this.logger.level
131
277
  })
132
278
  }
133
279
 
@@ -138,28 +284,112 @@ export class ViteSSRStackable extends NodeStackable {
138
284
  return this.url
139
285
  }
140
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
+
141
301
  await super.start({ listen })
142
302
  await super._listen()
143
303
  }
144
304
 
145
- getMeta () {
146
- if (!this.#basePath) {
147
- this.#basePath = this._getApplication().vite.devServer.config.base.replace(/(^\/)|(\/$)/g, '')
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)
148
315
  }
149
316
 
150
- return {
151
- composer: {
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
+
363
+ getMeta () {
364
+ let composer = { prefix: this.servicePrefix, wantsAbsoluteUrls: true, needsRootRedirect: true }
365
+
366
+ if (this.url) {
367
+ if (!this.#basePath) {
368
+ const application = this._getApplication()
369
+ const config = application.vite.devServer?.config ?? application.vite.config.vite
370
+ this.#basePath = (config.base ?? '').replace(/(^\/)|(\/$)/g, '')
371
+ }
372
+
373
+ composer = {
152
374
  tcp: true,
153
375
  url: this.url,
154
- prefix: this.#basePath,
155
- wantsAbsoluteUrls: true
376
+ prefix: this.#basePath ?? this.servicePrefix,
377
+ wantsAbsoluteUrls: true,
378
+ needsRootRedirect: true
156
379
  }
157
380
  }
381
+
382
+ return { composer }
383
+ }
384
+
385
+ _findEntrypoint () {
386
+ const config = this.configManager.current.vite ?? {}
387
+ return resolve(this.root, config.ssr.entrypoint)
158
388
  }
159
389
  }
160
390
 
161
391
  /* c8 ignore next 9 */
162
- function transformConfig () {
392
+ export function transformConfig () {
163
393
  if (this.current.watch === undefined) {
164
394
  this.current.watch = { enabled: false }
165
395
  }
@@ -168,28 +398,40 @@ function transformConfig () {
168
398
  this.current.watch = { enabled: this.current.watch || false }
169
399
  }
170
400
 
171
- if (this.current.vite?.ssr === true) {
172
- 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
+ }
173
408
  }
409
+
410
+ basicTransformConfig.call(this)
174
411
  }
175
412
 
176
413
  export async function buildStackable (opts) {
177
414
  const root = opts.context.directory
178
415
 
179
- const configManager = new ConfigManager({ schema, source: opts.config ?? {}, transformConfig })
416
+ const configManager = new ConfigManager({ schema, source: opts.config ?? {}, schemaOptions, transformConfig })
180
417
  await configManager.parseAndValidate()
181
418
 
182
- // When in SSR mode, we use @platformatic/node
183
- if (configManager.current.vite?.ssr) {
184
- 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)
185
424
  }
186
425
 
187
426
  return new ViteStackable(opts, root, configManager)
188
427
  }
189
428
 
429
+ export { schema, schemaComponents } from './lib/schema.js'
430
+
190
431
  export default {
191
432
  configType: 'vite',
192
433
  configManagerConfig: {
434
+ schemaOptions,
193
435
  transformConfig
194
436
  },
195
437
  buildStackable,
package/lib/schema.js CHANGED
@@ -1,43 +1,67 @@
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
- export const schema = {
8
- $id: `https://schemas.platformatic.dev/@platformatic/vite/${packageJson.version}.json`,
9
- $schema: 'http://json-schema.org/draft-07/schema#',
10
- title: 'Platformatic Vite Stackable',
7
+ const vite = {
11
8
  type: 'object',
12
9
  properties: {
13
- $schema: {
14
- type: 'string',
10
+ configFile: {
11
+ oneOf: [{ type: 'string' }, { type: 'boolean' }]
15
12
  },
16
- server: utilsSchema.server,
17
- watch: schemaComponents.watch,
18
- application: schemaComponents.application,
19
- vite: {
13
+ devServer: {
20
14
  type: 'object',
21
15
  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
- },
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
+ }
36
22
  },
37
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
+
50
+ export const schema = {
51
+ $id: `https://schemas.platformatic.dev/@platformatic/vite/${packageJson.version}.json`,
52
+ $schema: 'http://json-schema.org/draft-07/schema#',
53
+ title: 'Platformatic Vite Stackable',
54
+ type: 'object',
55
+ properties: {
56
+ $schema: {
57
+ type: 'string'
38
58
  },
59
+ server: utilsSchemaComponents.server,
60
+ watch: basicSchemaComponents.watch,
61
+ application: basicSchemaComponents.application,
62
+ vite
39
63
  },
40
- additionalProperties: false,
64
+ additionalProperties: false
41
65
  }
42
66
 
43
67
  /* c8 ignore next 3 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/vite",
3
- "version": "2.0.0-alpha.6",
3
+ "version": "2.0.0-alpha.8",
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": "^4.28.1",
18
20
  "semver": "^7.6.3",
19
- "@platformatic/basic": "2.0.0-alpha.6",
20
- "@platformatic/node": "2.0.0-alpha.6",
21
- "@platformatic/config": "2.0.0-alpha.6",
22
- "@platformatic/utils": "2.0.0-alpha.6"
21
+ "@platformatic/basic": "2.0.0-alpha.8",
22
+ "@platformatic/config": "2.0.0-alpha.8",
23
+ "@platformatic/utils": "2.0.0-alpha.8",
24
+ "@platformatic/node": "2.0.0-alpha.8"
23
25
  },
24
26
  "devDependencies": {
25
27
  "@fastify/vite": "^6.0.7",
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.6",
37
- "@platformatic/service": "2.0.0-alpha.6"
37
+ "@platformatic/composer": "2.0.0-alpha.8",
38
+ "@platformatic/service": "2.0.0-alpha.8"
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",