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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createRscStream.d.ts","sourceRoot":"","sources":["../../../../plugin/worker/rsc/createRscStream.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,wBAAgB,eAAe,CAC7B,WAAW,EAAE,cAAc,EAC3B,WAAW,EAAE,QAAQ,EACrB,UAAU,EAAE,WAAW,GAAG,IAAI,OA+B/B"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vite-plugin-react-server
|
|
3
|
-
* Copyright (c) Nico Brinkkemper
|
|
4
|
-
* MIT License
|
|
5
|
-
*/
|
|
6
|
-
import { renderToPipeableStream } from 'react-server-dom-esm/server.node';
|
|
7
|
-
|
|
8
|
-
function createRscStream(renderState, writeStream, parentPort) {
|
|
9
|
-
console.log("[createRscStream] Creating stream for:", renderState.id);
|
|
10
|
-
const stream = renderToPipeableStream(renderState.componentImport, {
|
|
11
|
-
onShellReady() {
|
|
12
|
-
console.log("[createRscStream] onShellReady called for:", renderState.id);
|
|
13
|
-
stream.pipe(writeStream);
|
|
14
|
-
},
|
|
15
|
-
onAllReady() {
|
|
16
|
-
console.log("[createRscStream] onAllReady called for:", renderState.id);
|
|
17
|
-
writeStream.on("finish", () => {
|
|
18
|
-
parentPort?.postMessage({
|
|
19
|
-
type: "WROTE_FILE",
|
|
20
|
-
id: renderState.id,
|
|
21
|
-
outputPath: renderState.rscOutputPath
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
},
|
|
25
|
-
onError(error) {
|
|
26
|
-
console.error("[createRscStream] Render error:", error);
|
|
27
|
-
parentPort?.postMessage({
|
|
28
|
-
type: "ERROR",
|
|
29
|
-
error: error instanceof Error ? error.message : String(error),
|
|
30
|
-
id: renderState.id
|
|
31
|
-
});
|
|
32
|
-
stream.abort();
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
return stream;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export { createRscStream };
|
|
39
|
-
//# sourceMappingURL=createRscStream.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createRscStream.js","sources":["../../../../plugin/worker/rsc/createRscStream.ts"],"sourcesContent":["import { renderToPipeableStream \n // @ts-ignore\n} from \"react-server-dom-esm/server.node\";\nimport type { Writable } from \"node:stream\";\nimport type { MessagePort } from \"node:worker_threads\";\nimport type { RscRenderState } from \"../types.js\";\n\nexport function createRscStream(\n renderState: RscRenderState,\n writeStream: Writable,\n parentPort: MessagePort | null\n) {\n console.log(\"[createRscStream] Creating stream for:\", renderState.id);\n\n const stream = renderToPipeableStream(renderState.componentImport, {\n onShellReady() {\n console.log(\"[createRscStream] onShellReady called for:\", renderState.id);\n stream.pipe(writeStream);\n },\n onAllReady() {\n console.log(\"[createRscStream] onAllReady called for:\", renderState.id);\n writeStream.on(\"finish\", () => {\n parentPort?.postMessage({\n type: \"WROTE_FILE\",\n id: renderState.id,\n outputPath: renderState.rscOutputPath\n });\n });\n },\n onError(error: unknown) {\n console.error(\"[createRscStream] Render error:\", error);\n parentPort?.postMessage({\n type: \"ERROR\",\n error: error instanceof Error ? error.message : String(error),\n id: renderState.id\n });\n stream.abort();\n }\n });\n\n return stream;\n}\n"],"names":[],"mappings":";;;;;;;AAOgB,SAAA,eAAA,CACd,WACA,EAAA,WAAA,EACA,UACA,EAAA;AACA,EAAQ,OAAA,CAAA,GAAA,CAAI,wCAA0C,EAAA,WAAA,CAAY,EAAE,CAAA;AAEpE,EAAM,MAAA,MAAA,GAAS,sBAAuB,CAAA,WAAA,CAAY,eAAiB,EAAA;AAAA,IACjE,YAAe,GAAA;AACb,MAAQ,OAAA,CAAA,GAAA,CAAI,4CAA8C,EAAA,WAAA,CAAY,EAAE,CAAA;AACxE,MAAA,MAAA,CAAO,KAAK,WAAW,CAAA;AAAA,KACzB;AAAA,IACA,UAAa,GAAA;AACX,MAAQ,OAAA,CAAA,GAAA,CAAI,0CAA4C,EAAA,WAAA,CAAY,EAAE,CAAA;AACtE,MAAY,WAAA,CAAA,EAAA,CAAG,UAAU,MAAM;AAC7B,QAAA,UAAA,EAAY,WAAY,CAAA;AAAA,UACtB,IAAM,EAAA,YAAA;AAAA,UACN,IAAI,WAAY,CAAA,EAAA;AAAA,UAChB,YAAY,WAAY,CAAA;AAAA,SACzB,CAAA;AAAA,OACF,CAAA;AAAA,KACH;AAAA,IACA,QAAQ,KAAgB,EAAA;AACtB,MAAQ,OAAA,CAAA,KAAA,CAAM,mCAAmC,KAAK,CAAA;AACtD,MAAA,UAAA,EAAY,WAAY,CAAA;AAAA,QACtB,IAAM,EAAA,OAAA;AAAA,QACN,OAAO,KAAiB,YAAA,KAAA,GAAQ,KAAM,CAAA,OAAA,GAAU,OAAO,KAAK,CAAA;AAAA,QAC5D,IAAI,WAAY,CAAA;AAAA,OACjB,CAAA;AACD,MAAA,MAAA,CAAO,KAAM,EAAA;AAAA;AACf,GACD,CAAA;AAED,EAAO,OAAA,MAAA;AACT;;;;"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { createRscStream as devCreateRscStream } from './createRscStream.js';
|
|
2
|
-
import { createWorker as devCreateWorker } from '../createWorker.js';
|
|
3
|
-
export declare const createRscStream: typeof devCreateRscStream;
|
|
4
|
-
export declare const createWorker: typeof devCreateWorker;
|
|
5
|
-
//# sourceMappingURL=development.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"development.d.ts","sourceRoot":"","sources":["../../../../plugin/worker/rsc/development.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,YAAY,IAAI,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrE,eAAO,MAAM,eAAe,2BAAqB,CAAC;AAClD,eAAO,MAAM,YAAY,wBAAkB,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vite-plugin-react-server
|
|
3
|
-
* Copyright (c) Nico Brinkkemper
|
|
4
|
-
* MIT License
|
|
5
|
-
*/
|
|
6
|
-
import { createRscStream as createRscStream$1 } from './createRscStream.js';
|
|
7
|
-
import { createWorker as createWorker$1 } from '../createWorker.js';
|
|
8
|
-
|
|
9
|
-
const createRscStream = createRscStream$1;
|
|
10
|
-
const createWorker = createWorker$1;
|
|
11
|
-
|
|
12
|
-
export { createRscStream, createWorker };
|
|
13
|
-
//# sourceMappingURL=development.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"development.js","sources":["../../../../plugin/worker/rsc/development.ts"],"sourcesContent":["import { createRscStream as devCreateRscStream } from './createRscStream.js';\nimport { createWorker as devCreateWorker } from '../createWorker.js';\n\n// Development-specific implementations\nexport const createRscStream = devCreateRscStream;\nexport const createWorker = devCreateWorker; "],"names":["devCreateRscStream","devCreateWorker"],"mappings":";;;;;;;;AAIO,MAAM,eAAkB,GAAAA;AACxB,MAAM,YAAe,GAAAC;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["../../../../plugin/worker/rsc/plugin.ts"],"sourcesContent":["import type { Plugin } from \"vite\";\nimport { resolve } from \"path\";\nimport type { ModuleFormat } from 'rollup';\nimport type { StreamPluginOptions } from \"../../types.js\";\nimport { DEFAULT_CONFIG } from \"../../config/defaults.js\";\nimport { getPluginRoot } from \"../../config/getPaths.js\";\n\nexport function reactRscWorkerPlugin(options: StreamPluginOptions): Plugin {\n return {\n name: \"vite:react-rsc-worker\",\n config(config) {\n const root = config.root ?? process.cwd();\n const pluginRoot = getPluginRoot();\n const rscWorkerPath = typeof options.rscWorkerPath === 'string' \n ? resolve(root, options.rscWorkerPath) \n : resolve(pluginRoot, DEFAULT_CONFIG.RSC_WORKER_PATH);\n \n const format: ModuleFormat = 'esm';\n\n // Single worker output for server build\n const workerConfig = {\n input: {\n 'rsc-worker': rscWorkerPath,\n },\n output: {\n format,\n dir: options.build?.server ?? 'dist/server', // Output to server directory\n entryFileNames: '[name].js',\n preserveModules: true,\n manualChunks: {\n 'rsc-worker': [rscWorkerPath]\n },\n resolve: {\n conditions: ['react-server'],\n }\n }\n };\n\n return {\n build: {\n rollupOptions: {\n preserveEntrySignatures: 'strict',\n input: {\n ...workerConfig.input,\n ...(typeof config.build?.rollupOptions?.input === 'object' \n ? config.build?.rollupOptions?.input \n : {}),\n },\n external: [\n 'vite',\n 'rollup',\n 'react',\n 'react-dom',\n 'react-dom/server',\n 'react-server-dom-esm',\n 'react-server-dom-esm/client.node',\n 'react-server-dom-esm/server.node',\n 'react-server-dom-esm/node-loader',\n 'source-map',\n 'acorn-loose',\n 'webpack-sources',\n 'stream',\n 'util',\n 'crypto',\n 'async_hooks',\n 'fs',\n 'path',\n 'worker_threads',\n // if we use node: paths in our code, it should always be catched by below rule.\n /^node:.*/,\n ],\n output: {\n ...workerConfig.output,\n }\n },\n manifest: true, // Ensure manifest is generated\n minify: false,\n sourcemap: true,\n }\n };\n },\n };\n}\n"],"names":[],"mappings":";;;;;;;;;AAOO,SAAS,qBAAqB,OAAsC,EAAA;AACzE,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,uBAAA;AAAA,IACN,OAAO,MAAQ,EAAA;AACb,MAAA,MAAM,IAAO,GAAA,MAAA,CAAO,IAAQ,IAAA,OAAA,CAAQ,GAAI,EAAA;AACxC,MAAA,MAAM,aAAa,aAAc,EAAA;AACjC,MAAA,MAAM,aAAgB,GAAA,OAAO,OAAQ,CAAA,aAAA,KAAkB,QACnD,GAAA,OAAA,CAAQ,IAAM,EAAA,OAAA,CAAQ,aAAa,CAAA,GACnC,OAAQ,CAAA,UAAA,EAAY,eAAe,eAAe,CAAA;AAEtD,MAAA,MAAM,MAAuB,GAAA,KAAA;AAG7B,MAAA,MAAM,YAAe,GAAA;AAAA,QACnB,KAAO,EAAA;AAAA,UACL,YAAc,EAAA;AAAA,SAChB;AAAA,QACA,MAAQ,EAAA;AAAA,UACN,MAAA;AAAA,UACA,GAAA,EAAK,OAAQ,CAAA,KAAA,EAAO,MAAU,IAAA,aAAA;AAAA;AAAA,UAC9B,cAAgB,EAAA,WAAA;AAAA,UAChB,eAAiB,EAAA,IAAA;AAAA,UACjB,YAAc,EAAA;AAAA,YACZ,YAAA,EAAc,CAAC,aAAa;AAAA,WAC9B;AAAA,UACA,OAAS,EAAA;AAAA,YACP,UAAA,EAAY,CAAC,cAAc;AAAA;AAC7B;AACF,OACF;AAEA,MAAO,OAAA;AAAA,QACL,KAAO,EAAA;AAAA,UACL,aAAe,EAAA;AAAA,YACb,uBAAyB,EAAA,QAAA;AAAA,YACzB,KAAO,EAAA;AAAA,cACL,GAAG,YAAa,CAAA,KAAA;AAAA,cAChB,GAAI,OAAO,MAAA,CAAO,KAAO,EAAA,aAAA,EAAe,KAAU,KAAA,QAAA,GAC9C,MAAO,CAAA,KAAA,EAAO,aAAe,EAAA,KAAA,GAC7B;AAAC,aACP;AAAA,YACA,QAAU,EAAA;AAAA,cACR,MAAA;AAAA,cACA,QAAA;AAAA,cACA,OAAA;AAAA,cACA,WAAA;AAAA,cACA,kBAAA;AAAA,cACA,sBAAA;AAAA,cACA,kCAAA;AAAA,cACA,kCAAA;AAAA,cACA,kCAAA;AAAA,cACA,YAAA;AAAA,cACA,aAAA;AAAA,cACA,iBAAA;AAAA,cACA,QAAA;AAAA,cACA,MAAA;AAAA,cACA,QAAA;AAAA,cACA,aAAA;AAAA,cACA,IAAA;AAAA,cACA,MAAA;AAAA,cACA,gBAAA;AAAA;AAAA,cAEA;AAAA,aACF;AAAA,YACA,MAAQ,EAAA;AAAA,cACN,GAAG,YAAa,CAAA;AAAA;AAClB,WACF;AAAA,UACA,QAAU,EAAA,IAAA;AAAA;AAAA,UACV,MAAQ,EAAA,KAAA;AAAA,UACR,SAAW,EAAA;AAAA;AACb,OACF;AAAA;AACF,GACF;AACF;;;;"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { createRscStream as prodCreateRscStream } from './createRscStream.js';
|
|
2
|
-
import { createWorker as prodCreateWorker } from '../createWorker.js';
|
|
3
|
-
export declare const createRscStream: typeof prodCreateRscStream;
|
|
4
|
-
export declare const createWorker: typeof prodCreateWorker;
|
|
5
|
-
//# sourceMappingURL=production.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"production.d.ts","sourceRoot":"","sources":["../../../../plugin/worker/rsc/production.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtE,eAAO,MAAM,eAAe,4BAAsB,CAAC;AACnD,eAAO,MAAM,YAAY,yBAAmB,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vite-plugin-react-server
|
|
3
|
-
* Copyright (c) Nico Brinkkemper
|
|
4
|
-
* MIT License
|
|
5
|
-
*/
|
|
6
|
-
import { createRscStream as createRscStream$1 } from './createRscStream.js';
|
|
7
|
-
import { createWorker as createWorker$1 } from '../createWorker.js';
|
|
8
|
-
|
|
9
|
-
const createRscStream = createRscStream$1;
|
|
10
|
-
const createWorker = createWorker$1;
|
|
11
|
-
|
|
12
|
-
export { createRscStream, createWorker };
|
|
13
|
-
//# sourceMappingURL=production.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"production.js","sources":["../../../../plugin/worker/rsc/production.ts"],"sourcesContent":["import { createRscStream as prodCreateRscStream } from './createRscStream.js';\nimport { createWorker as prodCreateWorker } from '../createWorker.js';\n\n// Production-specific optimizations could go here\nexport const createRscStream = prodCreateRscStream;\nexport const createWorker = prodCreateWorker; "],"names":["prodCreateRscStream","prodCreateWorker"],"mappings":";;;;;;;;AAIO,MAAM,eAAkB,GAAAA;AACxB,MAAM,YAAe,GAAAC;;;;"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { mergeInputsAsync } from "./mergeInputs.js";
|
|
2
|
-
import type { createBuildConfigFn } from "../types.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export const createClientBuildConfig: createBuildConfigFn<'react-client'> = async ({
|
|
6
|
-
userConfig,
|
|
7
|
-
inputNormalizer
|
|
8
|
-
}) => {
|
|
9
|
-
const { input: inputConfig, ...restRollupOptions } = userConfig.build.rollupOptions ?? {};
|
|
10
|
-
|
|
11
|
-
return {
|
|
12
|
-
...userConfig,
|
|
13
|
-
build: {
|
|
14
|
-
...userConfig.build,
|
|
15
|
-
rollupOptions: {
|
|
16
|
-
...restRollupOptions,
|
|
17
|
-
input: await mergeInputsAsync({}, inputConfig, inputNormalizer),
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
import type { ResolvedUserConfig, ResolvedUserOptions } from "../types.js";
|
|
3
|
-
import type { UserConfig } from "vite";
|
|
4
|
-
|
|
5
|
-
interface CreateServerBuildConfigProps {
|
|
6
|
-
condition: string;
|
|
7
|
-
userConfig: ResolvedUserConfig;
|
|
8
|
-
userOptions: ResolvedUserOptions;
|
|
9
|
-
mode: string;
|
|
10
|
-
inputNormalizer: any;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export async function createServerBuildConfig({
|
|
14
|
-
userConfig,
|
|
15
|
-
userOptions,
|
|
16
|
-
mode,
|
|
17
|
-
}: CreateServerBuildConfigProps): Promise<UserConfig> {
|
|
18
|
-
const { build, appType, mode: configMode, ...restUserConfig } = userConfig;
|
|
19
|
-
const { outDir, ssr, target, assetsDir, manifest, ssrManifest, ssrEmitAssets, rollupOptions, ...restBuildOptions } = build ?? {};
|
|
20
|
-
const { input, output, ...restRollupOptions } = rollupOptions ?? {};
|
|
21
|
-
const {
|
|
22
|
-
format,
|
|
23
|
-
preserveModules,
|
|
24
|
-
hoistTransitiveImports,
|
|
25
|
-
esModule,
|
|
26
|
-
entryFileNames,
|
|
27
|
-
chunkFileNames,
|
|
28
|
-
assetFileNames,
|
|
29
|
-
...restOutputOptions
|
|
30
|
-
} = output && !Array.isArray(output) ? output : {};
|
|
31
|
-
|
|
32
|
-
const resolvedBuildConfig = {
|
|
33
|
-
build: {
|
|
34
|
-
ssr: ssr ?? true,
|
|
35
|
-
target: target ?? 'es2020',
|
|
36
|
-
outDir: outDir ?? userOptions.build.server,
|
|
37
|
-
assetsDir: assetsDir ?? '',
|
|
38
|
-
manifest: manifest ?? true,
|
|
39
|
-
ssrManifest: ssrManifest ?? true,
|
|
40
|
-
ssrEmitAssets: ssrEmitAssets ?? true,
|
|
41
|
-
rollupOptions: {
|
|
42
|
-
input: {
|
|
43
|
-
'client': join(userOptions.projectRoot, userOptions.clientEntry)
|
|
44
|
-
},
|
|
45
|
-
output: {
|
|
46
|
-
format: format ?? 'esm',
|
|
47
|
-
preserveModules: preserveModules ?? true,
|
|
48
|
-
hoistTransitiveImports: hoistTransitiveImports ?? false,
|
|
49
|
-
esModule: esModule ?? true,
|
|
50
|
-
entryFileNames: entryFileNames ?? '[name].js',
|
|
51
|
-
chunkFileNames: chunkFileNames ?? '[name].js',
|
|
52
|
-
assetFileNames: assetFileNames ?? '[name][extname]',
|
|
53
|
-
...restOutputOptions
|
|
54
|
-
},
|
|
55
|
-
...restRollupOptions
|
|
56
|
-
},
|
|
57
|
-
...restBuildOptions
|
|
58
|
-
},
|
|
59
|
-
appType: appType ?? 'mpa',
|
|
60
|
-
mode: mode ?? 'production',
|
|
61
|
-
...restUserConfig
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
console.log('resolvedBuildConfig', resolvedBuildConfig);
|
|
65
|
-
return resolvedBuildConfig;
|
|
66
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { InputOption } from "rollup";
|
|
2
|
-
import type { UserConfig } from "vite";
|
|
3
|
-
|
|
4
|
-
export function validateModuleBase(
|
|
5
|
-
input: InputOption,
|
|
6
|
-
moduleBase: string,
|
|
7
|
-
moduleBaseExceptions: string[]
|
|
8
|
-
) {
|
|
9
|
-
for (const [key, value] of Object.entries(input)) {
|
|
10
|
-
const isException = 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(`Invalid input: ${key} does not start with ${moduleBase}`);
|
|
17
|
-
}
|
|
18
|
-
if (!value.startsWith("/" + moduleBase) && !isException) {
|
|
19
|
-
throw new Error(`Invalid value: ${value} does not start with ${moduleBase}`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function createSharedBuildConfig(config: UserConfig, rollupOptions: any): UserConfig {
|
|
25
|
-
return {
|
|
26
|
-
...config,
|
|
27
|
-
build: {
|
|
28
|
-
...config.build,
|
|
29
|
-
rollupOptions: {
|
|
30
|
-
...config.build?.rollupOptions,
|
|
31
|
-
...rollupOptions
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { InputOption } from "rollup";
|
|
2
|
-
import type { InputNormalizer, InputNormalizerWorker } from "../types.js";
|
|
3
|
-
|
|
4
|
-
export const mergeInputsAsync = async (
|
|
5
|
-
input: { [key: string]: string },
|
|
6
|
-
input2: InputOption | undefined,
|
|
7
|
-
inputNormalizer: InputNormalizerWorker
|
|
8
|
-
): Promise<Record<string, string>> => {
|
|
9
|
-
if(typeof input === "undefined"){
|
|
10
|
-
throw new Error("The first input can not be undefined");
|
|
11
|
-
} else if(typeof input2 === "undefined") {
|
|
12
|
-
return input;
|
|
13
|
-
} else if(Array.isArray(input2)) {
|
|
14
|
-
const inputsFromArray = Object.fromEntries(await Promise.all(input2.map(async (input)=>inputNormalizer(input))))
|
|
15
|
-
return {
|
|
16
|
-
...input,
|
|
17
|
-
...inputsFromArray,
|
|
18
|
-
}
|
|
19
|
-
} else if(typeof input2 === "object" && input2 != null) {
|
|
20
|
-
return { ...input, ...input2 };
|
|
21
|
-
} else if (typeof input2 === "string") {
|
|
22
|
-
const [key, value] = await inputNormalizer(input2)
|
|
23
|
-
return {
|
|
24
|
-
...input,
|
|
25
|
-
[key]: value,
|
|
26
|
-
}
|
|
27
|
-
} else {
|
|
28
|
-
throw new Error(`Invalid input: ${input2}`);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const mergeInputs = (
|
|
33
|
-
input: { [key: string]: string },
|
|
34
|
-
input2: InputOption | undefined,
|
|
35
|
-
inputNormalizer: InputNormalizer
|
|
36
|
-
): Record<string, string> => {
|
|
37
|
-
if(typeof input === "undefined"){
|
|
38
|
-
throw new Error("The first input can not be undefined");
|
|
39
|
-
} else if(typeof input2 === "undefined") {
|
|
40
|
-
return input;
|
|
41
|
-
} else if(Array.isArray(input2)) {
|
|
42
|
-
const inputsFromArray = Object.fromEntries(input2.map(inputNormalizer))
|
|
43
|
-
return {
|
|
44
|
-
...input,
|
|
45
|
-
...inputsFromArray,
|
|
46
|
-
}
|
|
47
|
-
} else if(typeof input2 === "object" && input2 != null) {
|
|
48
|
-
return { ...input, ...input2 };
|
|
49
|
-
} else if (typeof input2 === "string") {
|
|
50
|
-
const [key, value] = inputNormalizer(input2)
|
|
51
|
-
return {
|
|
52
|
-
...input,
|
|
53
|
-
[key]: value,
|
|
54
|
-
}
|
|
55
|
-
} else {
|
|
56
|
-
throw new Error(`Invalid input: ${input2}`);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { normalizePath } from "vite";
|
|
2
|
-
import { DEFAULT_CONFIG } from "./defaults.js";
|
|
3
|
-
|
|
4
|
-
export const moduleIdDefault =
|
|
5
|
-
({
|
|
6
|
-
projectRoot,
|
|
7
|
-
output: _,
|
|
8
|
-
isProduction,
|
|
9
|
-
}: {
|
|
10
|
-
isProduction: boolean;
|
|
11
|
-
projectRoot: string;
|
|
12
|
-
output: { dir: string };
|
|
13
|
-
}) =>
|
|
14
|
-
(moduleId: string) => {
|
|
15
|
-
const normalized = normalizePath(moduleId);
|
|
16
|
-
const noRoot = normalized.startsWith(projectRoot)
|
|
17
|
-
? normalized.slice(projectRoot.length)
|
|
18
|
-
: normalized;
|
|
19
|
-
if (!isProduction) {
|
|
20
|
-
return noRoot;
|
|
21
|
-
}
|
|
22
|
-
return noRoot.replace(DEFAULT_CONFIG.FILE_REGEX, ".js");
|
|
23
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { Worker } from 'worker_threads';
|
|
2
|
-
import type { InputNormalizerWorker } from '../types.js';
|
|
3
|
-
|
|
4
|
-
type ClientNormalizerOptions = {
|
|
5
|
-
rscWorker: Worker;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const createClientInputNormalizer = ({
|
|
9
|
-
rscWorker
|
|
10
|
-
}: ClientNormalizerOptions): InputNormalizerWorker => {
|
|
11
|
-
return async (input): Promise<[string, string]> => {
|
|
12
|
-
// Handle string
|
|
13
|
-
if(typeof input === "string") {
|
|
14
|
-
return [input, input];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// Handle React component
|
|
18
|
-
if(typeof input === "function") {
|
|
19
|
-
return new Promise((resolve, reject) => {
|
|
20
|
-
const handler = (message: any) => {
|
|
21
|
-
if (message.type === "CLIENT_REFERENCE") {
|
|
22
|
-
rscWorker.off('message', handler);
|
|
23
|
-
resolve([message.ref.$$id, message.ref.$$location]);
|
|
24
|
-
}
|
|
25
|
-
if (message.type === "ERROR") {
|
|
26
|
-
rscWorker.off('message', handler);
|
|
27
|
-
reject(new Error(message.error));
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
rscWorker.on('message', handler);
|
|
32
|
-
rscWorker.postMessage({
|
|
33
|
-
type: "CLIENT_REFERENCE",
|
|
34
|
-
id: input.name || 'AnonymousComponent',
|
|
35
|
-
location: input.toString(),
|
|
36
|
-
key: input.name
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Handle arrays
|
|
42
|
-
if(Array.isArray(input)) {
|
|
43
|
-
return [input[0], input[0]];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
throw new Error('Invalid client input type');
|
|
47
|
-
};
|
|
48
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
import type { Worker } from "node:worker_threads";
|
|
3
|
-
import type { InputNormalizerWorker } from "../types.js";
|
|
4
|
-
|
|
5
|
-
interface ServerNormalizerOptions {
|
|
6
|
-
root: string;
|
|
7
|
-
htmlWorker: Worker;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function createServerInputNormalizer({
|
|
11
|
-
root,
|
|
12
|
-
htmlWorker
|
|
13
|
-
}: ServerNormalizerOptions): InputNormalizerWorker {
|
|
14
|
-
return async (input) => {
|
|
15
|
-
// Handle React components with worker
|
|
16
|
-
if (typeof input === "function") {
|
|
17
|
-
return new Promise((resolve, reject) => {
|
|
18
|
-
const handler = (message: any) => {
|
|
19
|
-
if (message.type === "CLIENT_REFERENCE") {
|
|
20
|
-
htmlWorker.off('message', handler);
|
|
21
|
-
resolve([message.ref.$$id, message.ref.$$location]);
|
|
22
|
-
}
|
|
23
|
-
if (message.type === "ERROR") {
|
|
24
|
-
htmlWorker.off('message', handler);
|
|
25
|
-
reject(new Error(message.error));
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
htmlWorker.on('message', handler);
|
|
30
|
-
htmlWorker.postMessage({
|
|
31
|
-
type: "CLIENT_REFERENCE",
|
|
32
|
-
id: input.name || 'AnonymousComponent',
|
|
33
|
-
location: input.toString(),
|
|
34
|
-
key: input.name
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Handle tuple input [key, path]
|
|
40
|
-
if (Array.isArray(input)) {
|
|
41
|
-
const [key, path] = input;
|
|
42
|
-
return [key, join(root, path)];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Handle string input
|
|
46
|
-
if (typeof input === "string") {
|
|
47
|
-
return [input, join(root, input)];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
throw new Error(`Invalid input type: ${typeof input}`);
|
|
51
|
-
};
|
|
52
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
import type { InputNormalizer } from "../types.js";
|
|
3
|
-
|
|
4
|
-
interface StaticNormalizerOptions {
|
|
5
|
-
root: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function createStaticInputNormalizer({ root }: StaticNormalizerOptions): InputNormalizer {
|
|
9
|
-
return (input) => {
|
|
10
|
-
// Handle tuple input [key, path]
|
|
11
|
-
if (Array.isArray(input)) {
|
|
12
|
-
const [key, path] = input;
|
|
13
|
-
// Keep the key as-is for Rollup entry point naming
|
|
14
|
-
// Just resolve the path relative to root
|
|
15
|
-
return [key, join(root, path)];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Handle string input
|
|
19
|
-
if (typeof input === "string") {
|
|
20
|
-
// For single string inputs, let Rollup handle the naming
|
|
21
|
-
return [input, join(root, input)];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
throw new Error(`Invalid input type: ${typeof input}`);
|
|
25
|
-
};
|
|
26
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { ModuleInfo, PluginContext } from 'rollup';
|
|
2
|
-
|
|
3
|
-
interface ModuleManifestEntry {
|
|
4
|
-
file: string;
|
|
5
|
-
name: string;
|
|
6
|
-
src?: string;
|
|
7
|
-
isEntry?: boolean;
|
|
8
|
-
imports?: string[];
|
|
9
|
-
dynamicImports?: string[];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function getModuleManifest(this: PluginContext): Record<string, ModuleManifestEntry> {
|
|
13
|
-
const manifest: Record<string, ModuleManifestEntry> = {};
|
|
14
|
-
|
|
15
|
-
// Build module graph from plugin context
|
|
16
|
-
for (const id of this.getModuleIds()) {
|
|
17
|
-
const info: ModuleInfo | null = this.getModuleInfo(id);
|
|
18
|
-
if (!info) continue;
|
|
19
|
-
|
|
20
|
-
manifest[id] = {
|
|
21
|
-
file: info.id,
|
|
22
|
-
src: info.id,
|
|
23
|
-
name: id,
|
|
24
|
-
isEntry: info.isEntry,
|
|
25
|
-
imports: Array.from(info.importedIds),
|
|
26
|
-
dynamicImports: Array.from(info.dynamicallyImportedIds)
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return manifest;
|
|
31
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { Worker } from "node:worker_threads";
|
|
2
|
-
import type { InputNormalizerWorker, NormalizerInput } from "../types.js";
|
|
3
|
-
import { createInputNormalizer } from "./inputNormalizer.js";
|
|
4
|
-
|
|
5
|
-
interface WorkerNormalizerOptions {
|
|
6
|
-
root: string;
|
|
7
|
-
moduleBase: string;
|
|
8
|
-
worker: Worker;
|
|
9
|
-
moduleBaseExceptions?: string[];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function createInputNormalizerWorker({
|
|
13
|
-
root,
|
|
14
|
-
worker,
|
|
15
|
-
}: WorkerNormalizerOptions): InputNormalizerWorker {
|
|
16
|
-
|
|
17
|
-
const baseNormalizer = createInputNormalizer(root);
|
|
18
|
-
|
|
19
|
-
return async (input: NormalizerInput): Promise<[string, string]> => {
|
|
20
|
-
// Handle React components specially with worker
|
|
21
|
-
if (typeof input === "function") {
|
|
22
|
-
return new Promise((resolve, reject) => {
|
|
23
|
-
const handler = (message: any) => {
|
|
24
|
-
if (message.type === "CLIENT_REFERENCE") {
|
|
25
|
-
worker.off('message', handler);
|
|
26
|
-
resolve([message.ref.$$id, message.ref.$$location]);
|
|
27
|
-
}
|
|
28
|
-
if (message.type === "ERROR") {
|
|
29
|
-
worker.off('message', handler);
|
|
30
|
-
reject(new Error(message.error));
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
worker.on('message', handler);
|
|
35
|
-
worker.postMessage({
|
|
36
|
-
type: "CLIENT_REFERENCE",
|
|
37
|
-
id: input.name || 'AnonymousComponent',
|
|
38
|
-
location: input.toString(),
|
|
39
|
-
key: input.name
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// For all other types, use the base normalizer
|
|
45
|
-
return baseNormalizer(input);
|
|
46
|
-
};
|
|
47
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { normalizePath } from "vite";
|
|
2
|
-
|
|
3
|
-
type NormalizedRelativePathOptions = {
|
|
4
|
-
// will automatically remove this part
|
|
5
|
-
root: string;
|
|
6
|
-
// will automatically see this as a optional extra part of the rootDir that will be removed
|
|
7
|
-
outDir: string;
|
|
8
|
-
// will ensure it always starts with this path, if it does not it will be added
|
|
9
|
-
moduleBase: string;
|
|
10
|
-
// will ensure it never starts with a leading /, which in some cases is needed (vite entry), other cases it is not for example from project root /
|
|
11
|
-
noLeadingSlash: boolean;
|
|
12
|
-
// will ensure it never ends with a trailing /
|
|
13
|
-
noTrailingSlash: boolean;
|
|
14
|
-
// allowed exception to moduleBase rules
|
|
15
|
-
moduleBaseExceptions: string[];
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const createNormalizedRelativePath = (
|
|
19
|
-
options: NormalizedRelativePathOptions = {
|
|
20
|
-
root: process.cwd(),
|
|
21
|
-
outDir: "dist",
|
|
22
|
-
moduleBase: "src",
|
|
23
|
-
noLeadingSlash: false,
|
|
24
|
-
noTrailingSlash: false,
|
|
25
|
-
moduleBaseExceptions: [],
|
|
26
|
-
}
|
|
27
|
-
) => {
|
|
28
|
-
let base =
|
|
29
|
-
options.noLeadingSlash && options.moduleBase.startsWith("/")
|
|
30
|
-
? options.moduleBase.slice(1)
|
|
31
|
-
: options.moduleBase;
|
|
32
|
-
if (options.noTrailingSlash && base.endsWith("/")) {
|
|
33
|
-
base = base.slice(0, -1);
|
|
34
|
-
}
|
|
35
|
-
const removeOutDir = (path: string) =>
|
|
36
|
-
(options.outDir as string) === path
|
|
37
|
-
? path.slice(options.outDir.length)
|
|
38
|
-
: path;
|
|
39
|
-
|
|
40
|
-
const removeRoot = (path: string) => {
|
|
41
|
-
const relative = path.startsWith(options.root)
|
|
42
|
-
? path.slice(options.root.length)
|
|
43
|
-
: path;
|
|
44
|
-
return relative;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const ensureModuleBase = (path: string) => {
|
|
48
|
-
let transformed = path;
|
|
49
|
-
if (options.noLeadingSlash && path.startsWith("/")) {
|
|
50
|
-
transformed = path.slice(1);
|
|
51
|
-
}
|
|
52
|
-
if (options.noTrailingSlash && transformed.endsWith("/")) {
|
|
53
|
-
transformed = transformed.slice(0, -1);
|
|
54
|
-
}
|
|
55
|
-
return transformed;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
return (path: string) => ensureModuleBase(removeOutDir(removeRoot(normalizePath(path))));
|
|
59
|
-
};
|