Fix react and react-dom peer dependencies mismatch #4
This commit is contained in:
parent
57957b89a4
commit
c19b7c9607
@ -9,6 +9,8 @@ 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 { ROOT_DIR } = 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;
|
||||||
@ -16,7 +18,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 { renderToReadableStream } = await import(`${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);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"name": "@moduletrace/bunext",
|
"name": "@moduletrace/bunext",
|
||||||
"module": "index.ts",
|
"module": "index.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "1.0.54",
|
"version": "1.0.55",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@ -1,7 +1,17 @@
|
|||||||
import { describe, expect, test, beforeAll, afterAll } from "bun:test";
|
import { describe, expect, test, beforeAll, afterAll } from "bun:test";
|
||||||
import startServer from "../../../src/functions/server/start-server";
|
import startServer from "../../../src/functions/server/start-server";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import fs from "fs";
|
import fs, { FSWatcher } from "fs";
|
||||||
|
import { execSync } from "child_process";
|
||||||
|
import {
|
||||||
|
BundlerCTXMap,
|
||||||
|
BunextConfig,
|
||||||
|
GlobalHMRControllerObject,
|
||||||
|
PageFiles,
|
||||||
|
} from "../../types";
|
||||||
|
import { FileSystemRouter } from "bun";
|
||||||
|
import { BuildContext } from "esbuild";
|
||||||
|
import grabDirNames from "../../utils/grab-dir-names";
|
||||||
|
|
||||||
// Fixture lives under test/ so the framework's directory guard allows it
|
// Fixture lives under test/ so the framework's directory guard allows it
|
||||||
const fixtureDir = path.resolve(__dirname, "../../../test/e2e-fixture");
|
const fixtureDir = path.resolve(__dirname, "../../../test/e2e-fixture");
|
||||||
@ -11,6 +21,25 @@ const fixtureIndexPage = path.join(fixturePagesDir, "index.tsx");
|
|||||||
let originalCwd = process.cwd();
|
let originalCwd = process.cwd();
|
||||||
let originalPort: string | undefined;
|
let originalPort: string | undefined;
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
var CONFIG: BunextConfig;
|
||||||
|
var SERVER: Bun.Server<any> | undefined;
|
||||||
|
var RECOMPILING: boolean;
|
||||||
|
var WATCHER_TIMEOUT: any;
|
||||||
|
var ROUTER: FileSystemRouter;
|
||||||
|
var HMR_CONTROLLERS: GlobalHMRControllerObject[];
|
||||||
|
var LAST_BUILD_TIME: number;
|
||||||
|
var BUNDLER_CTX_MAP: { [k: string]: BundlerCTXMap } | undefined;
|
||||||
|
var BUNDLER_REBUILDS: 0;
|
||||||
|
var PAGES_SRC_WATCHER: FSWatcher | undefined;
|
||||||
|
var CURRENT_VERSION: string | undefined;
|
||||||
|
var PAGE_FILES: PageFiles[];
|
||||||
|
var ROOT_FILE_UPDATED: boolean;
|
||||||
|
var SKIPPED_BROWSER_MODULES: Set<string>;
|
||||||
|
var BUNDLER_CTX: BuildContext | undefined;
|
||||||
|
var DIR_NAMES: ReturnType<typeof grabDirNames>;
|
||||||
|
}
|
||||||
|
|
||||||
describe("E2E Integration", () => {
|
describe("E2E Integration", () => {
|
||||||
let server: any;
|
let server: any;
|
||||||
|
|
||||||
@ -21,6 +50,10 @@ describe("E2E Integration", () => {
|
|||||||
|
|
||||||
process.chdir(fixtureDir);
|
process.chdir(fixtureDir);
|
||||||
|
|
||||||
|
execSync(`bun init -y && bun install react react-dom`, {
|
||||||
|
cwd: fixtureDir,
|
||||||
|
});
|
||||||
|
|
||||||
global.CONFIG = { development: true };
|
global.CONFIG = { development: true };
|
||||||
global.HMR_CONTROLLERS = [];
|
global.HMR_CONTROLLERS = [];
|
||||||
global.BUNDLER_REBUILDS = 0;
|
global.BUNDLER_REBUILDS = 0;
|
||||||
@ -81,7 +114,9 @@ describe("E2E Integration", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("returns 404 for unknown route", async () => {
|
test("returns 404 for unknown route", async () => {
|
||||||
const response = await fetch(`http://localhost:${server.port}/unknown-foo-bar123`);
|
const response = await fetch(
|
||||||
|
`http://localhost:${server.port}/unknown-foo-bar123`,
|
||||||
|
);
|
||||||
expect(response.status).toBe(404);
|
expect(response.status).toBe(404);
|
||||||
const text = await response.text();
|
const text = await response.text();
|
||||||
// Default 404 component is rendered
|
// Default 404 component is rendered
|
||||||
@ -93,7 +128,9 @@ describe("E2E Integration", () => {
|
|||||||
const pageFilePath = fixtureIndexPage;
|
const pageFilePath = fixtureIndexPage;
|
||||||
|
|
||||||
// Write a temporary .server.ts companion that injects a prop
|
// Write a temporary .server.ts companion that injects a prop
|
||||||
await Bun.write(serverFilePath, `
|
await Bun.write(
|
||||||
|
serverFilePath,
|
||||||
|
`
|
||||||
import type { BunextPageServerFn } from "../../../../../src/types";
|
import type { BunextPageServerFn } from "../../../../../src/types";
|
||||||
|
|
||||||
const server: BunextPageServerFn<{ greeting: string }> = async () => {
|
const server: BunextPageServerFn<{ greeting: string }> = async () => {
|
||||||
@ -101,18 +138,19 @@ const server: BunextPageServerFn<{ greeting: string }> = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default server;
|
export default server;
|
||||||
`);
|
`,
|
||||||
|
);
|
||||||
|
|
||||||
// Add the fixture page to the BUNDLER_CTX_MAP
|
// Add the fixture page to the BUNDLER_CTX_MAP
|
||||||
global.BUNDLER_CTX_MAP[pageFilePath] = {
|
// global.BUNDLER_CTX_MAP[pageFilePath] = {
|
||||||
path: ".bunext/public/pages/index.js",
|
// path: ".bunext/public/pages/index.js",
|
||||||
hash: "index",
|
// hash: "index",
|
||||||
type: "text/javascript",
|
// type: "text/javascript",
|
||||||
entrypoint: pageFilePath,
|
// entrypoint: pageFilePath,
|
||||||
local_path: pageFilePath,
|
// local_path: pageFilePath,
|
||||||
url_path: "/",
|
// url_path: "/",
|
||||||
file_name: "index",
|
// file_name: "index",
|
||||||
};
|
// };
|
||||||
|
|
||||||
const response = await fetch(`http://localhost:${server.port}/`);
|
const response = await fetch(`http://localhost:${server.port}/`);
|
||||||
expect(response.status).toBe(200);
|
expect(response.status).toBe(200);
|
||||||
|
|||||||
@ -9,6 +9,9 @@ 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 { ROOT_DIR } = grabDirNames();
|
||||||
|
|
||||||
let _reactVersion = "19";
|
let _reactVersion = "19";
|
||||||
try {
|
try {
|
||||||
@ -33,7 +36,7 @@ export default async function genWebHTML({
|
|||||||
grabContants();
|
grabContants();
|
||||||
|
|
||||||
const { renderToReadableStream } = await import(
|
const { renderToReadableStream } = await import(
|
||||||
`${global.DIR_NAMES.ROOT_DIR}/node_modules/react-dom/server.js`
|
`${ROOT_DIR}/node_modules/react-dom/server.js`
|
||||||
);
|
);
|
||||||
|
|
||||||
const is_dev = isDevelopment();
|
const is_dev = isDevelopment();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user