@platformatic/vite 3.27.0 → 3.28.0
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 +2 -0
- package/lib/capability.js +38 -19
- package/package.json +6 -6
- package/schema.json +20 -1
package/config.d.ts
CHANGED
|
@@ -499,6 +499,7 @@ export interface PlatformaticViteConfig {
|
|
|
499
499
|
[k: string]: string;
|
|
500
500
|
};
|
|
501
501
|
sourceMaps?: boolean;
|
|
502
|
+
nodeModulesSourceMaps?: string[];
|
|
502
503
|
scheduler?: {
|
|
503
504
|
enabled?: boolean | string;
|
|
504
505
|
name: string;
|
|
@@ -553,6 +554,7 @@ export interface PlatformaticViteConfig {
|
|
|
553
554
|
};
|
|
554
555
|
envfile?: string;
|
|
555
556
|
sourceMaps?: boolean;
|
|
557
|
+
nodeModulesSourceMaps?: string[];
|
|
556
558
|
packageManager?: "npm" | "pnpm" | "yarn";
|
|
557
559
|
preload?: string | string[];
|
|
558
560
|
nodeOptions?: string;
|
package/lib/capability.js
CHANGED
|
@@ -6,23 +6,22 @@ import {
|
|
|
6
6
|
ensureTrailingSlash,
|
|
7
7
|
errors,
|
|
8
8
|
getServerUrl,
|
|
9
|
-
importFile
|
|
9
|
+
importFile,
|
|
10
|
+
resolvePackageViaCJS
|
|
10
11
|
} from '@platformatic/basic'
|
|
11
|
-
import { resolvePackageViaCJS } from '@platformatic/basic/lib/utils.js'
|
|
12
12
|
import { ensureLoggableError } from '@platformatic/foundation'
|
|
13
13
|
import { NodeCapability } from '@platformatic/node'
|
|
14
14
|
import fastify from 'fastify'
|
|
15
15
|
import { existsSync } from 'node:fs'
|
|
16
16
|
import { readFile, writeFile } from 'node:fs/promises'
|
|
17
17
|
import { dirname, resolve } from 'node:path'
|
|
18
|
-
import {
|
|
18
|
+
import { satisfies } from 'semver'
|
|
19
19
|
import { version } from './schema.js'
|
|
20
20
|
|
|
21
21
|
const supportedVersions = ['^5.0.0', '^6.0.0', '^7.0.0']
|
|
22
22
|
|
|
23
23
|
export class ViteCapability extends BaseCapability {
|
|
24
24
|
#vite
|
|
25
|
-
#viteVersion
|
|
26
25
|
#app
|
|
27
26
|
#server
|
|
28
27
|
#basePath
|
|
@@ -46,7 +45,6 @@ export class ViteCapability extends BaseCapability {
|
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
const vitePackage = JSON.parse(await readFile(resolve(this.#vite, 'package.json'), 'utf-8'))
|
|
49
|
-
this.#viteVersion = parse(vitePackage.version)
|
|
50
48
|
|
|
51
49
|
if (!supportedVersions.some(v => satisfies(vitePackage.version, v))) {
|
|
52
50
|
throw new errors.UnsupportedVersion('vite', vitePackage.version, supportedVersions)
|
|
@@ -155,13 +153,13 @@ export class ViteCapability extends BaseCapability {
|
|
|
155
153
|
return { statusCode, headers, body, payload, rawPayload }
|
|
156
154
|
}
|
|
157
155
|
|
|
158
|
-
getMeta () {
|
|
156
|
+
getMeta (prefix) {
|
|
159
157
|
const config = this.subprocessConfig ?? this.#app?.config
|
|
160
158
|
|
|
161
159
|
const gateway = {
|
|
162
160
|
tcp: typeof this.url !== 'undefined',
|
|
163
161
|
url: this.url,
|
|
164
|
-
prefix: this.basePath ?? config?.base ?? this.#basePath,
|
|
162
|
+
prefix: this.basePath ?? config?.base ?? prefix ?? this.#basePath,
|
|
165
163
|
wantsAbsoluteUrls: true,
|
|
166
164
|
needsRootTrailingSlash: true
|
|
167
165
|
}
|
|
@@ -169,10 +167,22 @@ export class ViteCapability extends BaseCapability {
|
|
|
169
167
|
return { gateway }
|
|
170
168
|
}
|
|
171
169
|
|
|
172
|
-
|
|
170
|
+
_getApp () {
|
|
173
171
|
return this.#app
|
|
174
172
|
}
|
|
175
173
|
|
|
174
|
+
_setApp (app) {
|
|
175
|
+
this.#app = app
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
_getViteModule () {
|
|
179
|
+
return this.#vite
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
_setViteModule (vitePath) {
|
|
183
|
+
this.#vite = vitePath
|
|
184
|
+
}
|
|
185
|
+
|
|
176
186
|
async #startDevelopment () {
|
|
177
187
|
const config = this.config
|
|
178
188
|
const command = this.config.application.commands.development
|
|
@@ -258,18 +268,10 @@ export class ViteCapability extends BaseCapability {
|
|
|
258
268
|
|
|
259
269
|
this.#app = fastify({ loggerInstance: this.logger })
|
|
260
270
|
|
|
261
|
-
const outputDirectory = resolve(this.root, config.application.outputDirectory)
|
|
262
|
-
this.verifyOutputDirectory(outputDirectory)
|
|
263
|
-
const buildInfoPath = resolve(outputDirectory, '.platformatic-build.json')
|
|
271
|
+
const outputDirectory = this.outputDirectory ?? resolve(this.root, config.application.outputDirectory)
|
|
264
272
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
const buildInfo = JSON.parse(await readFile(buildInfoPath, 'utf-8'))
|
|
268
|
-
this.#basePath = buildInfo.basePath
|
|
269
|
-
} catch (e) {
|
|
270
|
-
globalThis.platformatic.logger.error({ err: ensureLoggableError(e) }, 'Reading build info failed.')
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
+
this.verifyOutputDirectory(outputDirectory)
|
|
274
|
+
this.#basePath = await this._getBasePathFromBuildInfo()
|
|
273
275
|
|
|
274
276
|
await this.#app.register(fastifyStatic, {
|
|
275
277
|
root: outputDirectory,
|
|
@@ -288,6 +290,23 @@ export class ViteCapability extends BaseCapability {
|
|
|
288
290
|
|
|
289
291
|
await this.#app.ready()
|
|
290
292
|
}
|
|
293
|
+
|
|
294
|
+
async _getBasePathFromBuildInfo () {
|
|
295
|
+
const config = this.config
|
|
296
|
+
const outputDirectory = this.outputDirectory ?? resolve(this.root, config.application.outputDirectory)
|
|
297
|
+
const buildInfoPath = this.buildInfoPath ?? resolve(outputDirectory, '.platformatic-build.json')
|
|
298
|
+
|
|
299
|
+
if (!this.#basePath && existsSync(buildInfoPath)) {
|
|
300
|
+
try {
|
|
301
|
+
const buildInfo = JSON.parse(await readFile(buildInfoPath, 'utf-8'))
|
|
302
|
+
this.#basePath = buildInfo.basePath
|
|
303
|
+
} catch (e) {
|
|
304
|
+
globalThis.platformatic.logger.error({ err: ensureLoggableError(e) }, 'Reading build info failed.')
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return this.#basePath
|
|
309
|
+
}
|
|
291
310
|
}
|
|
292
311
|
|
|
293
312
|
export class ViteSSRCapability extends NodeCapability {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/vite",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.28.0",
|
|
4
4
|
"description": "Platformatic Vite Capability",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"@fastify/static": "^8.0.0",
|
|
19
19
|
"fastify": "^5.0.0",
|
|
20
20
|
"semver": "^7.6.3",
|
|
21
|
-
"@platformatic/basic": "3.
|
|
22
|
-
"@platformatic/
|
|
23
|
-
"@platformatic/
|
|
21
|
+
"@platformatic/basic": "3.28.0",
|
|
22
|
+
"@platformatic/node": "3.28.0",
|
|
23
|
+
"@platformatic/foundation": "3.28.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"cleaner-spec-reporter": "^0.5.0",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"typescript": "^5.5.4",
|
|
33
33
|
"vite": "^7.1.4",
|
|
34
34
|
"ws": "^8.18.0",
|
|
35
|
-
"@platformatic/gateway": "3.
|
|
36
|
-
"@platformatic/service": "3.
|
|
35
|
+
"@platformatic/gateway": "3.28.0",
|
|
36
|
+
"@platformatic/service": "3.28.0"
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=22.19.0"
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/vite/3.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/vite/3.28.0.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Vite Config",
|
|
5
5
|
"type": "object",
|
|
@@ -593,6 +593,12 @@
|
|
|
593
593
|
"sourceMaps": {
|
|
594
594
|
"type": "boolean"
|
|
595
595
|
},
|
|
596
|
+
"nodeModulesSourceMaps": {
|
|
597
|
+
"type": "array",
|
|
598
|
+
"items": {
|
|
599
|
+
"type": "string"
|
|
600
|
+
}
|
|
601
|
+
},
|
|
596
602
|
"packageManager": {
|
|
597
603
|
"type": "string",
|
|
598
604
|
"enum": [
|
|
@@ -1839,6 +1845,13 @@
|
|
|
1839
1845
|
"type": "boolean",
|
|
1840
1846
|
"default": false
|
|
1841
1847
|
},
|
|
1848
|
+
"nodeModulesSourceMaps": {
|
|
1849
|
+
"type": "array",
|
|
1850
|
+
"items": {
|
|
1851
|
+
"type": "string"
|
|
1852
|
+
},
|
|
1853
|
+
"default": []
|
|
1854
|
+
},
|
|
1842
1855
|
"scheduler": {
|
|
1843
1856
|
"type": "array",
|
|
1844
1857
|
"items": {
|
|
@@ -2092,6 +2105,12 @@
|
|
|
2092
2105
|
"sourceMaps": {
|
|
2093
2106
|
"type": "boolean"
|
|
2094
2107
|
},
|
|
2108
|
+
"nodeModulesSourceMaps": {
|
|
2109
|
+
"type": "array",
|
|
2110
|
+
"items": {
|
|
2111
|
+
"type": "string"
|
|
2112
|
+
}
|
|
2113
|
+
},
|
|
2095
2114
|
"packageManager": {
|
|
2096
2115
|
"type": "string",
|
|
2097
2116
|
"enum": [
|