@platformatic/remix 3.29.1 → 3.31.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 +26 -2
- package/lib/capability.js +63 -60
- package/package.json +9 -11
- package/schema.json +67 -9
package/config.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
export interface PlatformaticRemixConfig {
|
|
9
9
|
$schema?: string;
|
|
10
10
|
logger?: {
|
|
11
|
-
level
|
|
11
|
+
level?: (
|
|
12
12
|
| ("fatal" | "error" | "warn" | "info" | "debug" | "trace" | "silent")
|
|
13
13
|
| {
|
|
14
14
|
[k: string]: unknown;
|
|
@@ -139,7 +139,7 @@ export interface PlatformaticRemixConfig {
|
|
|
139
139
|
};
|
|
140
140
|
workersRestartDelay?: number | string;
|
|
141
141
|
logger?: {
|
|
142
|
-
level
|
|
142
|
+
level?: (
|
|
143
143
|
| ("fatal" | "error" | "warn" | "info" | "debug" | "trace" | "silent")
|
|
144
144
|
| {
|
|
145
145
|
[k: string]: unknown;
|
|
@@ -522,6 +522,18 @@ export interface PlatformaticRemixConfig {
|
|
|
522
522
|
[k: string]: string | [string, ...string[]];
|
|
523
523
|
};
|
|
524
524
|
};
|
|
525
|
+
compileCache?:
|
|
526
|
+
| boolean
|
|
527
|
+
| {
|
|
528
|
+
/**
|
|
529
|
+
* Enable Node.js module compile cache for faster startup
|
|
530
|
+
*/
|
|
531
|
+
enabled?: boolean;
|
|
532
|
+
/**
|
|
533
|
+
* Directory to store compile cache. Defaults to .plt/compile-cache in app root
|
|
534
|
+
*/
|
|
535
|
+
directory?: string;
|
|
536
|
+
};
|
|
525
537
|
application?: {
|
|
526
538
|
reuseTcpPorts?: boolean;
|
|
527
539
|
workers?:
|
|
@@ -580,6 +592,18 @@ export interface PlatformaticRemixConfig {
|
|
|
580
592
|
)[];
|
|
581
593
|
[k: string]: unknown;
|
|
582
594
|
};
|
|
595
|
+
compileCache?:
|
|
596
|
+
| boolean
|
|
597
|
+
| {
|
|
598
|
+
/**
|
|
599
|
+
* Enable Node.js module compile cache for faster startup
|
|
600
|
+
*/
|
|
601
|
+
enabled?: boolean;
|
|
602
|
+
/**
|
|
603
|
+
* Directory to store compile cache. Defaults to .plt/compile-cache in app root
|
|
604
|
+
*/
|
|
605
|
+
directory?: string;
|
|
606
|
+
};
|
|
583
607
|
};
|
|
584
608
|
};
|
|
585
609
|
vite?: {
|
package/lib/capability.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import fastifyStatic from '@fastify/static'
|
|
1
2
|
import {
|
|
2
3
|
cleanBasePath,
|
|
3
4
|
createServerListener,
|
|
@@ -8,13 +9,12 @@ import {
|
|
|
8
9
|
resolvePackageViaCJS
|
|
9
10
|
} from '@platformatic/basic'
|
|
10
11
|
import { ViteCapability } from '@platformatic/vite'
|
|
11
|
-
import { createRequestHandler } from '@remix-run/
|
|
12
|
-
import
|
|
13
|
-
import inject from 'light-my-request'
|
|
12
|
+
import { createRequestHandler } from '@remix-run/node'
|
|
13
|
+
import fastify from 'fastify'
|
|
14
14
|
import { existsSync } from 'node:fs'
|
|
15
15
|
import { readFile } from 'node:fs/promises'
|
|
16
|
-
import { dirname, resolve } from 'node:path'
|
|
17
|
-
import {
|
|
16
|
+
import { dirname, join, resolve } from 'node:path'
|
|
17
|
+
import { Readable } from 'node:stream'
|
|
18
18
|
import { satisfies } from 'semver'
|
|
19
19
|
import { packageJson } from './schema.js'
|
|
20
20
|
|
|
@@ -22,7 +22,6 @@ const supportedVersions = '^2.0.0'
|
|
|
22
22
|
|
|
23
23
|
export class RemixCapability extends ViteCapability {
|
|
24
24
|
#app
|
|
25
|
-
#server
|
|
26
25
|
#remix
|
|
27
26
|
#basePath
|
|
28
27
|
|
|
@@ -72,20 +71,6 @@ export class RemixCapability extends ViteCapability {
|
|
|
72
71
|
return this.isProduction ? this.#startProduction(listen) : this.#startDevelopment(listen)
|
|
73
72
|
}
|
|
74
73
|
|
|
75
|
-
async stop () {
|
|
76
|
-
await super.stop()
|
|
77
|
-
|
|
78
|
-
if (this.childManager) {
|
|
79
|
-
return this.stopCommand()
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (this.isProduction) {
|
|
83
|
-
return this.#stopProduction()
|
|
84
|
-
} else if (this.#app) {
|
|
85
|
-
return this.#app.close()
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
74
|
async build () {
|
|
90
75
|
const config = this.config
|
|
91
76
|
const command = config.application.commands.build
|
|
@@ -114,23 +99,6 @@ export class RemixCapability extends ViteCapability {
|
|
|
114
99
|
}
|
|
115
100
|
}
|
|
116
101
|
|
|
117
|
-
async inject (injectParams, onInject) {
|
|
118
|
-
if (!this.isProduction) {
|
|
119
|
-
return super.inject(injectParams, onInject)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const res = await inject(this.#app, injectParams, onInject)
|
|
123
|
-
|
|
124
|
-
/* c8 ignore next 3 */
|
|
125
|
-
if (onInject) {
|
|
126
|
-
return
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// Since inject might be called from the main thread directly via ITC, let's clean it up
|
|
130
|
-
const { statusCode, headers, body, payload, rawPayload } = res
|
|
131
|
-
return { statusCode, headers, body, payload, rawPayload }
|
|
132
|
-
}
|
|
133
|
-
|
|
134
102
|
getMeta () {
|
|
135
103
|
if (!this.isProduction) {
|
|
136
104
|
return super.getMeta()
|
|
@@ -177,16 +145,8 @@ export class RemixCapability extends ViteCapability {
|
|
|
177
145
|
createServerListener(false, false, { backlog: serverOptions.backlog })
|
|
178
146
|
}
|
|
179
147
|
|
|
180
|
-
this.#
|
|
181
|
-
|
|
182
|
-
.listen(listenOptions, function () {
|
|
183
|
-
resolve(this)
|
|
184
|
-
})
|
|
185
|
-
.on('error', reject)
|
|
186
|
-
})
|
|
187
|
-
|
|
188
|
-
this.url = getServerUrl(this.#server)
|
|
189
|
-
|
|
148
|
+
await this.#app.listen(listenOptions)
|
|
149
|
+
this.url = getServerUrl(this.#app.server)
|
|
190
150
|
return this.url
|
|
191
151
|
}
|
|
192
152
|
|
|
@@ -196,23 +156,66 @@ export class RemixCapability extends ViteCapability {
|
|
|
196
156
|
const build = await importFile(resolve(this.root, `${outputDirectory}/server/index.js`))
|
|
197
157
|
this.#basePath = ensureTrailingSlash(cleanBasePath(build.basename))
|
|
198
158
|
|
|
199
|
-
// Setup
|
|
200
|
-
this.#app =
|
|
201
|
-
this.#app
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
this.#app.
|
|
205
|
-
|
|
159
|
+
// Setup fastify
|
|
160
|
+
this.#app = fastify({ loggerInstance: this.logger })
|
|
161
|
+
this._setApp(this.#app)
|
|
162
|
+
|
|
163
|
+
// Since it uses the Fetch API, we don't need to parse the request body.
|
|
164
|
+
this.#app.removeAllContentTypeParsers()
|
|
165
|
+
this.#app.addContentTypeParser('*', function (_, payload, done) {
|
|
166
|
+
done(null, payload)
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
await this.#app.register(fastifyStatic, {
|
|
170
|
+
root: resolve(this.root, `${outputDirectory}/client/assets`),
|
|
171
|
+
prefix: join(this.#basePath, 'assets'),
|
|
172
|
+
prefixAvoidTrailingSlash: true,
|
|
173
|
+
schemaHide: true
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
this.#app.all(
|
|
177
|
+
`${ensureTrailingSlash(cleanBasePath(this.#basePath))}*`,
|
|
178
|
+
this.#handleRequest.bind(this, createRequestHandler(build, process.env.NODE_ENV))
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
await this.#app.ready()
|
|
206
182
|
await this._collectMetrics()
|
|
207
|
-
return this.url
|
|
208
183
|
}
|
|
209
184
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
185
|
+
#handleRequest (handle, req) {
|
|
186
|
+
// Support aborting
|
|
187
|
+
const ac = new AbortController()
|
|
188
|
+
let ended = false
|
|
189
|
+
|
|
190
|
+
req.raw.on('aborted', () => ac.abort())
|
|
191
|
+
req.raw.on('end', () => { ended = true })
|
|
192
|
+
req.raw.on('close', () => {
|
|
193
|
+
if (!ended) {
|
|
194
|
+
ac.abort()
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
const headers = new Headers()
|
|
199
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
200
|
+
if (value) {
|
|
201
|
+
headers.set(key, Array.isArray(value) ? value.join(',') : value)
|
|
202
|
+
}
|
|
214
203
|
}
|
|
215
204
|
|
|
216
|
-
|
|
205
|
+
let body
|
|
206
|
+
|
|
207
|
+
if (!['GET', 'HEAD'].includes(req.method)) {
|
|
208
|
+
body = Readable.toWeb(req.raw)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return handle(
|
|
212
|
+
new Request(`${req.protocol}://${req.hostname}${req.raw.url}`, {
|
|
213
|
+
method: req.method,
|
|
214
|
+
headers,
|
|
215
|
+
body,
|
|
216
|
+
duplex: body ? 'half' : undefined,
|
|
217
|
+
signal: ac.signal
|
|
218
|
+
})
|
|
219
|
+
)
|
|
217
220
|
}
|
|
218
221
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/remix",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.31.0",
|
|
4
4
|
"description": "Platformatic Remix Capability",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -15,14 +15,12 @@
|
|
|
15
15
|
},
|
|
16
16
|
"homepage": "https://github.com/platformatic/platformatic#readme",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@
|
|
19
|
-
"
|
|
20
|
-
"light-my-request": "^6.0.0",
|
|
21
|
-
"pino-http": "^10.2.0",
|
|
18
|
+
"@fastify/static": "^8.0.0",
|
|
19
|
+
"fastify": "^5.7.0",
|
|
22
20
|
"semver": "^7.6.3",
|
|
23
|
-
"@platformatic/basic": "3.
|
|
24
|
-
"@platformatic/
|
|
25
|
-
"@platformatic/
|
|
21
|
+
"@platformatic/basic": "3.31.0",
|
|
22
|
+
"@platformatic/foundation": "3.31.0",
|
|
23
|
+
"@platformatic/vite": "3.31.0"
|
|
26
24
|
},
|
|
27
25
|
"devDependencies": {
|
|
28
26
|
"@remix-run/dev": "^2.16.8",
|
|
@@ -32,7 +30,7 @@
|
|
|
32
30
|
"@types/react-dom": "^19.1.7",
|
|
33
31
|
"cleaner-spec-reporter": "^0.5.0",
|
|
34
32
|
"eslint": "9",
|
|
35
|
-
"fastify": "^5.
|
|
33
|
+
"fastify": "^5.7.0",
|
|
36
34
|
"isbot": "^5.1.17",
|
|
37
35
|
"json-schema-to-typescript": "^15.0.1",
|
|
38
36
|
"neostandard": "^0.12.0",
|
|
@@ -41,8 +39,8 @@
|
|
|
41
39
|
"typescript": "^5.5.4",
|
|
42
40
|
"vite": "^7.0.0",
|
|
43
41
|
"ws": "^8.18.0",
|
|
44
|
-
"@platformatic/
|
|
45
|
-
"@platformatic/
|
|
42
|
+
"@platformatic/service": "3.31.0",
|
|
43
|
+
"@platformatic/gateway": "3.31.0"
|
|
46
44
|
},
|
|
47
45
|
"engines": {
|
|
48
46
|
"node": ">=22.19.0"
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/remix/3.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/remix/3.31.0.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Remix Config",
|
|
5
5
|
"type": "object",
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
"properties": {
|
|
13
13
|
"level": {
|
|
14
14
|
"type": "string",
|
|
15
|
-
"default": "info",
|
|
16
15
|
"oneOf": [
|
|
17
16
|
{
|
|
18
17
|
"enum": [
|
|
@@ -155,9 +154,6 @@
|
|
|
155
154
|
"additionalProperties": true
|
|
156
155
|
}
|
|
157
156
|
},
|
|
158
|
-
"required": [
|
|
159
|
-
"level"
|
|
160
|
-
],
|
|
161
157
|
"default": {},
|
|
162
158
|
"additionalProperties": true
|
|
163
159
|
},
|
|
@@ -698,6 +694,28 @@
|
|
|
698
694
|
}
|
|
699
695
|
}
|
|
700
696
|
}
|
|
697
|
+
},
|
|
698
|
+
"compileCache": {
|
|
699
|
+
"anyOf": [
|
|
700
|
+
{
|
|
701
|
+
"type": "boolean"
|
|
702
|
+
},
|
|
703
|
+
{
|
|
704
|
+
"type": "object",
|
|
705
|
+
"properties": {
|
|
706
|
+
"enabled": {
|
|
707
|
+
"type": "boolean",
|
|
708
|
+
"default": true,
|
|
709
|
+
"description": "Enable Node.js module compile cache for faster startup"
|
|
710
|
+
},
|
|
711
|
+
"directory": {
|
|
712
|
+
"type": "string",
|
|
713
|
+
"description": "Directory to store compile cache. Defaults to .plt/compile-cache in app root"
|
|
714
|
+
}
|
|
715
|
+
},
|
|
716
|
+
"additionalProperties": false
|
|
717
|
+
}
|
|
718
|
+
]
|
|
701
719
|
}
|
|
702
720
|
}
|
|
703
721
|
}
|
|
@@ -777,7 +795,6 @@
|
|
|
777
795
|
"properties": {
|
|
778
796
|
"level": {
|
|
779
797
|
"type": "string",
|
|
780
|
-
"default": "info",
|
|
781
798
|
"oneOf": [
|
|
782
799
|
{
|
|
783
800
|
"enum": [
|
|
@@ -920,9 +937,6 @@
|
|
|
920
937
|
"additionalProperties": true
|
|
921
938
|
}
|
|
922
939
|
},
|
|
923
|
-
"required": [
|
|
924
|
-
"level"
|
|
925
|
-
],
|
|
926
940
|
"default": {},
|
|
927
941
|
"additionalProperties": true
|
|
928
942
|
},
|
|
@@ -1964,6 +1978,28 @@
|
|
|
1964
1978
|
],
|
|
1965
1979
|
"additionalProperties": false
|
|
1966
1980
|
},
|
|
1981
|
+
"compileCache": {
|
|
1982
|
+
"anyOf": [
|
|
1983
|
+
{
|
|
1984
|
+
"type": "boolean"
|
|
1985
|
+
},
|
|
1986
|
+
{
|
|
1987
|
+
"type": "object",
|
|
1988
|
+
"properties": {
|
|
1989
|
+
"enabled": {
|
|
1990
|
+
"type": "boolean",
|
|
1991
|
+
"default": true,
|
|
1992
|
+
"description": "Enable Node.js module compile cache for faster startup"
|
|
1993
|
+
},
|
|
1994
|
+
"directory": {
|
|
1995
|
+
"type": "string",
|
|
1996
|
+
"description": "Directory to store compile cache. Defaults to .plt/compile-cache in app root"
|
|
1997
|
+
}
|
|
1998
|
+
},
|
|
1999
|
+
"additionalProperties": false
|
|
2000
|
+
}
|
|
2001
|
+
]
|
|
2002
|
+
},
|
|
1967
2003
|
"application": {
|
|
1968
2004
|
"type": "object",
|
|
1969
2005
|
"properties": {
|
|
@@ -2228,6 +2264,28 @@
|
|
|
2228
2264
|
}
|
|
2229
2265
|
}
|
|
2230
2266
|
}
|
|
2267
|
+
},
|
|
2268
|
+
"compileCache": {
|
|
2269
|
+
"anyOf": [
|
|
2270
|
+
{
|
|
2271
|
+
"type": "boolean"
|
|
2272
|
+
},
|
|
2273
|
+
{
|
|
2274
|
+
"type": "object",
|
|
2275
|
+
"properties": {
|
|
2276
|
+
"enabled": {
|
|
2277
|
+
"type": "boolean",
|
|
2278
|
+
"default": true,
|
|
2279
|
+
"description": "Enable Node.js module compile cache for faster startup"
|
|
2280
|
+
},
|
|
2281
|
+
"directory": {
|
|
2282
|
+
"type": "string",
|
|
2283
|
+
"description": "Directory to store compile cache. Defaults to .plt/compile-cache in app root"
|
|
2284
|
+
}
|
|
2285
|
+
},
|
|
2286
|
+
"additionalProperties": false
|
|
2287
|
+
}
|
|
2288
|
+
]
|
|
2231
2289
|
}
|
|
2232
2290
|
},
|
|
2233
2291
|
"additionalProperties": false
|