@platformatic/vite 2.0.0-alpha.7 → 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 -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 +11 -10
  6. package/schema.json +63 -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.8.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Vite Stackable",
5
5
  "type": "object",
@@ -497,9 +497,43 @@
497
497
  "properties": {
498
498
  "basePath": {
499
499
  "type": "string"
500
+ },
501
+ "outputDirectory": {
502
+ "type": "string",
503
+ "default": "dist"
504
+ },
505
+ "include": {
506
+ "type": "array",
507
+ "items": {
508
+ "type": "string"
509
+ },
510
+ "default": [
511
+ "dist"
512
+ ]
513
+ },
514
+ "commands": {
515
+ "type": "object",
516
+ "properties": {
517
+ "install": {
518
+ "type": "string",
519
+ "default": "npm ci --omit-dev"
520
+ },
521
+ "build": {
522
+ "type": "string"
523
+ },
524
+ "development": {
525
+ "type": "string"
526
+ },
527
+ "production": {
528
+ "type": "string"
529
+ }
530
+ },
531
+ "default": {},
532
+ "additionalProperties": false
500
533
  }
501
534
  },
502
- "additionalProperties": false
535
+ "additionalProperties": false,
536
+ "default": {}
503
537
  },
504
538
  "vite": {
505
539
  "type": "object",
@@ -514,13 +548,36 @@
514
548
  }
515
549
  ]
516
550
  },
551
+ "devServer": {
552
+ "type": "object",
553
+ "properties": {
554
+ "strict": {
555
+ "type": "boolean",
556
+ "default": false
557
+ }
558
+ },
559
+ "additionalProperties": false,
560
+ "default": {}
561
+ },
517
562
  "ssr": {
518
563
  "oneOf": [
519
564
  {
520
565
  "type": "object",
521
566
  "properties": {
567
+ "enabled": {
568
+ "type": "boolean"
569
+ },
522
570
  "entrypoint": {
523
- "type": "string"
571
+ "type": "string",
572
+ "default": "server.js"
573
+ },
574
+ "clientDirectory": {
575
+ "type": "string",
576
+ "default": "client"
577
+ },
578
+ "serverDirectory": {
579
+ "type": "string",
580
+ "default": "server"
524
581
  }
525
582
  },
526
583
  "required": [
@@ -531,37 +588,12 @@
531
588
  {
532
589
  "type": "boolean"
533
590
  }
534
- ]
591
+ ],
592
+ "default": false
535
593
  }
536
594
  },
595
+ "default": {},
537
596
  "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
597
  }
566
598
  },
567
599
  "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
- }