@platformatic/vite 2.0.0-alpha.5
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.
- package/LICENSE +201 -0
- package/NOTICE +13 -0
- package/README.md +13 -0
- package/config.d.ts +164 -0
- package/eslint.config.js +5 -0
- package/index.js +198 -0
- package/lib/schema.js +46 -0
- package/package.json +47 -0
- package/schema.json +541 -0
- package/test/fixtures/platformatic-composer/platformatic.composer.json +20 -0
- package/test/fixtures/platformatic-composer/platformatic.no-prefix.composer.json +23 -0
- package/test/fixtures/platformatic-composer/plugin.js +9 -0
- package/test/fixtures/platformatic-service/platformatic.service.json +15 -0
- package/test/fixtures/platformatic-service/plugin.js +19 -0
- package/test/fixtures/vite/composer-autodetect-prefix/custom.vite.config.js +3 -0
- package/test/fixtures/vite/composer-autodetect-prefix/index.html +13 -0
- package/test/fixtures/vite/composer-autodetect-prefix/main.js +3 -0
- package/test/fixtures/vite/composer-autodetect-prefix/package.json +14 -0
- package/test/fixtures/vite/composer-autodetect-prefix/platformatic.application.json +11 -0
- package/test/fixtures/vite/composer-autodetect-prefix/platformatic.runtime.json +20 -0
- package/test/fixtures/vite/composer-with-prefix/index.html +13 -0
- package/test/fixtures/vite/composer-with-prefix/main.js +3 -0
- package/test/fixtures/vite/composer-with-prefix/package.json +14 -0
- package/test/fixtures/vite/composer-with-prefix/platformatic.application.json +11 -0
- package/test/fixtures/vite/composer-with-prefix/platformatic.runtime.json +21 -0
- package/test/fixtures/vite/composer-without-prefix/index.html +13 -0
- package/test/fixtures/vite/composer-without-prefix/main.js +3 -0
- package/test/fixtures/vite/composer-without-prefix/package.json +14 -0
- package/test/fixtures/vite/composer-without-prefix/platformatic.application.json +8 -0
- package/test/fixtures/vite/composer-without-prefix/platformatic.runtime.json +21 -0
- package/test/fixtures/vite/ssr-autodetect-prefix/client/index.html +12 -0
- package/test/fixtures/vite/ssr-autodetect-prefix/client/index.js +7 -0
- package/test/fixtures/vite/ssr-autodetect-prefix/package.json +15 -0
- package/test/fixtures/vite/ssr-autodetect-prefix/platformatic.application.json +11 -0
- package/test/fixtures/vite/ssr-autodetect-prefix/platformatic.runtime.json +21 -0
- package/test/fixtures/vite/ssr-autodetect-prefix/server.js +35 -0
- package/test/fixtures/vite/ssr-autodetect-prefix/vite.config.js +7 -0
- package/test/fixtures/vite/ssr-with-prefix/client/index.html +12 -0
- package/test/fixtures/vite/ssr-with-prefix/client/index.js +7 -0
- package/test/fixtures/vite/ssr-with-prefix/package.json +15 -0
- package/test/fixtures/vite/ssr-with-prefix/platformatic.application.json +14 -0
- package/test/fixtures/vite/ssr-with-prefix/platformatic.runtime.json +21 -0
- package/test/fixtures/vite/ssr-with-prefix/server.js +35 -0
- package/test/fixtures/vite/ssr-with-prefix/vite.config.js +7 -0
- package/test/fixtures/vite/ssr-without-prefix/client/index.html +12 -0
- package/test/fixtures/vite/ssr-without-prefix/client/index.js +7 -0
- package/test/fixtures/vite/ssr-without-prefix/package.json +15 -0
- package/test/fixtures/vite/ssr-without-prefix/platformatic.application.json +11 -0
- package/test/fixtures/vite/ssr-without-prefix/platformatic.runtime.json +21 -0
- package/test/fixtures/vite/ssr-without-prefix/server.js +34 -0
- package/test/fixtures/vite/ssr-without-prefix/vite.config.js +7 -0
- package/test/fixtures/vite/standalone/custom.vite.config.js +3 -0
- package/test/fixtures/vite/standalone/index.html +13 -0
- package/test/fixtures/vite/standalone/main.js +3 -0
- package/test/fixtures/vite/standalone/package.json +15 -0
- package/test/fixtures/vite/standalone/platformatic.runtime.json +18 -0
- package/test/index.test.js +161 -0
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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>
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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>
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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>
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
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 }
|
|
@@ -0,0 +1,12 @@
|
|
|
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>
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
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: globalThis.platformatic.basePath, logLevel: globalThis.platformatic.logger.level }
|
|
@@ -0,0 +1,12 @@
|
|
|
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>
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
|
|
21
|
+
server.get('/', (req, reply) => {
|
|
22
|
+
return reply.type('text/html').html()
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
server.get('/direct', (req, reply) => {
|
|
26
|
+
return { ok: true }
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
server.get('/*', (req, reply) => {
|
|
30
|
+
return reply.type('text/html').html()
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
return server
|
|
34
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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>
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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": "main",
|
|
15
|
+
"path": "."
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|