rasengan 1.0.0-beta.42 → 1.0.0-beta.44

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.
@@ -7,6 +7,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
7
7
  }
8
8
  return to.concat(ar || Array.prototype.slice.call(from));
9
9
  };
10
+ // import { fileURLToPath } from "node:url";
10
11
  /**
11
12
  * Function to define the config for the app
12
13
  * It will be used by vite.config.ts and other files in other to configure the app
@@ -44,9 +45,9 @@ export var defineConfig = function (loadedConfig) {
44
45
  },
45
46
  };
46
47
  // Define default values for experimentals features coming from loadedConfig.experimentals
47
- var defaultExperimentalFeaturesConfig = {
48
- stream: (experimental === null || experimental === void 0 ? void 0 : experimental.stream) || false
49
- };
48
+ // const defaultExperimentalFeaturesConfig = {
49
+ // stream: experimental?.stream || true
50
+ // }
50
51
  try {
51
52
  var config = {
52
53
  reactStrictMode: reactStrictMode === undefined ? true : reactStrictMode,
@@ -90,13 +91,12 @@ export var defineConfig = function (loadedConfig) {
90
91
  },
91
92
  appType: "custom",
92
93
  },
93
- experimental: defaultExperimentalFeaturesConfig,
94
+ // experimental: defaultExperimentalFeaturesConfig,
94
95
  // More config options...
95
96
  };
96
97
  return config;
97
98
  }
98
99
  catch (error) {
99
- console.error(error);
100
100
  return {
101
101
  reactStrictMode: true,
102
102
  vite: {
@@ -127,9 +127,9 @@ export var defineConfig = function (loadedConfig) {
127
127
  ],
128
128
  },
129
129
  },
130
- experimental: {
131
- stream: false
132
- },
130
+ // experimental: {
131
+ // stream: true
132
+ // },
133
133
  };
134
134
  }
135
135
  };
@@ -165,3 +165,33 @@ export var resolvePath = function (path) {
165
165
  }
166
166
  return path;
167
167
  };
168
+ /**
169
+ * Asynchronously loads a module from a file path relative to the project root directory.
170
+ *
171
+ * This function checks the current environment (production or development) and adjusts the file path accordingly. It then resolves the file path to a valid URL format based on the operating system.
172
+ *
173
+ * @param filename - The name of the file to be loaded.
174
+ * @returns The loaded module.
175
+ */
176
+ // export const loadAsyncFromRoot = async (filename: string) => {
177
+ // try {
178
+ // const isProduction = process.env.NODE_ENV === "production";
179
+ // let __pathToRoot = "";
180
+ // if (!isProduction) {
181
+ // __pathToRoot = process.cwd();
182
+ // } else {
183
+ // __pathToRoot = path.join(process.cwd(), "./../../");
184
+ // }
185
+ // const filePath = resolvePath(path.join(__pathToRoot, filename));
186
+ // const file = await import(`./${filePath}`);
187
+ // return file;
188
+ // } catch (error) {
189
+ // console.error(error);
190
+ // return {};
191
+ // }
192
+ // }
193
+ // export const getDirname = (url: string) => {
194
+ // // Get directory name
195
+ // const __dirname = dirname(fileURLToPath(url));
196
+ // return __dirname;
197
+ // }
@@ -24,7 +24,7 @@ var __assign = (this && this.__assign) || function () {
24
24
  };
25
25
  return __assign.apply(this, arguments);
26
26
  };
27
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
27
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
28
28
  import React from "react";
29
29
  import { generateMetadata, getRouter } from "../../routing/utils/index.js";
30
30
  import { Outlet, useParams } from "react-router-dom";
@@ -124,10 +124,10 @@ export var Heads = function (_a) {
124
124
  * Body component
125
125
  */
126
126
  export var Body = function (_a) {
127
- var _b = _a.children, children = _b === void 0 ? undefined : _b, _c = _a.asChild, asChild = _c === void 0 ? false : _c;
127
+ var _b = _a.children, children = _b === void 0 ? undefined : _b, _c = _a.asChild, asChild = _c === void 0 ? false : _c, _d = _a.AppContent, AppContent = _d === void 0 ? undefined : _d;
128
128
  return (_jsxs("body", { children: [_jsx("noscript", { dangerouslySetInnerHTML: {
129
129
  __html: "<b>Enable JavaScript to run this app.</b>",
130
- } }), asChild ? (_jsx("div", { id: 'root', children: children })) : (_jsxs(_Fragment, { children: [_jsx("div", { id: "root", children: "rasengan-body-app" }), children] }))] }));
130
+ } }), asChild ? (_jsx("div", { id: 'root', children: AppContent })) : (_jsx("div", { id: "root", children: "rasengan-body-app" })), children] }));
131
131
  };
132
132
  /**
133
133
  * Scripts component
@@ -60,11 +60,11 @@ var RenderApp = function (_a) {
60
60
  return (_jsxs(Heads, { data: helmetContext, styles: styles, bootstrap: bootstrap, children: [viteScripts, children] }));
61
61
  }, Body: function (_a) {
62
62
  var children = _a.children;
63
- return _jsx(Body, { asChild: true, children: children });
63
+ return (_jsx(Body, { asChild: true, AppContent: _jsx(App, { Component: Component, children: _jsx(StaticRouterProvider, { router: router, context: context }) }), children: children }));
64
64
  }, Script: function (_a) {
65
65
  var children = _a.children;
66
- return _jsx(Scripts, { bootstrap: bootstrap, children: children });
67
- }, children: _jsx(App, { Component: Component, children: _jsx(StaticRouterProvider, { router: router, context: context }) }) }) }) }));
66
+ return (_jsx(Scripts, { bootstrap: bootstrap, children: children }));
67
+ } }) }) }));
68
68
  };
69
69
  export default function renderStream(router_1, context_1) {
70
70
  return __awaiter(this, arguments, void 0, function (router, context, helmetContext, bootstrap, styles, res) {
@@ -74,17 +74,9 @@ export default function renderStream(router_1, context_1) {
74
74
  var shellRendered = false;
75
75
  var responseStatusCode = 200;
76
76
  var _a = renderToPipeableStream(_jsx(RenderApp, { router: router, context: context, helmetContext: helmetContext, bootstrap: bootstrap, styles: styles }), {
77
- // bootstrapModules: [bootstrap],
78
77
  onShellReady: function () {
79
- // console.log("hummm")
80
78
  shellRendered = true;
81
- // const body = new PassThrough();
82
- // const stream = createReadableStreamFromReadable(body);
83
- // console.log({
84
- // body,
85
- // stream
86
- // })
87
- res.status(200).set({
79
+ res.status(responseStatusCode).set({
88
80
  "Content-Type": "text/html",
89
81
  "Cache-Control": "max-age=31536000",
90
82
  });
@@ -35,20 +35,22 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  }
36
36
  };
37
37
  import { jsx as _jsx } from "react/jsx-runtime";
38
- import React from "react";
38
+ // import React from "react";
39
39
  import ReactDOMServer from "react-dom/server";
40
40
  // @ts-ignore
41
41
  import AppRouter from "./../../../../../src/app/app.router";
42
42
  // @ts-ignore
43
- import App from "./../../../../../src/main";
43
+ // import App from "./../../../../../src/main";
44
44
  // @ts-ignore
45
45
  import Template from "./../../../../../src/template";
46
46
  // @ts-ignore
47
47
  import { generateStaticRoutes } from "../routing/utils/index.js";
48
- import { StaticRouterProvider, } from "react-router-dom/server.js";
49
48
  // @ts-ignore
50
- import config from "./../../../../../rasengan.config.js";
51
- import { Component, ErrorBoundary, Heads, Body, Scripts, } from "../core/components/index.js";
49
+ // import config from "./../../../../../rasengan.config.js";
50
+ import {
51
+ // Component,
52
+ // ErrorBoundary,
53
+ Heads, Body, Scripts, } from "../core/components/index.js";
52
54
  import * as HelmetAsync from "react-helmet-async";
53
55
  import renderStream from "./entry-server-stream.js";
54
56
  // @ts-ignore
@@ -76,21 +78,16 @@ var TemplateHtml = function (_a) {
76
78
  */
77
79
  export function render(router_1, context_1) {
78
80
  return __awaiter(this, arguments, void 0, function (router, context, helmetContext, bootstrap, styles, res) {
79
- var html;
80
81
  if (helmetContext === void 0) { helmetContext = {}; }
81
82
  if (bootstrap === void 0) { bootstrap = ""; }
82
83
  if (styles === void 0) { styles = ""; }
83
84
  return __generator(this, function (_a) {
84
85
  switch (_a.label) {
85
86
  case 0:
86
- if (!config.experimental.stream) return [3 /*break*/, 2];
87
87
  if (!res)
88
88
  return [2 /*return*/];
89
89
  return [4 /*yield*/, renderStream(router, context, helmetContext, bootstrap, styles, res)];
90
90
  case 1: return [2 /*return*/, _a.sent()];
91
- case 2:
92
- html = ReactDOMServer.renderToString(config.reactStrictMode ? (_jsx(React.StrictMode, { children: _jsx(H.HelmetProvider, { context: helmetContext, children: _jsx(ErrorBoundary, { children: _jsx(App, { Component: Component, children: _jsx(StaticRouterProvider, { router: router, context: context }) }) }) }) })) : (_jsx(H.HelmetProvider, { context: helmetContext, children: _jsx(ErrorBoundary, { children: _jsx(App, { Component: Component, children: _jsx(StaticRouterProvider, { router: router, context: context }) }) }) })));
93
- return [2 /*return*/, { html: html }];
94
91
  }
95
92
  });
96
93
  });
@@ -1,37 +1,26 @@
1
1
  import { execa } from "execa";
2
2
  import chalk from "chalk";
3
+ import { checkOsPlateform } from "./utils/check-os.js";
4
+ import { generateCopyExecaArray } from "./utils/copy.js";
3
5
  var hostingStrategy = process.env.HOSTING_STRATEGY || "custom";
4
6
  (function () {
7
+ var copyCommand = checkOsPlateform("win32") ? "xcopy" : "cp";
5
8
  if (hostingStrategy === "vercel") {
6
9
  // Displaying the message
7
10
  console.log("Your project is configured to be hosted on ".concat(chalk.bold.blue(hostingStrategy), "\n"));
8
- // Copying the api folder to the root directory
9
- execa("cp", ["-r", "node_modules/rasengan/lib/esm/server/functions/vercel/api", "."], {
10
- stdio: "inherit",
11
- });
12
- // Copying the vercel.json file to the root directory
13
- execa("cp", ["node_modules/rasengan/lib/esm/server/functions/vercel/vercel.json", "."], {
11
+ // Copying the vercel folder content to the root directory
12
+ execa(copyCommand, generateCopyExecaArray("node_modules/rasengan/lib/esm/server/functions/vercel", "."), {
14
13
  stdio: "inherit",
14
+ shell: true,
15
15
  });
16
16
  }
17
17
  else if (hostingStrategy === "netlify") {
18
18
  // Displaying the message
19
19
  console.log("Your project is configured to be hosted on ".concat(chalk.bold.blue(hostingStrategy), "\n"));
20
- // create a netlify folder at the root
21
- execa("mkdir", ["-p", "netlify"], {
22
- stdio: "inherit",
23
- });
24
- // Copying the netlify folder to the root directory
25
- execa("cp", [
26
- "-r",
27
- "node_modules/rasengan/lib/esm/server/functions/netlify/functions",
28
- "./netlify",
29
- ], {
30
- stdio: "inherit",
31
- });
32
- // Copying the netlify.toml file to the root directory
33
- execa("cp", ["node_modules/rasengan/lib/esm/server/functions/netlify/netlify.toml", "."], {
20
+ // Copying the netlify folder content to the root directory
21
+ execa(copyCommand, generateCopyExecaArray("node_modules/rasengan/lib/esm/server/functions/netlify", "."), {
34
22
  stdio: "inherit",
23
+ shell: true,
35
24
  });
36
25
  }
37
26
  })();
@@ -0,0 +1,7 @@
1
+ import os from "node:os";
2
+ /**
3
+ * Check if the current OS is the provided one
4
+ * @param {"aix"| "darwin"| "freebsd"| "linux"| "openbsd"| "sunos"| "win32"} osname
5
+ * @returns {boolean}
6
+ */
7
+ export var checkOsPlateform = function (osname) { return osname === os.platform(); };
@@ -0,0 +1,16 @@
1
+ import { checkOsPlateform } from "./check-os.js";
2
+ import path from "node:path";
3
+ /**
4
+ * Generates an array of command-line arguments for the `execa` function to copy files from one location to another.
5
+ *
6
+ * @param {string} from - The source directory or file path.
7
+ * @param {string} to - The destination directory or file path.
8
+ * @return {Array<string>} - An array of command-line arguments for the `execa` function.
9
+ */
10
+ export var generateCopyExecaArray = function (from, to) {
11
+ var fromPath = path.normalize(from);
12
+ var toPath = path.normalize(to);
13
+ var copyCommand = ["-r", path.join(fromPath, "/*"), toPath];
14
+ var copyCommandWindows = ["\"".concat(fromPath, "\""), "\"".concat(toPath, "\""), "/s /e /i"];
15
+ return checkOsPlateform("win32") ? copyCommandWindows : copyCommand;
16
+ };
@@ -54,12 +54,11 @@ var RASENGAN_VERCEL_CONFIG = process.env.RASENGAN_VERCEL_CONFIG;
54
54
  // Create server for production only
55
55
  export default function handler(req, res) {
56
56
  return __awaiter(this, void 0, void 0, function () {
57
- var url, host, appPath, config_1, configPath, config, filePath, file, err_1, segments, segmentsWithoutOrigin, _i, segments_1, segment, filePath, file, otherFile, result, mimeType, file, templateHtml, serverFilePath, bootstrapDirPath, entry, bootstrap, styles, render, staticRoutes, loadTemplateHtml, handler_1, fetchRequest, context, status_1, redirect, helmetContext, router, rendered, html, e_1;
58
- var _a;
59
- return __generator(this, function (_b) {
60
- switch (_b.label) {
57
+ var url, host, appPath, config_1, configPath, config, filePath, file, err_1, segments, segmentsWithoutOrigin, _i, segments_1, segment, filePath, file, otherFile, result, mimeType, file, templateHtml, serverFilePath, bootstrapDirPath, entry, bootstrap, styles, render, staticRoutes, loadTemplateHtml, handler_1, fetchRequest, context, status_1, redirect, helmetContext, router, e_1;
58
+ return __generator(this, function (_a) {
59
+ switch (_a.label) {
61
60
  case 0:
62
- _b.trys.push([0, 18, , 19]);
61
+ _a.trys.push([0, 16, , 17]);
63
62
  url = req.url;
64
63
  host = req.headers.host;
65
64
  appPath = process.cwd();
@@ -69,25 +68,24 @@ export default function handler(req, res) {
69
68
  // Get the app path
70
69
  appPath = join(appPath, config_1.rootDirectory);
71
70
  }
72
- console.log({ env: appPath });
73
- configPath = path.resolve(join(process.cwd() + "./../../", "rasengan.config.js"));
71
+ configPath = path.resolve(join(appPath, "rasengan.config.js"));
74
72
  return [4 /*yield*/, import(configPath)];
75
73
  case 1:
76
- config = (_b.sent()).default;
74
+ config = (_a.sent()).default;
77
75
  if (!(url === "/robots.txt")) return [3 /*break*/, 6];
78
- _b.label = 2;
76
+ _a.label = 2;
79
77
  case 2:
80
- _b.trys.push([2, 5, , 6]);
78
+ _a.trys.push([2, 5, , 6]);
81
79
  filePath = join(appPath, "dist/client/robots.txt");
82
80
  return [4 /*yield*/, fs.access(path.resolve(filePath))];
83
81
  case 3:
84
- _b.sent();
82
+ _a.sent();
85
83
  return [4 /*yield*/, fs.readFile(filePath, "utf-8")];
86
84
  case 4:
87
- file = _b.sent();
85
+ file = _a.sent();
88
86
  return [2 /*return*/, res.send(file)];
89
87
  case 5:
90
- err_1 = _b.sent();
88
+ err_1 = _a.sent();
91
89
  return [2 /*return*/, res.send("\n user-agent: *\n disallow: /downloads/\n disallow: /private/\n allow: /\n \n user-agent: magicsearchbot\n disallow: /uploads/\n ")];
92
90
  case 6:
93
91
  // ! Sitemap Fix
@@ -111,7 +109,7 @@ export default function handler(req, res) {
111
109
  filePath = join(appPath, "dist/client", segmentsWithoutOrigin.join("/"));
112
110
  return [4 /*yield*/, fs.readFile(filePath, "utf-8")];
113
111
  case 7:
114
- file = _b.sent();
112
+ file = _a.sent();
115
113
  if (url.endsWith(".js") || url.endsWith(".css")) {
116
114
  return [2 /*return*/, new Response(file, {
117
115
  headers: {
@@ -124,10 +122,10 @@ export default function handler(req, res) {
124
122
  }
125
123
  return [4 /*yield*/, fs.readFile(filePath)];
126
124
  case 8:
127
- otherFile = _b.sent();
125
+ otherFile = _a.sent();
128
126
  return [4 /*yield*/, fileTypeFromBuffer(otherFile)];
129
127
  case 9:
130
- result = _b.sent();
128
+ result = _a.sent();
131
129
  mimeType = result
132
130
  ? result.mime
133
131
  : url.endsWith(".svg")
@@ -143,7 +141,7 @@ export default function handler(req, res) {
143
141
  if (!(url.endsWith(".js") || url.endsWith(".css"))) return [3 /*break*/, 12];
144
142
  return [4 /*yield*/, fs.readFile(url, "utf-8")];
145
143
  case 11:
146
- file = _b.sent();
144
+ file = _a.sent();
147
145
  return [2 /*return*/, res
148
146
  .status(200)
149
147
  .setHeader("Content-Type", url.endsWith(".js") ? "text/javascript" : "text/css")
@@ -155,7 +153,7 @@ export default function handler(req, res) {
155
153
  bootstrapDirPath = join(appPath, "dist/client/assets");
156
154
  return [4 /*yield*/, import(serverFilePath)];
157
155
  case 13:
158
- entry = _b.sent();
156
+ entry = _a.sent();
159
157
  bootstrap = "/assets/" +
160
158
  fsSync
161
159
  .readdirSync(bootstrapDirPath)
@@ -169,7 +167,7 @@ export default function handler(req, res) {
169
167
  fetchRequest = createFetchRequest(req, host);
170
168
  return [4 /*yield*/, handler_1.query(fetchRequest)];
171
169
  case 14:
172
- context = _b.sent();
170
+ context = _a.sent();
173
171
  status_1 = context.status;
174
172
  if (status_1 === 302) {
175
173
  redirect = context.headers.get("Location");
@@ -178,29 +176,16 @@ export default function handler(req, res) {
178
176
  }
179
177
  helmetContext = {};
180
178
  router = createStaticRouter(handler_1.dataRoutes, context);
181
- if (!config.experimental.stream) return [3 /*break*/, 16];
182
179
  return [4 /*yield*/, render(router, context, helmetContext, bootstrap, styles, res)];
183
- case 15: return [2 /*return*/, _b.sent()];
184
- case 16: return [4 /*yield*/, render(router, context, helmetContext)];
185
- case 17:
186
- rendered = _b.sent();
187
- // Load template html
188
- if (!templateHtml) {
189
- templateHtml = loadTemplateHtml(helmetContext, bootstrap, styles);
190
- }
191
- html = templateHtml.replace("rasengan-body-app", (_a = rendered.html) !== null && _a !== void 0 ? _a : "");
192
- // Send the rendered html page
193
- return [2 /*return*/, res
194
- .status(200)
195
- .setHeader("Content-Type", "text/html")
196
- .setHeader("Cache-Control", "max-age=31536000")
197
- .end(html)];
198
- case 18:
199
- e_1 = _b.sent();
180
+ case 15:
181
+ // If stream mode enabled, render the page as a plain text
182
+ return [2 /*return*/, _a.sent()];
183
+ case 16:
184
+ e_1 = _a.sent();
200
185
  console.log(e_1.stack);
201
186
  res.status(500).end(e_1.stack);
202
- return [3 /*break*/, 19];
203
- case 19: return [2 /*return*/];
187
+ return [3 /*break*/, 17];
188
+ case 17: return [2 /*return*/];
204
189
  }
205
190
  });
206
191
  });
@@ -37,9 +37,6 @@ export declare const defineConfig: (loadedConfig: AppConfig) => {
37
37
  };
38
38
  appType: string;
39
39
  };
40
- experimental: {
41
- stream: boolean;
42
- };
43
40
  } | {
44
41
  reactStrictMode: boolean;
45
42
  vite: {
@@ -55,9 +52,6 @@ export declare const defineConfig: (loadedConfig: AppConfig) => {
55
52
  }[];
56
53
  };
57
54
  };
58
- experimental: {
59
- stream: boolean;
60
- };
61
55
  };
62
56
  /**
63
57
  * Function to adapt the path for dev and prod
@@ -71,3 +65,11 @@ export declare const adaptPath: (paths: string | Array<string>) => string | stri
71
65
  * @returns The adapted file path in a valid URL format.
72
66
  */
73
67
  export declare const resolvePath: (path: string) => string;
68
+ /**
69
+ * Asynchronously loads a module from a file path relative to the project root directory.
70
+ *
71
+ * This function checks the current environment (production or development) and adjusts the file path accordingly. It then resolves the file path to a valid URL format based on the operating system.
72
+ *
73
+ * @param filename - The name of the file to be loaded.
74
+ * @returns The loaded module.
75
+ */
@@ -34,9 +34,10 @@ export declare const Heads: ({ data, children, bootstrap, styles, }: {
34
34
  /**
35
35
  * Body component
36
36
  */
37
- export declare const Body: ({ children, asChild, }: {
37
+ export declare const Body: ({ children, asChild, AppContent, }: {
38
38
  children?: React.ReactNode;
39
39
  asChild?: boolean;
40
+ AppContent?: React.ReactNode;
40
41
  }) => import("react/jsx-runtime").JSX.Element;
41
42
  /**
42
43
  * Scripts component
@@ -125,7 +125,6 @@ export type HelmetContext = {
125
125
  * Template props
126
126
  */
127
127
  export type TemplateProps = {
128
- children: React.ReactNode;
129
128
  Head: React.FC<{
130
129
  children: React.ReactNode;
131
130
  }>;
@@ -0,0 +1 @@
1
+ export function checkOsPlateform(osname: "aix" | "darwin" | "freebsd" | "linux" | "openbsd" | "sunos" | "win32"): boolean;
@@ -0,0 +1 @@
1
+ export function generateCopyExecaArray(from: string, to: string): Array<string>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rasengan",
3
3
  "private": false,
4
- "version": "1.0.0-beta.42",
4
+ "version": "1.0.0-beta.44",
5
5
  "description": "The modern frontend framework for React",
6
6
  "type": "module",
7
7
  "main": "lib/esm/index.js",
package/server.js CHANGED
@@ -133,46 +133,44 @@ async function createServer({
133
133
  let router = createStaticRouter(handler.dataRoutes, context);
134
134
 
135
135
  // If stream mode enabled, render the page as a plain text
136
- if (config.experimental.stream) {
137
- return await render(
138
- router,
139
- context,
140
- helmetContext,
141
- bootstrap,
142
- styles,
143
- res
144
- );
145
- }
146
-
147
- // Render the html page on the server
148
- const rendered = await render(
136
+ return await render(
149
137
  router,
150
138
  context,
151
139
  helmetContext,
152
140
  bootstrap,
153
- styles
141
+ styles,
142
+ res
154
143
  );
155
144
 
156
- // Load template html
157
- if (!templateHtml) {
158
- templateHtml = loadTemplateHtml(helmetContext, bootstrap, styles);
159
-
160
- if (!isProduction) {
161
- templateHtml = await vite.transformIndexHtml(url, templateHtml);
162
- }
163
- }
164
-
165
- // Replacing the app-html placeholder with the rendered html
166
- let html = templateHtml.replace(`rasengan-body-app`, rendered.html ?? "");
167
-
168
- // Send the rendered html page
169
- return res
170
- .status(200)
171
- .set({
172
- "Content-Type": "text/html",
173
- "Cache-Control": "max-age=31536000",
174
- })
175
- .end(html);
145
+ // Render the html page on the server
146
+ // const rendered = await render(
147
+ // router,
148
+ // context,
149
+ // helmetContext,
150
+ // bootstrap,
151
+ // styles
152
+ // );
153
+
154
+ // // Load template html
155
+ // if (!templateHtml) {
156
+ // templateHtml = loadTemplateHtml(helmetContext, bootstrap, styles);
157
+
158
+ // if (!isProduction) {
159
+ // templateHtml = await vite.transformIndexHtml(url, templateHtml);
160
+ // }
161
+ // }
162
+
163
+ // // Replacing the app-html placeholder with the rendered html
164
+ // let html = templateHtml.replace(`rasengan-body-app`, rendered.html ?? "");
165
+
166
+ // // Send the rendered html page
167
+ // return res
168
+ // .status(200)
169
+ // .set({
170
+ // "Content-Type": "text/html",
171
+ // "Cache-Control": "max-age=31536000",
172
+ // })
173
+ // .end(html);
176
174
  } catch (e) {
177
175
  vite?.ssrFixStacktrace(e);
178
176
 
package/vite.config.ts CHANGED
@@ -1,14 +1,12 @@
1
1
  import { defineConfig } from "vite";
2
2
  import react from "@vitejs/plugin-react";
3
3
 
4
- // Load rasengan config file
5
- // @ts-ignore
6
- import config from "./../../rasengan.config.js";
7
-
8
4
  import path from "node:path";
9
5
 
10
- // Extract vite config
11
- const { vite } = config;
6
+ // Load config
7
+ // @ts-ignore
8
+ import config from "./../../rasengan.config.js";
9
+ // import { config } from "./AppEntry";
12
10
 
13
11
  // Getting root path
14
12
  let __pathToRoot = "";
@@ -41,6 +39,9 @@ export default defineConfig(async ({ command, mode }: any) => {
41
39
  __pathToRoot = path.join(process.cwd(), "./../../");
42
40
  }
43
41
 
42
+ // Extract vite config
43
+ const { vite } = config;
44
+
44
45
  return {
45
46
  // Define env
46
47
  define: {
@@ -59,7 +60,8 @@ export default defineConfig(async ({ command, mode }: any) => {
59
60
 
60
61
  // Build options
61
62
  build: {
62
- sourcemap: true,
63
+ sourcemap: mode === "development" ? true : false,
64
+ minify: "esbuild",
63
65
  rollupOptions: {
64
66
  input: "./lib/esm/entries/entry-client.js",
65
67
  output: {