Bugfix. Update generate-web-html function

This commit is contained in:
2026-03-21 14:05:02 +01:00
parent a38841a587
commit 51db0c447c
8 changed files with 43 additions and 11 deletions
+4 -5
View File
@@ -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
View 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;
}
}