Fix react and react-dom peer dependencies mismatch #3
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
import { existsSync } from "fs";
|
||||
import path from "path";
|
||||
import grabDirNames from "../../utils/grab-dir-names";
|
||||
import AppNames from "../../utils/grab-app-names";
|
||||
import grabConstants from "../../utils/grab-constants";
|
||||
import pagePathTransform from "../../utils/page-path-transform";
|
||||
import grabRootFilePath from "../server/web-pages/grab-root-file-path";
|
||||
|
||||
const { PAGES_DIR } = grabDirNames();
|
||||
const { ROOT_DIR } = grabDirNames();
|
||||
|
||||
type Params = {
|
||||
page_local_path: string;
|
||||
@@ -52,7 +49,7 @@ export default async function grabClientHydrationScript({
|
||||
|
||||
let txt = ``;
|
||||
|
||||
txt += `import { hydrateRoot } from "react-dom/client";\n`;
|
||||
txt += `import { hydrateRoot } from "${ROOT_DIR}/node_modules/react-dom/client.js";\n`;
|
||||
if (root_file_path) {
|
||||
txt += `import Root from "${root_file_path}";\n`;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { renderToReadableStream, renderToString } from "react-dom/server";
|
||||
import grabContants from "../../../utils/grab-constants";
|
||||
import EJSON from "../../../utils/ejson";
|
||||
import type { LivePageDistGenParams } from "../../../types";
|
||||
@@ -10,9 +9,6 @@ import { AppData } from "../../../data/app-data";
|
||||
import { readFileSync } from "fs";
|
||||
import path from "path";
|
||||
import _ from "lodash";
|
||||
import grabDirNames from "../../../utils/grab-dir-names";
|
||||
|
||||
const {} = grabDirNames();
|
||||
|
||||
let _reactVersion = "19";
|
||||
try {
|
||||
@@ -36,6 +32,10 @@ export default async function genWebHTML({
|
||||
const { ClientRootElementIDName, ClientWindowPagePropsName } =
|
||||
grabContants();
|
||||
|
||||
const { renderToReadableStream } = await import(
|
||||
`${global.DIR_NAMES.ROOT_DIR}/node_modules/react-dom/server.js`
|
||||
);
|
||||
|
||||
const is_dev = isDevelopment();
|
||||
|
||||
if (debug) {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import type {
|
||||
BunextPageModule,
|
||||
BunextPageModuleServerReturn,
|
||||
BunextPageServerModule,
|
||||
BunextRootModule,
|
||||
BunxRouteParams,
|
||||
} from "../../../types";
|
||||
@@ -9,9 +7,6 @@ import grabPageBundledReactComponent from "./grab-page-bundled-react-component";
|
||||
import _ from "lodash";
|
||||
import { log } from "../../../utils/log";
|
||||
import grabRootFilePath from "./grab-root-file-path";
|
||||
import grabPageServerRes from "./grab-page-server-res";
|
||||
import grabPageServerPath from "./grab-page-server-path";
|
||||
import type { JSX } from "react";
|
||||
import grabPageCombinedServerRes from "./grab-page-combined-server-res";
|
||||
|
||||
type Params = {
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
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")
|
||||
);
|
||||
|
||||
if (!reactDomServerDynamicImport.renderToString) {
|
||||
return reactDomServer;
|
||||
}
|
||||
|
||||
return reactDomServerDynamicImport;
|
||||
} catch (error) {
|
||||
return reactDomServer;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user