jeasx 2.3.0 β 2.3.2
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/CHANGELOG.md +15 -1
- package/cli.js +1 -3
- package/env.js +5 -6
- package/esbuild.config.js +12 -16
- package/package.json +15 -15
- package/server.js +1 -1
- package/serverless.js +6 -8
- package/serverless.js.map +1 -1
- package/serverless.ts +13 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2026-02-12 - Jeasx 2.3.2 released
|
|
4
|
+
|
|
5
|
+
π Upgraded to @types/node@25, enabling seamless development with Node 25 while maintaining compatibility for Node 24 users.
|
|
6
|
+
|
|
7
|
+
Dependency updates: `esbuild@0.27.3`, `@types/node@25.2.3`
|
|
8
|
+
|
|
9
|
+
## 2026-02-04 - Jeasx 2.3.1 released
|
|
10
|
+
|
|
11
|
+
π Just a patch release to update Fastify to fix [CVE-2026-25224](https://github.com/fastify/fastify/security/advisories/GHSA-mrq3-vjjr-p77c).
|
|
12
|
+
|
|
13
|
+
Additionally, I performed minor refactorings identified by [oxlint](https://oxc.rs/docs/guide/usage/linter.html) and replaced `prettier` with [oxfmt](https://oxc.rs/docs/guide/usage/formatter), a high-performance formatter optimized for the JavaScript ecosystem.
|
|
14
|
+
|
|
15
|
+
Dependency updates: `fastify@5.7.4`, `@types/node@24.10.10`
|
|
16
|
+
|
|
3
17
|
## 2026-01-30 - Jeasx 2.3.0 released
|
|
4
18
|
|
|
5
19
|
π This release introduces support for [MDX](https://mdxjs.com), enabling you to seamlessly embed JSX within Markdown content. Just create a route with a `.mdx` extension, and youβre all set to enhance your websites and blogs with Markdown enriched by dynamic JSX components.
|
|
@@ -398,7 +412,7 @@ Added two new environment variables (`FASTIFY_DISABLE_REQUEST_LOGGING` and `FAST
|
|
|
398
412
|
|
|
399
413
|
## 2024-12-01 - Jeasx 1.1.0 released
|
|
400
414
|
|
|
401
|
-
π Migrated from dotenv to dotenv-flow, so you can use NODE_ENV-specific .env\* files (like `.env.development`) to configure different environments for production and development. This is useful to disable caching headers (e.g. via `FASTIFY_STATIC_HEADERS`) in development, as Jeasx applies `FASTIFY_STATIC_HEADERS` in development from now on for a more consistent developer
|
|
415
|
+
π Migrated from dotenv to dotenv-flow, so you can use NODE_ENV-specific .env\* files (like `.env.development`) to configure different environments for production and development. This is useful to disable caching headers (e.g. via `FASTIFY_STATIC_HEADERS`) in development, as Jeasx applies `FASTIFY_STATIC_HEADERS` in development from now on for a more consistent developer experience. See updated .env-files in the quickstart-project for an example how to disable caching in development. This is only needed if you have configured `FASTIFY_STATIC_HEADERS` for your existing projects.
|
|
402
416
|
|
|
403
417
|
Bumped default environment variable `ESBUILD_BROWSER_TARGET` to more recent browser versions (e.g. `chrome126, edge126, firefox128, safari17`). If you want to stick with older versions, you can override it via the environment. Learn more about possible values at the esbuild website.
|
|
404
418
|
|
package/cli.js
CHANGED
|
@@ -23,9 +23,7 @@ switch (process.argv[2]) {
|
|
|
23
23
|
break;
|
|
24
24
|
|
|
25
25
|
default:
|
|
26
|
-
console.info(
|
|
27
|
-
`β Error: Unknown command '${process.argv[2]}'.\nUse 'jeasx help' for options.`
|
|
28
|
-
);
|
|
26
|
+
console.info(`β Error: Unknown command '${process.argv[2]}'.\nUse 'jeasx help' for options.`);
|
|
29
27
|
process.exit(1);
|
|
30
28
|
}
|
|
31
29
|
|
package/env.js
CHANGED
|
@@ -16,12 +16,12 @@ import { join } from "node:path";
|
|
|
16
16
|
export default async function env() {
|
|
17
17
|
if (process.loadEnvFile) {
|
|
18
18
|
[
|
|
19
|
-
...(process.env.NODE_ENV
|
|
20
|
-
[`.env.${process.env.NODE_ENV}.local`, `.env.${process.env.NODE_ENV}`]
|
|
21
|
-
|
|
19
|
+
...(process.env.NODE_ENV
|
|
20
|
+
? [`.env.${process.env.NODE_ENV}.local`, `.env.${process.env.NODE_ENV}`]
|
|
21
|
+
: []),
|
|
22
22
|
".env.local",
|
|
23
23
|
".env",
|
|
24
|
-
".env.defaults"
|
|
24
|
+
".env.defaults",
|
|
25
25
|
]
|
|
26
26
|
.filter(existsSync)
|
|
27
27
|
.forEach(process.loadEnvFile);
|
|
@@ -31,8 +31,7 @@ export default async function env() {
|
|
|
31
31
|
const envObject = (await import(envFile)).default;
|
|
32
32
|
Object.entries(envObject).forEach(([key, value]) => {
|
|
33
33
|
try {
|
|
34
|
-
process.env[key] =
|
|
35
|
-
typeof value === "string" ? value : JSON.stringify(value);
|
|
34
|
+
process.env[key] = typeof value === "string" ? value : JSON.stringify(value);
|
|
36
35
|
} catch (error) {
|
|
37
36
|
// JSON.stringify throws TypeError for circular references or BigInts.
|
|
38
37
|
console.error("β", `"${key}" in .env.js throws`, error);
|
package/esbuild.config.js
CHANGED
|
@@ -13,14 +13,14 @@ const BROWSER_PUBLIC_ENV = Object.keys(ENV)
|
|
|
13
13
|
env[`process.env.${key}`] = `"${ENV[key]}"`;
|
|
14
14
|
return env;
|
|
15
15
|
},
|
|
16
|
-
{ "process.env.BROWSER_PUBLIC_BUILD_TIME": BUILD_TIME }
|
|
16
|
+
{ "process.env.BROWSER_PUBLIC_BUILD_TIME": BUILD_TIME },
|
|
17
17
|
);
|
|
18
18
|
|
|
19
19
|
const ESBUILD_BROWSER_TARGET = ENV.ESBUILD_BROWSER_TARGET || [
|
|
20
20
|
"chrome130",
|
|
21
21
|
"edge130",
|
|
22
22
|
"firefox130",
|
|
23
|
-
"safari18"
|
|
23
|
+
"safari18",
|
|
24
24
|
];
|
|
25
25
|
|
|
26
26
|
const ESBUILD_MDX_PLUGIN = mdx({
|
|
@@ -28,22 +28,20 @@ const ESBUILD_MDX_PLUGIN = mdx({
|
|
|
28
28
|
jsxImportSource: "jsx-async-runtime",
|
|
29
29
|
elementAttributeNameCase: "html",
|
|
30
30
|
stylePropertyNameCase: "css",
|
|
31
|
-
...
|
|
31
|
+
...ENV.ESBUILD_MDX_OPTIONS,
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
/** @type esbuild.BuildOptions[] */
|
|
35
35
|
const buildOptions = [
|
|
36
36
|
{
|
|
37
|
-
entryPoints: ["js", "ts", "jsx", "tsx", "mdx"].map(
|
|
38
|
-
(ext) => `src/**/[*].${ext}`
|
|
39
|
-
),
|
|
37
|
+
entryPoints: ["js", "ts", "jsx", "tsx", "mdx"].map((ext) => `src/**/[*].${ext}`),
|
|
40
38
|
define: {
|
|
41
|
-
"process.env.BUILD_TIME": BUILD_TIME
|
|
39
|
+
"process.env.BUILD_TIME": BUILD_TIME,
|
|
42
40
|
},
|
|
43
41
|
minify: process.env.NODE_ENV !== "development",
|
|
44
42
|
logLevel: "info",
|
|
45
43
|
logOverride: {
|
|
46
|
-
"empty-glob": "silent"
|
|
44
|
+
"empty-glob": "silent",
|
|
47
45
|
},
|
|
48
46
|
color: true,
|
|
49
47
|
bundle: true,
|
|
@@ -52,17 +50,15 @@ const buildOptions = [
|
|
|
52
50
|
outdir: "dist/server",
|
|
53
51
|
platform: "neutral",
|
|
54
52
|
packages: "external",
|
|
55
|
-
plugins: [ESBUILD_MDX_PLUGIN]
|
|
53
|
+
plugins: [ESBUILD_MDX_PLUGIN],
|
|
56
54
|
},
|
|
57
55
|
{
|
|
58
|
-
entryPoints: ["js", "ts", "jsx", "tsx", "css"].map(
|
|
59
|
-
(ext) => `src/**/index.${ext}`
|
|
60
|
-
),
|
|
56
|
+
entryPoints: ["js", "ts", "jsx", "tsx", "css"].map((ext) => `src/**/index.${ext}`),
|
|
61
57
|
define: BROWSER_PUBLIC_ENV,
|
|
62
58
|
minify: process.env.NODE_ENV !== "development",
|
|
63
59
|
logLevel: "info",
|
|
64
60
|
logOverride: {
|
|
65
|
-
"empty-glob": "silent"
|
|
61
|
+
"empty-glob": "silent",
|
|
66
62
|
},
|
|
67
63
|
color: true,
|
|
68
64
|
bundle: true,
|
|
@@ -84,10 +80,10 @@ const buildOptions = [
|
|
|
84
80
|
"*.ttf",
|
|
85
81
|
"*.otf",
|
|
86
82
|
"*.woff",
|
|
87
|
-
"*.woff2"
|
|
83
|
+
"*.woff2",
|
|
88
84
|
],
|
|
89
|
-
plugins: [ESBUILD_MDX_PLUGIN]
|
|
90
|
-
}
|
|
85
|
+
plugins: [ESBUILD_MDX_PLUGIN],
|
|
86
|
+
},
|
|
91
87
|
];
|
|
92
88
|
|
|
93
89
|
buildOptions.forEach(async (options) => {
|
package/package.json
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jeasx",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.2",
|
|
4
4
|
"description": "Jeasx - the ease of JSX with the power of SSR",
|
|
5
5
|
"keywords": [
|
|
6
|
+
"fastify",
|
|
6
7
|
"jsx",
|
|
7
|
-
"ssr",
|
|
8
8
|
"node",
|
|
9
|
-
"
|
|
9
|
+
"ssr"
|
|
10
10
|
],
|
|
11
|
-
"license": "MIT",
|
|
12
11
|
"homepage": "https://www.jeasx.dev",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"author": {
|
|
14
|
+
"name": "Maik Jablonski",
|
|
15
|
+
"email": "mail@jeasx.dev"
|
|
16
|
+
},
|
|
13
17
|
"repository": {
|
|
14
18
|
"type": "git",
|
|
15
19
|
"url": "https://github.com/jeasx/jeasx.git"
|
|
16
20
|
},
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"email": "mail@jeasx.dev"
|
|
21
|
+
"bin": {
|
|
22
|
+
"jeasx": "cli.js"
|
|
20
23
|
},
|
|
21
24
|
"type": "module",
|
|
22
25
|
"main": "server.js",
|
|
23
|
-
"
|
|
24
|
-
"
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "esbuild --platform=node --format=esm --sourcemap=linked --sources-content=false --outdir=. serverless.ts"
|
|
25
28
|
},
|
|
26
29
|
"dependencies": {
|
|
27
30
|
"@fastify/cookie": "11.0.2",
|
|
@@ -29,12 +32,9 @@
|
|
|
29
32
|
"@fastify/multipart": "9.4.0",
|
|
30
33
|
"@fastify/static": "9.0.0",
|
|
31
34
|
"@mdx-js/esbuild": "3.1.1",
|
|
32
|
-
"@types/node": "
|
|
33
|
-
"esbuild": "0.27.
|
|
34
|
-
"fastify": "5.7.
|
|
35
|
+
"@types/node": "25.2.3",
|
|
36
|
+
"esbuild": "0.27.3",
|
|
37
|
+
"fastify": "5.7.4",
|
|
35
38
|
"jsx-async-runtime": "2.0.2"
|
|
36
|
-
},
|
|
37
|
-
"scripts": {
|
|
38
|
-
"build": "esbuild --platform=node --format=esm --sourcemap=linked --sources-content=false --outdir=. serverless.ts"
|
|
39
39
|
}
|
|
40
40
|
}
|
package/server.js
CHANGED
package/serverless.js
CHANGED
|
@@ -14,20 +14,20 @@ const NODE_ENV_IS_DEVELOPMENT = process.env.NODE_ENV === "development";
|
|
|
14
14
|
const JEASX_ROUTE_CACHE_LIMIT = Math.floor(freemem() / 1024 / 1024);
|
|
15
15
|
var serverless_default = Fastify({
|
|
16
16
|
logger: true,
|
|
17
|
-
...ENV.FASTIFY_SERVER_OPTIONS
|
|
17
|
+
...ENV.FASTIFY_SERVER_OPTIONS
|
|
18
18
|
}).register(fastifyCookie, {
|
|
19
|
-
...ENV.FASTIFY_COOKIE_OPTIONS
|
|
19
|
+
...ENV.FASTIFY_COOKIE_OPTIONS
|
|
20
20
|
}).register(fastifyFormbody, {
|
|
21
|
-
...ENV.FASTIFY_FORMBODY_OPTIONS
|
|
21
|
+
...ENV.FASTIFY_FORMBODY_OPTIONS
|
|
22
22
|
}).register(fastifyMultipart, {
|
|
23
23
|
attachFieldsToBody: "keyValues",
|
|
24
|
-
...ENV.FASTIFY_MULTIPART_OPTIONS
|
|
24
|
+
...ENV.FASTIFY_MULTIPART_OPTIONS
|
|
25
25
|
}).register(fastifyStatic, {
|
|
26
26
|
root: [["public"], ["dist", "browser"]].map((dir) => join(CWD, ...dir)),
|
|
27
27
|
prefix: "/",
|
|
28
28
|
wildcard: false,
|
|
29
29
|
preCompressed: true,
|
|
30
|
-
...ENV.FASTIFY_STATIC_OPTIONS
|
|
30
|
+
...ENV.FASTIFY_STATIC_OPTIONS
|
|
31
31
|
}).decorateRequest("route", "").decorateRequest("path", "").addHook("onRequest", async (request, reply) => {
|
|
32
32
|
reply.header("Content-Type", "text/html; charset=utf-8");
|
|
33
33
|
const index = request.url.indexOf("?");
|
|
@@ -133,9 +133,7 @@ function generateEdges(path) {
|
|
|
133
133
|
const edges = [];
|
|
134
134
|
if (path) {
|
|
135
135
|
const lastSegment = path.lastIndexOf("/") + 1;
|
|
136
|
-
edges.push(
|
|
137
|
-
`${path.substring(0, lastSegment)}[${path.substring(lastSegment)}]`
|
|
138
|
-
);
|
|
136
|
+
edges.push(`${path.substring(0, lastSegment)}[${path.substring(lastSegment)}]`);
|
|
139
137
|
}
|
|
140
138
|
edges.push(`${path}/[index]`);
|
|
141
139
|
return edges;
|
package/serverless.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["serverless.ts"],
|
|
4
|
-
"mappings": "AAAA,OAAO,mBAA6C;AACpD,OAAO,qBAAiD;AACxD,OAAO,sBAAmD;AAC1D,OAAO,mBAA6C;AACpD,OAAO,
|
|
4
|
+
"mappings": "AAAA,OAAO,mBAA6C;AACpD,OAAO,qBAAiD;AACxD,OAAO,sBAAmD;AAC1D,OAAO,mBAA6C;AACpD,OAAO,aAAqE;AAC5E,SAAS,mBAAmB;AAC5B,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,OAAO,SAAS;AAEhB,MAAM,MAAM,MAAM,IAAI;AAEtB,MAAM,MAAM,QAAQ,IAAI;AACxB,MAAM,0BAA0B,QAAQ,IAAI,aAAa;AACzD,MAAM,0BAA0B,KAAK,MAAM,QAAQ,IAAI,OAAO,IAAI;AAUlE,IAAO,qBAAQ,QAAQ;AAAA,EACrB,QAAQ;AAAA,EACR,GAAI,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AAC,CAAC,OAAO,OAAO,QAAQ,YAAY,UAAU,OAAO,WAAW;AACzE;AAKA,eAAe,UAAU,SAAiB,UAAmB;AAC3D,QAAM,UAAU,MAAM,QAAQ,IAAI,MAAM,YAAY,KAAK,SAAS,QAAQ,IAAI;AAG9E,QAAM,kBAAkB,QAAQ,iBAAiB;AACjD,SAAO,OAAO,oBAAoB,aAC9B,MAAM,gBAAgB,KAAK,SAAS,OAAO,IAC3C;AACN;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/serverless.ts
CHANGED
|
@@ -2,11 +2,7 @@ import fastifyCookie, { FastifyCookieOptions } from "@fastify/cookie";
|
|
|
2
2
|
import fastifyFormbody, { FastifyFormbodyOptions } from "@fastify/formbody";
|
|
3
3
|
import fastifyMultipart, { FastifyMultipartOptions } from "@fastify/multipart";
|
|
4
4
|
import fastifyStatic, { FastifyStaticOptions } from "@fastify/static";
|
|
5
|
-
import Fastify, {
|
|
6
|
-
FastifyReply,
|
|
7
|
-
FastifyRequest,
|
|
8
|
-
FastifyServerOptions
|
|
9
|
-
} from "fastify";
|
|
5
|
+
import Fastify, { FastifyReply, FastifyRequest, FastifyServerOptions } from "fastify";
|
|
10
6
|
import { jsxToString } from "jsx-async-runtime";
|
|
11
7
|
import { stat } from "node:fs/promises";
|
|
12
8
|
import { freemem } from "node:os";
|
|
@@ -29,24 +25,24 @@ declare module "fastify" {
|
|
|
29
25
|
// Create and export a Fastify app instance
|
|
30
26
|
export default Fastify({
|
|
31
27
|
logger: true,
|
|
32
|
-
...(
|
|
28
|
+
...(ENV.FASTIFY_SERVER_OPTIONS as FastifyServerOptions),
|
|
33
29
|
})
|
|
34
30
|
.register(fastifyCookie, {
|
|
35
|
-
...(
|
|
31
|
+
...(ENV.FASTIFY_COOKIE_OPTIONS as FastifyCookieOptions),
|
|
36
32
|
})
|
|
37
33
|
.register(fastifyFormbody, {
|
|
38
|
-
...(
|
|
34
|
+
...(ENV.FASTIFY_FORMBODY_OPTIONS as FastifyFormbodyOptions),
|
|
39
35
|
})
|
|
40
36
|
.register(fastifyMultipart, {
|
|
41
37
|
attachFieldsToBody: "keyValues",
|
|
42
|
-
...(
|
|
38
|
+
...(ENV.FASTIFY_MULTIPART_OPTIONS as FastifyMultipartOptions),
|
|
43
39
|
})
|
|
44
40
|
.register(fastifyStatic, {
|
|
45
41
|
root: [["public"], ["dist", "browser"]].map((dir) => join(CWD, ...dir)),
|
|
46
42
|
prefix: "/",
|
|
47
43
|
wildcard: false,
|
|
48
44
|
preCompressed: true,
|
|
49
|
-
...(
|
|
45
|
+
...(ENV.FASTIFY_STATIC_OPTIONS as FastifyStaticOptions),
|
|
50
46
|
})
|
|
51
47
|
.decorateRequest("route", "")
|
|
52
48
|
.decorateRequest("path", "")
|
|
@@ -132,7 +128,7 @@ async function handler(request: FastifyRequest, reply: FastifyReply) {
|
|
|
132
128
|
response = await module.default.call(context, {
|
|
133
129
|
request,
|
|
134
130
|
reply,
|
|
135
|
-
...(typeof response === "object" ? response : {})
|
|
131
|
+
...(typeof response === "object" ? response : {}),
|
|
136
132
|
});
|
|
137
133
|
|
|
138
134
|
if (reply.sent) {
|
|
@@ -144,11 +140,7 @@ async function handler(request: FastifyRequest, reply: FastifyReply) {
|
|
|
144
140
|
reply.status(404);
|
|
145
141
|
}
|
|
146
142
|
break;
|
|
147
|
-
} else if (
|
|
148
|
-
typeof response === "string" ||
|
|
149
|
-
Buffer.isBuffer(response) ||
|
|
150
|
-
isJSX(response)
|
|
151
|
-
) {
|
|
143
|
+
} else if (typeof response === "string" || Buffer.isBuffer(response) || isJSX(response)) {
|
|
152
144
|
break;
|
|
153
145
|
} else if (
|
|
154
146
|
route.endsWith("/[...guard]") &&
|
|
@@ -190,7 +182,7 @@ function generateRoutes(path: string): string[] {
|
|
|
190
182
|
.map((segment) => `${segment}/[...guard]`),
|
|
191
183
|
...edges.map((edge) => `${edge}`),
|
|
192
184
|
...segments.map((segment) => `${segment}/[...path]`),
|
|
193
|
-
...segments.map((segment) => `${segment}/[404]`)
|
|
185
|
+
...segments.map((segment) => `${segment}/[404]`),
|
|
194
186
|
];
|
|
195
187
|
}
|
|
196
188
|
|
|
@@ -222,9 +214,7 @@ function generateEdges(path: string): string[] {
|
|
|
222
214
|
const edges = [];
|
|
223
215
|
if (path) {
|
|
224
216
|
const lastSegment = path.lastIndexOf("/") + 1;
|
|
225
|
-
edges.push(
|
|
226
|
-
`${path.substring(0, lastSegment)}[${path.substring(lastSegment)}]`
|
|
227
|
-
);
|
|
217
|
+
edges.push(`${path.substring(0, lastSegment)}[${path.substring(lastSegment)}]`);
|
|
228
218
|
}
|
|
229
219
|
edges.push(`${path}/[index]`);
|
|
230
220
|
return edges;
|
|
@@ -241,12 +231,11 @@ function isJSX(obj: unknown): boolean {
|
|
|
241
231
|
* Renders JSX to string and applies optional response handler.
|
|
242
232
|
*/
|
|
243
233
|
async function renderJSX(context: object, response: unknown) {
|
|
244
|
-
const payload =
|
|
245
|
-
isJSX(response) ? await jsxToString.call(context, response) : response;
|
|
234
|
+
const payload = isJSX(response) ? await jsxToString.call(context, response) : response;
|
|
246
235
|
|
|
247
236
|
// Post-process the payload with an optional response handler
|
|
248
237
|
const responseHandler = context["responseHandler"];
|
|
249
|
-
return typeof responseHandler === "function"
|
|
250
|
-
|
|
238
|
+
return typeof responseHandler === "function"
|
|
239
|
+
? await responseHandler.call(context, payload)
|
|
251
240
|
: payload;
|
|
252
241
|
}
|