Bugfix. Update generate-web-html function
This commit is contained in:
parent
a38841a587
commit
51db0c447c
6
dist/functions/server/watcher.js
vendored
6
dist/functions/server/watcher.js
vendored
@ -20,9 +20,9 @@ export default function watcher() {
|
||||
});
|
||||
return;
|
||||
}
|
||||
const target_files_match = /\.(tsx?|jsx?|css)$/;
|
||||
if (event !== "rename") {
|
||||
if (filename.match(/\.(tsx?|jsx?|css)$/) &&
|
||||
global.BUNDLER_CTX) {
|
||||
if (filename.match(target_files_match) && global.BUNDLER_CTX) {
|
||||
if (global.RECOMPILING)
|
||||
return;
|
||||
global.RECOMPILING = true;
|
||||
@ -30,7 +30,7 @@ export default function watcher() {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!filename.match(/\.(tsx?|jsx?)$/)) {
|
||||
if (!filename.match(target_files_match)) {
|
||||
return;
|
||||
}
|
||||
if (!filename.match(/^src\/pages\//))
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { renderToString } from "react-dom/server";
|
||||
import grabContants from "../../../utils/grab-constants";
|
||||
import EJSON from "../../../utils/ejson";
|
||||
import isDevelopment from "../../../utils/is-development";
|
||||
@ -7,11 +6,15 @@ import grabWebPageHydrationScript from "./grab-web-page-hydration-script";
|
||||
import grabWebMetaHTML from "./grab-web-meta-html";
|
||||
import { log } from "../../../utils/log";
|
||||
import { AppData } from "../../../data/app-data";
|
||||
import path from "path";
|
||||
import importReactDomServer from "../../../utils/import-react-dom-server";
|
||||
export default async function genWebHTML({ component, pageProps, bundledMap, head: Head, module, meta, routeParams, debug, }) {
|
||||
const { ClientRootElementIDName, ClientWindowPagePropsName } = grabContants();
|
||||
if (debug) {
|
||||
log.info("component", component);
|
||||
}
|
||||
const reactDomServer = await importReactDomServer();
|
||||
const renderToString = reactDomServer.renderToString;
|
||||
const componentHTML = renderToString(component);
|
||||
if (debug) {
|
||||
log.info("componentHTML", componentHTML);
|
||||
|
||||
1
dist/utils/import-react-dom-server.d.ts
vendored
Normal file
1
dist/utils/import-react-dom-server.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export default function importReactDomServer(): Promise<any>;
|
||||
11
dist/utils/import-react-dom-server.js
vendored
Normal file
11
dist/utils/import-react-dom-server.js
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
import path from "path";
|
||||
import reactDomServer from "react-dom/server";
|
||||
export default async function importReactDomServer() {
|
||||
try {
|
||||
const reactDomServerDynamicImport = await import(path.join(process.cwd(), "node_modules", "react-dom", "server"));
|
||||
return reactDomServerDynamicImport;
|
||||
}
|
||||
catch (error) {
|
||||
return reactDomServer;
|
||||
}
|
||||
}
|
||||
@ -27,7 +27,7 @@
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "tsc --watch",
|
||||
"git:push": "bun run test && tsc --noEmit && tsc && git add . && git commit -m 'Major Bugfix. Update init function' && git push",
|
||||
"git:push": "tsc --noEmit && tsc && git add . && git commit -m 'Bugfix. Update generate-web-html function' && git push",
|
||||
"compile": "bun build ./src/commands/index.ts --compile --outfile bin/bunext",
|
||||
"build": "tsc",
|
||||
"test": "bun test --max-concurrency=1"
|
||||
|
||||
@ -27,11 +27,10 @@ export default function watcher() {
|
||||
return;
|
||||
}
|
||||
|
||||
const target_files_match = /\.(tsx?|jsx?|css)$/;
|
||||
|
||||
if (event !== "rename") {
|
||||
if (
|
||||
filename.match(/\.(tsx?|jsx?|css)$/) &&
|
||||
global.BUNDLER_CTX
|
||||
) {
|
||||
if (filename.match(target_files_match) && global.BUNDLER_CTX) {
|
||||
if (global.RECOMPILING) return;
|
||||
global.RECOMPILING = true;
|
||||
await global.BUNDLER_CTX.rebuild();
|
||||
@ -39,7 +38,7 @@ export default function watcher() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!filename.match(/\.(tsx?|jsx?)$/)) {
|
||||
if (!filename.match(target_files_match)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { renderToString } from "react-dom/server";
|
||||
import grabContants from "../../../utils/grab-constants";
|
||||
import EJSON from "../../../utils/ejson";
|
||||
import type { LivePageDistGenParams } from "../../../types";
|
||||
@ -7,6 +6,8 @@ import grabWebPageHydrationScript from "./grab-web-page-hydration-script";
|
||||
import grabWebMetaHTML from "./grab-web-meta-html";
|
||||
import { log } from "../../../utils/log";
|
||||
import { AppData } from "../../../data/app-data";
|
||||
import path from "path";
|
||||
import importReactDomServer from "../../../utils/import-react-dom-server";
|
||||
|
||||
export default async function genWebHTML({
|
||||
component,
|
||||
@ -25,6 +26,9 @@ export default async function genWebHTML({
|
||||
log.info("component", component);
|
||||
}
|
||||
|
||||
const reactDomServer = await importReactDomServer();
|
||||
const renderToString = reactDomServer.renderToString;
|
||||
|
||||
const componentHTML = renderToString(component);
|
||||
|
||||
if (debug) {
|
||||
|
||||
14
src/utils/import-react-dom-server.ts
Normal file
14
src/utils/import-react-dom-server.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import path from "path";
|
||||
import reactDomServer from "react-dom/server";
|
||||
|
||||
export default async function importReactDomServer() {
|
||||
try {
|
||||
const reactDomServerDynamicImport = await import(
|
||||
path.join(process.cwd(), "node_modules", "react-dom", "server")
|
||||
);
|
||||
|
||||
return reactDomServerDynamicImport;
|
||||
} catch (error) {
|
||||
return reactDomServer;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user