@platformatic/vite 2.0.0-alpha.5 → 2.0.0-alpha.7
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/config.d.ts +7 -0
- package/index.js +49 -28
- package/lib/schema.js +9 -8
- package/package.json +8 -8
- package/schema.json +28 -1
- package/test/fixtures/vite/composer-without-prefix/platformatic.application.json +1 -1
package/config.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
BaseStackable,
|
|
3
|
+
transformConfig as basicTransformConfig,
|
|
4
|
+
createServerListener,
|
|
5
|
+
errors,
|
|
6
|
+
getServerUrl,
|
|
7
|
+
importFile,
|
|
8
|
+
schemaOptions
|
|
9
|
+
} from '@platformatic/basic'
|
|
2
10
|
import { ConfigManager } from '@platformatic/config'
|
|
3
11
|
import { NodeStackable } from '@platformatic/node'
|
|
4
12
|
import { readFile } from 'node:fs/promises'
|
|
@@ -21,8 +29,6 @@ export class ViteStackable extends BaseStackable {
|
|
|
21
29
|
}
|
|
22
30
|
|
|
23
31
|
async init () {
|
|
24
|
-
globalThis[Symbol.for('plt.runtime.itc')].handle('getServiceMeta', this.getMeta.bind(this))
|
|
25
|
-
|
|
26
32
|
this.#vite = dirname(createRequire(this.root).resolve('vite'))
|
|
27
33
|
const vitePackage = JSON.parse(await readFile(resolve(this.#vite, 'package.json'), 'utf-8'))
|
|
28
34
|
|
|
@@ -54,7 +60,7 @@ export class ViteStackable extends BaseStackable {
|
|
|
54
60
|
https,
|
|
55
61
|
cors,
|
|
56
62
|
origin: 'http://localhost',
|
|
57
|
-
hmr: true
|
|
63
|
+
hmr: true
|
|
58
64
|
}
|
|
59
65
|
|
|
60
66
|
// Require Vite
|
|
@@ -70,7 +76,7 @@ export class ViteStackable extends BaseStackable {
|
|
|
70
76
|
logLevel: this.logger.level,
|
|
71
77
|
clearScreen: false,
|
|
72
78
|
optimizeDeps: { force: false },
|
|
73
|
-
server: serverOptions
|
|
79
|
+
server: serverOptions
|
|
74
80
|
})
|
|
75
81
|
|
|
76
82
|
await this.#app.listen()
|
|
@@ -85,23 +91,32 @@ export class ViteStackable extends BaseStackable {
|
|
|
85
91
|
/* c8 ignore next 5 */
|
|
86
92
|
async getWatchConfig () {
|
|
87
93
|
return {
|
|
88
|
-
enabled: false
|
|
94
|
+
enabled: false
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
getMeta () {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
99
|
+
const deploy = this.configManager.current.deploy
|
|
100
|
+
let composer
|
|
96
101
|
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
if (this.url) {
|
|
103
|
+
if (!this.#basePath) {
|
|
104
|
+
this.#basePath = this.#app.config.base.replace(/(^\/)|(\/$)/g, '')
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
composer = {
|
|
99
108
|
tcp: true,
|
|
100
109
|
url: this.url,
|
|
101
110
|
prefix: this.#basePath,
|
|
102
|
-
wantsAbsoluteUrls: true
|
|
103
|
-
}
|
|
111
|
+
wantsAbsoluteUrls: true
|
|
112
|
+
}
|
|
104
113
|
}
|
|
114
|
+
|
|
115
|
+
return { deploy, composer }
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
_getVite () {
|
|
119
|
+
return this.#app
|
|
105
120
|
}
|
|
106
121
|
}
|
|
107
122
|
|
|
@@ -115,20 +130,18 @@ export class ViteSSRStackable extends NodeStackable {
|
|
|
115
130
|
}
|
|
116
131
|
|
|
117
132
|
async init () {
|
|
118
|
-
globalThis[Symbol.for('plt.runtime.itc')].handle('getServiceMeta', this.getMeta.bind(this))
|
|
119
|
-
|
|
120
133
|
const config = this.configManager.current
|
|
121
134
|
|
|
122
135
|
this.#basePath = config.application?.basePath
|
|
123
136
|
? `/${config.application?.basePath}`.replaceAll(/\/+/g, '/').replace(/\/$/, '')
|
|
124
137
|
: ''
|
|
125
138
|
|
|
126
|
-
|
|
139
|
+
this.registerGlobals({
|
|
127
140
|
// Always use URL to avoid serialization problem in Windows
|
|
128
141
|
root: pathToFileURL(this.root),
|
|
129
142
|
basePath: this.#basePath,
|
|
130
|
-
logger: { id: this.id, level: this.logger.level }
|
|
131
|
-
}
|
|
143
|
+
logger: { id: this.id, level: this.logger.level }
|
|
144
|
+
})
|
|
132
145
|
}
|
|
133
146
|
|
|
134
147
|
async start ({ listen }) {
|
|
@@ -143,18 +156,23 @@ export class ViteSSRStackable extends NodeStackable {
|
|
|
143
156
|
}
|
|
144
157
|
|
|
145
158
|
getMeta () {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
159
|
+
const deploy = this.configManager.current.deploy
|
|
160
|
+
let composer
|
|
149
161
|
|
|
150
|
-
|
|
151
|
-
|
|
162
|
+
if (this.url) {
|
|
163
|
+
if (!this.#basePath) {
|
|
164
|
+
this.#basePath = this._getApplication().vite.devServer.config.base.replace(/(^\/)|(\/$)/g, '')
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
composer = {
|
|
152
168
|
tcp: true,
|
|
153
169
|
url: this.url,
|
|
154
170
|
prefix: this.#basePath,
|
|
155
|
-
wantsAbsoluteUrls: true
|
|
156
|
-
}
|
|
171
|
+
wantsAbsoluteUrls: true
|
|
172
|
+
}
|
|
157
173
|
}
|
|
174
|
+
|
|
175
|
+
return { deploy, composer }
|
|
158
176
|
}
|
|
159
177
|
}
|
|
160
178
|
|
|
@@ -171,12 +189,14 @@ function transformConfig () {
|
|
|
171
189
|
if (this.current.vite?.ssr === true) {
|
|
172
190
|
this.current.vite.ssr = { entrypoint: 'server.js' }
|
|
173
191
|
}
|
|
192
|
+
|
|
193
|
+
basicTransformConfig.call(this)
|
|
174
194
|
}
|
|
175
195
|
|
|
176
196
|
export async function buildStackable (opts) {
|
|
177
197
|
const root = opts.context.directory
|
|
178
198
|
|
|
179
|
-
const configManager = new ConfigManager({ schema, source: opts.config ?? {}, transformConfig })
|
|
199
|
+
const configManager = new ConfigManager({ schema, source: opts.config ?? {}, schemaOptions, transformConfig })
|
|
180
200
|
await configManager.parseAndValidate()
|
|
181
201
|
|
|
182
202
|
// When in SSR mode, we use @platformatic/node
|
|
@@ -190,9 +210,10 @@ export async function buildStackable (opts) {
|
|
|
190
210
|
export default {
|
|
191
211
|
configType: 'vite',
|
|
192
212
|
configManagerConfig: {
|
|
193
|
-
|
|
213
|
+
schemaOptions,
|
|
214
|
+
transformConfig
|
|
194
215
|
},
|
|
195
216
|
buildStackable,
|
|
196
217
|
schema,
|
|
197
|
-
version: packageJson.version
|
|
218
|
+
version: packageJson.version
|
|
198
219
|
}
|
package/lib/schema.js
CHANGED
|
@@ -11,7 +11,7 @@ export const schema = {
|
|
|
11
11
|
type: 'object',
|
|
12
12
|
properties: {
|
|
13
13
|
$schema: {
|
|
14
|
-
type: 'string'
|
|
14
|
+
type: 'string'
|
|
15
15
|
},
|
|
16
16
|
server: utilsSchema.server,
|
|
17
17
|
watch: schemaComponents.watch,
|
|
@@ -20,7 +20,7 @@ export const schema = {
|
|
|
20
20
|
type: 'object',
|
|
21
21
|
properties: {
|
|
22
22
|
configFile: {
|
|
23
|
-
oneOf: [{ type: 'string' }, { type: 'boolean' }]
|
|
23
|
+
oneOf: [{ type: 'string' }, { type: 'boolean' }]
|
|
24
24
|
},
|
|
25
25
|
ssr: {
|
|
26
26
|
oneOf: [
|
|
@@ -28,16 +28,17 @@ export const schema = {
|
|
|
28
28
|
type: 'object',
|
|
29
29
|
properties: { entrypoint: { type: 'string' } },
|
|
30
30
|
required: ['entrypoint'],
|
|
31
|
-
additionalProperties: false
|
|
31
|
+
additionalProperties: false
|
|
32
32
|
},
|
|
33
|
-
{ type: 'boolean' }
|
|
34
|
-
]
|
|
35
|
-
}
|
|
33
|
+
{ type: 'boolean' }
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
36
|
},
|
|
37
|
-
additionalProperties: false
|
|
37
|
+
additionalProperties: false
|
|
38
38
|
},
|
|
39
|
+
deploy: schemaComponents.deploy
|
|
39
40
|
},
|
|
40
|
-
additionalProperties: false
|
|
41
|
+
additionalProperties: false
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
/* 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.
|
|
3
|
+
"version": "2.0.0-alpha.7",
|
|
4
4
|
"description": "Platformatic Vite Stackable",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -16,25 +16,25 @@
|
|
|
16
16
|
"homepage": "https://github.com/platformatic/platformatic#readme",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"semver": "^7.6.3",
|
|
19
|
-
"@platformatic/
|
|
20
|
-
"@platformatic/
|
|
21
|
-
"@platformatic/
|
|
22
|
-
"@platformatic/
|
|
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"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@fastify/vite": "^6.0.7",
|
|
26
26
|
"borp": "^0.17.0",
|
|
27
27
|
"eslint": "9",
|
|
28
28
|
"fastify": "^4.28.1",
|
|
29
|
+
"json-schema-to-typescript": "^15.0.1",
|
|
29
30
|
"neostandard": "^0.11.1",
|
|
30
|
-
"json-schema-to-typescript": "^15.0.0",
|
|
31
31
|
"react": "^18.3.1",
|
|
32
32
|
"react-dom": "^18.3.1",
|
|
33
33
|
"typescript": "^5.5.4",
|
|
34
34
|
"vite": "^5.4.0",
|
|
35
35
|
"ws": "^8.18.0",
|
|
36
|
-
"@platformatic/composer": "2.0.0-alpha.
|
|
37
|
-
"@platformatic/service": "2.0.0-alpha.
|
|
36
|
+
"@platformatic/composer": "2.0.0-alpha.7",
|
|
37
|
+
"@platformatic/service": "2.0.0-alpha.7"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"test": "npm run lint && borp --concurrency=1 --timeout=180000",
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/vite/2.0.0-alpha.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/vite/2.0.0-alpha.7.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Vite Stackable",
|
|
5
5
|
"type": "object",
|
|
@@ -535,6 +535,33 @@
|
|
|
535
535
|
}
|
|
536
536
|
},
|
|
537
537
|
"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": {}
|
|
538
565
|
}
|
|
539
566
|
},
|
|
540
567
|
"additionalProperties": false
|