@xfe-repo/web-app 1.6.2 → 2.0.0-beta.1

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.
Files changed (48) hide show
  1. package/README.md +64 -1
  2. package/client.d.ts +1 -0
  3. package/deploy/.drone.yml +12 -5
  4. package/deploy/Dockerfile +14 -6
  5. package/deploy/helm/templates/deployment.yaml +5 -18
  6. package/deploy/helm/templates/svc.yaml +1 -1
  7. package/dist/cli.js +275 -413
  8. package/dist/cli.mjs +273 -267
  9. package/dist/config.d.mts +20 -6
  10. package/dist/config.d.ts +20 -6
  11. package/dist/config.js +83 -297
  12. package/dist/config.mjs +69 -2
  13. package/dist/framework.d.mts +10 -0
  14. package/dist/framework.d.ts +10 -0
  15. package/dist/framework.js +174 -0
  16. package/dist/framework.mjs +137 -0
  17. package/dist/react-router-config.d.mts +11 -0
  18. package/dist/react-router-config.d.ts +11 -0
  19. package/dist/react-router-config.js +66 -0
  20. package/dist/react-router-config.mjs +35 -0
  21. package/dist/root.d.mts +17 -0
  22. package/dist/root.d.ts +17 -0
  23. package/dist/root.js +61 -0
  24. package/dist/root.mjs +34 -0
  25. package/dist/serve.d.mts +10 -0
  26. package/dist/serve.d.ts +10 -0
  27. package/dist/serve.js +71 -0
  28. package/dist/serve.mjs +36 -0
  29. package/dist/vite.d.mts +9 -0
  30. package/dist/vite.d.ts +9 -0
  31. package/dist/vite.js +135 -0
  32. package/dist/vite.mjs +100 -0
  33. package/package.json +22 -71
  34. package/tsconfig.json +4 -1
  35. package/config/env.js +0 -104
  36. package/config/getHttpsConfig.js +0 -66
  37. package/config/jest/babelTransform.js +0 -29
  38. package/config/jest/cssTransform.js +0 -14
  39. package/config/jest/fileTransform.js +0 -40
  40. package/config/modules.js +0 -133
  41. package/config/paths.js +0 -65
  42. package/config/webpack/persistentCache/createEnvironmentHash.js +0 -9
  43. package/config/webpack/webpack.config.js +0 -724
  44. package/config/webpack/webpackDevServer.config.js +0 -122
  45. package/deploy/nginx.conf +0 -62
  46. package/dist/chunk-75BJNL7E.mjs +0 -239
  47. package/scripts/build.js +0 -217
  48. package/scripts/dev.js +0 -162
package/dist/serve.js ADDED
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/serve.ts
31
+ var serve_exports = {};
32
+ __export(serve_exports, {
33
+ serveClient: () => serveClient
34
+ });
35
+ module.exports = __toCommonJS(serve_exports);
36
+ var import_node_fs = require("fs");
37
+ var import_node_path = __toESM(require("path"));
38
+ var import_express = __toESM(require("express"));
39
+ var serveClient = ({
40
+ directory,
41
+ host,
42
+ port,
43
+ basename = "/"
44
+ }) => {
45
+ const indexFile = import_node_path.default.join(directory, "index.html");
46
+ if (!(0, import_node_fs.existsSync)(indexFile)) throw new Error(`\u672A\u627E\u5230 SPA \u5165\u53E3 ${indexFile}\uFF0C\u8BF7\u5148\u6267\u884C xfe-web build`);
47
+ const app = (0, import_express.default)().disable("x-powered-by");
48
+ const router = import_express.default.Router();
49
+ app.use((_request, response, next) => {
50
+ response.setHeader("Access-Control-Allow-Origin", "*");
51
+ next();
52
+ });
53
+ app.use(
54
+ "/assets",
55
+ import_express.default.static(import_node_path.default.join(directory, "assets"), { immutable: true, maxAge: "1y" }),
56
+ (_request, response) => response.status(404).end()
57
+ );
58
+ app.use(import_express.default.static(directory));
59
+ router.get("/{*path}", (_request, response) => response.sendFile(indexFile));
60
+ app.use(basename, router);
61
+ const server = app.listen(port, host);
62
+ server.once("listening", () => {
63
+ const address = server.address();
64
+ console.log(`[xfe-web] SPA http://${host}:${typeof address === "object" && address ? address.port : port}${basename}`);
65
+ });
66
+ return server;
67
+ };
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
70
+ serveClient
71
+ });
package/dist/serve.mjs ADDED
@@ -0,0 +1,36 @@
1
+ // src/serve.ts
2
+ import { existsSync } from "fs";
3
+ import path from "path";
4
+ import express from "express";
5
+ var serveClient = ({
6
+ directory,
7
+ host,
8
+ port,
9
+ basename = "/"
10
+ }) => {
11
+ const indexFile = path.join(directory, "index.html");
12
+ if (!existsSync(indexFile)) throw new Error(`\u672A\u627E\u5230 SPA \u5165\u53E3 ${indexFile}\uFF0C\u8BF7\u5148\u6267\u884C xfe-web build`);
13
+ const app = express().disable("x-powered-by");
14
+ const router = express.Router();
15
+ app.use((_request, response, next) => {
16
+ response.setHeader("Access-Control-Allow-Origin", "*");
17
+ next();
18
+ });
19
+ app.use(
20
+ "/assets",
21
+ express.static(path.join(directory, "assets"), { immutable: true, maxAge: "1y" }),
22
+ (_request, response) => response.status(404).end()
23
+ );
24
+ app.use(express.static(directory));
25
+ router.get("/{*path}", (_request, response) => response.sendFile(indexFile));
26
+ app.use(basename, router);
27
+ const server = app.listen(port, host);
28
+ server.once("listening", () => {
29
+ const address = server.address();
30
+ console.log(`[xfe-web] SPA http://${host}:${typeof address === "object" && address ? address.port : port}${basename}`);
31
+ });
32
+ return server;
33
+ };
34
+ export {
35
+ serveClient
36
+ };
@@ -0,0 +1,9 @@
1
+ import * as vite from 'vite';
2
+
3
+ declare const adaptPageRoute: (code: string, options: string | {
4
+ id: string;
5
+ clientOnly?: boolean;
6
+ }) => string | undefined;
7
+ declare const _default: vite.UserConfigFnObject;
8
+
9
+ export { adaptPageRoute, _default as default };
package/dist/vite.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import * as vite from 'vite';
2
+
3
+ declare const adaptPageRoute: (code: string, options: string | {
4
+ id: string;
5
+ clientOnly?: boolean;
6
+ }) => string | undefined;
7
+ declare const _default: vite.UserConfigFnObject;
8
+
9
+ export { adaptPageRoute, _default as default };
package/dist/vite.js ADDED
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/vite.ts
31
+ var vite_exports = {};
32
+ __export(vite_exports, {
33
+ adaptPageRoute: () => adaptPageRoute,
34
+ default: () => vite_default
35
+ });
36
+ module.exports = __toCommonJS(vite_exports);
37
+ var import_node_path = __toESM(require("path"));
38
+ var import_node_fs = require("fs");
39
+ var import_vite = require("@react-router/dev/vite");
40
+ var import_vite2 = require("vite");
41
+
42
+ // src/config.ts
43
+ var import_path = __toESM(require("path"));
44
+ var import_fs = __toESM(require("fs"));
45
+ var import_yaml = __toESM(require("yaml"));
46
+ var loadXfeConfig = (root = process.cwd()) => {
47
+ const xfeConfigPath = import_path.default.join(root, "xfe.json");
48
+ if (!import_fs.default.existsSync(xfeConfigPath)) {
49
+ throw new Error("xfe.json \u914D\u7F6E\u6587\u4EF6\u4E0D\u5B58\u5728\uFF0C\u8BF7\u5728\u9879\u76EE\u6839\u76EE\u5F55\u4E0B\u521B\u5EFA\u8BE5\u6587\u4EF6\u3002");
50
+ }
51
+ const xfeConfigContent = import_fs.default.readFileSync(xfeConfigPath, "utf8");
52
+ const config = JSON.parse(xfeConfigContent);
53
+ const renderMode = config.webapp?.renderMode;
54
+ if (renderMode !== void 0 && renderMode !== "client" && renderMode !== "server") {
55
+ throw new Error("xfe.json.webapp.renderMode \u53EA\u80FD\u4E3A client \u6216 server");
56
+ }
57
+ return config;
58
+ };
59
+
60
+ // src/vite.ts
61
+ var chromeDevToolsConfigPath = "/.well-known/appspecific/com.chrome.devtools.json";
62
+ var adaptPageRoute = (code, options) => {
63
+ const { id, clientOnly = false } = typeof options === "string" ? { id: options } : options;
64
+ if (!/[\\/]pages[\\/].+\.(?:jsx?|tsx?)$/.test(id) || !/^\s*export\s+const\s+page\s*=/m.test(code)) return;
65
+ const fallback = clientOnly ? "" : "export const HydrateFallback = page.HydrateFallback\n";
66
+ return `${code}
67
+ export default page.Component
68
+ export const clientLoader = page.clientLoader
69
+ ${fallback}export const ErrorBoundary = page.ErrorBoundary
70
+ export const meta = page.meta
71
+ `;
72
+ };
73
+ var frameworkPlugin = (clientOnly) => ({
74
+ name: "xfe:framework",
75
+ enforce: "pre",
76
+ configureServer(server) {
77
+ server.middlewares.use(chromeDevToolsConfigPath, (_request, response) => response.writeHead(404).end());
78
+ },
79
+ transform(code, id) {
80
+ return adaptPageRoute(code, { id, clientOnly });
81
+ }
82
+ });
83
+ var vite_default = (0, import_vite2.defineConfig)(({ mode }) => {
84
+ const projectRoot = process.env.XFE_WEB_ROOT;
85
+ if (!projectRoot) throw new Error("\u7F3A\u5C11 XFE_WEB_ROOT\uFF0CVite \u5FC5\u987B\u901A\u8FC7 xfe-web \u542F\u52A8");
86
+ const env = (0, import_vite2.loadEnv)(mode, projectRoot, "");
87
+ const { webapp = {} } = loadXfeConfig(projectRoot);
88
+ const publicEnv = (key) => process.env[key] || env[key] || "";
89
+ return {
90
+ plugins: [frameworkPlugin(webapp.renderMode === "client"), (0, import_vite.reactRouter)()],
91
+ build: { emptyOutDir: true },
92
+ envDir: projectRoot,
93
+ envPrefix: ["VITE_", "REACT_APP_"],
94
+ publicDir: import_node_path.default.join(projectRoot, "public"),
95
+ define: {
96
+ "import.meta.env.XFE_JWT_AUD": JSON.stringify(publicEnv("XFE_JWT_AUD")),
97
+ "import.meta.env.XFE_JWT_KEY_ID": JSON.stringify(publicEnv("XFE_JWT_KEY_ID")),
98
+ "process.env.REACT_APP_RELEASE": JSON.stringify(publicEnv("REACT_APP_RELEASE")),
99
+ "process.env.REACT_APP_API_ENV": JSON.stringify(publicEnv("REACT_APP_API_ENV")),
100
+ "process.env.REACT_APP_BUSINESS": JSON.stringify(publicEnv("REACT_APP_BUSINESS")),
101
+ "process.env.XFE_JWT_AUD": JSON.stringify(publicEnv("XFE_JWT_AUD")),
102
+ "process.env.XFE_JWT_KEY_ID": JSON.stringify(publicEnv("XFE_JWT_KEY_ID")),
103
+ "process.env.XFE_JWT_PRIVATE_KEY": "undefined"
104
+ },
105
+ css: {
106
+ preprocessorOptions: {
107
+ less: {
108
+ javascriptEnabled: true,
109
+ paths: [import_node_path.default.join(projectRoot, "src")]
110
+ }
111
+ }
112
+ },
113
+ resolve: {
114
+ tsconfigPaths: true,
115
+ // workspace 和本地框架链接均使用消费应用的 React 与状态管理实例。
116
+ dedupe: ["react", "react-dom", "react-redux", "@reduxjs/toolkit"].filter(
117
+ (name) => (0, import_node_fs.existsSync)(import_node_path.default.join(projectRoot, "node_modules", name))
118
+ )
119
+ },
120
+ ssr: {
121
+ // 路由属于框架内部依赖,SSR/SPA 预渲染产物也不能要求业务项目直接安装它。
122
+ noExternal: ["react-router", "isbot", /^@xfe-repo\/web-/, /^@ant-design\//, /^@emotion\//, /^@rc-component\//, /^rc-/, "antd"]
123
+ },
124
+ server: {
125
+ cors: true,
126
+ fs: { allow: [projectRoot] },
127
+ host: env.HOST || webapp.host || "0.0.0.0",
128
+ port: Number(env.PORT || webapp.port) || 3e3
129
+ }
130
+ };
131
+ });
132
+ // Annotate the CommonJS export names for ESM import in node:
133
+ 0 && (module.exports = {
134
+ adaptPageRoute
135
+ });
package/dist/vite.mjs ADDED
@@ -0,0 +1,100 @@
1
+ // src/vite.ts
2
+ import path2 from "path";
3
+ import { existsSync } from "fs";
4
+ import { reactRouter } from "@react-router/dev/vite";
5
+ import { defineConfig, loadEnv } from "vite";
6
+
7
+ // src/config.ts
8
+ import path from "path";
9
+ import fs from "fs";
10
+ import yaml from "yaml";
11
+ var loadXfeConfig = (root = process.cwd()) => {
12
+ const xfeConfigPath = path.join(root, "xfe.json");
13
+ if (!fs.existsSync(xfeConfigPath)) {
14
+ throw new Error("xfe.json \u914D\u7F6E\u6587\u4EF6\u4E0D\u5B58\u5728\uFF0C\u8BF7\u5728\u9879\u76EE\u6839\u76EE\u5F55\u4E0B\u521B\u5EFA\u8BE5\u6587\u4EF6\u3002");
15
+ }
16
+ const xfeConfigContent = fs.readFileSync(xfeConfigPath, "utf8");
17
+ const config = JSON.parse(xfeConfigContent);
18
+ const renderMode = config.webapp?.renderMode;
19
+ if (renderMode !== void 0 && renderMode !== "client" && renderMode !== "server") {
20
+ throw new Error("xfe.json.webapp.renderMode \u53EA\u80FD\u4E3A client \u6216 server");
21
+ }
22
+ return config;
23
+ };
24
+
25
+ // src/vite.ts
26
+ var chromeDevToolsConfigPath = "/.well-known/appspecific/com.chrome.devtools.json";
27
+ var adaptPageRoute = (code, options) => {
28
+ const { id, clientOnly = false } = typeof options === "string" ? { id: options } : options;
29
+ if (!/[\\/]pages[\\/].+\.(?:jsx?|tsx?)$/.test(id) || !/^\s*export\s+const\s+page\s*=/m.test(code)) return;
30
+ const fallback = clientOnly ? "" : "export const HydrateFallback = page.HydrateFallback\n";
31
+ return `${code}
32
+ export default page.Component
33
+ export const clientLoader = page.clientLoader
34
+ ${fallback}export const ErrorBoundary = page.ErrorBoundary
35
+ export const meta = page.meta
36
+ `;
37
+ };
38
+ var frameworkPlugin = (clientOnly) => ({
39
+ name: "xfe:framework",
40
+ enforce: "pre",
41
+ configureServer(server) {
42
+ server.middlewares.use(chromeDevToolsConfigPath, (_request, response) => response.writeHead(404).end());
43
+ },
44
+ transform(code, id) {
45
+ return adaptPageRoute(code, { id, clientOnly });
46
+ }
47
+ });
48
+ var vite_default = defineConfig(({ mode }) => {
49
+ const projectRoot = process.env.XFE_WEB_ROOT;
50
+ if (!projectRoot) throw new Error("\u7F3A\u5C11 XFE_WEB_ROOT\uFF0CVite \u5FC5\u987B\u901A\u8FC7 xfe-web \u542F\u52A8");
51
+ const env = loadEnv(mode, projectRoot, "");
52
+ const { webapp = {} } = loadXfeConfig(projectRoot);
53
+ const publicEnv = (key) => process.env[key] || env[key] || "";
54
+ return {
55
+ plugins: [frameworkPlugin(webapp.renderMode === "client"), reactRouter()],
56
+ build: { emptyOutDir: true },
57
+ envDir: projectRoot,
58
+ envPrefix: ["VITE_", "REACT_APP_"],
59
+ publicDir: path2.join(projectRoot, "public"),
60
+ define: {
61
+ "import.meta.env.XFE_JWT_AUD": JSON.stringify(publicEnv("XFE_JWT_AUD")),
62
+ "import.meta.env.XFE_JWT_KEY_ID": JSON.stringify(publicEnv("XFE_JWT_KEY_ID")),
63
+ "process.env.REACT_APP_RELEASE": JSON.stringify(publicEnv("REACT_APP_RELEASE")),
64
+ "process.env.REACT_APP_API_ENV": JSON.stringify(publicEnv("REACT_APP_API_ENV")),
65
+ "process.env.REACT_APP_BUSINESS": JSON.stringify(publicEnv("REACT_APP_BUSINESS")),
66
+ "process.env.XFE_JWT_AUD": JSON.stringify(publicEnv("XFE_JWT_AUD")),
67
+ "process.env.XFE_JWT_KEY_ID": JSON.stringify(publicEnv("XFE_JWT_KEY_ID")),
68
+ "process.env.XFE_JWT_PRIVATE_KEY": "undefined"
69
+ },
70
+ css: {
71
+ preprocessorOptions: {
72
+ less: {
73
+ javascriptEnabled: true,
74
+ paths: [path2.join(projectRoot, "src")]
75
+ }
76
+ }
77
+ },
78
+ resolve: {
79
+ tsconfigPaths: true,
80
+ // workspace 和本地框架链接均使用消费应用的 React 与状态管理实例。
81
+ dedupe: ["react", "react-dom", "react-redux", "@reduxjs/toolkit"].filter(
82
+ (name) => existsSync(path2.join(projectRoot, "node_modules", name))
83
+ )
84
+ },
85
+ ssr: {
86
+ // 路由属于框架内部依赖,SSR/SPA 预渲染产物也不能要求业务项目直接安装它。
87
+ noExternal: ["react-router", "isbot", /^@xfe-repo\/web-/, /^@ant-design\//, /^@emotion\//, /^@rc-component\//, /^rc-/, "antd"]
88
+ },
89
+ server: {
90
+ cors: true,
91
+ fs: { allow: [projectRoot] },
92
+ host: env.HOST || webapp.host || "0.0.0.0",
93
+ port: Number(env.PORT || webapp.port) || 3e3
94
+ }
95
+ };
96
+ });
97
+ export {
98
+ adaptPageRoute,
99
+ vite_default as default
100
+ };
package/package.json CHANGED
@@ -1,90 +1,41 @@
1
1
  {
2
2
  "name": "@xfe-repo/web-app",
3
- "version": "1.6.2",
3
+ "version": "2.0.0-beta.1",
4
4
  "bin": {
5
5
  "xfe-web": "./bin/index.js"
6
6
  },
7
7
  "files": [
8
8
  "dist",
9
9
  "bin",
10
- "config",
11
10
  "deploy",
12
- "scripts",
13
11
  "tsconfig.json",
12
+ "client.d.ts",
14
13
  ".eslintrc.js"
15
14
  ],
15
+ "engines": {
16
+ "node": ">=22.22.0"
17
+ },
16
18
  "dependencies": {
17
- "@babel/core": "^7.16.0",
18
- "@babel/plugin-transform-private-property-in-object": "^7.21.11",
19
- "@loadable/babel-plugin": "^5.15.3",
20
- "@loadable/webpack-plugin": "^5.15.2",
21
- "@pmmmwh/react-refresh-webpack-plugin": "^0.5.3",
22
- "@svgr/webpack": "^5.5.0",
23
- "@testing-library/jest-dom": "^6.9.1",
24
- "@testing-library/react": "^16.3.2",
25
- "@testing-library/user-event": "^14.6.1",
26
- "@types/minimist": "^1.2.5",
27
- "@types/node": "^20.17.0",
28
- "@types/react": "^18.0.0",
29
- "babel-jest": "^30.2.0",
30
- "babel-loader": "^8.2.3",
31
- "babel-plugin-named-asset-import": "^0.3.8",
32
- "babel-preset-react-app": "^10.0.1",
33
- "bfj": "^7.0.2",
34
- "browserslist": "^4.18.1",
35
- "camelcase": "^6.2.1",
36
- "case-sensitive-paths-webpack-plugin": "^2.4.0",
37
- "css-loader": "^6.5.1",
38
- "css-minimizer-webpack-plugin": "^3.2.0",
39
- "dotenv": "^10.0.0",
40
- "dotenv-expand": "^5.1.0",
41
- "eslint": "8.57.1",
42
- "eslint-config-react-app": "^7.0.1",
43
- "eslint-webpack-plugin": "^3.1.1",
44
- "file-loader": "^6.2.0",
45
- "fs-extra": "^10.0.0",
46
- "html-webpack-plugin": "^5.5.0",
47
- "husky": "^9.1.6",
48
- "identity-obj-proxy": "^3.0.0",
49
- "ignore-loader": "^0.1.2",
50
- "jest": "^30.2.0",
51
- "jest-resolve": "^30.2.0",
52
- "jest-watch-typeahead": "^3.0.1",
19
+ "@react-router/dev": "8.3.0",
20
+ "@react-router/serve": "8.3.0",
21
+ "@types/node": "^22.0.0",
22
+ "express": "5.2.1",
23
+ "isbot": "^5.1.36",
53
24
  "less": "^4.1.3",
54
- "less-loader": "^11.1.0",
55
- "mini-css-extract-plugin": "^2.4.5",
56
- "minimist": "^1.2.8",
57
- "nodemon": "^2.0.22",
58
- "postcss": "^8.4.4",
59
- "postcss-flexbugs-fixes": "^5.0.2",
60
- "postcss-loader": "^6.2.1",
61
- "postcss-normalize": "^10.0.1",
62
- "postcss-preset-env": "^7.0.1",
63
- "prompts": "^2.4.2",
64
- "react-app-polyfill": "^3.0.0",
65
- "react-dev-utils": "^12.0.1",
66
- "react-refresh": "^0.11.0",
67
- "resolve": "^1.20.0",
68
- "resolve-url-loader": "^4.0.0",
69
- "sass-loader": "^12.3.0",
70
- "semver": "^7.3.5",
71
- "source-map-loader": "^3.0.0",
72
- "style-loader": "^3.3.1",
73
- "tailwindcss": "^3.0.2",
74
- "terser-webpack-plugin": "^5.2.5",
75
- "web-vitals": "^2.1.4",
76
- "webpack": "~5.64.4",
77
- "webpack-bundle-analyzer": "^4.8.0",
78
- "webpack-dev-server": "^4.6.0",
79
- "webpack-manifest-plugin": "^4.0.2",
80
- "workbox-webpack-plugin": "^7.0.0",
81
- "yaml": "^2.3.4",
82
- "@xfe-repo/typescript-config": "1.6.2",
83
- "@xfe-repo/eslint-config": "1.6.0"
25
+ "react-router": "8.3.0",
26
+ "typescript": "~5.9.3",
27
+ "vite": "^8.2.1",
28
+ "yaml": "^2.4.2",
29
+ "@xfe-repo/eslint-config": "2.0.0-beta.1",
30
+ "@xfe-repo/web-router": "2.0.0-beta.1",
31
+ "@xfe-repo/typescript-config": "2.0.0-beta.1"
32
+ },
33
+ "devDependencies": {
34
+ "@types/express": "5.0.6"
84
35
  },
85
36
  "peerDependencies": {
86
- "react": "18.2.0",
87
- "react-dom": "18.2.0"
37
+ "react": ">=19.2.7",
38
+ "react-dom": ">=19.2.7"
88
39
  },
89
40
  "publishConfig": {
90
41
  "registry": "https://registry.npmjs.org/"
package/tsconfig.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "extends": "@xfe-repo/typescript-config/react.json",
3
3
  "compilerOptions": {
4
+ "target": "ES2022",
5
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
6
+ "types": ["node"],
4
7
  "paths": {
5
8
  "@/*": ["./*"],
6
9
  "@/types/*": ["../types/*"],
7
10
  "@common/services": ["../node_modules/@xfe-repo/web-service/dist/index"]
8
11
  }
9
12
  },
10
- "exclude": ["node_modules", "build", "dist"]
13
+ "exclude": ["node_modules", "build", "dist", ".react-router"]
11
14
  }
package/config/env.js DELETED
@@ -1,104 +0,0 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
- const paths = require('./paths');
6
-
7
- // Make sure that including paths.js after env.js will read .env variables.
8
- delete require.cache[require.resolve('./paths')];
9
-
10
- const NODE_ENV = process.env.NODE_ENV;
11
- if (!NODE_ENV) {
12
- throw new Error(
13
- 'The NODE_ENV environment variable is required but was not specified.'
14
- );
15
- }
16
-
17
- // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
18
- const dotenvFiles = [
19
- `${paths.dotenv}.${NODE_ENV}.local`,
20
- // Don't include `.env.local` for `test` environment
21
- // since normally you expect tests to produce the same
22
- // results for everyone
23
- NODE_ENV !== 'test' && `${paths.dotenv}.local`,
24
- `${paths.dotenv}.${NODE_ENV}`,
25
- paths.dotenv,
26
- ].filter(Boolean);
27
-
28
- // Load environment variables from .env* files. Suppress warnings using silent
29
- // if this file is missing. dotenv will never modify any environment variables
30
- // that have already been set. Variable expansion is supported in .env files.
31
- // https://github.com/motdotla/dotenv
32
- // https://github.com/motdotla/dotenv-expand
33
- dotenvFiles.forEach(dotenvFile => {
34
- if (fs.existsSync(dotenvFile)) {
35
- require('dotenv-expand')(
36
- require('dotenv').config({
37
- path: dotenvFile,
38
- })
39
- );
40
- }
41
- });
42
-
43
- // We support resolving modules according to `NODE_PATH`.
44
- // This lets you use absolute paths in imports inside large monorepos:
45
- // https://github.com/facebook/create-react-app/issues/253.
46
- // It works similar to `NODE_PATH` in Node itself:
47
- // https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
48
- // Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored.
49
- // Otherwise, we risk importing Node.js core modules into an app instead of webpack shims.
50
- // https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421
51
- // We also resolve them to make sure all tools using them work consistently.
52
- const appDirectory = fs.realpathSync(process.cwd());
53
- process.env.NODE_PATH = (process.env.NODE_PATH || '')
54
- .split(path.delimiter)
55
- .filter(folder => folder && !path.isAbsolute(folder))
56
- .map(folder => path.resolve(appDirectory, folder))
57
- .join(path.delimiter);
58
-
59
- // Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
60
- // injected into the application via DefinePlugin in webpack configuration.
61
- const REACT_APP = /^(REACT_APP|XFE)_/i;
62
-
63
- function getClientEnvironment(publicUrl) {
64
- const raw = Object.keys(process.env)
65
- .filter(key => REACT_APP.test(key))
66
- .reduce(
67
- (env, key) => {
68
- env[key] = process.env[key];
69
- return env;
70
- },
71
- {
72
- // Useful for determining whether we’re running in production mode.
73
- // Most importantly, it switches React into the correct mode.
74
- NODE_ENV: process.env.NODE_ENV || 'development',
75
- // Useful for resolving the correct path to static assets in `public`.
76
- // For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
77
- // This should only be used as an escape hatch. Normally you would put
78
- // images into the `src` and `import` them in code to get their paths.
79
- PUBLIC_URL: publicUrl,
80
- // We support configuring the sockjs pathname during development.
81
- // These settings let a developer run multiple simultaneous projects.
82
- // They are used as the connection `hostname`, `pathname` and `port`
83
- // in webpackHotDevClient. They are used as the `sockHost`, `sockPath`
84
- // and `sockPort` options in webpack-dev-server.
85
- WDS_SOCKET_HOST: process.env.WDS_SOCKET_HOST,
86
- WDS_SOCKET_PATH: process.env.WDS_SOCKET_PATH,
87
- WDS_SOCKET_PORT: process.env.WDS_SOCKET_PORT,
88
- // Whether or not react-refresh is enabled.
89
- // It is defined here so it is available in the webpackHotDevClient.
90
- FAST_REFRESH: process.env.FAST_REFRESH !== 'false',
91
- }
92
- );
93
- // Stringify all values so we can feed into webpack DefinePlugin
94
- const stringified = {
95
- 'process.env': Object.keys(raw).reduce((env, key) => {
96
- env[key] = JSON.stringify(raw[key]);
97
- return env;
98
- }, {}),
99
- };
100
-
101
- return { raw, stringified };
102
- }
103
-
104
- module.exports = getClientEnvironment;
@@ -1,66 +0,0 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
- const crypto = require('crypto');
6
- const chalk = require('react-dev-utils/chalk');
7
- const paths = require('./paths');
8
-
9
- // Ensure the certificate and key provided are valid and if not
10
- // throw an easy to debug error
11
- function validateKeyAndCerts({ cert, key, keyFile, crtFile }) {
12
- let encrypted;
13
- try {
14
- // publicEncrypt will throw an error with an invalid cert
15
- encrypted = crypto.publicEncrypt(cert, Buffer.from('test'));
16
- } catch (err) {
17
- throw new Error(
18
- `The certificate "${chalk.yellow(crtFile)}" is invalid.\n${err.message}`
19
- );
20
- }
21
-
22
- try {
23
- // privateDecrypt will throw an error with an invalid key
24
- crypto.privateDecrypt(key, encrypted);
25
- } catch (err) {
26
- throw new Error(
27
- `The certificate key "${chalk.yellow(keyFile)}" is invalid.\n${
28
- err.message
29
- }`
30
- );
31
- }
32
- }
33
-
34
- // Read file and throw an error if it doesn't exist
35
- function readEnvFile(file, type) {
36
- if (!fs.existsSync(file)) {
37
- throw new Error(
38
- `You specified ${chalk.cyan(
39
- type
40
- )} in your env, but the file "${chalk.yellow(file)}" can't be found.`
41
- );
42
- }
43
- return fs.readFileSync(file);
44
- }
45
-
46
- // Get the https config
47
- // Return cert files if provided in env, otherwise just true or false
48
- function getHttpsConfig() {
49
- const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env;
50
- const isHttps = HTTPS === 'true';
51
-
52
- if (isHttps && SSL_CRT_FILE && SSL_KEY_FILE) {
53
- const crtFile = path.resolve(paths.appPath, SSL_CRT_FILE);
54
- const keyFile = path.resolve(paths.appPath, SSL_KEY_FILE);
55
- const config = {
56
- cert: readEnvFile(crtFile, 'SSL_CRT_FILE'),
57
- key: readEnvFile(keyFile, 'SSL_KEY_FILE'),
58
- };
59
-
60
- validateKeyAndCerts({ ...config, keyFile, crtFile });
61
- return config;
62
- }
63
- return isHttps;
64
- }
65
-
66
- module.exports = getHttpsConfig;