Fix react and react-dom peer dependencies mismatch #3

This commit is contained in:
Benjamin Toby 2026-04-05 17:58:52 +01:00
parent f49a17b24e
commit d441f9982e
12 changed files with 21 additions and 66 deletions

View File

@ -19,8 +19,6 @@
"micromatch": "^4.0.8", "micromatch": "^4.0.8",
"ora": "^9.0.0", "ora": "^9.0.0",
"postcss": "^8.5.8", "postcss": "^8.5.8",
"react": "19.0.0",
"react-dom": "19.0.0",
"tailwindcss": "^4.2.2", "tailwindcss": "^4.2.2",
"typescript": "^5.0.0", "typescript": "^5.0.0",
}, },
@ -30,6 +28,10 @@
"@types/micromatch": "^4.0.10", "@types/micromatch": "^4.0.10",
"happy-dom": "^20.8.4", "happy-dom": "^20.8.4",
}, },
"peerDependencies": {
"react": "^19",
"react-dom": "^19",
},
}, },
}, },
"packages": { "packages": {

View File

@ -1,11 +1,8 @@
import { existsSync } from "fs"; import { existsSync } from "fs";
import path from "path";
import grabDirNames from "../../utils/grab-dir-names"; import grabDirNames from "../../utils/grab-dir-names";
import AppNames from "../../utils/grab-app-names";
import grabConstants from "../../utils/grab-constants"; import grabConstants from "../../utils/grab-constants";
import pagePathTransform from "../../utils/page-path-transform";
import grabRootFilePath from "../server/web-pages/grab-root-file-path"; import grabRootFilePath from "../server/web-pages/grab-root-file-path";
const { PAGES_DIR } = grabDirNames(); const { ROOT_DIR } = grabDirNames();
export default async function grabClientHydrationScript({ page_local_path, }) { export default async function grabClientHydrationScript({ page_local_path, }) {
const { ClientRootElementIDName, ClientRootComponentWindowName, ClientWindowPagePropsName, } = grabConstants(); const { ClientRootElementIDName, ClientRootComponentWindowName, ClientWindowPagePropsName, } = grabConstants();
const { root_file_path } = grabRootFilePath(); const { root_file_path } = grabRootFilePath();
@ -30,7 +27,7 @@ export default async function grabClientHydrationScript({ page_local_path, }) {
return undefined; return undefined;
} }
let txt = ``; 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) { if (root_file_path) {
txt += `import Root from "${root_file_path}";\n`; txt += `import Root from "${root_file_path}";\n`;
} }

View File

@ -1,5 +1,4 @@
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { renderToReadableStream, renderToString } from "react-dom/server";
import grabContants from "../../../utils/grab-constants"; import grabContants from "../../../utils/grab-constants";
import EJSON from "../../../utils/ejson"; import EJSON from "../../../utils/ejson";
import isDevelopment from "../../../utils/is-development"; import isDevelopment from "../../../utils/is-development";
@ -10,8 +9,6 @@ import { AppData } from "../../../data/app-data";
import { readFileSync } from "fs"; import { readFileSync } from "fs";
import path from "path"; import path from "path";
import _ from "lodash"; import _ from "lodash";
import grabDirNames from "../../../utils/grab-dir-names";
const {} = grabDirNames();
let _reactVersion = "19"; let _reactVersion = "19";
try { try {
_reactVersion = JSON.parse(readFileSync(path.join(process.cwd(), "node_modules/react/package.json"), "utf-8")).version; _reactVersion = JSON.parse(readFileSync(path.join(process.cwd(), "node_modules/react/package.json"), "utf-8")).version;
@ -19,6 +16,7 @@ try {
catch { } catch { }
export default async function genWebHTML({ component, pageProps, bundledMap, module, routeParams, debug, root_module, }) { export default async function genWebHTML({ component, pageProps, bundledMap, module, routeParams, debug, root_module, }) {
const { ClientRootElementIDName, ClientWindowPagePropsName } = grabContants(); const { ClientRootElementIDName, ClientWindowPagePropsName } = grabContants();
const { renderToReadableStream } = await import(`${global.DIR_NAMES.ROOT_DIR}/node_modules/react-dom/server.js`);
const is_dev = isDevelopment(); const is_dev = isDevelopment();
if (debug) { if (debug) {
log.info("component", component); log.info("component", component);

View File

@ -1,5 +1,4 @@
import type { BunextPageModule, BunextPageModuleServerReturn, BunxRouteParams } from "../../../types"; import type { BunextPageModule, BunxRouteParams } from "../../../types";
import type { JSX } from "react";
type Params = { type Params = {
file_path: string; file_path: string;
debug?: boolean; debug?: boolean;
@ -8,8 +7,8 @@ type Params = {
routeParams?: BunxRouteParams; routeParams?: BunxRouteParams;
}; };
export default function grabPageModules({ file_path, debug, url, query, routeParams, }: Params): Promise<{ export default function grabPageModules({ file_path, debug, url, query, routeParams, }: Params): Promise<{
component: JSX.Element; component: import("react").JSX.Element;
serverRes: BunextPageModuleServerReturn; serverRes: import("../../../types").BunextPageModuleServerReturn;
module: BunextPageModule; module: BunextPageModule;
root_module: BunextPageModule | undefined; root_module: BunextPageModule | undefined;
}>; }>;

View File

@ -2,8 +2,6 @@ import grabPageBundledReactComponent from "./grab-page-bundled-react-component";
import _ from "lodash"; import _ from "lodash";
import { log } from "../../../utils/log"; import { log } from "../../../utils/log";
import grabRootFilePath from "./grab-root-file-path"; import grabRootFilePath from "./grab-root-file-path";
import grabPageServerRes from "./grab-page-server-res";
import grabPageServerPath from "./grab-page-server-path";
import grabPageCombinedServerRes from "./grab-page-combined-server-res"; import grabPageCombinedServerRes from "./grab-page-combined-server-res";
export default async function grabPageModules({ file_path, debug, url, query, routeParams, }) { export default async function grabPageModules({ file_path, debug, url, query, routeParams, }) {
const now = Date.now(); const now = Date.now();

View File

@ -1 +0,0 @@
export default function importReactDomServer(): Promise<any>;

View File

@ -1,14 +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;
}
}

View File

@ -2,7 +2,7 @@
"name": "@moduletrace/bunext", "name": "@moduletrace/bunext",
"module": "index.ts", "module": "index.ts",
"type": "module", "type": "module",
"version": "1.0.52", "version": "1.0.53",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
"exports": { "exports": {
@ -38,13 +38,15 @@
"@types/micromatch": "^4.0.10", "@types/micromatch": "^4.0.10",
"happy-dom": "^20.8.4" "happy-dom": "^20.8.4"
}, },
"peerDependencies": {
"react": "^19",
"react-dom": "^19"
},
"publishConfig": { "publishConfig": {
"registry": "https://npm.pkg.github.com" "registry": "https://npm.pkg.github.com"
}, },
"dependencies": { "dependencies": {
"typescript": "^5.0.0", "typescript": "^5.0.0",
"react": "19.0.0",
"react-dom": "19.0.0",
"@tailwindcss/postcss": "^4.2.2", "@tailwindcss/postcss": "^4.2.2",
"@types/bun": "latest", "@types/bun": "latest",
"@types/node": "^24.10.0", "@types/node": "^24.10.0",

View File

@ -1,12 +1,9 @@
import { existsSync } from "fs"; import { existsSync } from "fs";
import path from "path";
import grabDirNames from "../../utils/grab-dir-names"; import grabDirNames from "../../utils/grab-dir-names";
import AppNames from "../../utils/grab-app-names";
import grabConstants from "../../utils/grab-constants"; import grabConstants from "../../utils/grab-constants";
import pagePathTransform from "../../utils/page-path-transform";
import grabRootFilePath from "../server/web-pages/grab-root-file-path"; import grabRootFilePath from "../server/web-pages/grab-root-file-path";
const { PAGES_DIR } = grabDirNames(); const { ROOT_DIR } = grabDirNames();
type Params = { type Params = {
page_local_path: string; page_local_path: string;
@ -52,7 +49,7 @@ export default async function grabClientHydrationScript({
let txt = ``; 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) { if (root_file_path) {
txt += `import Root from "${root_file_path}";\n`; txt += `import Root from "${root_file_path}";\n`;
} }

View File

@ -1,4 +1,3 @@
import { renderToReadableStream, renderToString } from "react-dom/server";
import grabContants from "../../../utils/grab-constants"; import grabContants from "../../../utils/grab-constants";
import EJSON from "../../../utils/ejson"; import EJSON from "../../../utils/ejson";
import type { LivePageDistGenParams } from "../../../types"; import type { LivePageDistGenParams } from "../../../types";
@ -10,9 +9,6 @@ import { AppData } from "../../../data/app-data";
import { readFileSync } from "fs"; import { readFileSync } from "fs";
import path from "path"; import path from "path";
import _ from "lodash"; import _ from "lodash";
import grabDirNames from "../../../utils/grab-dir-names";
const {} = grabDirNames();
let _reactVersion = "19"; let _reactVersion = "19";
try { try {
@ -36,6 +32,10 @@ export default async function genWebHTML({
const { ClientRootElementIDName, ClientWindowPagePropsName } = const { ClientRootElementIDName, ClientWindowPagePropsName } =
grabContants(); grabContants();
const { renderToReadableStream } = await import(
`${global.DIR_NAMES.ROOT_DIR}/node_modules/react-dom/server.js`
);
const is_dev = isDevelopment(); const is_dev = isDevelopment();
if (debug) { if (debug) {

View File

@ -1,7 +1,5 @@
import type { import type {
BunextPageModule, BunextPageModule,
BunextPageModuleServerReturn,
BunextPageServerModule,
BunextRootModule, BunextRootModule,
BunxRouteParams, BunxRouteParams,
} from "../../../types"; } from "../../../types";
@ -9,9 +7,6 @@ import grabPageBundledReactComponent from "./grab-page-bundled-react-component";
import _ from "lodash"; import _ from "lodash";
import { log } from "../../../utils/log"; import { log } from "../../../utils/log";
import grabRootFilePath from "./grab-root-file-path"; 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"; import grabPageCombinedServerRes from "./grab-page-combined-server-res";
type Params = { type Params = {

View File

@ -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;
}
}