@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/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/vite/2.0.0-alpha.7.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/vite/2.0.0-alpha.9.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Vite Stackable",
5
5
  "type": "object",
@@ -161,6 +161,9 @@
161
161
  }
162
162
  ]
163
163
  },
164
+ "loggerInstance": {
165
+ "type": "object"
166
+ },
164
167
  "serializerOpts": {
165
168
  "type": "object",
166
169
  "properties": {
@@ -497,9 +500,43 @@
497
500
  "properties": {
498
501
  "basePath": {
499
502
  "type": "string"
503
+ },
504
+ "outputDirectory": {
505
+ "type": "string",
506
+ "default": "dist"
507
+ },
508
+ "include": {
509
+ "type": "array",
510
+ "items": {
511
+ "type": "string"
512
+ },
513
+ "default": [
514
+ "dist"
515
+ ]
516
+ },
517
+ "commands": {
518
+ "type": "object",
519
+ "properties": {
520
+ "install": {
521
+ "type": "string",
522
+ "default": "npm ci --omit-dev"
523
+ },
524
+ "build": {
525
+ "type": "string"
526
+ },
527
+ "development": {
528
+ "type": "string"
529
+ },
530
+ "production": {
531
+ "type": "string"
532
+ }
533
+ },
534
+ "default": {},
535
+ "additionalProperties": false
500
536
  }
501
537
  },
502
- "additionalProperties": false
538
+ "additionalProperties": false,
539
+ "default": {}
503
540
  },
504
541
  "vite": {
505
542
  "type": "object",
@@ -514,13 +551,36 @@
514
551
  }
515
552
  ]
516
553
  },
554
+ "devServer": {
555
+ "type": "object",
556
+ "properties": {
557
+ "strict": {
558
+ "type": "boolean",
559
+ "default": false
560
+ }
561
+ },
562
+ "additionalProperties": false,
563
+ "default": {}
564
+ },
517
565
  "ssr": {
518
566
  "oneOf": [
519
567
  {
520
568
  "type": "object",
521
569
  "properties": {
570
+ "enabled": {
571
+ "type": "boolean"
572
+ },
522
573
  "entrypoint": {
523
- "type": "string"
574
+ "type": "string",
575
+ "default": "server.js"
576
+ },
577
+ "clientDirectory": {
578
+ "type": "string",
579
+ "default": "client"
580
+ },
581
+ "serverDirectory": {
582
+ "type": "string",
583
+ "default": "server"
524
584
  }
525
585
  },
526
586
  "required": [
@@ -531,37 +591,12 @@
531
591
  {
532
592
  "type": "boolean"
533
593
  }
534
- ]
594
+ ],
595
+ "default": false
535
596
  }
536
597
  },
598
+ "default": {},
537
599
  "additionalProperties": false
538
- },
539
- "deploy": {
540
- "type": "object",
541
- "properties": {
542
- "include": {
543
- "type": "array",
544
- "items": {
545
- "type": "string"
546
- },
547
- "default": [
548
- "dist"
549
- ]
550
- },
551
- "buildCommand": {
552
- "type": "string",
553
- "default": "npm run build"
554
- },
555
- "installCommand": {
556
- "type": "string",
557
- "default": "npm ci --omit-dev"
558
- },
559
- "startCommand": {
560
- "type": "string",
561
- "default": "npm run start"
562
- }
563
- },
564
- "default": {}
565
600
  }
566
601
  },
567
602
  "additionalProperties": false
@@ -1,20 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/composer/1.52.0.json",
3
- "composer": {
4
- "services": [
5
- {
6
- "id": "frontend"
7
- },
8
- {
9
- "id": "service"
10
- }
11
- ]
12
- },
13
- "plugins": {
14
- "paths": [
15
- {
16
- "path": "./plugin.js"
17
- }
18
- ]
19
- }
20
- }
@@ -1,23 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/composer/1.52.0.json",
3
- "composer": {
4
- "services": [
5
- {
6
- "id": "frontend",
7
- "proxy": {
8
- "prefix": ""
9
- }
10
- },
11
- {
12
- "id": "service"
13
- }
14
- ]
15
- },
16
- "plugins": {
17
- "paths": [
18
- {
19
- "path": "./plugin.js"
20
- }
21
- ]
22
- }
23
- }
@@ -1,9 +0,0 @@
1
- export default async function (app) {
2
- app.get('/plugin', async () => {
3
- return { ok: true }
4
- })
5
-
6
- app.get('/frontend/plugin', async () => {
7
- return { ok: true }
8
- })
9
- }
@@ -1,15 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/service/1.52.0.json",
3
- "server": {
4
- "logger": {
5
- "level": "error"
6
- }
7
- },
8
- "plugins": {
9
- "paths": [
10
- {
11
- "path": "./plugin.js"
12
- }
13
- ]
14
- }
15
- }
@@ -1,19 +0,0 @@
1
- 'use strict'
2
-
3
- export default async function (app) {
4
- app.get('/mesh', async () => {
5
- const meta = await globalThis[Symbol.for('plt.runtime.itc')].send('getServiceMeta', 'frontend')
6
-
7
- const url = new URL(`${meta.composer.prefix}/direct`.replaceAll(/\/+/g, '/'), 'http://frontend.plt.local')
8
- const response = await fetch(url)
9
- return response.json()
10
- })
11
-
12
- app.get('/direct', async () => {
13
- return { ok: true }
14
- })
15
-
16
- app.get('/time', async () => {
17
- return { time: Date.now() }
18
- })
19
- }
@@ -1,3 +0,0 @@
1
- export default {
2
- base: '/nested/base/dir',
3
- }
@@ -1,13 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>Vite App</title>
8
- </head>
9
- <body>
10
- <div id="app"></div>
11
- <script type="module" src="/main.js"></script>
12
- </body>
13
- </html>
@@ -1,3 +0,0 @@
1
- import { version } from '../../../tmp/version.js'
2
-
3
- document.querySelector('#app').innerHTML = `<div>Hello from ${version}</div>`
@@ -1,14 +0,0 @@
1
- {
2
- "name": "vite",
3
- "private": true,
4
- "version": "0.0.0",
5
- "type": "module",
6
- "scripts": {
7
- "dev": "vite",
8
- "build": "vite build",
9
- "preview": "vite preview"
10
- },
11
- "devDependencies": {
12
- "vite": "^5.3.4"
13
- }
14
- }
@@ -1,11 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/vite/2.0.0.json",
3
- "server": {
4
- "logger": {
5
- "level": "error"
6
- }
7
- },
8
- "vite": {
9
- "configFile": "custom.vite.config.js"
10
- }
11
- }
@@ -1,20 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/runtime/2.0.0.json",
3
- "entrypoint": "main",
4
- "watch": false,
5
- "managementApi": false,
6
- "metrics": false,
7
- "server": {
8
- "logger": {
9
- "level": "error"
10
- }
11
- },
12
- "services": [
13
- {
14
- "id": "frontend",
15
- "path": "."
16
- },
17
- { "id": "service", "config": "platformatic.service.json", "path": "../../platformatic-service" },
18
- { "id": "main", "config": "platformatic.no-prefix.composer.json", "path": "../../platformatic-composer" }
19
- ]
20
- }
@@ -1,13 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>Vite App</title>
8
- </head>
9
- <body>
10
- <div id="app"></div>
11
- <script type="module" src="/main.js"></script>
12
- </body>
13
- </html>
@@ -1,3 +0,0 @@
1
- import { version } from '../../../tmp/version.js'
2
-
3
- document.querySelector('#app').innerHTML = `<div>Hello from ${version}</div>`
@@ -1,14 +0,0 @@
1
- {
2
- "name": "vite",
3
- "private": true,
4
- "version": "0.0.0",
5
- "type": "module",
6
- "scripts": {
7
- "dev": "vite",
8
- "build": "vite build",
9
- "preview": "vite preview"
10
- },
11
- "devDependencies": {
12
- "vite": "^5.3.4"
13
- }
14
- }
@@ -1,11 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/vite/2.0.0.json",
3
- "server": {
4
- "logger": {
5
- "level": "error"
6
- }
7
- },
8
- "application": {
9
- "basePath": "/frontend"
10
- }
11
- }
@@ -1,21 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/runtime/1.52.0.json",
3
- "entrypoint": "main",
4
- "watch": false,
5
- "managementApi": false,
6
- "metrics": false,
7
- "server": {
8
- "logger": {
9
- "level": "error"
10
- }
11
- },
12
- "services": [
13
- {
14
- "id": "frontend",
15
- "path": ".",
16
- "config": "platformatic.application.json"
17
- },
18
- { "id": "service", "config": "platformatic.service.json", "path": "../../platformatic-service" },
19
- { "id": "main", "config": "platformatic.composer.json", "path": "../../platformatic-composer" }
20
- ]
21
- }
@@ -1,13 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>Vite App</title>
8
- </head>
9
- <body>
10
- <div id="app"></div>
11
- <script type="module" src="/main.js"></script>
12
- </body>
13
- </html>
@@ -1,3 +0,0 @@
1
- import { version } from '../../../tmp/version.js'
2
-
3
- document.querySelector('#app').innerHTML = `<div>Hello from ${version}</div>`
@@ -1,14 +0,0 @@
1
- {
2
- "name": "vite",
3
- "private": true,
4
- "version": "0.0.0",
5
- "type": "module",
6
- "scripts": {
7
- "dev": "vite",
8
- "build": "vite build",
9
- "preview": "vite preview"
10
- },
11
- "devDependencies": {
12
- "vite": "^5.3.4"
13
- }
14
- }
@@ -1,8 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/vite/2.0.0.json",
3
- "server": {
4
- "logger": {
5
- "level": "error"
6
- }
7
- }
8
- }
@@ -1,21 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/runtime/1.52.0.json",
3
- "entrypoint": "main",
4
- "watch": false,
5
- "managementApi": false,
6
- "metrics": false,
7
- "server": {
8
- "logger": {
9
- "level": "error"
10
- }
11
- },
12
- "services": [
13
- {
14
- "id": "frontend",
15
- "path": ".",
16
- "config": "platformatic.application.json"
17
- },
18
- { "id": "service", "config": "platformatic.service.json", "path": "../../platformatic-service" },
19
- { "id": "main", "config": "platformatic.no-prefix.composer.json", "path": "../../platformatic-composer" }
20
- ]
21
- }
@@ -1,12 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>Vite App</title>
8
- </head>
9
- <body>
10
- <div id="app"><!-- element --></div>
11
- </body>
12
- </html>
@@ -1,7 +0,0 @@
1
- import { version } from '../../../../tmp/version.js'
2
-
3
- export async function generate () {
4
- const response = await fetch('http://service.plt.local/time')
5
- const { time } = await response.json()
6
- return `<div>Hello from v${version} t${time}</div>`
7
- }
@@ -1,15 +0,0 @@
1
- {
2
- "name": "vite",
3
- "private": true,
4
- "version": "0.0.0",
5
- "type": "module",
6
- "scripts": {
7
- "dev": "vite",
8
- "build": "vite build",
9
- "preview": "vite preview"
10
- },
11
- "dependencies": {
12
- "@platformatic/vite": "workspace:*",
13
- "vite": "^5.3.4"
14
- }
15
- }
@@ -1,11 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/vite/2.0.0.json",
3
- "server": {
4
- "logger": {
5
- "level": "error"
6
- }
7
- },
8
- "vite": {
9
- "ssr": true
10
- }
11
- }
@@ -1,21 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/runtime/1.52.0.json",
3
- "entrypoint": "main",
4
- "watch": false,
5
- "managementApi": false,
6
- "metrics": false,
7
- "server": {
8
- "logger": {
9
- "level": "error"
10
- }
11
- },
12
- "services": [
13
- {
14
- "id": "frontend",
15
- "path": ".",
16
- "config": "platformatic.application.json"
17
- },
18
- { "id": "service", "config": "platformatic.service.json", "path": "../../platformatic-service" },
19
- { "id": "main", "config": "platformatic.no-prefix.composer.json", "path": "../../platformatic-composer" }
20
- ]
21
- }
@@ -1,35 +0,0 @@
1
- import fastifyVite from '@fastify/vite'
2
- import fastify from 'fastify'
3
-
4
- export async function build () {
5
- const server = fastify()
6
-
7
- await server.register(fastifyVite, {
8
- root: import.meta.url,
9
- dev: true,
10
- createRenderFunction ({ generate }) {
11
- return async () => {
12
- return {
13
- element: await generate()
14
- }
15
- }
16
- }
17
- })
18
-
19
- await server.vite.ready()
20
- const prefix = server.vite.devServer.config.base.replace(/\/$/, '')
21
-
22
- server.get(prefix, (req, reply) => {
23
- return reply.type('text/html').html()
24
- })
25
-
26
- server.get(prefix + '/direct', (req, reply) => {
27
- return { ok: true }
28
- })
29
-
30
- server.get(prefix + '/*', (req, reply) => {
31
- return reply.type('text/html').html()
32
- })
33
-
34
- return server
35
- }
@@ -1,7 +0,0 @@
1
- import { dirname, resolve } from 'node:path'
2
- import { fileURLToPath } from 'node:url'
3
-
4
- const path = fileURLToPath(import.meta.url)
5
- const root = resolve(dirname(path), 'client')
6
-
7
- export default { root, base: '/nested/base/dir', logLevel: globalThis.platformatic.logger.level }
@@ -1,12 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>Vite App</title>
8
- </head>
9
- <body>
10
- <div id="app"><!-- element --></div>
11
- </body>
12
- </html>
@@ -1,7 +0,0 @@
1
- import { version } from '../../../../tmp/version.js'
2
-
3
- export async function generate () {
4
- const response = await fetch('http://service.plt.local/time')
5
- const { time } = await response.json()
6
- return `<div>Hello from v${version} t${time}</div>`
7
- }
@@ -1,15 +0,0 @@
1
- {
2
- "name": "vite",
3
- "private": true,
4
- "version": "0.0.0",
5
- "type": "module",
6
- "scripts": {
7
- "dev": "vite",
8
- "build": "vite build",
9
- "preview": "vite preview"
10
- },
11
- "dependencies": {
12
- "@platformatic/vite": "workspace:*",
13
- "vite": "^5.3.4"
14
- }
15
- }
@@ -1,14 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/vite/2.0.0.json",
3
- "server": {
4
- "logger": {
5
- "level": "error"
6
- }
7
- },
8
- "application": {
9
- "basePath": "/frontend"
10
- },
11
- "vite": {
12
- "ssr": true
13
- }
14
- }
@@ -1,21 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/runtime/1.52.0.json",
3
- "entrypoint": "main",
4
- "watch": false,
5
- "managementApi": false,
6
- "metrics": false,
7
- "server": {
8
- "logger": {
9
- "level": "error"
10
- }
11
- },
12
- "services": [
13
- {
14
- "id": "frontend",
15
- "path": ".",
16
- "config": "platformatic.application.json"
17
- },
18
- { "id": "service", "config": "platformatic.service.json", "path": "../../platformatic-service" },
19
- { "id": "main", "config": "platformatic.composer.json", "path": "../../platformatic-composer" }
20
- ]
21
- }