rasengan 1.0.0-beta.10 → 1.0.0-beta.12
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/lib/cjs/cli/index.js +0 -4
- package/lib/cjs/config/index.js +3 -3
- package/lib/cjs/core/components/index.js +2 -2
- package/lib/cjs/entries/entry-server.js +4 -4
- package/lib/cjs/server/functions/vercel/api/index.js +11 -8
- package/lib/esm/cli/index.js +0 -4
- package/lib/esm/config/index.js +3 -3
- package/lib/esm/core/components/index.js +2 -2
- package/lib/esm/entries/entry-server.js +4 -4
- package/lib/esm/server/functions/vercel/api/index.js +11 -8
- package/lib/types/core/components/index.d.ts +2 -1
- package/lib/types/entries/entry-server.d.ts +1 -1
- package/package.json +1 -1
- package/server.js +11 -2
- package/vite.config.ts +1 -2
package/lib/cjs/cli/index.js
CHANGED
|
@@ -122,10 +122,6 @@ program
|
|
|
122
122
|
(0, execa_1.execa)("cp", ["node_modules/rasengan/lib/esm/server/functions/vercel/vercel.json", "."], {
|
|
123
123
|
stdio: "inherit",
|
|
124
124
|
});
|
|
125
|
-
// Removing index.d.ts and index.js.map files from the api folder
|
|
126
|
-
(0, execa_1.execa)("rm", ["api/index.d.ts"], {
|
|
127
|
-
stdio: "inherit",
|
|
128
|
-
});
|
|
129
125
|
}
|
|
130
126
|
else if (hostingStrategy === "netlify") { }
|
|
131
127
|
});
|
package/lib/cjs/config/index.js
CHANGED
|
@@ -127,14 +127,14 @@ exports.defineConfig = defineConfig;
|
|
|
127
127
|
var adaptPath = function (paths) {
|
|
128
128
|
// Check if we are in dev mode or prod
|
|
129
129
|
var isProduction = process.env.NODE_ENV === "production";
|
|
130
|
-
var prefix = isProduction ? "
|
|
130
|
+
var prefix = isProduction ? "./../../" : "";
|
|
131
131
|
// Chech if the path is an array
|
|
132
132
|
var isArray = Array.isArray(paths);
|
|
133
133
|
// If the path is an array
|
|
134
134
|
if (isArray) {
|
|
135
|
-
return paths.map(function (path) { return "".concat(prefix).concat(path); });
|
|
135
|
+
return paths.map(function (path) { return "".concat(process.cwd(), "/").concat(prefix).concat(path); });
|
|
136
136
|
}
|
|
137
137
|
// If the path is a string
|
|
138
|
-
return "".concat(prefix).concat(paths);
|
|
138
|
+
return "".concat(process.cwd(), "/").concat(prefix).concat(paths);
|
|
139
139
|
};
|
|
140
140
|
exports.adaptPath = adaptPath;
|
|
@@ -140,10 +140,10 @@ var ErrorFallbackComponent = function (_a) {
|
|
|
140
140
|
* @returns
|
|
141
141
|
*/
|
|
142
142
|
var Heads = function (_a) {
|
|
143
|
-
var data = _a.data, _b = _a.children, children = _b === void 0 ? undefined : _b, _c = _a.bootstrap, bootstrap = _c === void 0 ? "" : _c;
|
|
143
|
+
var data = _a.data, _b = _a.children, children = _b === void 0 ? undefined : _b, _c = _a.bootstrap, bootstrap = _c === void 0 ? "" : _c, _d = _a.styles, styles = _d === void 0 ? "" : _d;
|
|
144
144
|
if (!data)
|
|
145
145
|
return null;
|
|
146
|
-
return ((0, jsx_runtime_1.jsxs)("head", { children: [children, data.helmet && data.helmet.meta.toComponent({}), data.helmet && data.helmet.title.toComponent({}), bootstrap && ((0, jsx_runtime_1.jsx)("script", { type: "module", src: bootstrap, defer: true }))] }));
|
|
146
|
+
return ((0, jsx_runtime_1.jsxs)("head", { children: [children, data.helmet && data.helmet.meta.toComponent({}), data.helmet && data.helmet.title.toComponent({}), bootstrap && ((0, jsx_runtime_1.jsx)("script", { type: "module", src: bootstrap, defer: true })), styles && ((0, jsx_runtime_1.jsx)("link", { rel: "stylesheet", crossOrigin: "", type: "text/css", href: styles }))] }));
|
|
147
147
|
};
|
|
148
148
|
exports.Heads = Heads;
|
|
149
149
|
/**
|
|
@@ -47,10 +47,10 @@ var HelmetAsync = __importStar(require("react-helmet-async"));
|
|
|
47
47
|
var H = HelmetAsync.default ? HelmetAsync.default : HelmetAsync;
|
|
48
48
|
// const ABORT_DELAY = 5000;
|
|
49
49
|
var TemplateHtml = function (_a) {
|
|
50
|
-
var helmetContext = _a.helmetContext, bootstrap = _a.bootstrap;
|
|
50
|
+
var helmetContext = _a.helmetContext, bootstrap = _a.bootstrap, styles = _a.styles;
|
|
51
51
|
return ((0, jsx_runtime_1.jsx)(template_1.default, { Head: function (_a) {
|
|
52
52
|
var children = _a.children;
|
|
53
|
-
return ((0, jsx_runtime_1.jsx)(index_js_2.Heads, { data: helmetContext, bootstrap: bootstrap, children: children }));
|
|
53
|
+
return ((0, jsx_runtime_1.jsx)(index_js_2.Heads, { data: helmetContext, bootstrap: bootstrap, styles: styles, children: children }));
|
|
54
54
|
}, Body: function (_a) {
|
|
55
55
|
var children = _a.children;
|
|
56
56
|
return (0, jsx_runtime_1.jsx)(index_js_2.Body, { children: children });
|
|
@@ -73,8 +73,8 @@ function render(router, context, helmetContext) {
|
|
|
73
73
|
}
|
|
74
74
|
exports.render = render;
|
|
75
75
|
exports.staticRoutes = (0, index_js_1.generateStaticRoutes)(app_router_1.default);
|
|
76
|
-
var loadTemplateHtml = function (helmetContext, bootstrap) {
|
|
77
|
-
var html = server_1.default.renderToString((0, jsx_runtime_1.jsx)(TemplateHtml, { helmetContext: helmetContext, bootstrap: bootstrap }));
|
|
76
|
+
var loadTemplateHtml = function (helmetContext, bootstrap, styles) {
|
|
77
|
+
var html = server_1.default.renderToString((0, jsx_runtime_1.jsx)(TemplateHtml, { helmetContext: helmetContext, bootstrap: bootstrap, styles: styles }));
|
|
78
78
|
return "\n <!DOCTYPE html>\n ".concat(html, "\n ");
|
|
79
79
|
};
|
|
80
80
|
exports.loadTemplateHtml = loadTemplateHtml;
|
|
@@ -76,7 +76,7 @@ var __dirname = (0, node_path_1.dirname)(__filename);
|
|
|
76
76
|
function handler(req, res) {
|
|
77
77
|
var _a;
|
|
78
78
|
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
-
var url, host, appPath, err_1, templateHtml, serverFilePath, bootstrapDirPath, entry, bootstrap, render, staticRoutes, loadTemplateHtml, handler_1, fetchRequest, context, status_1, redirect, helmetContext, router, rendered, html, e_1;
|
|
79
|
+
var url, host, appPath, err_1, templateHtml, serverFilePath, bootstrapDirPath, entry, bootstrap, styles, render, staticRoutes, loadTemplateHtml, handler_1, fetchRequest, context, status_1, redirect, helmetContext, router, rendered, html, e_1;
|
|
80
80
|
return __generator(this, function (_b) {
|
|
81
81
|
switch (_b.label) {
|
|
82
82
|
case 0:
|
|
@@ -114,6 +114,10 @@ function handler(req, res) {
|
|
|
114
114
|
node_fs_1.default
|
|
115
115
|
.readdirSync(bootstrapDirPath)
|
|
116
116
|
.filter(function (fn) { return fn.includes("entry-client") && fn.endsWith(".js"); })[0];
|
|
117
|
+
styles = "/assets/" +
|
|
118
|
+
node_fs_1.default
|
|
119
|
+
.readdirSync((0, node_path_1.join)(appPath, "dist/client/assets"))
|
|
120
|
+
.filter(function (fn) { return fn.includes("entry-client") && fn.endsWith(".css"); })[0];
|
|
117
121
|
render = entry.render, staticRoutes = entry.staticRoutes, loadTemplateHtml = entry.loadTemplateHtml;
|
|
118
122
|
handler_1 = (0, server_js_1.createStaticHandler)(staticRoutes);
|
|
119
123
|
fetchRequest = (0, rasengan_1.createFetchRequest)(req, host);
|
|
@@ -133,16 +137,15 @@ function handler(req, res) {
|
|
|
133
137
|
rendered = _b.sent();
|
|
134
138
|
// Load template html
|
|
135
139
|
if (!templateHtml) {
|
|
136
|
-
templateHtml = loadTemplateHtml(helmetContext, bootstrap);
|
|
140
|
+
templateHtml = loadTemplateHtml(helmetContext, bootstrap, styles);
|
|
137
141
|
}
|
|
138
142
|
html = templateHtml.replace("rasengan-body-app", (_a = rendered.html) !== null && _a !== void 0 ? _a : "");
|
|
139
143
|
// Send the rendered html page
|
|
140
|
-
res
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return [3 /*break*/, 9];
|
|
144
|
+
return [2 /*return*/, res
|
|
145
|
+
.status(200)
|
|
146
|
+
.setHeader("Content-Type", "text/html")
|
|
147
|
+
.setHeader("Cache-Control", "max-age=31536000")
|
|
148
|
+
.end(html)];
|
|
146
149
|
case 8:
|
|
147
150
|
e_1 = _b.sent();
|
|
148
151
|
console.log(e_1.stack);
|
package/lib/esm/cli/index.js
CHANGED
|
@@ -117,10 +117,6 @@ program
|
|
|
117
117
|
execa("cp", ["node_modules/rasengan/lib/esm/server/functions/vercel/vercel.json", "."], {
|
|
118
118
|
stdio: "inherit",
|
|
119
119
|
});
|
|
120
|
-
// Removing index.d.ts and index.js.map files from the api folder
|
|
121
|
-
execa("rm", ["api/index.d.ts"], {
|
|
122
|
-
stdio: "inherit",
|
|
123
|
-
});
|
|
124
120
|
}
|
|
125
121
|
else if (hostingStrategy === "netlify") { }
|
|
126
122
|
});
|
package/lib/esm/config/index.js
CHANGED
|
@@ -123,13 +123,13 @@ export var defineConfig = function (loadedConfig) {
|
|
|
123
123
|
export var adaptPath = function (paths) {
|
|
124
124
|
// Check if we are in dev mode or prod
|
|
125
125
|
var isProduction = process.env.NODE_ENV === "production";
|
|
126
|
-
var prefix = isProduction ? "
|
|
126
|
+
var prefix = isProduction ? "./../../" : "";
|
|
127
127
|
// Chech if the path is an array
|
|
128
128
|
var isArray = Array.isArray(paths);
|
|
129
129
|
// If the path is an array
|
|
130
130
|
if (isArray) {
|
|
131
|
-
return paths.map(function (path) { return "".concat(prefix).concat(path); });
|
|
131
|
+
return paths.map(function (path) { return "".concat(process.cwd(), "/").concat(prefix).concat(path); });
|
|
132
132
|
}
|
|
133
133
|
// If the path is a string
|
|
134
|
-
return "".concat(prefix).concat(paths);
|
|
134
|
+
return "".concat(process.cwd(), "/").concat(prefix).concat(paths);
|
|
135
135
|
};
|
|
@@ -109,10 +109,10 @@ var ErrorFallbackComponent = function (_a) {
|
|
|
109
109
|
* @returns
|
|
110
110
|
*/
|
|
111
111
|
export var Heads = function (_a) {
|
|
112
|
-
var data = _a.data, _b = _a.children, children = _b === void 0 ? undefined : _b, _c = _a.bootstrap, bootstrap = _c === void 0 ? "" : _c;
|
|
112
|
+
var data = _a.data, _b = _a.children, children = _b === void 0 ? undefined : _b, _c = _a.bootstrap, bootstrap = _c === void 0 ? "" : _c, _d = _a.styles, styles = _d === void 0 ? "" : _d;
|
|
113
113
|
if (!data)
|
|
114
114
|
return null;
|
|
115
|
-
return (_jsxs("head", { children: [children, data.helmet && data.helmet.meta.toComponent({}), data.helmet && data.helmet.title.toComponent({}), bootstrap && (_jsx("script", { type: "module", src: bootstrap, defer: true }))] }));
|
|
115
|
+
return (_jsxs("head", { children: [children, data.helmet && data.helmet.meta.toComponent({}), data.helmet && data.helmet.title.toComponent({}), bootstrap && (_jsx("script", { type: "module", src: bootstrap, defer: true })), styles && (_jsx("link", { rel: "stylesheet", crossOrigin: "", type: "text/css", href: styles }))] }));
|
|
116
116
|
};
|
|
117
117
|
/**
|
|
118
118
|
* Body component
|
|
@@ -18,10 +18,10 @@ import * as HelmetAsync from "react-helmet-async";
|
|
|
18
18
|
var H = HelmetAsync.default ? HelmetAsync.default : HelmetAsync;
|
|
19
19
|
// const ABORT_DELAY = 5000;
|
|
20
20
|
var TemplateHtml = function (_a) {
|
|
21
|
-
var helmetContext = _a.helmetContext, bootstrap = _a.bootstrap;
|
|
21
|
+
var helmetContext = _a.helmetContext, bootstrap = _a.bootstrap, styles = _a.styles;
|
|
22
22
|
return (_jsx(Template, { Head: function (_a) {
|
|
23
23
|
var children = _a.children;
|
|
24
|
-
return (_jsx(Heads, { data: helmetContext, bootstrap: bootstrap, children: children }));
|
|
24
|
+
return (_jsx(Heads, { data: helmetContext, bootstrap: bootstrap, styles: styles, children: children }));
|
|
25
25
|
}, Body: function (_a) {
|
|
26
26
|
var children = _a.children;
|
|
27
27
|
return _jsx(Body, { children: children });
|
|
@@ -43,7 +43,7 @@ export function render(router, context, helmetContext) {
|
|
|
43
43
|
return { html: html };
|
|
44
44
|
}
|
|
45
45
|
export var staticRoutes = generateStaticRoutes(AppRouter);
|
|
46
|
-
export var loadTemplateHtml = function (helmetContext, bootstrap) {
|
|
47
|
-
var html = ReactDOMServer.renderToString(_jsx(TemplateHtml, { helmetContext: helmetContext, bootstrap: bootstrap }));
|
|
46
|
+
export var loadTemplateHtml = function (helmetContext, bootstrap, styles) {
|
|
47
|
+
var html = ReactDOMServer.renderToString(_jsx(TemplateHtml, { helmetContext: helmetContext, bootstrap: bootstrap, styles: styles }));
|
|
48
48
|
return "\n <!DOCTYPE html>\n ".concat(html, "\n ");
|
|
49
49
|
};
|
|
@@ -48,7 +48,7 @@ var __dirname = dirname(__filename);
|
|
|
48
48
|
export default function handler(req, res) {
|
|
49
49
|
var _a;
|
|
50
50
|
return __awaiter(this, void 0, void 0, function () {
|
|
51
|
-
var url, host, appPath, err_1, templateHtml, serverFilePath, bootstrapDirPath, entry, bootstrap, render, staticRoutes, loadTemplateHtml, handler_1, fetchRequest, context, status_1, redirect, helmetContext, router, rendered, html, e_1;
|
|
51
|
+
var url, host, appPath, err_1, templateHtml, serverFilePath, bootstrapDirPath, entry, bootstrap, styles, render, staticRoutes, loadTemplateHtml, handler_1, fetchRequest, context, status_1, redirect, helmetContext, router, rendered, html, e_1;
|
|
52
52
|
return __generator(this, function (_b) {
|
|
53
53
|
switch (_b.label) {
|
|
54
54
|
case 0:
|
|
@@ -86,6 +86,10 @@ export default function handler(req, res) {
|
|
|
86
86
|
fsSync
|
|
87
87
|
.readdirSync(bootstrapDirPath)
|
|
88
88
|
.filter(function (fn) { return fn.includes("entry-client") && fn.endsWith(".js"); })[0];
|
|
89
|
+
styles = "/assets/" +
|
|
90
|
+
fsSync
|
|
91
|
+
.readdirSync(join(appPath, "dist/client/assets"))
|
|
92
|
+
.filter(function (fn) { return fn.includes("entry-client") && fn.endsWith(".css"); })[0];
|
|
89
93
|
render = entry.render, staticRoutes = entry.staticRoutes, loadTemplateHtml = entry.loadTemplateHtml;
|
|
90
94
|
handler_1 = createStaticHandler(staticRoutes);
|
|
91
95
|
fetchRequest = createFetchRequest(req, host);
|
|
@@ -105,16 +109,15 @@ export default function handler(req, res) {
|
|
|
105
109
|
rendered = _b.sent();
|
|
106
110
|
// Load template html
|
|
107
111
|
if (!templateHtml) {
|
|
108
|
-
templateHtml = loadTemplateHtml(helmetContext, bootstrap);
|
|
112
|
+
templateHtml = loadTemplateHtml(helmetContext, bootstrap, styles);
|
|
109
113
|
}
|
|
110
114
|
html = templateHtml.replace("rasengan-body-app", (_a = rendered.html) !== null && _a !== void 0 ? _a : "");
|
|
111
115
|
// Send the rendered html page
|
|
112
|
-
res
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return [3 /*break*/, 9];
|
|
116
|
+
return [2 /*return*/, res
|
|
117
|
+
.status(200)
|
|
118
|
+
.setHeader("Content-Type", "text/html")
|
|
119
|
+
.setHeader("Cache-Control", "max-age=31536000")
|
|
120
|
+
.end(html)];
|
|
118
121
|
case 8:
|
|
119
122
|
e_1 = _b.sent();
|
|
120
123
|
console.log(e_1.stack);
|
|
@@ -25,10 +25,11 @@ export declare class ErrorBoundary extends React.Component {
|
|
|
25
25
|
* @params data - Helmet context
|
|
26
26
|
* @returns
|
|
27
27
|
*/
|
|
28
|
-
export declare const Heads: ({ data, children, bootstrap, }: {
|
|
28
|
+
export declare const Heads: ({ data, children, bootstrap, styles, }: {
|
|
29
29
|
data: HelmetContext;
|
|
30
30
|
children?: React.ReactNode;
|
|
31
31
|
bootstrap?: string;
|
|
32
|
+
styles?: string;
|
|
32
33
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
33
34
|
/**
|
|
34
35
|
* Body component
|
|
@@ -11,4 +11,4 @@ export declare function render(router: Router, context: StaticHandlerContext, he
|
|
|
11
11
|
html: string;
|
|
12
12
|
};
|
|
13
13
|
export declare const staticRoutes: any;
|
|
14
|
-
export declare const loadTemplateHtml: (helmetContext: any, bootstrap: string) => string;
|
|
14
|
+
export declare const loadTemplateHtml: (helmetContext: any, bootstrap: string, styles: string) => string;
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -46,6 +46,8 @@ async function createServer({
|
|
|
46
46
|
let templateHtml = "";
|
|
47
47
|
// Bootstrap
|
|
48
48
|
let bootstrap = "";
|
|
49
|
+
// Styles
|
|
50
|
+
let styles = "";
|
|
49
51
|
|
|
50
52
|
// Add Vite or respective production middlewares
|
|
51
53
|
let vite;
|
|
@@ -94,6 +96,13 @@ async function createServer({
|
|
|
94
96
|
.filter(
|
|
95
97
|
(fn) => fn.includes("entry-client") && fn.endsWith(".js")
|
|
96
98
|
)[0];
|
|
99
|
+
|
|
100
|
+
// replace styles with compiled styles
|
|
101
|
+
styles =
|
|
102
|
+
"/assets/" +
|
|
103
|
+
fs
|
|
104
|
+
.readdirSync(join(appPath, "dist/client/assets"))
|
|
105
|
+
.filter((fn) => fn.includes("entry-client") && fn.endsWith(".css"))[0];
|
|
97
106
|
}
|
|
98
107
|
|
|
99
108
|
// Get entry values
|
|
@@ -126,7 +135,7 @@ async function createServer({
|
|
|
126
135
|
|
|
127
136
|
// Load template html
|
|
128
137
|
if (!templateHtml) {
|
|
129
|
-
templateHtml = loadTemplateHtml(helmetContext, bootstrap);
|
|
138
|
+
templateHtml = loadTemplateHtml(helmetContext, bootstrap, styles);
|
|
130
139
|
|
|
131
140
|
if (!isProduction) {
|
|
132
141
|
templateHtml = await vite.transformIndexHtml(url, templateHtml);
|
|
@@ -137,7 +146,7 @@ async function createServer({
|
|
|
137
146
|
let html = templateHtml.replace(`rasengan-body-app`, rendered.html ?? "");
|
|
138
147
|
|
|
139
148
|
// Send the rendered html page
|
|
140
|
-
res
|
|
149
|
+
return res
|
|
141
150
|
.status(200)
|
|
142
151
|
.set({
|
|
143
152
|
"Content-Type": "text/html",
|
package/vite.config.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { defineConfig } from "vite";
|
|
2
2
|
import react from "@vitejs/plugin-react";
|
|
3
|
-
import cssInjectedByJsPlugin from "vite-plugin-css-injected-by-js";
|
|
4
3
|
|
|
5
4
|
// Load rasengan config file
|
|
6
5
|
// @ts-ignore
|
|
@@ -20,7 +19,7 @@ const __pathToRoot = path.resolve(__dirname, "./../../");
|
|
|
20
19
|
|
|
21
20
|
export default defineConfig({
|
|
22
21
|
// Vite Plugins
|
|
23
|
-
plugins: [react(),
|
|
22
|
+
plugins: [react(), ...vite?.plugins],
|
|
24
23
|
|
|
25
24
|
// define index.html location
|
|
26
25
|
root: __pathToRoot,
|