vite-plugin-react-server 0.3.15 → 0.3.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/patch.mjs +12 -19
- package/dist/package.json +8 -8
- package/dist/plugin/collect-css-manifest.d.ts.map +1 -1
- package/dist/plugin/collect-css-manifest.js +4 -4
- package/dist/plugin/collect-css-manifest.js.map +1 -1
- package/dist/plugin/config/defaults.d.ts +3 -3
- package/dist/plugin/config/defaults.js +3 -3
- package/dist/plugin/config/defaults.js.map +1 -1
- package/dist/plugin/config/resolveUserConfig.js +2 -2
- package/dist/plugin/config/resolveUserConfig.js.map +1 -1
- package/dist/plugin/react-client/plugin.d.ts.map +1 -1
- package/dist/plugin/react-client/plugin.js +16 -0
- package/dist/plugin/react-client/plugin.js.map +1 -1
- package/dist/plugin/react-server/createRscStream.d.ts.map +1 -1
- package/dist/plugin/react-server/createRscStream.js +5 -1
- package/dist/plugin/react-server/createRscStream.js.map +1 -1
- package/dist/plugin/react-server/plugin.d.ts.map +1 -1
- package/dist/plugin/react-server/plugin.js +11 -19
- package/dist/plugin/react-server/plugin.js.map +1 -1
- package/dist/plugin/resolveProps.d.ts.map +1 -1
- package/dist/plugin/resolveProps.js +1 -0
- package/dist/plugin/resolveProps.js.map +1 -1
- package/dist/plugin/worker/createWorker.js +2 -2
- package/dist/plugin/worker/createWorker.js.map +1 -1
- package/dist/plugin/worker/html/html-worker.production.js +5 -0
- package/dist/plugin/worker/html/html-worker.production.js.map +1 -1
- package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/html/messageHandler.js.map +1 -1
- package/dist/plugin/worker/html/renderPages.d.ts.map +1 -1
- package/dist/plugin/worker/html/renderPages.js +2 -2
- package/dist/plugin/worker/html/renderPages.js.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.js +3 -4
- package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/plugin/collect-css-manifest.ts +5 -6
- package/plugin/config/defaults.ts +3 -3
- package/plugin/config/resolveUserConfig.ts +2 -2
- package/plugin/react-client/plugin.ts +17 -0
- package/plugin/react-server/createRscStream.ts +5 -1
- package/plugin/react-server/plugin.ts +11 -21
- package/plugin/resolveProps.ts +1 -0
- package/plugin/worker/createWorker.ts +1 -1
- package/plugin/worker/html/html-worker.production.tsx +5 -0
- package/plugin/worker/html/messageHandler.ts +0 -2
- package/plugin/worker/html/renderPages.ts +2 -3
- package/plugin/worker/rsc/messageHandler.tsx +6 -11
- package/scripts/check-react-version.mjs +8 -26
- package/scripts/react+0.0.0-experimental-eda36a1c-20250228.patch +57 -0
- package/scripts/react-dom+0.0.0-experimental-eda36a1c-20250228.patch +552 -0
- package/scripts/{react-server-dom-esm+0.0.0-experimental-b3a95caf-20250113.patch → react-server-dom-esm+0.0.0-experimental-eda36a1c-20250228.patch} +103 -82
- package/tsconfig.json +1 -1
- package/dist/plugin/server.d.ts +0 -2
- package/dist/plugin/server.d.ts.map +0 -1
- package/dist/plugin/server.js +0 -1
- package/plugin/server.tsx +0 -0
- package/scripts/react+0.0.0-experimental-b3a95caf-20250113.patch +0 -264
- package/scripts/react-dom+0.0.0-experimental-b3a95caf-20250113.patch +0 -39796
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-react-server",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.18",
|
|
4
4
|
"description": "Vite plugin for React Server Components (RSC)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/plugin/index.js",
|
|
@@ -62,12 +62,13 @@
|
|
|
62
62
|
"test": "npm run build && npm run test:client && NODE_ENV=development npm run test:server",
|
|
63
63
|
"test:coverage": "vitest run --coverage",
|
|
64
64
|
"test:ui": "vitest --ui",
|
|
65
|
-
"experimental:clean-install": "npm install react-server-dom-esm react@experimental react-dom@experimental",
|
|
65
|
+
"experimental:clean-install": "npm install react-server-dom-esm react@experimental react-dom@experimental && npm install react-server-dom-esm",
|
|
66
66
|
"experimental:copy": "cp -r ./oss-experimental/* ./node_modules/",
|
|
67
67
|
"experimental:patch": "npx patch-package react-server-dom-esm react react-dom --exclude 'nothing'",
|
|
68
68
|
"experimental:move-patches": "mv patches/* ./scripts/",
|
|
69
|
-
"experimental:setup": "rm -rf patches/* && npm run experimental:clean-install && npm run experimental:copy && npm run experimental:patch && npm run experimental:move-patches
|
|
70
|
-
"
|
|
69
|
+
"experimental:setup": "rm -rf patches/* && npm run experimental:clean-install && npm run experimental:copy && npm run experimental:patch && npm run experimental:move-patches",
|
|
70
|
+
"experimental:patch-react": "npm run experimental:clean-install && node scripts/check-react-version.mjs && node bin/patch.mjs",
|
|
71
|
+
"postinstall": "patch-package"
|
|
71
72
|
},
|
|
72
73
|
"keywords": [
|
|
73
74
|
"vite",
|
|
@@ -90,8 +91,8 @@
|
|
|
90
91
|
},
|
|
91
92
|
"homepage": "https://github.com/nicobrinkkemper/vite-plugin-react-server#readme",
|
|
92
93
|
"peerDependencies": {
|
|
93
|
-
"react": "
|
|
94
|
-
"react-dom": "
|
|
94
|
+
"react": "^0.0.0-experimental-d55cc79b-20250228",
|
|
95
|
+
"react-dom": "^0.0.0-experimental-d55cc79b-20250228",
|
|
95
96
|
"vite": "*"
|
|
96
97
|
},
|
|
97
98
|
"peerDependenciesMeta": {
|
|
@@ -109,9 +110,8 @@
|
|
|
109
110
|
"@types/react": "^19.0.8",
|
|
110
111
|
"@types/react-dom": "^19.0.3",
|
|
111
112
|
"acorn-loose": "^8.3.0",
|
|
113
|
+
"happy-dom": "^17.1.8",
|
|
112
114
|
"patch-package": "^8.0.0",
|
|
113
|
-
"react": "^0.0.0-experimental-d55cc79b-20250228",
|
|
114
|
-
"react-dom": "^0.0.0-experimental-d55cc79b-20250228",
|
|
115
115
|
"react-server-dom-esm": "^0.0.1",
|
|
116
116
|
"rollup": "^4.34.0",
|
|
117
117
|
"source-map": "^0.7.4",
|
|
@@ -33,13 +33,12 @@ export function collectManifestCss(
|
|
|
33
33
|
onCss?: (path: string, parentUrl: string) => void,
|
|
34
34
|
parentUrl?: string
|
|
35
35
|
) {
|
|
36
|
-
const relativePagePath = pagePath.startsWith(root +
|
|
37
|
-
? pagePath.slice(root.length + 1)
|
|
36
|
+
const relativePagePath = root !== "" && pagePath.startsWith(root.endsWith('/') ? root : root + '/')
|
|
37
|
+
? pagePath.slice(root.length + (root.endsWith('/') ? 0 : 1))
|
|
38
38
|
: pagePath;
|
|
39
|
-
if (!relativePagePath) return new Map<string, string>();
|
|
40
39
|
const cssFiles = new Map<string, string>();
|
|
41
40
|
const seen = new Set<string>();
|
|
42
|
-
|
|
41
|
+
const manifestValues = Object.values(manifest);
|
|
43
42
|
const walkManifestEntry = (id: string) => {
|
|
44
43
|
if (seen.has(id)) return;
|
|
45
44
|
seen.add(id);
|
|
@@ -54,13 +53,13 @@ export function collectManifestCss(
|
|
|
54
53
|
return;
|
|
55
54
|
}
|
|
56
55
|
// Get the manifest entry
|
|
57
|
-
const entry = manifest[id];
|
|
56
|
+
const entry = manifest[id] ?? manifestValues.find(e => e.file === id);
|
|
58
57
|
if (!entry) return;
|
|
59
58
|
|
|
60
59
|
// Add direct CSS
|
|
61
60
|
if (entry.css) {
|
|
62
61
|
entry.css.forEach((css: string) => {
|
|
63
|
-
cssFiles.set(entry.file, css);
|
|
62
|
+
cssFiles.set(entry.src ?? entry.file ?? '', css);
|
|
64
63
|
onCss?.(css, parentUrl ?? pagePath);
|
|
65
64
|
});
|
|
66
65
|
}
|
|
@@ -11,9 +11,9 @@ export const DEFAULT_CONFIG = {
|
|
|
11
11
|
SERVER_ENTRY: "src/server.tsx",
|
|
12
12
|
PAGE_EXPORT_NAME: "Page",
|
|
13
13
|
PROPS_EXPORT_NAME: "props",
|
|
14
|
-
HTML_WORKER_PATH: `worker/html/html-worker.${process.env['NODE_ENV'] === 'development' ? 'development' : 'production'}.js`,
|
|
15
|
-
RSC_WORKER_PATH: `worker/rsc/rsc-worker.${process.env['NODE_ENV'] === 'development' ? 'development' : 'production'}.js`,
|
|
16
|
-
LOADER_PATH: 'worker/loader.js',
|
|
14
|
+
HTML_WORKER_PATH: `node_modules/vite-plugin-react-server/dist/plugin/worker/html/html-worker.${process.env['NODE_ENV'] === 'development' ? 'development' : 'production'}.js`,
|
|
15
|
+
RSC_WORKER_PATH: `node_modules/vite-plugin-react-server/dist/plugin/worker/rsc/rsc-worker.${process.env['NODE_ENV'] === 'development' ? 'development' : 'production'}.js`,
|
|
16
|
+
LOADER_PATH: 'node_modules/vite-plugin-react-server/dist/plugin/worker/loader.js',
|
|
17
17
|
RSC_EXTENSION: ".rsc",
|
|
18
18
|
HTML: ({ children }: { children: any }) => children,
|
|
19
19
|
COLLECT_CSS: true,
|
|
@@ -146,7 +146,7 @@ export function resolveUserConfig({
|
|
|
146
146
|
userConfig: {
|
|
147
147
|
...config,
|
|
148
148
|
root: root,
|
|
149
|
-
mode: configEnv.command === "build" ? "production" : "development",
|
|
149
|
+
mode: configEnv.mode ?? configEnv.command === "build" ? "production" : "development",
|
|
150
150
|
resolve: {
|
|
151
151
|
external: ["react", "react-dom"],
|
|
152
152
|
alias: {},
|
|
@@ -194,7 +194,7 @@ export function resolveUserConfig({
|
|
|
194
194
|
userConfig: {
|
|
195
195
|
...config,
|
|
196
196
|
root: root,
|
|
197
|
-
mode: configEnv.command === "build" ? "production" : "development",
|
|
197
|
+
mode: configEnv.mode ?? configEnv.command === "build" ? "production" : "development",
|
|
198
198
|
resolve: {
|
|
199
199
|
alias: {},
|
|
200
200
|
externalConditions: ["react-server"],
|
|
@@ -24,6 +24,7 @@ import type {
|
|
|
24
24
|
RscWorkerResponse,
|
|
25
25
|
} from "../worker/types.js";
|
|
26
26
|
import { createLogger } from "../utils/logger.js";
|
|
27
|
+
import { readFileSync } from "node:fs";
|
|
27
28
|
|
|
28
29
|
const log = createLogger("react-client");
|
|
29
30
|
let userOptions: ResolvedUserOptions;
|
|
@@ -188,6 +189,7 @@ export function reactClientPlugin(options: StreamPluginOptions): Plugin {
|
|
|
188
189
|
if (foundClient) {
|
|
189
190
|
res.setHeader("Content-Type", "application/javascript");
|
|
190
191
|
res.end(foundClient);
|
|
192
|
+
return;
|
|
191
193
|
}
|
|
192
194
|
const foundServer =
|
|
193
195
|
serverManifest &&
|
|
@@ -207,6 +209,21 @@ export function reactClientPlugin(options: StreamPluginOptions): Plugin {
|
|
|
207
209
|
next();
|
|
208
210
|
}
|
|
209
211
|
} else {
|
|
212
|
+
let html = '';
|
|
213
|
+
try {
|
|
214
|
+
const last = value.split('/').pop();
|
|
215
|
+
if(!last?.includes('.')) {
|
|
216
|
+
const isDir = await stat(join(fileRoot, value));
|
|
217
|
+
if (isDir.isDirectory()) {
|
|
218
|
+
html = readFileSync(join(fileRoot, value, 'index.html'), 'utf-8');
|
|
219
|
+
res.setHeader("Content-Type", "text/html");
|
|
220
|
+
res.end(html);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
} catch (error) {
|
|
225
|
+
|
|
226
|
+
}
|
|
210
227
|
next();
|
|
211
228
|
}
|
|
212
229
|
});
|
|
@@ -21,7 +21,8 @@ function CssCollector({
|
|
|
21
21
|
return React.createElement('link', {
|
|
22
22
|
key: css,
|
|
23
23
|
rel: 'stylesheet',
|
|
24
|
-
href: url
|
|
24
|
+
href: url,
|
|
25
|
+
precedence: 'high'
|
|
25
26
|
})
|
|
26
27
|
}),
|
|
27
28
|
children
|
|
@@ -68,6 +69,9 @@ export function createRscStream({
|
|
|
68
69
|
moduleBasePath,
|
|
69
70
|
{
|
|
70
71
|
onError: (error: Error) => {
|
|
72
|
+
if(process.env['NODE_ENV'] === 'development') {
|
|
73
|
+
console.trace(error);
|
|
74
|
+
}
|
|
71
75
|
logger.error(`Stream error at ${route}.`, {error});
|
|
72
76
|
},
|
|
73
77
|
onPostpone: logger.info ?? console.info,
|
|
@@ -33,6 +33,7 @@ import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
|
33
33
|
import { getBundleManifest } from "../helpers/getBundleManifest.js";
|
|
34
34
|
import type { ServerResponse } from "node:http";
|
|
35
35
|
import { collectManifestCss } from "../collect-css-manifest.js";
|
|
36
|
+
import { cssFiles } from "../worker/rsc/state.js";
|
|
36
37
|
|
|
37
38
|
let resolvedConfig: ResolvedConfig | null = null;
|
|
38
39
|
let serverManifestPath: string | null = null;
|
|
@@ -286,16 +287,11 @@ export function reactServerPlugin(
|
|
|
286
287
|
|
|
287
288
|
const clientManifest = clientManifestResult.manifest;
|
|
288
289
|
|
|
289
|
-
// Initialize worker
|
|
290
|
-
const htmlWorkerPath = join(
|
|
291
|
-
getPluginRoot(),
|
|
292
|
-
DEFAULT_CONFIG.HTML_WORKER_PATH
|
|
293
|
-
);
|
|
294
290
|
|
|
295
291
|
worker = await createWorker({
|
|
296
292
|
projectRoot: root,
|
|
297
|
-
workerPath: htmlWorkerPath,
|
|
298
|
-
condition:
|
|
293
|
+
workerPath: userOptions.htmlWorkerPath,
|
|
294
|
+
condition: 'react-server',
|
|
299
295
|
reverseCondition: true,
|
|
300
296
|
mode: (resolvedConfig?.mode ?? "production") as
|
|
301
297
|
| "production"
|
|
@@ -402,13 +398,13 @@ export function reactServerPlugin(
|
|
|
402
398
|
{
|
|
403
399
|
pipableStreamOptions: {
|
|
404
400
|
bootstrapModules: clientManifest["index.html"]?.file
|
|
405
|
-
? [clientManifest["index.html"].file]
|
|
401
|
+
? [clientManifest["index.html"].file.startsWith('/') ? clientManifest["index.html"].file : '/' + clientManifest["index.html"].file]
|
|
406
402
|
: [],
|
|
407
403
|
},
|
|
408
404
|
moduleBasePath: "",
|
|
409
405
|
moduleBaseURL: "",
|
|
410
406
|
clientCss: clientManifest["index.html"]?.css
|
|
411
|
-
? clientManifest["index.html"].css
|
|
407
|
+
? clientManifest["index.html"].css.map(css => css.startsWith('/') ? css : '/' + css)
|
|
412
408
|
: [],
|
|
413
409
|
userConfig,
|
|
414
410
|
pluginOptions: userOptions,
|
|
@@ -433,14 +429,10 @@ export function reactServerPlugin(
|
|
|
433
429
|
|
|
434
430
|
// Update stats to include CSS and client components
|
|
435
431
|
const stats: BuildStats = {
|
|
436
|
-
htmlFiles:
|
|
437
|
-
clientComponents:
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
cssFiles: Object.keys(clientManifest)
|
|
441
|
-
.flatMap(userOptions.autoDiscover.cssPattern)
|
|
442
|
-
.filter(Boolean).length,
|
|
443
|
-
totalRoutes: userOptions.build.pages.length,
|
|
432
|
+
htmlFiles: files.urlMap.size,
|
|
433
|
+
clientComponents: clientComponents.size,
|
|
434
|
+
cssFiles: cssFiles.size,
|
|
435
|
+
totalRoutes: files.urlMap.size,
|
|
444
436
|
timing: {
|
|
445
437
|
config: ((timing.configResolved ?? 0) - timing.start) / 1000,
|
|
446
438
|
build:
|
|
@@ -464,10 +456,8 @@ export function reactServerPlugin(
|
|
|
464
456
|
|
|
465
457
|
console.log("\n[vite-plugin-react-server] Build Summary:");
|
|
466
458
|
console.log("─".repeat(50));
|
|
467
|
-
console.log(
|
|
468
|
-
console.log(
|
|
469
|
-
console.log(`🎨 Included ${stats.cssFiles} CSS files`);
|
|
470
|
-
console.log(`🛣️ Total routes: ${stats.totalRoutes}`);
|
|
459
|
+
console.log(`🎨 Included ${buildCssFiles.size} CSS files`);
|
|
460
|
+
console.log(`🛣️ Total routes: ${files.urlMap.size}`);
|
|
471
461
|
console.log("─".repeat(50));
|
|
472
462
|
console.log("⏱️ Timing:");
|
|
473
463
|
console.log(` Config: ${formatDuration(stats.timing.config)}`);
|
package/plugin/resolveProps.ts
CHANGED
|
@@ -53,7 +53,7 @@ export async function createWorker(options: CreateWorkerOptions) {
|
|
|
53
53
|
|
|
54
54
|
// Create worker with proper environment
|
|
55
55
|
const worker = new Worker(
|
|
56
|
-
workerPath.startsWith("/") ? workerPath :
|
|
56
|
+
workerPath.startsWith("/") ? workerPath : './' + workerPath,
|
|
57
57
|
{
|
|
58
58
|
env,
|
|
59
59
|
resourceLimits,
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { messageHandler } from "./messageHandler.js";
|
|
2
2
|
import { parentPort } from "node:worker_threads";
|
|
3
|
+
import { Window } from 'happy-dom';
|
|
4
|
+
const window = new Window({ url: 'https://localhost:8080' });
|
|
5
|
+
const document = window.document;
|
|
6
|
+
globalThis.window = window as any;
|
|
7
|
+
globalThis.document = document as any;
|
|
3
8
|
|
|
4
9
|
let ready = false;
|
|
5
10
|
if (!parentPort) throw new Error("This module must be run as a worker");
|
|
@@ -13,8 +13,6 @@ import { join } from "path";
|
|
|
13
13
|
const activeRenders = new Map<string, HtmlRenderState>();
|
|
14
14
|
const htmlContent = new Map<string, string>();
|
|
15
15
|
const htmlPromises = new Map<string, Promise<string>>();
|
|
16
|
-
|
|
17
|
-
|
|
18
16
|
export const messageHandler = async (message: HtmlWorkerMessage) => {
|
|
19
17
|
try {
|
|
20
18
|
switch (message.type) {
|
|
@@ -92,7 +92,7 @@ export async function renderPages(
|
|
|
92
92
|
});
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
-
collectManifestCss(
|
|
95
|
+
const newCssFiles = collectManifestCss(
|
|
96
96
|
options.clientManifest,
|
|
97
97
|
options.moduleBasePath,
|
|
98
98
|
'index.html',
|
|
@@ -125,7 +125,6 @@ export async function renderPages(
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
);
|
|
128
|
-
|
|
129
128
|
// Create handler for pure RSC output
|
|
130
129
|
const rscResult = await createHandler(route, {
|
|
131
130
|
...options.pluginOptions,
|
|
@@ -134,7 +133,7 @@ export async function renderPages(
|
|
|
134
133
|
loader: options.loader,
|
|
135
134
|
clientManifest: options.clientManifest,
|
|
136
135
|
serverManifest: options.serverManifest,
|
|
137
|
-
cssFiles: clientCss,
|
|
136
|
+
cssFiles: Array.from(newCssFiles.values()).concat(clientCss),
|
|
138
137
|
pipableStreamOptions: {
|
|
139
138
|
...options.pipableStreamOptions,
|
|
140
139
|
importMap: {
|
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { mkdir } from "node:fs/promises";
|
|
3
|
-
import { dirname, join } from "node:path";
|
|
4
|
-
import { parentPort } from "node:worker_threads";
|
|
1
|
+
import { join } from "node:path";
|
|
5
2
|
import { PassThrough } from "node:stream";
|
|
3
|
+
import { parentPort } from "node:worker_threads";
|
|
4
|
+
import React from "react";
|
|
6
5
|
import {
|
|
7
6
|
renderToPipeableStream,
|
|
8
7
|
// @ts-ignore
|
|
9
8
|
} from "react-server-dom-esm/server.node";
|
|
9
|
+
import { createLogger } from "../../utils/logger.js";
|
|
10
10
|
import type {
|
|
11
11
|
RscChunkMessage,
|
|
12
12
|
RscEndMessage,
|
|
13
13
|
RscWorkerMessage,
|
|
14
14
|
} from "../types.js";
|
|
15
|
-
import { createLogger } from "../../utils/logger.js";
|
|
16
15
|
import {
|
|
17
|
-
cssFiles,
|
|
18
|
-
clientFiles,
|
|
19
|
-
serverActionFiles,
|
|
20
16
|
addCssFile,
|
|
21
|
-
|
|
17
|
+
cssFiles
|
|
22
18
|
} from "./state.js";
|
|
23
|
-
import type { WriteStream } from "node:fs";
|
|
24
|
-
import React from "react";
|
|
25
19
|
|
|
26
20
|
const log = createLogger("rsc-worker");
|
|
27
21
|
|
|
@@ -85,6 +79,7 @@ export async function messageHandler(message: RscWorkerMessage) {
|
|
|
85
79
|
moduleBaseURL,
|
|
86
80
|
{
|
|
87
81
|
onError: (error: Error) => {
|
|
82
|
+
console.log('onError', error);
|
|
88
83
|
log.error(`Stream error at ${id}:`, error);
|
|
89
84
|
parentPort?.postMessage({
|
|
90
85
|
type: "ERROR",
|
|
@@ -6,28 +6,18 @@ import React from 'react'
|
|
|
6
6
|
|
|
7
7
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
8
8
|
|
|
9
|
-
const TEMPLATE_VERSION = '0.0.0-experimental-
|
|
10
|
-
const ACTUAL_TEMPLATE_VERSION = '19.1.0-experimental-b3a95caf-20250113'
|
|
11
|
-
const TARGET_VERSION = '0.0.0-experimental-d55cc79b-20250228'
|
|
12
|
-
const ACTUAL_TARGET_VERSION = '19.1.0-experimental-d55cc79b-20250228'
|
|
9
|
+
const TEMPLATE_VERSION = '0.0.0-experimental-eda36a1c-20250228'
|
|
13
10
|
const STUB_VERSION = '0.0.1'
|
|
14
11
|
|
|
15
12
|
async function main() {
|
|
16
13
|
// Read installed React version
|
|
17
|
-
const reactPkgPath = path.resolve(process.cwd(), 'node_modules/react/package.json')
|
|
18
|
-
const reactPkg = JSON.parse(await fs.readFile(reactPkgPath, 'utf-8'))
|
|
19
|
-
const userPkg = JSON.parse(await fs.readFile(path.resolve(process.cwd(), 'package.json'), 'utf-8'))
|
|
20
14
|
const patchVersion = React.version
|
|
15
|
+
const PATCH_RECONCILER_VERSION = patchVersion.replace('19.1.0', '0.0.0')
|
|
16
|
+
if(TEMPLATE_VERSION === PATCH_RECONCILER_VERSION) {
|
|
17
|
+
console.log('React version is already patched')
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
21
20
|
|
|
22
|
-
let userVersion = userPkg.dependencies?.react ?? userPkg.devDependencies?.react ?? userPkg.peerDependencies?.react
|
|
23
|
-
if(!userVersion) {
|
|
24
|
-
throw new Error('React version not found in package.json')
|
|
25
|
-
} else {
|
|
26
|
-
userVersion = userVersion.replace('^', '')
|
|
27
|
-
}
|
|
28
|
-
if(userVersion !== TARGET_VERSION) {
|
|
29
|
-
throw new Error(`React patch was made for version ${ACTUAL_TARGET_VERSION}, but you installed version ${userVersion}`)
|
|
30
|
-
}
|
|
31
21
|
// Define patches to process
|
|
32
22
|
const patches = [
|
|
33
23
|
{
|
|
@@ -36,11 +26,11 @@ async function main() {
|
|
|
36
26
|
},
|
|
37
27
|
{
|
|
38
28
|
template: path.resolve(__dirname, `react+${TEMPLATE_VERSION}.patch`),
|
|
39
|
-
output: `react+${
|
|
29
|
+
output: `react+${PATCH_RECONCILER_VERSION}.patch`
|
|
40
30
|
},
|
|
41
31
|
{
|
|
42
32
|
template: path.resolve(__dirname, `react-dom+${TEMPLATE_VERSION}.patch`),
|
|
43
|
-
output: `react-dom+${
|
|
33
|
+
output: `react-dom+${PATCH_RECONCILER_VERSION}.patch`
|
|
44
34
|
}
|
|
45
35
|
]
|
|
46
36
|
|
|
@@ -57,14 +47,6 @@ async function main() {
|
|
|
57
47
|
console.log(`Wrote patch file to ${outputPath}`)
|
|
58
48
|
}
|
|
59
49
|
|
|
60
|
-
console.log(`React version check result:
|
|
61
|
-
userVersion: ${userVersion}
|
|
62
|
-
patchVersion: ${patchVersion}
|
|
63
|
-
ACTUAL_TARGET_VERSION: ${ACTUAL_TARGET_VERSION}
|
|
64
|
-
ACTUAL_TEMPLATE_VERSION: ${ACTUAL_TEMPLATE_VERSION}
|
|
65
|
-
TARGET_VERSION: ${TARGET_VERSION}
|
|
66
|
-
TEMPLATE_VERSION: ${TEMPLATE_VERSION}
|
|
67
|
-
`)
|
|
68
50
|
}
|
|
69
51
|
|
|
70
52
|
const PATCH = ``
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
diff --git a/node_modules/react/cjs/react.development.js b/node_modules/react/cjs/react.development.js
|
|
2
|
+
index 9aa7fdf..2bc8270 100644
|
|
3
|
+
--- a/node_modules/react/cjs/react.development.js
|
|
4
|
+
+++ b/node_modules/react/cjs/react.development.js
|
|
5
|
+
@@ -1277,7 +1277,7 @@
|
|
6
|
+
exports.useTransition = function () {
|
|
7
|
+
return resolveDispatcher().useTransition();
|
|
8
|
+
};
|
|
9
|
+
- exports.version = "19.1.0-experimental-d55cc79b-20250228";
|
|
10
|
+
+ exports.version = "19.1.0-experimental-eda36a1c-20250228";
|
|
11
|
+
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
|
|
12
|
+
"function" ===
|
|
13
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
|
|
14
|
+
diff --git a/node_modules/react/cjs/react.production.js b/node_modules/react/cjs/react.production.js
|
|
15
|
+
index 3678d50..24d6e95 100644
|
|
16
|
+
--- a/node_modules/react/cjs/react.production.js
|
|
17
|
+
+++ b/node_modules/react/cjs/react.production.js
|
|
18
|
+
@@ -576,4 +576,4 @@ exports.useSyncExternalStore = function (
|
|
19
|
+
exports.useTransition = function () {
|
|
20
|
+
return ReactSharedInternals.H.useTransition();
|
|
21
|
+
};
|
|
22
|
+
-exports.version = "19.1.0-experimental-d55cc79b-20250228";
|
|
23
|
+
+exports.version = "19.1.0-experimental-eda36a1c-20250228";
|
|
24
|
+
diff --git a/node_modules/react/cjs/react.react-server.development.js b/node_modules/react/cjs/react.react-server.development.js
|
|
25
|
+
index 15d4371..8497113 100644
|
|
26
|
+
--- a/node_modules/react/cjs/react.react-server.development.js
|
|
27
|
+
+++ b/node_modules/react/cjs/react.react-server.development.js
|
|
28
|
+
@@ -981,5 +981,5 @@
|
|
29
|
+
exports.useMemo = function (create, deps) {
|
|
30
|
+
return resolveDispatcher().useMemo(create, deps);
|
|
31
|
+
};
|
|
32
|
+
- exports.version = "19.1.0-experimental-d55cc79b-20250228";
|
|
33
|
+
+ exports.version = "19.1.0-experimental-eda36a1c-20250228";
|
|
34
|
+
})();
|
|
35
|
+
diff --git a/node_modules/react/cjs/react.react-server.production.js b/node_modules/react/cjs/react.react-server.production.js
|
|
36
|
+
index 6c7c438..694169d 100644
|
|
37
|
+
--- a/node_modules/react/cjs/react.react-server.production.js
|
|
38
|
+
+++ b/node_modules/react/cjs/react.react-server.production.js
|
|
39
|
+
@@ -561,4 +561,4 @@ exports.useId = function () {
|
|
40
|
+
exports.useMemo = function (create, deps) {
|
|
41
|
+
return ReactSharedInternals.H.useMemo(create, deps);
|
|
42
|
+
};
|
|
43
|
+
-exports.version = "19.1.0-experimental-d55cc79b-20250228";
|
|
44
|
+
+exports.version = "19.1.0-experimental-eda36a1c-20250228";
|
|
45
|
+
diff --git a/node_modules/react/package.json b/node_modules/react/package.json
|
|
46
|
+
index f7c9f76..b6e85b0 100644
|
|
47
|
+
--- a/node_modules/react/package.json
|
|
48
|
+
+++ b/node_modules/react/package.json
|
|
49
|
+
@@ -4,7 +4,7 @@
|
|
50
|
+
"keywords": [
|
|
51
|
+
"react"
|
|
52
|
+
],
|
|
53
|
+
- "version": "0.0.0-experimental-d55cc79b-20250228",
|
|
54
|
+
+ "version": "0.0.0-experimental-eda36a1c-20250228",
|
|
55
|
+
"homepage": "https://react.dev/",
|
|
56
|
+
"bugs": "https://github.com/facebook/react/issues",
|
|
57
|
+
"license": "MIT",
|