vite-plugin-react-server 0.3.10 → 0.3.12
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/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -1
- package/dist/index.d.ts +3 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/package.json +16 -14
- package/dist/plugin/assertServerCondition.d.ts +5 -1
- package/dist/plugin/assertServerCondition.d.ts.map +1 -1
- package/dist/plugin/assertServerCondition.js +1 -3
- package/dist/plugin/checkFilesExist.d.ts +2 -2
- package/dist/plugin/checkFilesExist.d.ts.map +1 -1
- package/dist/plugin/checkFilesExist.js +43 -58
- package/dist/plugin/checkFilesExist.js.map +1 -1
- package/dist/plugin/collect-css-manifest.d.ts.map +1 -1
- package/dist/plugin/collect-css-manifest.js +5 -0
- package/dist/plugin/collect-css-manifest.js.map +1 -1
- package/dist/plugin/components.js +10 -15
- package/dist/plugin/config/createModuleIdGenerator.d.ts +11 -0
- package/dist/plugin/config/createModuleIdGenerator.d.ts.map +1 -0
- package/dist/plugin/config/createModuleIdGenerator.js +44 -0
- package/dist/plugin/config/createModuleIdGenerator.js.map +1 -0
- package/dist/plugin/config/defaults.d.ts +27 -24
- package/dist/plugin/config/defaults.d.ts.map +1 -1
- package/dist/plugin/config/defaults.js +26 -31
- package/dist/plugin/config/defaults.js.map +1 -1
- package/dist/plugin/config/getPaths.js +1 -1
- package/dist/plugin/config/resolveOptions.d.ts +1 -1
- package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
- package/dist/plugin/config/resolveOptions.js +223 -16
- package/dist/plugin/config/resolveOptions.js.map +1 -1
- package/dist/plugin/config/resolvePages.d.ts +2 -0
- package/dist/plugin/config/resolvePages.d.ts.map +1 -1
- package/dist/plugin/config/resolvePages.js.map +1 -1
- package/dist/plugin/config/resolveUserConfig.d.ts +2 -2
- package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
- package/dist/plugin/config/resolveUserConfig.js +149 -50
- package/dist/plugin/config/resolveUserConfig.js.map +1 -1
- package/dist/plugin/helpers/getBundleManifest.d.ts +25 -0
- package/dist/plugin/helpers/getBundleManifest.d.ts.map +1 -0
- package/dist/plugin/helpers/getBundleManifest.js +72 -0
- package/dist/plugin/helpers/getBundleManifest.js.map +1 -0
- package/dist/plugin/helpers/inputNormalizer.d.ts +14 -1
- package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
- package/dist/plugin/helpers/inputNormalizer.js +128 -16
- package/dist/plugin/helpers/inputNormalizer.js.map +1 -1
- package/dist/plugin/helpers/tryManifest.d.ts +3 -1
- package/dist/plugin/helpers/tryManifest.d.ts.map +1 -1
- package/dist/plugin/helpers/tryManifest.js +1 -1
- package/dist/plugin/helpers/tryManifest.js.map +1 -1
- package/dist/plugin/loader/createBuildLoader.d.ts +6 -2
- package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -1
- package/dist/plugin/loader/createBuildLoader.js +37 -9
- package/dist/plugin/loader/createBuildLoader.js.map +1 -1
- package/dist/plugin/loader/createPageLoader.d.ts.map +1 -1
- package/dist/plugin/loader/createPageLoader.js +0 -7
- package/dist/plugin/loader/css-loader.d.ts +16 -0
- package/dist/plugin/loader/css-loader.d.ts.map +1 -0
- package/dist/plugin/loader/css-loader.js +70 -0
- package/dist/plugin/loader/css-loader.js.map +1 -0
- package/dist/plugin/loader/react-loader.d.ts +17 -0
- package/dist/plugin/loader/react-loader.d.ts.map +1 -0
- package/dist/plugin/loader/react-loader.js +647 -0
- package/dist/plugin/loader/react-loader.js.map +1 -0
- package/dist/plugin/loader/rsc/messageHandler.d.ts +2 -0
- package/dist/plugin/loader/rsc/messageHandler.d.ts.map +1 -0
- package/dist/plugin/loader/rsc/messageHandler.js +1 -0
- package/dist/plugin/loader/rsc/rsc-worker.development.d.ts +2 -0
- package/dist/plugin/loader/rsc/rsc-worker.development.d.ts.map +1 -0
- package/dist/plugin/loader/rsc/rsc-worker.development.js +1 -0
- package/dist/plugin/plugin.d.ts +0 -1
- package/dist/plugin/plugin.d.ts.map +1 -1
- package/dist/plugin/plugin.js +2 -1
- package/dist/plugin/preserver/plugin.d.ts.map +1 -1
- package/dist/plugin/preserver/plugin.js +3 -2
- package/dist/plugin/preserver/plugin.js.map +1 -1
- package/dist/plugin/react-client/index.d.ts +2 -1
- package/dist/plugin/react-client/index.d.ts.map +1 -1
- package/dist/plugin/react-client/index.js +19 -1
- package/dist/plugin/react-client/index.js.map +1 -0
- package/dist/plugin/react-client/plugin.d.ts +2 -2
- package/dist/plugin/react-client/plugin.d.ts.map +1 -1
- package/dist/plugin/react-client/plugin.js +283 -10
- package/dist/plugin/react-client/plugin.js.map +1 -1
- package/dist/plugin/react-server/createHandler.d.ts +2 -2
- package/dist/plugin/react-server/createHandler.d.ts.map +1 -1
- package/dist/plugin/react-server/createHandler.js +15 -9
- package/dist/plugin/react-server/createHandler.js.map +1 -1
- package/dist/plugin/react-server/createRscStream.d.ts +15 -3
- package/dist/plugin/react-server/createRscStream.d.ts.map +1 -1
- package/dist/plugin/react-server/createRscStream.js +53 -36
- package/dist/plugin/react-server/createRscStream.js.map +1 -1
- package/dist/plugin/react-server/createSsrHandler.d.ts +2 -2
- package/dist/plugin/react-server/createSsrHandler.d.ts.map +1 -1
- package/dist/plugin/react-server/createSsrHandler.js +5 -12
- package/dist/plugin/react-server/index.js +18 -9
- package/dist/plugin/react-server/index.js.map +1 -0
- package/dist/plugin/react-server/plugin.d.ts.map +1 -1
- package/dist/plugin/react-server/plugin.js +147 -137
- package/dist/plugin/react-server/plugin.js.map +1 -1
- package/dist/plugin/transformer/plugin.d.ts +2 -1
- package/dist/plugin/transformer/plugin.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.js +68 -75
- package/dist/plugin/transformer/plugin.js.map +1 -1
- package/dist/plugin/transformer/types.d.ts +4 -0
- package/dist/plugin/transformer/types.d.ts.map +1 -1
- package/dist/plugin/types.d.ts +56 -20
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/utils/logger.d.ts +9 -0
- package/dist/plugin/utils/logger.d.ts.map +1 -0
- package/dist/plugin/utils/logger.js +68 -0
- package/dist/plugin/utils/logger.js.map +1 -0
- package/dist/plugin/worker/createWorker.d.ts +1 -0
- package/dist/plugin/worker/createWorker.d.ts.map +1 -1
- package/dist/plugin/worker/createWorker.js +23 -36
- package/dist/plugin/worker/createWorker.js.map +1 -1
- package/dist/plugin/worker/html/html-worker.production.js +5 -1
- 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 +33 -28
- package/dist/plugin/worker/html/messageHandler.js.map +1 -1
- package/dist/plugin/worker/html/plugin.d.ts.map +1 -1
- package/dist/plugin/worker/html/plugin.js +10 -5
- package/dist/plugin/worker/html/renderPages.d.ts +7 -6
- package/dist/plugin/worker/html/renderPages.d.ts.map +1 -1
- package/dist/plugin/worker/html/renderPages.js +147 -93
- package/dist/plugin/worker/html/renderPages.js.map +1 -1
- package/dist/plugin/worker/loader.d.ts +1 -11
- package/dist/plugin/worker/loader.d.ts.map +1 -1
- package/dist/plugin/worker/loader.js +2 -2
- package/dist/plugin/worker/loader.js.map +1 -1
- package/dist/plugin/worker/plugin.d.ts +10 -1
- package/dist/plugin/worker/plugin.d.ts.map +1 -1
- package/dist/plugin/worker/plugin.js +10 -1
- package/dist/plugin/worker/rsc/index.d.ts +1 -3
- package/dist/plugin/worker/rsc/index.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/index.js +1 -9
- package/dist/plugin/worker/rsc/index.js.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.d.ts +3 -0
- package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/messageHandler.js +107 -0
- package/dist/plugin/worker/rsc/messageHandler.js.map +1 -0
- package/dist/plugin/worker/rsc/plugin.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/plugin.js +74 -80
- package/dist/plugin/worker/rsc/rsc-worker.development.d.ts +32 -0
- package/dist/plugin/worker/rsc/rsc-worker.development.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/rsc-worker.development.js +43 -0
- package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -0
- package/dist/plugin/worker/rsc/rsc-worker.js +4 -106
- package/dist/plugin/worker/rsc/rsc-worker.production.d.ts +2 -0
- package/dist/plugin/worker/rsc/rsc-worker.production.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/rsc-worker.production.js +14 -0
- package/dist/plugin/worker/rsc/rsc-worker.production.js.map +1 -0
- package/dist/plugin/worker/rsc/state.d.ts +11 -0
- package/dist/plugin/worker/rsc/state.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/state.js +12 -0
- package/dist/plugin/worker/rsc/state.js.map +1 -0
- package/dist/plugin/worker/types.d.ts +62 -35
- package/dist/plugin/worker/types.d.ts.map +1 -1
- package/dist/server.d.ts +1 -3
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1 -3
- package/dist/server.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -14
- package/plugin/assertServerCondition.ts +2 -3
- package/plugin/checkFilesExist.ts +46 -66
- package/plugin/collect-css-manifest.ts +5 -1
- package/plugin/config/createModuleIdGenerator.ts +52 -0
- package/plugin/config/defaults.ts +27 -20
- package/plugin/config/resolveOptions.ts +311 -25
- package/plugin/config/resolvePages.ts +1 -1
- package/plugin/config/resolveUserConfig.ts +195 -61
- package/plugin/helpers/getBundleManifest.ts +113 -0
- package/plugin/helpers/inputNormalizer.ts +186 -25
- package/plugin/helpers/tryManifest.ts +3 -1
- package/plugin/loader/createBuildLoader.ts +50 -9
- package/plugin/loader/createPageLoader.ts +1 -7
- package/plugin/loader/css-loader.ts +96 -0
- package/plugin/loader/react-loader.ts +945 -0
- package/plugin/loader/rsc/messageHandler.tsx +1 -0
- package/plugin/loader/rsc/rsc-worker.development.ts +1 -0
- package/plugin/plugin.ts +2 -1
- package/plugin/preserver/plugin.ts +2 -1
- package/plugin/react-client/index.ts +12 -1
- package/plugin/react-client/plugin.ts +351 -11
- package/plugin/react-server/createHandler.ts +16 -18
- package/plugin/react-server/createRscStream.ts +75 -42
- package/plugin/react-server/createSsrHandler.ts +7 -26
- package/plugin/react-server/plugin.ts +192 -155
- package/plugin/transformer/plugin.ts +70 -104
- package/plugin/transformer/types.ts +4 -0
- package/plugin/types/global.d.ts +8 -0
- package/plugin/types.ts +120 -64
- package/plugin/utils/logger.ts +52 -0
- package/plugin/worker/createWorker.ts +43 -44
- package/plugin/worker/html/html-worker.production.tsx +7 -2
- package/plugin/worker/html/messageHandler.ts +42 -35
- package/plugin/worker/html/plugin.ts +15 -11
- package/plugin/worker/html/renderPages.ts +177 -123
- package/plugin/worker/loader.ts +4 -13
- package/plugin/worker/plugin.ts +10 -1
- package/plugin/worker/rsc/index.ts +4 -13
- package/plugin/worker/rsc/messageHandler.tsx +143 -0
- package/plugin/worker/rsc/plugin.ts +38 -37
- package/plugin/worker/rsc/rsc-worker.development.ts +107 -0
- package/plugin/worker/rsc/rsc-worker.production.ts +13 -0
- package/plugin/worker/rsc/rsc-worker.tsx +5 -128
- package/plugin/worker/rsc/state.ts +37 -0
- package/plugin/worker/types.ts +83 -38
- package/scripts/check-react-version.mjs +17 -7
- package/scripts/react+0.0.0-experimental-b3a95caf-20250113.patch +143 -4170
- package/scripts/react-dom+0.0.0-experimental-b3a95caf-20250113.patch +14271 -90079
- package/dist/node_modules/magic-string/dist/magic-string.es.js +0 -1283
- package/dist/node_modules/magic-string/dist/magic-string.es.js.map +0 -1
- package/dist/plugin/build/createClientBuildConfig.d.ts +0 -3
- package/dist/plugin/build/createClientBuildConfig.d.ts.map +0 -1
- package/dist/plugin/build/createClientBuildConfig.js +0 -14
- package/dist/plugin/build/createServerBuildConfig.d.ts +0 -12
- package/dist/plugin/build/createServerBuildConfig.d.ts.map +0 -1
- package/dist/plugin/build/createServerBuildConfig.js +0 -40
- package/dist/plugin/build/createSharedBuildConfig.d.ts +0 -5
- package/dist/plugin/build/createSharedBuildConfig.d.ts.map +0 -1
- package/dist/plugin/build/createSharedBuildConfig.js +0 -28
- package/dist/plugin/build/mergeInputs.d.ts +0 -9
- package/dist/plugin/build/mergeInputs.d.ts.map +0 -1
- package/dist/plugin/build/mergeInputs.js +0 -56
- package/dist/plugin/components.js.map +0 -1
- package/dist/plugin/config/moduleIdDefault.d.ts +0 -8
- package/dist/plugin/config/moduleIdDefault.d.ts.map +0 -1
- package/dist/plugin/config/moduleIdDefault.js +0 -23
- package/dist/plugin/config/moduleIdDefault.js.map +0 -1
- package/dist/plugin/helpers/createClientInputNormalizer.d.ts +0 -8
- package/dist/plugin/helpers/createClientInputNormalizer.d.ts.map +0 -1
- package/dist/plugin/helpers/createClientInputNormalizer.js +0 -35
- package/dist/plugin/helpers/createServerInputNormalizer.d.ts +0 -9
- package/dist/plugin/helpers/createServerInputNormalizer.d.ts.map +0 -1
- package/dist/plugin/helpers/createServerInputNormalizer.js +0 -37
- package/dist/plugin/helpers/createStaticInputNormalizer.d.ts +0 -7
- package/dist/plugin/helpers/createStaticInputNormalizer.d.ts.map +0 -1
- package/dist/plugin/helpers/createStaticInputNormalizer.js +0 -18
- package/dist/plugin/helpers/getModuleManifest.d.ts +0 -12
- package/dist/plugin/helpers/getModuleManifest.d.ts.map +0 -1
- package/dist/plugin/helpers/getModuleManifest.js +0 -24
- package/dist/plugin/helpers/getModuleManifest.js.map +0 -1
- package/dist/plugin/helpers/inputNormalizerWorker.d.ts +0 -11
- package/dist/plugin/helpers/inputNormalizerWorker.d.ts.map +0 -1
- package/dist/plugin/helpers/inputNormalizerWorker.js +0 -30
- package/dist/plugin/helpers/normalizedRelativePath.d.ts +0 -11
- package/dist/plugin/helpers/normalizedRelativePath.d.ts.map +0 -1
- package/dist/plugin/helpers/normalizedRelativePath.js +0 -36
- package/dist/plugin/helpers/resolveFilePath.d.ts +0 -13
- package/dist/plugin/helpers/resolveFilePath.d.ts.map +0 -1
- package/dist/plugin/helpers/resolveFilePath.js +0 -74
- package/dist/plugin/helpers/resolveWorkerModule.d.ts +0 -6
- package/dist/plugin/helpers/resolveWorkerModule.d.ts.map +0 -1
- package/dist/plugin/helpers/resolveWorkerModule.js +0 -24
- package/dist/plugin/helpers/validateModuleBase.d.ts +0 -3
- package/dist/plugin/helpers/validateModuleBase.d.ts.map +0 -1
- package/dist/plugin/helpers/validateModuleBase.js +0 -16
- package/dist/plugin/helpers/validateResolvedConfig.d.ts +0 -3
- package/dist/plugin/helpers/validateResolvedConfig.d.ts.map +0 -1
- package/dist/plugin/helpers/validateResolvedConfig.js +0 -17
- package/dist/plugin/react-server/createDevMiddleware.d.ts +0 -8
- package/dist/plugin/react-server/createDevMiddleware.d.ts.map +0 -1
- package/dist/plugin/react-server/createDevMiddleware.js +0 -68
- package/dist/plugin/react-server/createDevServer.d.ts +0 -4
- package/dist/plugin/react-server/createDevServer.d.ts.map +0 -1
- package/dist/plugin/react-server/createDevServer.js +0 -4
- package/dist/plugin/react-server/createReactNodeStreamer.d.ts +0 -10
- package/dist/plugin/react-server/createReactNodeStreamer.d.ts.map +0 -1
- package/dist/plugin/react-server/createReactNodeStreamer.js +0 -7
- package/dist/plugin/transformer/transformer-client-components.d.ts +0 -21
- package/dist/plugin/transformer/transformer-client-components.d.ts.map +0 -1
- package/dist/plugin/transformer/transformer-client-components.js +0 -61
- package/dist/plugin/transformer/transformer-client-components.js.map +0 -1
- package/dist/plugin/transformer/transformer-server-actions.d.ts +0 -29
- package/dist/plugin/transformer/transformer-server-actions.d.ts.map +0 -1
- package/dist/plugin/transformer/transformer-server-actions.js +0 -76
- package/dist/plugin/transformer/transformer-server-actions.js.map +0 -1
- package/dist/plugin/worker/rsc/createRscStream.d.ts +0 -5
- package/dist/plugin/worker/rsc/createRscStream.d.ts.map +0 -1
- package/dist/plugin/worker/rsc/createRscStream.js +0 -39
- package/dist/plugin/worker/rsc/createRscStream.js.map +0 -1
- package/dist/plugin/worker/rsc/development.d.ts +0 -5
- package/dist/plugin/worker/rsc/development.d.ts.map +0 -1
- package/dist/plugin/worker/rsc/development.js +0 -13
- package/dist/plugin/worker/rsc/development.js.map +0 -1
- package/dist/plugin/worker/rsc/plugin.js.map +0 -1
- package/dist/plugin/worker/rsc/production.d.ts +0 -5
- package/dist/plugin/worker/rsc/production.d.ts.map +0 -1
- package/dist/plugin/worker/rsc/production.js +0 -13
- package/dist/plugin/worker/rsc/production.js.map +0 -1
- package/plugin/build/createClientBuildConfig.ts +0 -21
- package/plugin/build/createServerBuildConfig.ts +0 -66
- package/plugin/build/createSharedBuildConfig.ts +0 -35
- package/plugin/build/mergeInputs.ts +0 -58
- package/plugin/config/moduleIdDefault.ts +0 -23
- package/plugin/helpers/createClientInputNormalizer.ts +0 -48
- package/plugin/helpers/createServerInputNormalizer.ts +0 -52
- package/plugin/helpers/createStaticInputNormalizer.ts +0 -26
- package/plugin/helpers/getModuleManifest.ts +0 -31
- package/plugin/helpers/inputNormalizerWorker.ts +0 -47
- package/plugin/helpers/normalizedRelativePath.ts +0 -59
- package/plugin/helpers/resolveFilePath.ts +0 -108
- package/plugin/helpers/resolveWorkerModule.ts +0 -41
- package/plugin/helpers/validateModuleBase.ts +0 -30
- package/plugin/helpers/validateResolvedConfig.ts +0 -21
- package/plugin/react-server/createDevMiddleware.ts +0 -91
- package/plugin/react-server/createDevServer.ts +0 -9
- package/plugin/react-server/createReactNodeStreamer.ts +0 -26
- package/plugin/transformer/transformer-client-components.ts +0 -94
- package/plugin/transformer/transformer-server-actions.ts +0 -110
- package/plugin/worker/rsc/createRscStream.ts +0 -42
- package/plugin/worker/rsc/development.ts +0 -6
- package/plugin/worker/rsc/production.ts +0 -6
- package/scripts/react-server-dom-esm+0.0.1.patch +0 -24775
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { join, basename } from "node:path";
|
|
2
|
-
import { access, realpath } from "node:fs/promises";
|
|
3
|
-
import { normalizePath } from "vite";
|
|
4
|
-
import { getDistDir, getMode, getNodePath, getPluginRoot } from "../config/getPaths.js";
|
|
5
|
-
import pkg from "../../package.json" with { type: 'json' };
|
|
6
|
-
|
|
7
|
-
type ResolveOptions = {
|
|
8
|
-
projectRoot?: string;
|
|
9
|
-
nodePath?: string;
|
|
10
|
-
pluginRoot?: string;
|
|
11
|
-
filePath: string;
|
|
12
|
-
subDir?: string;
|
|
13
|
-
normalize?: boolean;
|
|
14
|
-
distDir?: string;
|
|
15
|
-
mode?: "production" | "development" | "test";
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export async function resolveFilePath({
|
|
19
|
-
projectRoot = process.cwd(),
|
|
20
|
-
nodePath = getNodePath(projectRoot),
|
|
21
|
-
mode = getMode(),
|
|
22
|
-
pluginRoot = getPluginRoot(),
|
|
23
|
-
distDir = getDistDir(mode),
|
|
24
|
-
filePath,
|
|
25
|
-
subDir,
|
|
26
|
-
normalize = false,
|
|
27
|
-
}: ResolveOptions) {
|
|
28
|
-
try {
|
|
29
|
-
let resolvedPath: string | undefined;
|
|
30
|
-
|
|
31
|
-
// Helper to check if file exists
|
|
32
|
-
const exists = async (path: string) => {
|
|
33
|
-
try {
|
|
34
|
-
await access(path);
|
|
35
|
-
return true;
|
|
36
|
-
} catch {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// If it's a plugin export (like '/rsc-worker'), use exports map
|
|
42
|
-
if (filePath.startsWith('/') && filePath.slice(1) in pkg.exports) {
|
|
43
|
-
const exportPath = filePath.slice(1);
|
|
44
|
-
const pluginPath = pkg.exports[exportPath as keyof typeof pkg.exports];
|
|
45
|
-
return join(process.cwd(), pluginRoot, pluginPath); // Make absolute
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// In test mode, preserve relative paths
|
|
49
|
-
if (mode === 'test' && !filePath.startsWith('/')) {
|
|
50
|
-
return filePath;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// For all other paths, try relative to project root first
|
|
54
|
-
const projectPath = join(projectRoot, filePath);
|
|
55
|
-
if (await exists(projectPath)) {
|
|
56
|
-
return normalize ? normalizePath(projectPath) : projectPath;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// 1. Try dist folder
|
|
60
|
-
const distPath = join(distDir, subDir ?? '', basename(filePath));
|
|
61
|
-
if (await exists(distPath)) {
|
|
62
|
-
resolvedPath = await realpath(distPath);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// 2. Try node_modules path
|
|
66
|
-
if (!resolvedPath && filePath.startsWith('/node_modules/')) {
|
|
67
|
-
const npmPath = join(nodePath, filePath.slice('/node_modules/'.length));
|
|
68
|
-
if (await exists(npmPath)) {
|
|
69
|
-
resolvedPath = await realpath(npmPath);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// 3. Try direct path
|
|
74
|
-
if (!resolvedPath && await exists(filePath)) {
|
|
75
|
-
resolvedPath = await realpath(filePath);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// 4. Try relative to project root
|
|
79
|
-
if (!resolvedPath) {
|
|
80
|
-
const projectPath = join(projectRoot, filePath);
|
|
81
|
-
if (await exists(projectPath)) {
|
|
82
|
-
resolvedPath = await realpath(projectPath);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (!resolvedPath) {
|
|
87
|
-
throw new Error(
|
|
88
|
-
`Could not resolve path. Tried:\n` +
|
|
89
|
-
`- ${distPath}\n` +
|
|
90
|
-
`- ${join(nodePath, filePath.slice('/node_modules/'.length))}\n` +
|
|
91
|
-
`- ${filePath}\n` +
|
|
92
|
-
`- ${join(projectRoot, filePath)}`
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return normalize ? normalizePath(
|
|
97
|
-
resolvedPath
|
|
98
|
-
.replace(pluginRoot, "/node_modules/vite-plugin-react-server")
|
|
99
|
-
.replace(projectRoot, "/")
|
|
100
|
-
.replace(nodePath, "/node_modules")
|
|
101
|
-
.replace(/^(?!\/)/, '/')
|
|
102
|
-
) : resolvedPath;
|
|
103
|
-
|
|
104
|
-
} catch (error) {
|
|
105
|
-
// If realpath fails, return normalized input path
|
|
106
|
-
return normalize ? normalizePath(filePath) : filePath;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { tryManifest } from "./tryManifest.js";
|
|
2
|
-
|
|
3
|
-
export async function resolveWorkerModule(
|
|
4
|
-
moduleGraph: Set<string> | string[],
|
|
5
|
-
options: {
|
|
6
|
-
root: string,
|
|
7
|
-
outDir: string,
|
|
8
|
-
workerPath: string
|
|
9
|
-
}
|
|
10
|
-
) {
|
|
11
|
-
console.log('Resolving worker module:', {
|
|
12
|
-
moduleGraph: Array.from(moduleGraph),
|
|
13
|
-
options
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
// Try module graph first
|
|
17
|
-
const workerModule = Array.from(moduleGraph).find(id =>
|
|
18
|
-
id.includes(options.workerPath)
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
console.log('Found in module graph:', workerModule);
|
|
22
|
-
|
|
23
|
-
if (workerModule) {
|
|
24
|
-
return workerModule;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Fallback to manifest
|
|
28
|
-
const resolvedManifest = tryManifest({
|
|
29
|
-
root: options.root,
|
|
30
|
-
outDir: options.outDir,
|
|
31
|
-
ssrManifest: false
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
console.log('Manifest result:', resolvedManifest);
|
|
35
|
-
|
|
36
|
-
if (resolvedManifest.type === "error") {
|
|
37
|
-
throw new Error(`Could not find worker path in module graph or manifest: ${options.workerPath}`);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return resolvedManifest.manifest[options.workerPath]?.file;
|
|
41
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { InputOption } from "rollup";
|
|
2
|
-
|
|
3
|
-
export function validateModuleBase(
|
|
4
|
-
input: InputOption,
|
|
5
|
-
moduleBase: string,
|
|
6
|
-
moduleBaseExceptions: string[]
|
|
7
|
-
) {
|
|
8
|
-
for (const [key, value] of Object.entries(input)) {
|
|
9
|
-
const isException =
|
|
10
|
-
moduleBaseExceptions.includes(key) || ["/index", "index"].includes(key);
|
|
11
|
-
if (!key.includes("/")) return;
|
|
12
|
-
if (value.startsWith("//")) {
|
|
13
|
-
throw new Error(`Path shouldn't start with //`);
|
|
14
|
-
}
|
|
15
|
-
if (!key.startsWith(moduleBase) && !isException) {
|
|
16
|
-
throw new Error(
|
|
17
|
-
`Invalid input: ${key} does not start with ${moduleBase}. If this is a valid key, add it to moduleBaseExceptions otherwise put the file in the ${moduleBase} directory. Exception: ${moduleBaseExceptions.join(
|
|
18
|
-
", "
|
|
19
|
-
)}`
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
if (!value.startsWith("/" + moduleBase) && !isException) {
|
|
23
|
-
throw new Error(
|
|
24
|
-
`Invalid value: ${value} does not start with ${moduleBase}. If this is a valid path, add it to moduleBaseExceptions otherwise put the file in the ${moduleBase} directory. Exception: ${moduleBaseExceptions.join(
|
|
25
|
-
", "
|
|
26
|
-
)}`
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { ResolvedConfig } from "vite";
|
|
2
|
-
|
|
3
|
-
export function validateResolvedConfig(config: ResolvedConfig): asserts config is ResolvedConfig {
|
|
4
|
-
if (
|
|
5
|
-
typeof config === "object" &&
|
|
6
|
-
config != null &&
|
|
7
|
-
"build" in config &&
|
|
8
|
-
typeof config.build === "object" &&
|
|
9
|
-
config.build != null &&
|
|
10
|
-
"rollupOptions" in config.build &&
|
|
11
|
-
typeof config.build.rollupOptions === "object" &&
|
|
12
|
-
config.build.rollupOptions != null &&
|
|
13
|
-
"input" in config.build.rollupOptions &&
|
|
14
|
-
typeof config.build.rollupOptions.input === "object" &&
|
|
15
|
-
config.build.rollupOptions.input != null
|
|
16
|
-
) {
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
throw new Error("Invalid config");
|
|
20
|
-
};
|
|
21
|
-
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { IncomingMessage, ServerResponse } from "http";
|
|
2
|
-
import type { ViteDevServer } from "vite";
|
|
3
|
-
import { type RequestHandler, type StreamPluginOptions } from "../types.js";
|
|
4
|
-
import { createHandler } from "./createHandler.js";
|
|
5
|
-
|
|
6
|
-
export type DevMiddlewareOptions = Required<
|
|
7
|
-
Pick<
|
|
8
|
-
StreamPluginOptions,
|
|
9
|
-
"moduleBase" | "moduleBasePath" | "moduleBaseURL" | "projectRoot"
|
|
10
|
-
>
|
|
11
|
-
> &
|
|
12
|
-
Pick<StreamPluginOptions, "Page" | "props" | "build" | "Html" | "pageExportName" | "propsExportName">;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Creates a request handler for development
|
|
16
|
-
*/
|
|
17
|
-
export function createDevMiddleware(
|
|
18
|
-
server: ViteDevServer,
|
|
19
|
-
options: DevMiddlewareOptions
|
|
20
|
-
): RequestHandler {
|
|
21
|
-
// Add HMR support
|
|
22
|
-
const hmr = server.hot;
|
|
23
|
-
|
|
24
|
-
hmr?.on('vite:beforeUpdate', () => {
|
|
25
|
-
// Clear module cache before updates
|
|
26
|
-
server.moduleGraph.invalidateAll();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
return async (req: IncomingMessage, res: ServerResponse, next: any) => {
|
|
30
|
-
// Skip non-page requests
|
|
31
|
-
if (
|
|
32
|
-
!req.url ||
|
|
33
|
-
(req.url.includes(".") && !req.url.endsWith("/index.rsc"))
|
|
34
|
-
) {
|
|
35
|
-
return next();
|
|
36
|
-
}
|
|
37
|
-
const url = req.url.endsWith("/index.rsc")
|
|
38
|
-
? req.url.replace("/index.rsc", "/")
|
|
39
|
-
: req.url;
|
|
40
|
-
|
|
41
|
-
try {
|
|
42
|
-
console.log("[stream] Handling RSC stream");
|
|
43
|
-
|
|
44
|
-
const result = await createHandler(url, options, {
|
|
45
|
-
loader: (id)=>{
|
|
46
|
-
const mod = server.ssrLoadModule(id);
|
|
47
|
-
if(!mod) {
|
|
48
|
-
throw new Error(`[RSC] Module not found: ${id}`);
|
|
49
|
-
} else {
|
|
50
|
-
console.log('[RSC] Loaded module:', id);
|
|
51
|
-
}
|
|
52
|
-
return mod;
|
|
53
|
-
},
|
|
54
|
-
moduleGraph: server.moduleGraph,
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
if (result.type === "error") {
|
|
58
|
-
if (
|
|
59
|
-
(result.error as Error).message?.includes(
|
|
60
|
-
"module runner has been closed"
|
|
61
|
-
)
|
|
62
|
-
) {
|
|
63
|
-
console.log("[RSC] Module runner closed, returning 503");
|
|
64
|
-
res.writeHead(503, { "Content-Type": "text/x-component" });
|
|
65
|
-
res.end('{"error":"Server restarting..."}');
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
console.error("[RSC] Stream error:", result.error);
|
|
69
|
-
res.writeHead(500, { "Content-Type": "text/x-component" });
|
|
70
|
-
res.end('{"error":"Internal Server Error"}');
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (result.type !== "success") {
|
|
75
|
-
res.end();
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
res.setHeader("Content-Type", "text/x-component");
|
|
80
|
-
if (result.stream) result.stream.pipe(res);
|
|
81
|
-
} catch (error: any) {
|
|
82
|
-
if (error.message?.includes("module runner has been closed")) {
|
|
83
|
-
console.log("[RSC] Module runner closed, returning 503");
|
|
84
|
-
res.writeHead(503, { "Content-Type": "text/x-component" });
|
|
85
|
-
res.end('{"error":"Server restarting..."}');
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
next(error);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ViteDevServer } from "vite";
|
|
2
|
-
import { createDevMiddleware, type DevMiddlewareOptions } from "./createDevMiddleware.js";
|
|
3
|
-
|
|
4
|
-
export function createDevServer(
|
|
5
|
-
server: ViteDevServer,
|
|
6
|
-
options: DevMiddlewareOptions
|
|
7
|
-
) {
|
|
8
|
-
server.middlewares.use(createDevMiddleware(server, options));
|
|
9
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
createFromNodeStream,
|
|
4
|
-
type CreateFromNodeStreamOptions,
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
} from "react-server-dom-esm/client.node";
|
|
7
|
-
import type { Readable } from "stream";
|
|
8
|
-
|
|
9
|
-
export function createReactNodeStreamer({
|
|
10
|
-
stream,
|
|
11
|
-
moduleBasePath,
|
|
12
|
-
moduleBaseURL,
|
|
13
|
-
options,
|
|
14
|
-
}: {
|
|
15
|
-
stream: Readable;
|
|
16
|
-
moduleBasePath: string;
|
|
17
|
-
moduleBaseURL: string;
|
|
18
|
-
options?: CreateFromNodeStreamOptions;
|
|
19
|
-
}) {
|
|
20
|
-
return createFromNodeStream(
|
|
21
|
-
stream,
|
|
22
|
-
moduleBasePath,
|
|
23
|
-
moduleBaseURL,
|
|
24
|
-
options
|
|
25
|
-
) as React.Usable<React.ReactNode>;
|
|
26
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import type { Plugin as RollupPlugin } from "rollup";
|
|
2
|
-
import type { TransformerOptions } from "./types.js";
|
|
3
|
-
|
|
4
|
-
export function createClientComponentTransformer({
|
|
5
|
-
moduleId: userModuleId,
|
|
6
|
-
}: TransformerOptions): RollupPlugin {
|
|
7
|
-
let moduleIdFn = userModuleId;
|
|
8
|
-
|
|
9
|
-
return {
|
|
10
|
-
name: "vite-plugin-react-server:client-components-transformer",
|
|
11
|
-
|
|
12
|
-
async transform(code: string, id: string, options?: { ssr?: boolean }) {
|
|
13
|
-
try {
|
|
14
|
-
// Skip node_modules and vite internal files
|
|
15
|
-
if (id.includes('node_modules') || id.includes('vite/dist')) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Check if this is a client component from metadata or directive
|
|
20
|
-
const info = this?.getModuleInfo(id);
|
|
21
|
-
const hasDirective = code.match(/^["']use client["'];?/);
|
|
22
|
-
const isClientComponent = hasDirective || info?.meta?.['directives']?.includes('use client');
|
|
23
|
-
|
|
24
|
-
if (!isClientComponent) {
|
|
25
|
-
return null; // Not a client component, skip
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
let transformedCode = code;
|
|
29
|
-
const moduleId = moduleIdFn!(id, options?.ssr ?? false);
|
|
30
|
-
|
|
31
|
-
// Find all named exports
|
|
32
|
-
const exportMatches = Array.from(
|
|
33
|
-
code.matchAll(/export\s+(?:const|let|var|function|class)\s+(\w+)/g)
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
if (!exportMatches.length) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Transform each export
|
|
41
|
-
for (const [fullMatch, exportName] of exportMatches) {
|
|
42
|
-
if (!exportName) continue;
|
|
43
|
-
|
|
44
|
-
const isClass = fullMatch.includes("class");
|
|
45
|
-
|
|
46
|
-
// Remove export keyword
|
|
47
|
-
transformedCode = transformedCode.replace(
|
|
48
|
-
fullMatch,
|
|
49
|
-
fullMatch.replace("export ", "")
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
transformedCode += `
|
|
53
|
-
const ${exportName}Ref = Object.defineProperties(
|
|
54
|
-
${isClass
|
|
55
|
-
? `class extends ${exportName} {
|
|
56
|
-
constructor(...args) { super(...args); }
|
|
57
|
-
}`
|
|
58
|
-
: `function(...args) { return ${exportName}.apply(null, args); }`
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
$$typeof: { value: Symbol.for("react.client.reference") },
|
|
62
|
-
$$id: { value: ${JSON.stringify(moduleId + "#" + exportName)} },
|
|
63
|
-
$$filepath: { value: ${JSON.stringify(id)} }
|
|
64
|
-
}
|
|
65
|
-
);
|
|
66
|
-
export { ${exportName}Ref as ${exportName} };`;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return { code: transformedCode, map: null };
|
|
70
|
-
} catch (error) {
|
|
71
|
-
console.error(`[RSC] Error transforming client component: ${id}`, error);
|
|
72
|
-
throw error;
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* transformedCode += `
|
|
80
|
-
const ${exportName}Ref = Object.defineProperties(
|
|
81
|
-
${
|
|
82
|
-
isClass
|
|
83
|
-
? `class extends ${exportName} {
|
|
84
|
-
constructor(...args) { super(...args); }
|
|
85
|
-
}`
|
|
86
|
-
: `function(...args) { return ${exportName}.apply(null, args); }`
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
$$typeof: { value: Symbol.for("react.client.reference") },
|
|
90
|
-
$$id: { value: ${JSON.stringify(moduleId + "#" + exportName)} }
|
|
91
|
-
}
|
|
92
|
-
);
|
|
93
|
-
export { ${exportName}Ref as ${exportName} };`;
|
|
94
|
-
*/
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { SourceMapGenerator } from "source-map";
|
|
2
|
-
import type { TransformerOptions } from "./types.js";
|
|
3
|
-
|
|
4
|
-
export function createServerActionTransformer(options: TransformerOptions) {
|
|
5
|
-
return {
|
|
6
|
-
name: "vite-plugin-react-server:server-actions-transformer",
|
|
7
|
-
enforce: "post" as const,
|
|
8
|
-
|
|
9
|
-
async transform(
|
|
10
|
-
code: string,
|
|
11
|
-
path: string,
|
|
12
|
-
{ ssr }: { ssr: boolean } = { ssr: false }
|
|
13
|
-
) {
|
|
14
|
-
try {
|
|
15
|
-
let transformedCode = code;
|
|
16
|
-
const directiveMatch = code.match(/^["']use server["'];?/);
|
|
17
|
-
const moduleId = options.moduleId(path, ssr);
|
|
18
|
-
|
|
19
|
-
// Log the path transformation
|
|
20
|
-
console.log("[RSC Transform] Module path transformation:", {
|
|
21
|
-
original: path,
|
|
22
|
-
transformed: moduleId,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// Find all named exports
|
|
26
|
-
const exportMatches = Array.from(
|
|
27
|
-
code.matchAll(/export\s+(?:const|let|var|function|class)\s+(\w+)/g)
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
if (!exportMatches.length) {
|
|
31
|
-
console.warn(
|
|
32
|
-
`[RSC] No exports found in server action module: ${path}`
|
|
33
|
-
);
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Transform each export
|
|
38
|
-
for (const [fullMatch, exportName] of exportMatches) {
|
|
39
|
-
if (!exportName) {
|
|
40
|
-
console.warn(
|
|
41
|
-
`[RSC] Invalid export in server action module: ${path}`
|
|
42
|
-
);
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const isClass = fullMatch.includes("class");
|
|
47
|
-
|
|
48
|
-
// Remove export keyword
|
|
49
|
-
transformedCode = transformedCode.replace(
|
|
50
|
-
fullMatch,
|
|
51
|
-
fullMatch.replace("export ", "")
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
if (!directiveMatch || directiveMatch.index !== 0) {
|
|
55
|
-
// Server action
|
|
56
|
-
} else {
|
|
57
|
-
// Client component
|
|
58
|
-
transformedCode += `
|
|
59
|
-
const ${exportName}Ref = Object.defineProperties(
|
|
60
|
-
${
|
|
61
|
-
isClass
|
|
62
|
-
? `class extends ${exportName} {
|
|
63
|
-
constructor(...args) { super(...args); }
|
|
64
|
-
}`
|
|
65
|
-
: `function(...args) { return ${exportName}.apply(null, args); }`
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
$$typeof: { value: Symbol.for("react.server.reference") },
|
|
69
|
-
$$id: { value: ${JSON.stringify(moduleId + "#" + exportName)} },
|
|
70
|
-
$$filepath: { value: ${JSON.stringify(path)} },
|
|
71
|
-
$$async: { value: true }
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
export { ${exportName}Ref as ${exportName} };
|
|
75
|
-
`;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
code: transformedCode,
|
|
81
|
-
map: new SourceMapGenerator({ file: path }).toString(),
|
|
82
|
-
};
|
|
83
|
-
} catch (error) {
|
|
84
|
-
console.error(
|
|
85
|
-
`[RSC] Error transforming client component: ${path}`,
|
|
86
|
-
error
|
|
87
|
-
);
|
|
88
|
-
throw error;
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* transformedCode += `
|
|
96
|
-
const ${exportName}Ref = Object.defineProperties(
|
|
97
|
-
${
|
|
98
|
-
isClass
|
|
99
|
-
? `class extends ${exportName} {
|
|
100
|
-
constructor(...args) { super(...args); }
|
|
101
|
-
}`
|
|
102
|
-
: `function(...args) { return ${exportName}.apply(null, args); }`
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
$$typeof: { value: Symbol.for("react.client.reference") },
|
|
106
|
-
$$id: { value: ${JSON.stringify(moduleId + "#" + exportName)} }
|
|
107
|
-
}
|
|
108
|
-
);
|
|
109
|
-
export { ${exportName}Ref as ${exportName} };`;
|
|
110
|
-
*/
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { renderToPipeableStream
|
|
2
|
-
// @ts-ignore
|
|
3
|
-
} from "react-server-dom-esm/server.node";
|
|
4
|
-
import type { Writable } from "node:stream";
|
|
5
|
-
import type { MessagePort } from "node:worker_threads";
|
|
6
|
-
import type { RscRenderState } from "../types.js";
|
|
7
|
-
|
|
8
|
-
export function createRscStream(
|
|
9
|
-
renderState: RscRenderState,
|
|
10
|
-
writeStream: Writable,
|
|
11
|
-
parentPort: MessagePort | null
|
|
12
|
-
) {
|
|
13
|
-
console.log("[createRscStream] Creating stream for:", renderState.id);
|
|
14
|
-
|
|
15
|
-
const stream = renderToPipeableStream(renderState.componentImport, {
|
|
16
|
-
onShellReady() {
|
|
17
|
-
console.log("[createRscStream] onShellReady called for:", renderState.id);
|
|
18
|
-
stream.pipe(writeStream);
|
|
19
|
-
},
|
|
20
|
-
onAllReady() {
|
|
21
|
-
console.log("[createRscStream] onAllReady called for:", renderState.id);
|
|
22
|
-
writeStream.on("finish", () => {
|
|
23
|
-
parentPort?.postMessage({
|
|
24
|
-
type: "WROTE_FILE",
|
|
25
|
-
id: renderState.id,
|
|
26
|
-
outputPath: renderState.rscOutputPath
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
},
|
|
30
|
-
onError(error: unknown) {
|
|
31
|
-
console.error("[createRscStream] Render error:", error);
|
|
32
|
-
parentPort?.postMessage({
|
|
33
|
-
type: "ERROR",
|
|
34
|
-
error: error instanceof Error ? error.message : String(error),
|
|
35
|
-
id: renderState.id
|
|
36
|
-
});
|
|
37
|
-
stream.abort();
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
return stream;
|
|
42
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { createRscStream as devCreateRscStream } from './createRscStream.js';
|
|
2
|
-
import { createWorker as devCreateWorker } from '../createWorker.js';
|
|
3
|
-
|
|
4
|
-
// Development-specific implementations
|
|
5
|
-
export const createRscStream = devCreateRscStream;
|
|
6
|
-
export const createWorker = devCreateWorker;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { createRscStream as prodCreateRscStream } from './createRscStream.js';
|
|
2
|
-
import { createWorker as prodCreateWorker } from '../createWorker.js';
|
|
3
|
-
|
|
4
|
-
// Production-specific optimizations could go here
|
|
5
|
-
export const createRscStream = prodCreateRscStream;
|
|
6
|
-
export const createWorker = prodCreateWorker;
|