jeasx 1.6.2 → 1.7.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/cli.js +1 -12
- package/env.js +12 -4
- package/esbuild.config.js +30 -53
- package/package.json +4 -5
- package/ecosystem.config.cjs +0 -39
package/cli.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
|
-
import env from "./env.js";
|
|
4
3
|
|
|
5
4
|
switch (process.argv[2]) {
|
|
6
5
|
case "start":
|
|
@@ -35,23 +34,13 @@ async function start() {
|
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
async function build() {
|
|
38
|
-
env();
|
|
39
|
-
const argv = [...process.argv];
|
|
40
|
-
process.argv = [];
|
|
41
|
-
await clean();
|
|
42
37
|
await import("./esbuild.config.js");
|
|
43
|
-
process.argv = argv;
|
|
44
38
|
}
|
|
45
39
|
|
|
46
40
|
async function dev() {
|
|
47
41
|
process.env.NODE_ENV = "development";
|
|
48
|
-
// Run build to prepare browser assets for fastify-static
|
|
49
42
|
await build();
|
|
50
|
-
|
|
51
|
-
process.argv[2] = "start";
|
|
52
|
-
process.argv[3] ??= "node_modules/jeasx/ecosystem.config.cjs";
|
|
53
|
-
// @ts-ignore
|
|
54
|
-
await import("pm2/bin/pm2-runtime");
|
|
43
|
+
await start();
|
|
55
44
|
}
|
|
56
45
|
|
|
57
46
|
async function clean() {
|
package/env.js
CHANGED
|
@@ -11,6 +11,11 @@ import { existsSync } from "node:fs";
|
|
|
11
11
|
* 5. .env.<NODE_ENV>.local
|
|
12
12
|
*/
|
|
13
13
|
export default function env() {
|
|
14
|
+
if (!process.loadEnvFile) {
|
|
15
|
+
console.warn("🌻 <node:process.loadEnvFile> is not available");
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
14
19
|
const files = [".env.defaults", ".env", ".env.local"];
|
|
15
20
|
|
|
16
21
|
if (process.env.NODE_ENV) {
|
|
@@ -20,8 +25,11 @@ export default function env() {
|
|
|
20
25
|
);
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
files
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
files
|
|
29
|
+
.toReversed()
|
|
30
|
+
.filter(existsSync)
|
|
31
|
+
.forEach((file) => {
|
|
32
|
+
console.info(`🌻 Loading ${file}`);
|
|
33
|
+
process.loadEnvFile(file);
|
|
34
|
+
});
|
|
27
35
|
}
|
package/esbuild.config.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import * as esbuild from "esbuild";
|
|
2
|
+
import env from "./env.js";
|
|
3
|
+
|
|
4
|
+
env();
|
|
2
5
|
|
|
3
6
|
const BUILD_TIME = `"${Date.now().toString(36)}"`;
|
|
4
7
|
|
|
@@ -16,53 +19,20 @@ const ESBUILD_BROWSER_TARGET = process.env.ESBUILD_BROWSER_TARGET
|
|
|
16
19
|
? process.env.ESBUILD_BROWSER_TARGET.replace(/\s/g, "").split(",")
|
|
17
20
|
: ["chrome126", "edge126", "firefox128", "safari17"];
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
builds.push(
|
|
26
|
-
buildServer(
|
|
27
|
-
"src/routes/**/[*].js",
|
|
28
|
-
"src/routes/**/[*].ts",
|
|
29
|
-
"src/routes/**/[*].jsx",
|
|
30
|
-
"src/routes/**/[*].tsx"
|
|
31
|
-
)
|
|
32
|
-
);
|
|
33
|
-
break;
|
|
34
|
-
case "js":
|
|
35
|
-
builds.push(
|
|
36
|
-
buildBrowser(
|
|
37
|
-
"src/browser/**/index.js",
|
|
38
|
-
"src/browser/**/index.ts",
|
|
39
|
-
"src/browser/**/index.jsx",
|
|
40
|
-
"src/browser/**/index.tsx"
|
|
41
|
-
)
|
|
42
|
-
);
|
|
43
|
-
break;
|
|
44
|
-
case "css":
|
|
45
|
-
builds.push(buildBrowser("src/browser/**/index.css"));
|
|
46
|
-
break;
|
|
47
|
-
default:
|
|
48
|
-
console.info(`Error: Unknown argument '${arg}'.`);
|
|
49
|
-
process.exit(1);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
await Promise.all(builds);
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @param {string[]} entryPoints
|
|
57
|
-
*/
|
|
58
|
-
function buildServer(...entryPoints) {
|
|
59
|
-
esbuild.build({
|
|
60
|
-
entryPoints,
|
|
22
|
+
/** @type import("esbuild").BuildOptions[] */
|
|
23
|
+
const buildOptions = [
|
|
24
|
+
{
|
|
25
|
+
entryPoints: ["js", "ts", "jsx", "tsx"].map(
|
|
26
|
+
(ext) => `src/routes/**/[*].${ext}`
|
|
27
|
+
),
|
|
61
28
|
define: {
|
|
62
29
|
"process.env.BUILD_TIME": BUILD_TIME,
|
|
63
30
|
},
|
|
64
31
|
minify: process.env.NODE_ENV !== "development",
|
|
65
32
|
logLevel: "info",
|
|
33
|
+
logOverride: {
|
|
34
|
+
"empty-glob": "silent",
|
|
35
|
+
},
|
|
66
36
|
color: true,
|
|
67
37
|
bundle: true,
|
|
68
38
|
sourcemap: true,
|
|
@@ -71,18 +41,17 @@ function buildServer(...entryPoints) {
|
|
|
71
41
|
outdir: "dist",
|
|
72
42
|
platform: "neutral",
|
|
73
43
|
packages: "external",
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
*/
|
|
80
|
-
function buildBrowser(...entryPoints) {
|
|
81
|
-
esbuild.build({
|
|
82
|
-
entryPoints,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
entryPoints: ["js", "ts", "jsx", "tsx", "css"].map(
|
|
47
|
+
(ext) => `src/browser/**/index.${ext}`
|
|
48
|
+
),
|
|
83
49
|
define: BROWSER_PUBLIC_ENV,
|
|
84
50
|
minify: process.env.NODE_ENV !== "development",
|
|
85
51
|
logLevel: "info",
|
|
52
|
+
logOverride: {
|
|
53
|
+
"empty-glob": "silent",
|
|
54
|
+
},
|
|
86
55
|
color: true,
|
|
87
56
|
bundle: true,
|
|
88
57
|
sourcemap: true,
|
|
@@ -106,5 +75,13 @@ function buildBrowser(...entryPoints) {
|
|
|
106
75
|
"*.woff",
|
|
107
76
|
"*.woff2",
|
|
108
77
|
],
|
|
109
|
-
}
|
|
110
|
-
|
|
78
|
+
},
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
buildOptions.forEach(async (options) => {
|
|
82
|
+
if (process.env.NODE_ENV === "development") {
|
|
83
|
+
(await esbuild.context(options)).watch();
|
|
84
|
+
} else {
|
|
85
|
+
await esbuild.build(options);
|
|
86
|
+
}
|
|
87
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jeasx",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Jeasx - the ease of JSX with the power of SSR",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jsx",
|
|
@@ -28,11 +28,10 @@
|
|
|
28
28
|
"@fastify/formbody": "8.0.2",
|
|
29
29
|
"@fastify/multipart": "9.0.3",
|
|
30
30
|
"@fastify/static": "8.1.1",
|
|
31
|
-
"@types/node": "22.13.
|
|
31
|
+
"@types/node": "22.13.14",
|
|
32
32
|
"esbuild": "0.25.1",
|
|
33
|
-
"fastify": "5.2.
|
|
34
|
-
"jsx-async-runtime": "1.0.0"
|
|
35
|
-
"pm2": "6.0.5"
|
|
33
|
+
"fastify": "5.2.2",
|
|
34
|
+
"jsx-async-runtime": "1.0.0"
|
|
36
35
|
},
|
|
37
36
|
"scripts": {
|
|
38
37
|
"build": "esbuild --platform=node --format=esm --outdir=. serverless.ts"
|
package/ecosystem.config.cjs
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
apps: [
|
|
3
|
-
{
|
|
4
|
-
name: "jeasx:start:server",
|
|
5
|
-
script: "node_modules/jeasx/server.js",
|
|
6
|
-
watch: ["public"],
|
|
7
|
-
autorestart: true,
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
name: "jeasx:build:routes",
|
|
11
|
-
script: "node_modules/jeasx/esbuild.config.js",
|
|
12
|
-
args: "routes",
|
|
13
|
-
watch: ["js", "jsx", "ts", "tsx", "json"].map((ext) => `src/**/*.${ext}`),
|
|
14
|
-
ignore_watch: process.env.JEASX_BUILD_ROUTES_IGNORE_WATCH
|
|
15
|
-
? process.env.JEASX_BUILD_ROUTES_IGNORE_WATCH.split(",")
|
|
16
|
-
: ["src/browser"],
|
|
17
|
-
autorestart: false,
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
name: "jeasx:build:js",
|
|
21
|
-
script: "node_modules/jeasx/esbuild.config.js",
|
|
22
|
-
args: "js",
|
|
23
|
-
watch: (process.env.JEASX_BUILD_JS_WATCH
|
|
24
|
-
? process.env.JEASX_BUILD_JS_WATCH.split(",")
|
|
25
|
-
: ["src/browser"]
|
|
26
|
-
).flatMap((path) =>
|
|
27
|
-
["js", "jsx", "ts", "tsx", "json"].map((ext) => `${path}/**/*.${ext}`)
|
|
28
|
-
),
|
|
29
|
-
autorestart: false,
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
name: "jeasx:build:css",
|
|
33
|
-
script: "node_modules/jeasx/esbuild.config.js",
|
|
34
|
-
args: "css",
|
|
35
|
-
watch: ["src/**/*.css"],
|
|
36
|
-
autorestart: false,
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
};
|