vite-plugin-react-server 0.3.3 → 0.3.5
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/README.md +113 -222
- package/bin/patch.mjs +84 -0
- package/dist/_virtual/sourcemap-codec.umd.js +11 -0
- package/dist/_virtual/sourcemap-codec.umd.js.map +1 -0
- package/dist/_virtual/sourcemap-codec.umd2.js +9 -0
- package/dist/_virtual/sourcemap-codec.umd2.js.map +1 -0
- package/dist/client.d.ts +3 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +7 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -3
- package/dist/index.js.map +1 -1
- package/dist/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js +457 -0
- package/dist/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js.map +1 -0
- package/dist/node_modules/magic-string/dist/magic-string.es.js +1283 -0
- package/dist/node_modules/magic-string/dist/magic-string.es.js.map +1 -0
- package/dist/package.json +131 -0
- package/dist/plugin/assertServerCondition.d.ts.map +1 -0
- package/dist/plugin/assertServerCondition.js +15 -0
- package/dist/plugin/build/createClientBuildConfig.d.ts +3 -0
- package/dist/plugin/build/createClientBuildConfig.d.ts.map +1 -0
- package/dist/plugin/build/createClientBuildConfig.js +14 -0
- package/dist/plugin/build/createServerBuildConfig.d.ts +12 -0
- package/dist/plugin/build/createServerBuildConfig.d.ts.map +1 -0
- package/dist/plugin/build/createServerBuildConfig.js +40 -0
- package/dist/plugin/build/createSharedBuildConfig.d.ts +5 -0
- package/dist/plugin/build/createSharedBuildConfig.d.ts.map +1 -0
- package/dist/plugin/build/createSharedBuildConfig.js +28 -0
- package/dist/plugin/build/mergeInputs.d.ts +9 -0
- package/dist/plugin/build/mergeInputs.d.ts.map +1 -0
- package/dist/plugin/build/mergeInputs.js +56 -0
- package/dist/plugin/checkFilesExist.d.ts +3 -0
- package/dist/plugin/checkFilesExist.d.ts.map +1 -0
- package/dist/plugin/checkFilesExist.js +78 -0
- package/dist/plugin/checkFilesExist.js.map +1 -0
- package/dist/{collect-css-manifest.d.ts → plugin/collect-css-manifest.d.ts} +2 -2
- package/dist/plugin/collect-css-manifest.d.ts.map +1 -0
- package/dist/{src → plugin}/collect-css-manifest.js +8 -5
- package/dist/plugin/collect-css-manifest.js.map +1 -0
- package/dist/plugin/components.d.ts.map +1 -0
- package/dist/{src → plugin}/components.js +9 -4
- package/dist/plugin/components.js.map +1 -0
- package/dist/plugin/config/defaults.d.ts +51 -0
- package/dist/plugin/config/defaults.d.ts.map +1 -0
- package/dist/plugin/config/defaults.js +52 -0
- package/dist/plugin/config/defaults.js.map +1 -0
- package/dist/plugin/config/getCondition.d.ts +2 -0
- package/dist/plugin/config/getCondition.d.ts.map +1 -0
- package/dist/plugin/config/getCondition.js +11 -0
- package/dist/plugin/config/getCondition.js.map +1 -0
- package/dist/plugin/config/getPaths.d.ts +5 -0
- package/dist/plugin/config/getPaths.d.ts.map +1 -0
- package/dist/plugin/config/getPaths.js +21 -0
- package/dist/plugin/config/getPaths.js.map +1 -0
- package/dist/plugin/config/getWorkerPath.d.ts +2 -0
- package/dist/plugin/config/getWorkerPath.d.ts.map +1 -0
- package/dist/plugin/config/getWorkerPath.js +4 -0
- package/dist/plugin/config/index.d.ts +8 -0
- package/dist/plugin/config/index.d.ts.map +1 -0
- package/dist/plugin/config/index.js +7 -0
- package/dist/plugin/config/moduleIdDefault.d.ts +8 -0
- package/dist/plugin/config/moduleIdDefault.d.ts.map +1 -0
- package/dist/plugin/config/moduleIdDefault.js +23 -0
- package/dist/plugin/config/moduleIdDefault.js.map +1 -0
- package/dist/plugin/config/resolveOptions.d.ts +9 -0
- package/dist/plugin/config/resolveOptions.d.ts.map +1 -0
- package/dist/plugin/config/resolveOptions.js +56 -0
- package/dist/plugin/config/resolveOptions.js.map +1 -0
- package/dist/plugin/config/resolvePages.d.ts +9 -0
- package/dist/plugin/config/resolvePages.d.ts.map +1 -0
- package/dist/plugin/config/resolvePages.js +38 -0
- package/dist/plugin/config/resolvePages.js.map +1 -0
- package/dist/plugin/config/resolveUserConfig.d.ts +18 -0
- package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -0
- package/dist/plugin/config/resolveUserConfig.js +84 -0
- package/dist/plugin/config/resolveUserConfig.js.map +1 -0
- package/dist/plugin/copy-dir.d.ts.map +1 -0
- package/dist/plugin/copy-dir.js +20 -0
- package/dist/plugin/getCondition.d.ts +2 -0
- package/dist/plugin/getCondition.d.ts.map +1 -0
- package/dist/plugin/getCondition.js +1 -0
- package/dist/plugin/getEnv.d.ts.map +1 -0
- package/dist/plugin/getEnv.js +107 -0
- package/dist/plugin/helpers/createClientInputNormalizer.d.ts +8 -0
- package/dist/plugin/helpers/createClientInputNormalizer.d.ts.map +1 -0
- package/dist/plugin/helpers/createClientInputNormalizer.js +35 -0
- package/dist/plugin/helpers/createServerInputNormalizer.d.ts +9 -0
- package/dist/plugin/helpers/createServerInputNormalizer.d.ts.map +1 -0
- package/dist/plugin/helpers/createServerInputNormalizer.js +37 -0
- package/dist/plugin/helpers/createStaticInputNormalizer.d.ts +7 -0
- package/dist/plugin/helpers/createStaticInputNormalizer.d.ts.map +1 -0
- package/dist/plugin/helpers/createStaticInputNormalizer.js +18 -0
- package/dist/plugin/helpers/getModuleManifest.d.ts +12 -0
- package/dist/plugin/helpers/getModuleManifest.d.ts.map +1 -0
- package/dist/plugin/helpers/getModuleManifest.js +24 -0
- package/dist/plugin/helpers/getModuleManifest.js.map +1 -0
- package/dist/plugin/helpers/inputNormalizer.d.ts +3 -0
- package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -0
- package/dist/plugin/helpers/inputNormalizer.js +35 -0
- package/dist/plugin/helpers/inputNormalizer.js.map +1 -0
- package/dist/plugin/helpers/inputNormalizerWorker.d.ts +11 -0
- package/dist/plugin/helpers/inputNormalizerWorker.d.ts.map +1 -0
- package/dist/plugin/helpers/inputNormalizerWorker.js +30 -0
- package/dist/plugin/helpers/normalizedRelativePath.d.ts.map +1 -0
- package/dist/plugin/helpers/normalizedRelativePath.js +36 -0
- package/dist/plugin/helpers/resolveFilePath.d.ts +13 -0
- package/dist/plugin/helpers/resolveFilePath.d.ts.map +1 -0
- package/dist/plugin/helpers/resolveFilePath.js +74 -0
- package/dist/plugin/helpers/resolveWorkerModule.d.ts +6 -0
- package/dist/plugin/helpers/resolveWorkerModule.d.ts.map +1 -0
- package/dist/plugin/helpers/resolveWorkerModule.js +24 -0
- package/dist/plugin/helpers/tryManifest.d.ts.map +1 -0
- package/dist/{src → plugin}/helpers/tryManifest.js +11 -6
- package/dist/plugin/helpers/tryManifest.js.map +1 -0
- package/dist/plugin/helpers/validateModuleBase.d.ts +3 -0
- package/dist/plugin/helpers/validateModuleBase.d.ts.map +1 -0
- package/dist/plugin/helpers/validateModuleBase.js +16 -0
- package/dist/plugin/helpers/validateResolvedConfig.d.ts +3 -0
- package/dist/plugin/helpers/validateResolvedConfig.d.ts.map +1 -0
- package/dist/plugin/helpers/validateResolvedConfig.js +17 -0
- package/dist/plugin/index.d.ts +3 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +1 -0
- package/dist/plugin/loader/createBuildLoader.d.ts +9 -0
- package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -0
- package/dist/plugin/loader/createBuildLoader.js +52 -0
- package/dist/plugin/loader/createBuildLoader.js.map +1 -0
- package/dist/plugin/loader/createCssLoader.d.ts +30 -0
- package/dist/plugin/loader/createCssLoader.d.ts.map +1 -0
- package/dist/plugin/loader/createCssLoader.js +35 -0
- package/dist/{html → plugin/loader}/createPageLoader.d.ts +2 -4
- package/dist/plugin/loader/createPageLoader.d.ts.map +1 -0
- package/dist/plugin/loader/createPageLoader.js +57 -0
- package/dist/plugin/manifest.d.ts.map +1 -0
- package/dist/plugin/manifest.js +13 -0
- package/dist/plugin/module-graph.d.ts.map +1 -0
- package/dist/plugin/module-graph.js +35 -0
- package/dist/plugin/plugin.d.ts +7 -0
- package/dist/plugin/plugin.d.ts.map +1 -0
- package/dist/plugin/plugin.js +8 -0
- package/dist/plugin/preserver/index.d.ts +2 -0
- package/dist/plugin/preserver/index.d.ts.map +1 -0
- package/dist/plugin/preserver/index.js +1 -0
- package/dist/plugin/preserver/plugin.d.ts +4 -0
- package/dist/plugin/preserver/plugin.d.ts.map +1 -0
- package/dist/plugin/preserver/plugin.js +90 -0
- package/dist/plugin/preserver/plugin.js.map +1 -0
- package/dist/plugin/react-client/index.d.ts +2 -0
- package/dist/plugin/react-client/index.d.ts.map +1 -0
- package/dist/plugin/react-client/index.js +1 -0
- package/dist/plugin/react-client/plugin.d.ts +4 -0
- package/dist/plugin/react-client/plugin.d.ts.map +1 -0
- package/dist/plugin/react-client/plugin.js +34 -0
- package/dist/plugin/react-client/plugin.js.map +1 -0
- package/dist/plugin/react-server/createDevMiddleware.d.ts.map +1 -0
- package/dist/plugin/react-server/createDevMiddleware.js +68 -0
- package/dist/plugin/react-server/createDevServer.d.ts.map +1 -0
- package/dist/plugin/react-server/createDevServer.js +4 -0
- package/dist/plugin/react-server/createHandler.d.ts +17 -0
- package/dist/plugin/react-server/createHandler.d.ts.map +1 -0
- package/dist/{src → plugin}/react-server/createHandler.js +28 -17
- package/dist/plugin/react-server/createHandler.js.map +1 -0
- package/dist/plugin/react-server/createReactNodeStreamer.d.ts.map +1 -0
- package/dist/plugin/react-server/createReactNodeStreamer.js +7 -0
- package/dist/{react-server → plugin/react-server}/createRscStream.d.ts +1 -1
- package/dist/plugin/react-server/createRscStream.d.ts.map +1 -0
- package/dist/{src → plugin}/react-server/createRscStream.js +14 -13
- package/dist/plugin/react-server/createRscStream.js.map +1 -0
- package/dist/{react-server → plugin/react-server}/createSsrHandler.d.ts +1 -1
- package/dist/plugin/react-server/createSsrHandler.d.ts.map +1 -0
- package/dist/plugin/react-server/createSsrHandler.js +102 -0
- package/dist/plugin/react-server/index.d.ts +4 -0
- package/dist/plugin/react-server/index.d.ts.map +1 -0
- package/dist/plugin/react-server/index.js +10 -0
- package/dist/{react-server → plugin/react-server}/plugin.d.ts +2 -2
- package/dist/plugin/react-server/plugin.d.ts.map +1 -0
- package/dist/plugin/react-server/plugin.js +375 -0
- package/dist/plugin/react-server/plugin.js.map +1 -0
- package/dist/plugin/resolvePage.d.ts.map +1 -0
- package/dist/{src → plugin}/resolvePage.js +8 -4
- package/dist/plugin/resolvePage.js.map +1 -0
- package/dist/plugin/resolveProps.d.ts.map +1 -0
- package/dist/{src → plugin}/resolveProps.js +21 -8
- package/dist/plugin/resolveProps.js.map +1 -0
- package/dist/plugin/server.d.ts +2 -0
- package/dist/plugin/server.d.ts.map +1 -0
- package/dist/plugin/server.js +1 -0
- package/dist/plugin/transformer/index.d.ts +2 -0
- package/dist/plugin/transformer/index.d.ts.map +1 -0
- package/dist/plugin/transformer/index.js +1 -0
- package/dist/{transformer/index.d.ts → plugin/transformer/plugin.d.ts} +3 -3
- package/dist/plugin/transformer/plugin.d.ts.map +1 -0
- package/dist/plugin/transformer/plugin.js +86 -0
- package/dist/plugin/transformer/plugin.js.map +1 -0
- package/dist/plugin/transformer/transformer-client-components.d.ts +21 -0
- package/dist/plugin/transformer/transformer-client-components.d.ts.map +1 -0
- package/dist/plugin/transformer/transformer-client-components.js +61 -0
- package/dist/plugin/transformer/transformer-client-components.js.map +1 -0
- package/dist/{transformer/transformer.d.ts → plugin/transformer/transformer-server-actions.d.ts} +3 -4
- package/dist/plugin/transformer/transformer-server-actions.d.ts.map +1 -0
- package/dist/plugin/transformer/transformer-server-actions.js +76 -0
- package/dist/plugin/transformer/transformer-server-actions.js.map +1 -0
- package/dist/plugin/transformer/types.d.ts.map +1 -0
- package/dist/plugin/transformer/types.js +1 -0
- package/dist/plugin/types.d.ts +225 -0
- package/dist/plugin/types.d.ts.map +1 -0
- package/dist/plugin/types.js +1 -0
- package/dist/plugin/worker/createWorker.d.ts +15 -0
- package/dist/plugin/worker/createWorker.d.ts.map +1 -0
- package/dist/plugin/worker/createWorker.js +71 -0
- package/dist/plugin/worker/createWorker.js.map +1 -0
- package/dist/plugin/worker/html/html-worker.d.ts +2 -0
- package/dist/plugin/worker/html/html-worker.d.ts.map +1 -0
- package/dist/plugin/worker/html/html-worker.development.d.ts +2 -0
- package/dist/plugin/worker/html/html-worker.development.d.ts.map +1 -0
- package/dist/plugin/worker/html/html-worker.development.js +12 -0
- package/dist/plugin/worker/html/html-worker.development.js.map +1 -0
- package/dist/plugin/worker/html/html-worker.js +4 -0
- package/dist/plugin/worker/html/html-worker.production.d.ts +2 -0
- package/dist/plugin/worker/html/html-worker.production.d.ts.map +1 -0
- package/dist/plugin/worker/html/html-worker.production.js +12 -0
- package/dist/plugin/worker/html/html-worker.production.js.map +1 -0
- package/dist/plugin/worker/html/index.d.ts +2 -0
- package/dist/plugin/worker/html/index.d.ts.map +1 -0
- package/dist/plugin/worker/html/index.js +7 -0
- package/dist/plugin/worker/html/index.js.map +1 -0
- package/dist/plugin/worker/html/messageHandler.d.ts +3 -0
- package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -0
- package/dist/plugin/worker/html/messageHandler.js +98 -0
- package/dist/plugin/worker/html/messageHandler.js.map +1 -0
- package/dist/plugin/worker/html/plugin.d.ts +4 -0
- package/dist/plugin/worker/html/plugin.d.ts.map +1 -0
- package/dist/plugin/worker/html/plugin.js +89 -0
- package/dist/plugin/worker/html/renderPages.d.ts +38 -0
- package/dist/plugin/worker/html/renderPages.d.ts.map +1 -0
- package/dist/plugin/worker/html/renderPages.js +121 -0
- package/dist/plugin/worker/html/renderPages.js.map +1 -0
- package/dist/plugin/worker/loader.d.ts.map +1 -0
- package/dist/plugin/worker/loader.js +11 -0
- package/dist/plugin/worker/loader.js.map +1 -0
- package/dist/plugin/worker/plugin.d.ts +10 -0
- package/dist/plugin/worker/plugin.d.ts.map +1 -0
- package/dist/plugin/worker/plugin.js +14 -0
- package/dist/plugin/worker/rsc/createRscStream.d.ts +5 -0
- package/dist/plugin/worker/rsc/createRscStream.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/createRscStream.js +39 -0
- package/dist/plugin/worker/rsc/createRscStream.js.map +1 -0
- package/dist/plugin/worker/rsc/development.d.ts +5 -0
- package/dist/plugin/worker/rsc/development.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/development.js +13 -0
- package/dist/plugin/worker/rsc/development.js.map +1 -0
- package/dist/plugin/worker/rsc/index.d.ts +4 -0
- package/dist/plugin/worker/rsc/index.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/index.js +15 -0
- package/dist/plugin/worker/rsc/index.js.map +1 -0
- package/dist/plugin/worker/rsc/plugin.d.ts +4 -0
- package/dist/plugin/worker/rsc/plugin.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/plugin.js +82 -0
- package/dist/plugin/worker/rsc/plugin.js.map +1 -0
- package/dist/plugin/worker/rsc/production.d.ts +5 -0
- package/dist/plugin/worker/rsc/production.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/production.js +13 -0
- package/dist/plugin/worker/rsc/production.js.map +1 -0
- package/dist/plugin/worker/rsc/rsc-worker.d.ts +2 -0
- package/dist/plugin/worker/rsc/rsc-worker.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/rsc-worker.js +106 -0
- package/dist/plugin/worker/types.d.ts +99 -0
- package/dist/plugin/worker/types.d.ts.map +1 -0
- package/dist/plugin/worker/types.js +1 -0
- package/dist/server.d.ts +4 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +9 -0
- package/dist/server.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types.d.ts +1 -201
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/package.json +44 -25
- package/plugin/build/createClientBuildConfig.ts +21 -0
- package/plugin/build/createServerBuildConfig.ts +66 -0
- package/plugin/build/createSharedBuildConfig.ts +35 -0
- package/plugin/build/mergeInputs.ts +58 -0
- package/plugin/checkFilesExist.ts +82 -0
- package/{src → plugin}/collect-css-manifest.ts +4 -2
- package/plugin/config/defaults.ts +44 -0
- package/plugin/config/getCondition.ts +3 -0
- package/plugin/config/getPaths.ts +25 -0
- package/plugin/config/getWorkerPath.ts +5 -0
- package/plugin/config/index.ts +8 -0
- package/plugin/config/moduleIdDefault.ts +23 -0
- package/plugin/config/resolveOptions.ts +53 -0
- package/plugin/config/resolvePages.ts +43 -0
- package/plugin/config/resolveUserConfig.ts +97 -0
- package/{src → plugin}/getEnv.ts +1 -1
- package/plugin/helpers/createClientInputNormalizer.ts +48 -0
- package/plugin/helpers/createServerInputNormalizer.ts +52 -0
- package/plugin/helpers/createStaticInputNormalizer.ts +26 -0
- package/plugin/helpers/getModuleManifest.ts +31 -0
- package/plugin/helpers/inputNormalizer.ts +39 -0
- package/plugin/helpers/inputNormalizerWorker.ts +47 -0
- package/plugin/helpers/resolveFilePath.ts +108 -0
- package/plugin/helpers/resolveWorkerModule.ts +41 -0
- package/plugin/helpers/validateModuleBase.ts +30 -0
- package/plugin/helpers/validateResolvedConfig.ts +21 -0
- package/plugin/index.ts +2 -0
- package/plugin/loader/createBuildLoader.ts +60 -0
- package/plugin/loader/createCssLoader.ts +73 -0
- package/{src/html → plugin/loader}/createPageLoader.ts +35 -27
- package/plugin/plugin.ts +8 -0
- package/plugin/preserver/index.ts +1 -0
- package/plugin/preserver/plugin.ts +110 -0
- package/plugin/react-client/index.ts +1 -0
- package/plugin/react-client/plugin.ts +33 -0
- package/{src → plugin}/react-server/createDevMiddleware.ts +17 -1
- package/{src → plugin}/react-server/createDevServer.ts +0 -1
- package/{src → plugin}/react-server/createHandler.ts +31 -10
- package/{src → plugin}/react-server/createReactNodeStreamer.ts +1 -0
- package/{src → plugin}/react-server/createRscStream.ts +8 -12
- package/{src → plugin}/react-server/createSsrHandler.ts +16 -19
- package/plugin/react-server/index.ts +13 -0
- package/plugin/react-server/plugin.ts +465 -0
- package/{src → plugin}/resolvePage.ts +1 -1
- package/{src → plugin}/resolveProps.ts +15 -6
- package/plugin/server.tsx +0 -0
- package/plugin/transformer/index.ts +1 -0
- package/plugin/transformer/plugin.ts +131 -0
- package/plugin/transformer/transformer-client-components.ts +94 -0
- package/{src/transformer/transformer.ts → plugin/transformer/transformer-server-actions.ts} +14 -27
- package/{src → plugin}/types.ts +97 -55
- package/plugin/worker/createWorker.ts +84 -0
- package/plugin/worker/html/html-worker.development.tsx +8 -0
- package/plugin/worker/html/html-worker.production.tsx +8 -0
- package/plugin/worker/html/html-worker.ts +5 -0
- package/plugin/worker/html/index.ts +5 -0
- package/plugin/worker/html/messageHandler.ts +116 -0
- package/plugin/worker/html/plugin.ts +97 -0
- package/plugin/worker/html/renderPages.ts +187 -0
- package/plugin/worker/plugin.ts +17 -0
- package/plugin/worker/rsc/createRscStream.ts +42 -0
- package/plugin/worker/rsc/development.ts +6 -0
- package/plugin/worker/rsc/index.ts +14 -0
- package/plugin/worker/rsc/plugin.ts +83 -0
- package/plugin/worker/rsc/production.ts +6 -0
- package/plugin/worker/rsc/rsc-worker.tsx +128 -0
- package/plugin/worker/types.ts +124 -0
- package/scripts/bump-version.mjs +68 -0
- package/scripts/check-react-version.mjs +66 -0
- package/scripts/react+0.0.0-experimental-b3a95caf-20250113.patch +4291 -0
- package/scripts/react-dom+0.0.0-experimental-b3a95caf-20250113.patch +108798 -0
- package/scripts/react-server-dom-esm+0.0.0-experimental-b3a95caf-20250113.patch +24775 -0
- package/{patches → scripts}/react-server-dom-esm+0.0.1.patch +10259 -3
- package/tsconfig.json +15 -13
- package/dist/assertServerCondition.d.ts.map +0 -1
- package/dist/bin/patch.js +0 -51
- package/dist/bin/patch.js.map +0 -1
- package/dist/build/createBuildConfig.d.ts +0 -13
- package/dist/build/createBuildConfig.d.ts.map +0 -1
- package/dist/build/mergeInputs.d.ts +0 -5
- package/dist/build/mergeInputs.d.ts.map +0 -1
- package/dist/checkFilesExist.d.ts +0 -8
- package/dist/checkFilesExist.d.ts.map +0 -1
- package/dist/collect-css-manifest.d.ts.map +0 -1
- package/dist/components.d.ts.map +0 -1
- package/dist/copy-dir.d.ts.map +0 -1
- package/dist/getEnv.d.ts.map +0 -1
- package/dist/helpers/inputNormalizer.d.ts +0 -6
- package/dist/helpers/inputNormalizer.d.ts.map +0 -1
- package/dist/helpers/normalizedRelativePath.d.ts.map +0 -1
- package/dist/helpers/tryManifest.d.ts.map +0 -1
- package/dist/html/createPageLoader.d.ts.map +0 -1
- package/dist/manifest.d.ts.map +0 -1
- package/dist/module-graph.d.ts.map +0 -1
- package/dist/options.d.ts +0 -91
- package/dist/options.d.ts.map +0 -1
- package/dist/plugin.d.ts +0 -3
- package/dist/plugin.d.ts.map +0 -1
- package/dist/react-client/plugin.d.ts +0 -4
- package/dist/react-client/plugin.d.ts.map +0 -1
- package/dist/react-client/plugin.js +0 -28
- package/dist/react-client/plugin.js.map +0 -1
- package/dist/react-server/createDevMiddleware.d.ts.map +0 -1
- package/dist/react-server/createDevServer.d.ts.map +0 -1
- package/dist/react-server/createHandler.d.ts +0 -23
- package/dist/react-server/createHandler.d.ts.map +0 -1
- package/dist/react-server/createReactNodeStreamer.d.ts.map +0 -1
- package/dist/react-server/createRscStream.d.ts.map +0 -1
- package/dist/react-server/createSsrHandler.d.ts.map +0 -1
- package/dist/react-server/plugin.d.ts.map +0 -1
- package/dist/react-server/plugin.js +0 -345
- package/dist/react-server/plugin.js.map +0 -1
- package/dist/resolvePage.d.ts.map +0 -1
- package/dist/resolveProps.d.ts.map +0 -1
- package/dist/src/build/createBuildConfig.js +0 -44
- package/dist/src/build/createBuildConfig.js.map +0 -1
- package/dist/src/build/mergeInputs.js +0 -16
- package/dist/src/build/mergeInputs.js.map +0 -1
- package/dist/src/checkFilesExist.js +0 -61
- package/dist/src/checkFilesExist.js.map +0 -1
- package/dist/src/collect-css-manifest.js.map +0 -1
- package/dist/src/components.js.map +0 -1
- package/dist/src/getEnv.js +0 -76
- package/dist/src/getEnv.js.map +0 -1
- package/dist/src/helpers/inputNormalizer.js +0 -11
- package/dist/src/helpers/inputNormalizer.js.map +0 -1
- package/dist/src/helpers/normalizedRelativePath.js +0 -34
- package/dist/src/helpers/normalizedRelativePath.js.map +0 -1
- package/dist/src/helpers/tryManifest.js.map +0 -1
- package/dist/src/html/createPageLoader.js +0 -72
- package/dist/src/html/createPageLoader.js.map +0 -1
- package/dist/src/options.js +0 -307
- package/dist/src/options.js.map +0 -1
- package/dist/src/react-server/createHandler.js.map +0 -1
- package/dist/src/react-server/createRscStream.js.map +0 -1
- package/dist/src/resolvePage.js.map +0 -1
- package/dist/src/resolveProps.js.map +0 -1
- package/dist/src/worker/createHtmlStream.js +0 -62
- package/dist/src/worker/createHtmlStream.js.map +0 -1
- package/dist/src/worker/createWorker.js +0 -34
- package/dist/src/worker/createWorker.js.map +0 -1
- package/dist/src/worker/renderPages.js +0 -99
- package/dist/src/worker/renderPages.js.map +0 -1
- package/dist/transformer/index.d.ts.map +0 -1
- package/dist/transformer/preserveDirectives.d.ts +0 -4
- package/dist/transformer/preserveDirectives.d.ts.map +0 -1
- package/dist/transformer/preserver.d.ts +0 -2
- package/dist/transformer/preserver.d.ts.map +0 -1
- package/dist/transformer/transformer.d.ts.map +0 -1
- package/dist/transformer/types.d.ts.map +0 -1
- package/dist/worker/createHtmlStream.d.ts +0 -7
- package/dist/worker/createHtmlStream.d.ts.map +0 -1
- package/dist/worker/createWorker.d.ts +0 -10
- package/dist/worker/createWorker.d.ts.map +0 -1
- package/dist/worker/loader.d.ts.map +0 -1
- package/dist/worker/loader.js +0 -7
- package/dist/worker/loader.js.map +0 -1
- package/dist/worker/renderPages.d.ts +0 -18
- package/dist/worker/renderPages.d.ts.map +0 -1
- package/dist/worker/types.d.ts +0 -31
- package/dist/worker/types.d.ts.map +0 -1
- package/dist/worker/worker.d.ts +0 -7
- package/dist/worker/worker.d.ts.map +0 -1
- package/dist/worker/worker.js +0 -112
- package/dist/worker/worker.js.map +0 -1
- package/src/build/createBuildConfig.ts +0 -57
- package/src/build/mergeInputs.ts +0 -42
- package/src/checkFilesExist.ts +0 -67
- package/src/helpers/inputNormalizer.ts +0 -22
- package/src/index.ts +0 -4
- package/src/options.ts +0 -423
- package/src/plugin.ts +0 -5
- package/src/react-client/plugin.ts +0 -34
- package/src/react-server/plugin.ts +0 -409
- package/src/transformer/index.ts +0 -112
- package/src/transformer/preserveDirectives.ts +0 -100
- package/src/transformer/preserver.ts +0 -47
- package/src/worker/createHtmlStream.ts +0 -76
- package/src/worker/createWorker.ts +0 -44
- package/src/worker/renderPages.ts +0 -144
- package/src/worker/types.ts +0 -38
- package/src/worker/worker.tsx +0 -136
- /package/dist/{assertServerCondition.d.ts → plugin/assertServerCondition.d.ts} +0 -0
- /package/dist/{components.d.ts → plugin/components.d.ts} +0 -0
- /package/dist/{copy-dir.d.ts → plugin/copy-dir.d.ts} +0 -0
- /package/dist/{getEnv.d.ts → plugin/getEnv.d.ts} +0 -0
- /package/dist/{helpers → plugin/helpers}/normalizedRelativePath.d.ts +0 -0
- /package/dist/{helpers → plugin/helpers}/tryManifest.d.ts +0 -0
- /package/dist/{manifest.d.ts → plugin/manifest.d.ts} +0 -0
- /package/dist/{module-graph.d.ts → plugin/module-graph.d.ts} +0 -0
- /package/dist/{react-server → plugin/react-server}/createDevMiddleware.d.ts +0 -0
- /package/dist/{react-server → plugin/react-server}/createDevServer.d.ts +0 -0
- /package/dist/{react-server → plugin/react-server}/createReactNodeStreamer.d.ts +0 -0
- /package/dist/{resolvePage.d.ts → plugin/resolvePage.d.ts} +0 -0
- /package/dist/{resolveProps.d.ts → plugin/resolveProps.d.ts} +0 -0
- /package/dist/{transformer → plugin/transformer}/types.d.ts +0 -0
- /package/dist/{worker → plugin/worker}/loader.d.ts +0 -0
- /package/{src → plugin}/assertServerCondition.ts +0 -0
- /package/{src → plugin}/components.tsx +0 -0
- /package/{src → plugin}/copy-dir.ts +0 -0
- /package/{src/server.tsx → plugin/getCondition.ts} +0 -0
- /package/{src → plugin}/helpers/normalizedRelativePath.ts +0 -0
- /package/{src → plugin}/helpers/tryManifest.ts +0 -0
- /package/{src → plugin}/manifest.ts +0 -0
- /package/{src → plugin}/module-graph.ts +0 -0
- /package/{src → plugin}/transformer/README.md +0 -0
- /package/{src → plugin}/transformer/types.ts +0 -0
- /package/{src → plugin}/worker/loader.ts +0 -0
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { join, resolve } from "node:path";
|
|
2
2
|
import { Writable } from "node:stream";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
3
|
import { Worker } from "node:worker_threads";
|
|
5
4
|
import { type ViteDevServer } from "vite";
|
|
6
|
-
import { DEFAULT_CONFIG } from "../
|
|
5
|
+
import { DEFAULT_CONFIG } from "../config/defaults.js";
|
|
7
6
|
import type { RequestHandler, StreamPluginOptions } from "../types.js";
|
|
8
7
|
import type { WorkerRscChunkMessage } from "../worker/types.js";
|
|
9
8
|
import { createHandler } from "./createHandler.js";
|
|
10
9
|
|
|
11
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
10
|
|
|
13
11
|
export function createSsrHandler(
|
|
14
12
|
options: Required<
|
|
@@ -20,17 +18,16 @@ export function createSsrHandler(
|
|
|
20
18
|
Required<
|
|
21
19
|
Pick<
|
|
22
20
|
StreamPluginOptions,
|
|
23
|
-
"moduleBase" | "moduleBasePath" | "moduleBaseURL" | "projectRoot"
|
|
21
|
+
"moduleBase" | "moduleBasePath" | "moduleBaseURL" | "projectRoot" | "htmlWorkerPath"
|
|
24
22
|
>
|
|
25
|
-
|
|
26
|
-
Pick<StreamPluginOptions, "workerPath">,
|
|
23
|
+
>,
|
|
27
24
|
server: ViteDevServer,
|
|
28
|
-
|
|
25
|
+
_clientComponents: Map<string, string>
|
|
29
26
|
): RequestHandler {
|
|
30
27
|
const worker = new Worker(
|
|
31
|
-
options?.
|
|
32
|
-
? resolve(server.config.root, options?.
|
|
33
|
-
: DEFAULT_CONFIG.
|
|
28
|
+
options?.htmlWorkerPath
|
|
29
|
+
? resolve(server.config.root, options?.htmlWorkerPath)
|
|
30
|
+
: DEFAULT_CONFIG.HTML_WORKER_PATH,
|
|
34
31
|
{
|
|
35
32
|
env: {
|
|
36
33
|
NODE_OPTIONS: "--conditions ''",
|
|
@@ -70,16 +67,16 @@ export function createSsrHandler(
|
|
|
70
67
|
moduleGraph: server.moduleGraph,
|
|
71
68
|
}
|
|
72
69
|
);
|
|
73
|
-
const
|
|
70
|
+
const moduleRootPath = join(
|
|
74
71
|
server.config.cacheDir,
|
|
75
72
|
options.moduleBasePath
|
|
76
73
|
);
|
|
77
|
-
const htmlOutputPath = join(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
);
|
|
74
|
+
// const htmlOutputPath = join(
|
|
75
|
+
// server.config.cacheDir,
|
|
76
|
+
// server.config.build.outDir,
|
|
77
|
+
// req.url,
|
|
78
|
+
// "index.html"
|
|
79
|
+
// );
|
|
83
80
|
if (result.type !== "success") {
|
|
84
81
|
throw new Error(
|
|
85
82
|
result.type === "error" ? String(result.error) : "Skipped"
|
|
@@ -114,7 +111,7 @@ export function createSsrHandler(
|
|
|
114
111
|
type: "RSC_CHUNK",
|
|
115
112
|
id: req.url ?? "/",
|
|
116
113
|
chunk: rscData,
|
|
117
|
-
|
|
114
|
+
moduleRootPath: moduleRootPath,
|
|
118
115
|
moduleBaseURL: options.moduleBaseURL,
|
|
119
116
|
// Don't need file paths in dev mode
|
|
120
117
|
outDir: "",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PluginOption } from "vite";
|
|
2
|
+
import { reactPreservePlugin } from "../preserver/plugin.js";
|
|
3
|
+
import { reactTransformPlugin } from "../transformer/plugin.js";
|
|
4
|
+
import type { StreamPluginOptions } from "../types.js";
|
|
5
|
+
import { reactServerPlugin } from "./plugin.js";
|
|
6
|
+
|
|
7
|
+
export function vitePluginReactServer(options = {} as StreamPluginOptions): PluginOption[] {
|
|
8
|
+
return [
|
|
9
|
+
reactTransformPlugin(options),
|
|
10
|
+
reactServerPlugin(options),
|
|
11
|
+
reactPreservePlugin(options),
|
|
12
|
+
];
|
|
13
|
+
}
|
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
import { join, resolve } from "node:path";
|
|
2
|
+
import { performance } from "node:perf_hooks";
|
|
3
|
+
import { Worker } from "node:worker_threads";
|
|
4
|
+
import type { Plugin as RollupPlugin } from "rollup";
|
|
5
|
+
import type { Plugin as VitePlugin } from "vite";
|
|
6
|
+
import {
|
|
7
|
+
createLogger,
|
|
8
|
+
type ResolvedConfig,
|
|
9
|
+
type UserConfig,
|
|
10
|
+
type ViteDevServer,
|
|
11
|
+
} from "vite";
|
|
12
|
+
import { checkFilesExist } from "../checkFilesExist.js";
|
|
13
|
+
import { tryManifest } from "../helpers/tryManifest.js";
|
|
14
|
+
import { resolveOptions } from "../config/resolveOptions.js";
|
|
15
|
+
import { resolvePages } from "../config/resolvePages.js";
|
|
16
|
+
import { resolveUserConfig } from "../config/resolveUserConfig.js";
|
|
17
|
+
import type {
|
|
18
|
+
BuildTiming,
|
|
19
|
+
CheckFilesExistReturn,
|
|
20
|
+
ReactStreamPluginMeta,
|
|
21
|
+
ResolvedUserConfig,
|
|
22
|
+
ResolvedUserOptions,
|
|
23
|
+
} from "../types.js";
|
|
24
|
+
import { type StreamPluginOptions } from "../types.js";
|
|
25
|
+
import { createWorker } from "../worker/createWorker.js";
|
|
26
|
+
import { renderPages } from "../worker/html/renderPages.js";
|
|
27
|
+
import { createHandler } from "./createHandler.js";
|
|
28
|
+
import { readdirSync } from "fs";
|
|
29
|
+
import type { ServerResponse } from "node:http";
|
|
30
|
+
import { DEFAULT_CONFIG } from "../config/defaults.js";
|
|
31
|
+
import { getPluginRoot } from "../config/getPaths.js";
|
|
32
|
+
import { getModuleManifest } from "../helpers/getModuleManifest.js";
|
|
33
|
+
import { createBuildLoader } from '../loader/createBuildLoader.js';
|
|
34
|
+
import React from "react";
|
|
35
|
+
|
|
36
|
+
export function reactServerPlugin(
|
|
37
|
+
options: StreamPluginOptions
|
|
38
|
+
): VitePlugin & RollupPlugin & { meta: ReactStreamPluginMeta } {
|
|
39
|
+
const timing: BuildTiming = {
|
|
40
|
+
start: performance.now(),
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
let files: CheckFilesExistReturn;
|
|
44
|
+
// let env: Awaited<ReturnType<typeof getEnv>>;
|
|
45
|
+
let worker: Worker;
|
|
46
|
+
let finalConfig: ResolvedConfig;
|
|
47
|
+
let cssModules = new Set<string>();
|
|
48
|
+
let clientComponents = new Map<string, string>();
|
|
49
|
+
// let define: Record<string, string>;
|
|
50
|
+
let buildCssFiles = new Set<string>();
|
|
51
|
+
let root: string = process.cwd();
|
|
52
|
+
let userConfig: ResolvedUserConfig;
|
|
53
|
+
let userOptions: ResolvedUserOptions;
|
|
54
|
+
let moduleGraph: Record<
|
|
55
|
+
string,
|
|
56
|
+
{
|
|
57
|
+
file: string;
|
|
58
|
+
src: string;
|
|
59
|
+
name: string;
|
|
60
|
+
isEntry: boolean;
|
|
61
|
+
imports: string[];
|
|
62
|
+
dynamicImports: string[];
|
|
63
|
+
}
|
|
64
|
+
> = {};
|
|
65
|
+
|
|
66
|
+
interface BuildStats {
|
|
67
|
+
htmlFiles: number;
|
|
68
|
+
clientComponents: number;
|
|
69
|
+
cssFiles: number;
|
|
70
|
+
totalRoutes: number;
|
|
71
|
+
timing: {
|
|
72
|
+
config: number;
|
|
73
|
+
build: number;
|
|
74
|
+
render: number;
|
|
75
|
+
total: number;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const resolvedOptions = resolveOptions(options);
|
|
80
|
+
if (resolvedOptions.type === "error") {
|
|
81
|
+
throw resolvedOptions.error;
|
|
82
|
+
}
|
|
83
|
+
userOptions = resolvedOptions.userOptions;
|
|
84
|
+
root = userOptions.projectRoot;
|
|
85
|
+
return {
|
|
86
|
+
name: "vite:react-stream-server",
|
|
87
|
+
enforce: "post",
|
|
88
|
+
meta: { timing } as ReactStreamPluginMeta,
|
|
89
|
+
api: {
|
|
90
|
+
addCssFile(path: string) {
|
|
91
|
+
buildCssFiles.add(path);
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
configResolved(resolvedConfig) {
|
|
95
|
+
finalConfig = resolvedConfig;
|
|
96
|
+
timing.configResolved = performance.now();
|
|
97
|
+
if (finalConfig.command === "build") {
|
|
98
|
+
finalConfig = {
|
|
99
|
+
...finalConfig,
|
|
100
|
+
mode: "production",
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Verify transformer runs first, preserver runs last
|
|
105
|
+
const plugins = finalConfig.plugins;
|
|
106
|
+
const transformerIndex = plugins.findIndex(
|
|
107
|
+
(p) => p.name === "vite:react-stream-transformer"
|
|
108
|
+
);
|
|
109
|
+
const preserverIndex = plugins.findIndex(
|
|
110
|
+
(p) => p.name === "vite-plugin-react-server:preserve-directives"
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
if (transformerIndex === -1) {
|
|
114
|
+
throw new Error("Transformer plugin not installed");
|
|
115
|
+
}
|
|
116
|
+
if (preserverIndex < transformerIndex) {
|
|
117
|
+
throw new Error("Transformer plugin isn't installed or isn't running before preserver");
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
async configureServer(server: ViteDevServer) {
|
|
121
|
+
if (server.config.root !== root) {
|
|
122
|
+
console.log(
|
|
123
|
+
"[vite-plugin-react-server] Root dir changed",
|
|
124
|
+
server.config.root,
|
|
125
|
+
root
|
|
126
|
+
);
|
|
127
|
+
root = server.config.root;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const activeStreams = new Set<ServerResponse>();
|
|
131
|
+
|
|
132
|
+
// Handle Vite server restarts
|
|
133
|
+
server.ws.on("restart", (path) => {
|
|
134
|
+
console.log(
|
|
135
|
+
"[vite-plugin-react-server] 🔧 Plugin changed, preparing for restart:",
|
|
136
|
+
path
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
// Close streams with restart message
|
|
140
|
+
for (const res of activeStreams) {
|
|
141
|
+
res.writeHead(503, {
|
|
142
|
+
"Content-Type": "text/x-component",
|
|
143
|
+
"Retry-After": "1",
|
|
144
|
+
});
|
|
145
|
+
res.end('{"error":"Server restarting..."}');
|
|
146
|
+
}
|
|
147
|
+
activeStreams.clear();
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
server.ws.on("connection", (_socket, _req) => {
|
|
151
|
+
console.log("[vite-plugin-react-server] hooking up ws connection");
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
server.ws.on("listening", () => {
|
|
155
|
+
console.log("[vite-plugin-react-server] hooking up ws listening");
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
server.middlewares.use(async (req, res, next) => {
|
|
159
|
+
if (req.headers.accept !== "text/x-component") return next();
|
|
160
|
+
console.log("[vite-plugin-react-server] middleware called");
|
|
161
|
+
try {
|
|
162
|
+
const handler = await createHandler(
|
|
163
|
+
req.url ?? "",
|
|
164
|
+
{
|
|
165
|
+
Page: userOptions.Page,
|
|
166
|
+
props: userOptions.props,
|
|
167
|
+
build: userOptions.build,
|
|
168
|
+
Html: React.Fragment,
|
|
169
|
+
pageExportName: userOptions.pageExportName,
|
|
170
|
+
propsExportName: userOptions.propsExportName,
|
|
171
|
+
moduleBase: userOptions.moduleBase,
|
|
172
|
+
moduleBasePath: userOptions.moduleBasePath,
|
|
173
|
+
projectRoot: root,
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
cssFiles: Array.from(cssModules),
|
|
177
|
+
logger: createLogger(),
|
|
178
|
+
loader: server.ssrLoadModule,
|
|
179
|
+
moduleGraph: server.moduleGraph,
|
|
180
|
+
}
|
|
181
|
+
);
|
|
182
|
+
if (handler.type === "success") {
|
|
183
|
+
handler.stream?.pipe(res);
|
|
184
|
+
}
|
|
185
|
+
activeStreams.add(res);
|
|
186
|
+
} finally {
|
|
187
|
+
res.on("close", () => {
|
|
188
|
+
console.log(
|
|
189
|
+
"[vite-plugin-react-server] ➖ Stream closed for:",
|
|
190
|
+
req.url
|
|
191
|
+
);
|
|
192
|
+
activeStreams.delete(res);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
},
|
|
197
|
+
async config(config, configEnv): Promise<UserConfig> {
|
|
198
|
+
if(typeof config.root === 'string' && config.root !== root) {
|
|
199
|
+
console.log("[vite-plugin-react-server] Root dir changed", config.root, root);
|
|
200
|
+
root = config.root
|
|
201
|
+
}
|
|
202
|
+
const resolvedPages = await resolvePages(userOptions.build.pages);
|
|
203
|
+
if (resolvedPages.type === "error") {
|
|
204
|
+
throw resolvedPages.error;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
files = await checkFilesExist(
|
|
208
|
+
resolvedPages.pages,
|
|
209
|
+
userOptions,
|
|
210
|
+
root
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
const resolvedConfig = resolveUserConfig({
|
|
214
|
+
condition: "react-server",
|
|
215
|
+
config,
|
|
216
|
+
configEnv,
|
|
217
|
+
userOptions,
|
|
218
|
+
files,
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
if (resolvedConfig.type === "error") {
|
|
222
|
+
throw resolvedConfig.error;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
userConfig = resolvedConfig.userConfig;
|
|
226
|
+
|
|
227
|
+
return resolvedConfig.userConfig;
|
|
228
|
+
},
|
|
229
|
+
async buildStart() {
|
|
230
|
+
if (!timing.buildStart) {
|
|
231
|
+
timing.buildStart = performance.now();
|
|
232
|
+
} else {
|
|
233
|
+
console.log("Build already started");
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
async closeBundle() {
|
|
237
|
+
if (!userConfig || finalConfig.command !== "build") return;
|
|
238
|
+
try {
|
|
239
|
+
timing.renderStart = performance.now();
|
|
240
|
+
|
|
241
|
+
const resolvedServerManifest = tryManifest({
|
|
242
|
+
root,
|
|
243
|
+
outDir: userOptions.build.server,
|
|
244
|
+
ssrManifest: false,
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
const serverManifest =
|
|
248
|
+
resolvedServerManifest.type === "error"
|
|
249
|
+
? getModuleManifest.bind(this)()
|
|
250
|
+
: resolvedServerManifest.manifest;
|
|
251
|
+
// Get worker path from manifest
|
|
252
|
+
// Look for the html-worker entry directly
|
|
253
|
+
let htmlWorkerPath = serverManifest["html-worker"]?.file;
|
|
254
|
+
|
|
255
|
+
if (options.htmlWorkerPath) {
|
|
256
|
+
htmlWorkerPath = join(root, options.htmlWorkerPath);
|
|
257
|
+
} else {
|
|
258
|
+
htmlWorkerPath = join(
|
|
259
|
+
getPluginRoot(),
|
|
260
|
+
DEFAULT_CONFIG.HTML_WORKER_PATH
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Initialize worker with path from server directory
|
|
265
|
+
const workerPath = resolve(
|
|
266
|
+
root,
|
|
267
|
+
userOptions.build.server,
|
|
268
|
+
htmlWorkerPath
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
worker = await createWorker({
|
|
272
|
+
projectRoot: userOptions.projectRoot,
|
|
273
|
+
workerPath,
|
|
274
|
+
condition: "react-server",
|
|
275
|
+
reverseCondition: true,
|
|
276
|
+
mode: finalConfig.mode as "production" | "development",
|
|
277
|
+
nodeOptions: "--conditions=react-client",
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
// Get routes directly from pages
|
|
282
|
+
const resolvedPages = await resolvePages(userOptions.build.pages);
|
|
283
|
+
if (resolvedPages.type === "error") {
|
|
284
|
+
throw resolvedPages.error;
|
|
285
|
+
}
|
|
286
|
+
const routes = resolvedPages.pages;
|
|
287
|
+
console.log("[plugin] Routes to render:", routes);
|
|
288
|
+
|
|
289
|
+
const entries = Object.values(serverManifest).filter(
|
|
290
|
+
(entry) => entry.isEntry
|
|
291
|
+
);
|
|
292
|
+
const css = entries.flatMap((entry) => entry.css);
|
|
293
|
+
const loader = createBuildLoader({
|
|
294
|
+
root,
|
|
295
|
+
userConfig,
|
|
296
|
+
pluginContext: this
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
const { failedRoutes, completedRoutes } = await renderPages(routes, {
|
|
300
|
+
pipableStreamOptions: {
|
|
301
|
+
bootstrapModules: entries.map((entry) => "/" + entry.file),
|
|
302
|
+
},
|
|
303
|
+
moduleBasePath: userOptions.moduleBasePath,
|
|
304
|
+
moduleBaseURL: userOptions.moduleBaseURL,
|
|
305
|
+
clientCss: css?.map((css) => "/" + css) ?? [],
|
|
306
|
+
userConfig,
|
|
307
|
+
pluginOptions: userOptions,
|
|
308
|
+
worker: worker,
|
|
309
|
+
manifest: serverManifest,
|
|
310
|
+
loader,
|
|
311
|
+
onCssFile: (path: string) => {
|
|
312
|
+
if (buildCssFiles && path.endsWith(".css")) {
|
|
313
|
+
buildCssFiles.add(path);
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
// Debug render results
|
|
319
|
+
console.log("[vite-plugin-react-server] Render results:", {
|
|
320
|
+
failedRoutes,
|
|
321
|
+
completedRoutes,
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
if (failedRoutes.size) {
|
|
325
|
+
console.error(
|
|
326
|
+
"[vite-plugin-react-server] Failed to render routes:",
|
|
327
|
+
failedRoutes
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
console.log("[vite-plugin-react-server] Render complete");
|
|
331
|
+
console.log("[vite-plugin-react-server] Terminating worker");
|
|
332
|
+
if (worker) await worker.terminate();
|
|
333
|
+
|
|
334
|
+
timing.renderEnd = performance.now();
|
|
335
|
+
timing.total = (timing.renderEnd - timing.start) / 1000;
|
|
336
|
+
|
|
337
|
+
// Collect stats
|
|
338
|
+
const stats: BuildStats = {
|
|
339
|
+
htmlFiles: routes.length,
|
|
340
|
+
clientComponents: clientComponents.size,
|
|
341
|
+
cssFiles: cssModules.size,
|
|
342
|
+
totalRoutes: routes.length,
|
|
343
|
+
timing: {
|
|
344
|
+
config: ((timing.configResolved ?? 0) - timing.start) / 1000,
|
|
345
|
+
build:
|
|
346
|
+
((timing.buildStart ?? 0) - (timing.configResolved ?? 0)) / 1000,
|
|
347
|
+
render:
|
|
348
|
+
((timing.renderEnd ?? 0) - (timing.renderStart ?? 0)) / 1000,
|
|
349
|
+
total: (timing.renderEnd ?? 0 - timing.start) / 1000,
|
|
350
|
+
},
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
// Format duration helper
|
|
354
|
+
const formatDuration = (seconds: number) => {
|
|
355
|
+
if (seconds < 0.001) {
|
|
356
|
+
return `${(seconds * 1000000).toFixed(0)}μs`;
|
|
357
|
+
}
|
|
358
|
+
if (seconds < 1) {
|
|
359
|
+
return `${(seconds * 1000).toFixed(0)}ms`;
|
|
360
|
+
}
|
|
361
|
+
return `${seconds.toFixed(2)}s`;
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
console.log("\n[vite-plugin-react-server] Build Summary:");
|
|
365
|
+
console.log("─".repeat(50));
|
|
366
|
+
console.log(`�� Generated ${stats.htmlFiles} HTML files`);
|
|
367
|
+
console.log(`🎯 Processed ${stats.clientComponents} client components`);
|
|
368
|
+
console.log(`🎨 Included ${stats.cssFiles} CSS files`);
|
|
369
|
+
console.log(`🛣️ Total routes: ${stats.totalRoutes}`);
|
|
370
|
+
console.log("─".repeat(50));
|
|
371
|
+
console.log("⏱️ Timing:");
|
|
372
|
+
console.log(` Config: ${formatDuration(stats.timing.config)}`);
|
|
373
|
+
console.log(` Build: ${formatDuration(stats.timing.build)}`);
|
|
374
|
+
console.log(` Render: ${formatDuration(stats.timing.render)}`);
|
|
375
|
+
console.log(" ".repeat(12));
|
|
376
|
+
console.log(` Total: ${formatDuration(stats.timing.total)}`);
|
|
377
|
+
console.log("─".repeat(50));
|
|
378
|
+
|
|
379
|
+
// Ensure worker is terminated
|
|
380
|
+
if (worker) {
|
|
381
|
+
console.log("[vite-plugin-react-server] Terminating worker...");
|
|
382
|
+
await worker.terminate();
|
|
383
|
+
worker = null as any;
|
|
384
|
+
}
|
|
385
|
+
} catch (error) {
|
|
386
|
+
console.error("[vite-plugin-react-server] Build failed:", error);
|
|
387
|
+
// Make sure to terminate worker even on error
|
|
388
|
+
if (worker) await worker.terminate();
|
|
389
|
+
throw error;
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
async buildEnd(error) {
|
|
393
|
+
if (error) {
|
|
394
|
+
console.error("[vite-plugin-react-server] Build error:", error);
|
|
395
|
+
}
|
|
396
|
+
if (worker) await worker.terminate();
|
|
397
|
+
},
|
|
398
|
+
handleHotUpdate({ file }) {
|
|
399
|
+
if (file.endsWith(".css")) {
|
|
400
|
+
cssModules.add(file);
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
async renderChunk(_code: string, chunk: any, _options: any) {
|
|
404
|
+
const moduleIds = this.getModuleIds();
|
|
405
|
+
const fallbackManifestEntries = Object.fromEntries(
|
|
406
|
+
Array.from(moduleIds)
|
|
407
|
+
.map((module) => {
|
|
408
|
+
const moduleInfo = this.getModuleInfo(module);
|
|
409
|
+
if (!moduleInfo) return [module, null];
|
|
410
|
+
const {
|
|
411
|
+
code,
|
|
412
|
+
id,
|
|
413
|
+
isEntry,
|
|
414
|
+
importedIds,
|
|
415
|
+
dynamicallyImportedIds,
|
|
416
|
+
...rest
|
|
417
|
+
} = moduleInfo;
|
|
418
|
+
return [
|
|
419
|
+
chunk.name ?? id,
|
|
420
|
+
{
|
|
421
|
+
file: chunk.fileName,
|
|
422
|
+
src: module,
|
|
423
|
+
name: chunk.name ?? id,
|
|
424
|
+
isEntry: chunk.isEntry ?? isEntry,
|
|
425
|
+
imports: chunk.imports ?? importedIds,
|
|
426
|
+
dynamicImports: chunk.dynamicImports ?? dynamicallyImportedIds,
|
|
427
|
+
directive: rest.meta["directive"],
|
|
428
|
+
css: chunk.viteMetadata?.importedCss ?? [],
|
|
429
|
+
assets: chunk.viteMetadata?.importedAssets ?? [],
|
|
430
|
+
},
|
|
431
|
+
];
|
|
432
|
+
})
|
|
433
|
+
.filter(Boolean)
|
|
434
|
+
);
|
|
435
|
+
|
|
436
|
+
moduleGraph = {
|
|
437
|
+
...moduleGraph,
|
|
438
|
+
...fallbackManifestEntries,
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
if (chunk.fileName.includes("html-worker")) {
|
|
442
|
+
const workerPath = resolve(
|
|
443
|
+
root,
|
|
444
|
+
userOptions.build.server,
|
|
445
|
+
chunk.fileName
|
|
446
|
+
);
|
|
447
|
+
console.log("Files in output dir:", {
|
|
448
|
+
files: readdirSync(resolve(root, userOptions.build.server)),
|
|
449
|
+
workerPath,
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
// Don't initialize worker during build phase
|
|
453
|
+
if (finalConfig.command === "build") {
|
|
454
|
+
return null;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
worker = await createWorker({
|
|
458
|
+
projectRoot: userOptions.projectRoot,
|
|
459
|
+
workerPath,
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
return null;
|
|
463
|
+
},
|
|
464
|
+
};
|
|
465
|
+
}
|
|
@@ -56,7 +56,7 @@ export async function resolvePage({
|
|
|
56
56
|
typeof pageModule === "object" && pageModule != null
|
|
57
57
|
? keys.length
|
|
58
58
|
? "Available exports: " + keys.join(", ")
|
|
59
|
-
: "The object was defined but has no properties."
|
|
59
|
+
: "The object was defined but has no properties. \"" + JSON.stringify(pageModule) + "\""
|
|
60
60
|
: "typeof pageModule =" + typeof pageModule
|
|
61
61
|
}`,
|
|
62
62
|
{ cause: pageModule }
|
|
@@ -37,11 +37,14 @@ export async function resolveProps({
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
const keys = Object.keys(propsModule);
|
|
40
|
-
|
|
40
|
+
let found = keys.find((v) => v === exportName || v === url || v === path);
|
|
41
|
+
if(exportName in propsModule) {
|
|
42
|
+
found = exportName;
|
|
43
|
+
}
|
|
41
44
|
if (found) {
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
let value = propsModule[found];
|
|
44
46
|
try {
|
|
47
|
+
console.log("[resolveProps] Found:", found, value);
|
|
45
48
|
// If it's a function, call it with the URL
|
|
46
49
|
if (isFunction(value)) {
|
|
47
50
|
const props = await value(url);
|
|
@@ -71,7 +74,7 @@ export async function resolveProps({
|
|
|
71
74
|
};
|
|
72
75
|
}
|
|
73
76
|
|
|
74
|
-
|
|
77
|
+
|
|
75
78
|
return {
|
|
76
79
|
type: "error",
|
|
77
80
|
error: new Error(
|
|
@@ -104,10 +107,16 @@ export async function resolveProps({
|
|
|
104
107
|
: exportKeys.length
|
|
105
108
|
? exportKeys.join(", ")
|
|
106
109
|
: "no keys"
|
|
107
|
-
}, this will not work. Make sure to set esModule: true in rollupOptions.output`
|
|
110
|
+
}, this will not work. Make sure to set esModule: true in rollupOptions.output. ${JSON.stringify(propsModule)}`
|
|
108
111
|
),
|
|
109
112
|
};
|
|
110
113
|
}
|
|
114
|
+
if (Object.keys(propsModule).includes("error")) {
|
|
115
|
+
return {
|
|
116
|
+
type: "error",
|
|
117
|
+
error: propsModule["error"],
|
|
118
|
+
};
|
|
119
|
+
}
|
|
111
120
|
|
|
112
121
|
return {
|
|
113
122
|
type: "error",
|
|
@@ -115,7 +124,7 @@ export async function resolveProps({
|
|
|
115
124
|
`Could not find props export "${exportName}" in "${path}". ${
|
|
116
125
|
keys.length
|
|
117
126
|
? "Available exports: " + keys.join(", ")
|
|
118
|
-
: "The object was defined but has no properties."
|
|
127
|
+
: "The object was defined but has no properties. \"" + JSON.stringify(propsModule) + "\""
|
|
119
128
|
}`
|
|
120
129
|
),
|
|
121
130
|
};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { reactTransformPlugin } from "./plugin.js";
|