Bugfix. Update generate-web-html function
This commit is contained in:
Vendored
+3
-3
@@ -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\//))
|
||||
|
||||
+4
-1
@@ -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
@@ -0,0 +1 @@
|
||||
export default function importReactDomServer(): Promise<any>;
|
||||
+11
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user