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,345 +0,0 @@
|
|
|
1
|
-
import "node:fs";
|
|
2
|
-
import { relative, join, resolve } from "node:path";
|
|
3
|
-
import { performance } from "node:perf_hooks";
|
|
4
|
-
import "node:worker_threads";
|
|
5
|
-
import { createLogger } from "vite";
|
|
6
|
-
import { createBuildConfig } from "../src/build/createBuildConfig.js";
|
|
7
|
-
import { checkFilesExist } from "../src/checkFilesExist.js";
|
|
8
|
-
import { getEnv } from "../src/getEnv.js";
|
|
9
|
-
import { createPageLoader } from "../src/html/createPageLoader.js";
|
|
10
|
-
import { renderPages } from "../src/worker/renderPages.js";
|
|
11
|
-
import { resolveOptions, resolvePages, resolveUserConfig } from "../src/options.js";
|
|
12
|
-
import { createWorker } from "../src/worker/createWorker.js";
|
|
13
|
-
import { createHandler } from "../src/react-server/createHandler.js";
|
|
14
|
-
import { tryManifest } from "../src/helpers/tryManifest.js";
|
|
15
|
-
let files;
|
|
16
|
-
let env;
|
|
17
|
-
let worker;
|
|
18
|
-
let config;
|
|
19
|
-
let cssModules = /* @__PURE__ */ new Set();
|
|
20
|
-
let clientComponents = /* @__PURE__ */ new Map();
|
|
21
|
-
let define;
|
|
22
|
-
let buildCssFiles = /* @__PURE__ */ new Set();
|
|
23
|
-
let root = process.cwd();
|
|
24
|
-
async function reactStreamPlugin(options = {}) {
|
|
25
|
-
const timing = {
|
|
26
|
-
start: performance.now()
|
|
27
|
-
};
|
|
28
|
-
const resolvedOptions = resolveOptions(options);
|
|
29
|
-
if (resolvedOptions.type === "error") {
|
|
30
|
-
console.error(
|
|
31
|
-
"[vite-react-stream:server] Error resolving userOptions. Please check your userOptions."
|
|
32
|
-
);
|
|
33
|
-
throw resolvedOptions.error;
|
|
34
|
-
}
|
|
35
|
-
const { userOptions } = resolvedOptions;
|
|
36
|
-
return {
|
|
37
|
-
name: "vite:react-stream",
|
|
38
|
-
meta: {
|
|
39
|
-
timing
|
|
40
|
-
},
|
|
41
|
-
api: {
|
|
42
|
-
addCssFile(path) {
|
|
43
|
-
buildCssFiles.add(path);
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
configResolved(resolvedConfig) {
|
|
47
|
-
if (resolvedConfig.command === "build") {
|
|
48
|
-
timing.configResolved = performance.now();
|
|
49
|
-
console.log("[vite-react-stream] Starting build...");
|
|
50
|
-
}
|
|
51
|
-
config = resolvedConfig;
|
|
52
|
-
},
|
|
53
|
-
async configureServer(server) {
|
|
54
|
-
if (server.config.root) {
|
|
55
|
-
console.log(
|
|
56
|
-
"[vite-react-stream] Root dir changed",
|
|
57
|
-
server.config.root,
|
|
58
|
-
server.config.root
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
const activeStreams = /* @__PURE__ */ new Set();
|
|
62
|
-
server.ws.on("restart", (path) => {
|
|
63
|
-
console.log(
|
|
64
|
-
"[vite-react-stream] 🔧 Plugin changed, preparing for restart:",
|
|
65
|
-
path
|
|
66
|
-
);
|
|
67
|
-
for (const res of activeStreams) {
|
|
68
|
-
res.writeHead(503, {
|
|
69
|
-
"Content-Type": "text/x-component",
|
|
70
|
-
"Retry-After": "1"
|
|
71
|
-
});
|
|
72
|
-
res.end('{"error":"Server restarting..."}');
|
|
73
|
-
}
|
|
74
|
-
activeStreams.clear();
|
|
75
|
-
});
|
|
76
|
-
server.ws.on("connection", (socket, req) => {
|
|
77
|
-
console.log("[vite-react-stream] hooking up ws connection");
|
|
78
|
-
});
|
|
79
|
-
server.ws.on("listening", () => {
|
|
80
|
-
console.log("[vite-react-stream] hooking up ws listening");
|
|
81
|
-
});
|
|
82
|
-
server.middlewares.use(async (req, res, next) => {
|
|
83
|
-
if (req.headers.accept !== "text/x-component") return next();
|
|
84
|
-
console.log("[vite-react-stream] middleware called");
|
|
85
|
-
try {
|
|
86
|
-
const handler = await createHandler(
|
|
87
|
-
req.url ?? "",
|
|
88
|
-
{
|
|
89
|
-
Page: userOptions.Page,
|
|
90
|
-
props: userOptions.props,
|
|
91
|
-
build: userOptions.build,
|
|
92
|
-
Html: ({ children }) => children,
|
|
93
|
-
pageExportName: userOptions.pageExportName,
|
|
94
|
-
propsExportName: userOptions.propsExportName,
|
|
95
|
-
moduleBase: userOptions.moduleBase,
|
|
96
|
-
moduleBasePath: userOptions.moduleBasePath,
|
|
97
|
-
projectRoot: server.config.root ?? userOptions.projectRoot
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
cssFiles: Array.from(cssModules),
|
|
101
|
-
logger: createLogger(),
|
|
102
|
-
loader: server.ssrLoadModule,
|
|
103
|
-
moduleGraph: server.moduleGraph
|
|
104
|
-
}
|
|
105
|
-
);
|
|
106
|
-
handler?.stream?.pipe(res);
|
|
107
|
-
} finally {
|
|
108
|
-
res.on("close", () => {
|
|
109
|
-
console.log("[vite-react-stream] ➖ Stream closed for:", req.url);
|
|
110
|
-
activeStreams.delete(res);
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
},
|
|
115
|
-
async config(config2, configEnv) {
|
|
116
|
-
const resolvedPages = await resolvePages(userOptions.build.pages);
|
|
117
|
-
if (resolvedPages.type === "error") {
|
|
118
|
-
throw resolvedPages.error;
|
|
119
|
-
}
|
|
120
|
-
const { pages } = resolvedPages;
|
|
121
|
-
env = getEnv(config2, configEnv);
|
|
122
|
-
define = env.define;
|
|
123
|
-
files = await checkFilesExist(
|
|
124
|
-
pages,
|
|
125
|
-
userOptions,
|
|
126
|
-
config2.root ?? userOptions.projectRoot
|
|
127
|
-
);
|
|
128
|
-
root = config2.root ?? userOptions.projectRoot;
|
|
129
|
-
const resolvedConfig = resolveUserConfig(
|
|
130
|
-
"react-server",
|
|
131
|
-
[...pages, userOptions.workerPath, userOptions.loaderPath],
|
|
132
|
-
config2,
|
|
133
|
-
configEnv,
|
|
134
|
-
userOptions
|
|
135
|
-
);
|
|
136
|
-
if (resolvedConfig.type === "error") {
|
|
137
|
-
throw resolvedConfig.error;
|
|
138
|
-
}
|
|
139
|
-
const { userConfig } = resolvedConfig;
|
|
140
|
-
console.log({
|
|
141
|
-
worker: userOptions.workerPath,
|
|
142
|
-
loader: userOptions.loaderPath
|
|
143
|
-
});
|
|
144
|
-
const entriesClient = Object.fromEntries([
|
|
145
|
-
...Array.from(files.pageMap.entries()).map(([key, value]) => [
|
|
146
|
-
key,
|
|
147
|
-
relative(root, value)
|
|
148
|
-
]),
|
|
149
|
-
...Array.from(files.propsMap.entries()).map(([key, value]) => [
|
|
150
|
-
key,
|
|
151
|
-
relative(root, value)
|
|
152
|
-
])
|
|
153
|
-
]);
|
|
154
|
-
const entriesResolved = Object.fromEntries(
|
|
155
|
-
Object.entries(entriesClient).map(
|
|
156
|
-
([key, entry]) => {
|
|
157
|
-
if (typeof entry !== "string") {
|
|
158
|
-
return [key, entry];
|
|
159
|
-
}
|
|
160
|
-
return [key, entry];
|
|
161
|
-
}
|
|
162
|
-
)
|
|
163
|
-
);
|
|
164
|
-
const serverEntries = {
|
|
165
|
-
...entriesResolved,
|
|
166
|
-
["worker/worker"]: userOptions.workerPath,
|
|
167
|
-
["worker/loader"]: userOptions.loaderPath
|
|
168
|
-
};
|
|
169
|
-
const buildConfig = createBuildConfig({
|
|
170
|
-
input: serverEntries,
|
|
171
|
-
userConfig,
|
|
172
|
-
userOptions,
|
|
173
|
-
root,
|
|
174
|
-
moduleBaseExceptions: [
|
|
175
|
-
userOptions.workerPath,
|
|
176
|
-
userOptions.loaderPath,
|
|
177
|
-
...userOptions.moduleBaseExceptions
|
|
178
|
-
]
|
|
179
|
-
});
|
|
180
|
-
return {
|
|
181
|
-
...buildConfig,
|
|
182
|
-
define,
|
|
183
|
-
plugins: config2.plugins
|
|
184
|
-
};
|
|
185
|
-
},
|
|
186
|
-
async buildStart() {
|
|
187
|
-
timing.buildStart = performance.now();
|
|
188
|
-
},
|
|
189
|
-
async closeBundle() {
|
|
190
|
-
if (!config) return;
|
|
191
|
-
console.log("RSC CLOSE BUNDLE CALLED");
|
|
192
|
-
if (!files.pageSet.size) return;
|
|
193
|
-
timing.renderStart = performance.now();
|
|
194
|
-
try {
|
|
195
|
-
const resolvedServerManifest = tryManifest({
|
|
196
|
-
root,
|
|
197
|
-
outDir: userOptions.build.server,
|
|
198
|
-
ssrManifest: false
|
|
199
|
-
});
|
|
200
|
-
if (resolvedServerManifest.type === "error") {
|
|
201
|
-
console.error(
|
|
202
|
-
"[vite-react-stream] Server Build failed, can not build without a server manifest. Please set `manifest: true` in your vite config.",
|
|
203
|
-
resolvedServerManifest.error
|
|
204
|
-
);
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
const { manifest: serverManifest } = resolvedServerManifest;
|
|
208
|
-
const workerPath = serverManifest[userOptions.workerPath]?.file ?? serverManifest[relative(root, userOptions.workerPath)]?.file ?? serverManifest[relative(
|
|
209
|
-
join(root, userOptions.build.server),
|
|
210
|
-
userOptions.workerPath
|
|
211
|
-
)]?.file;
|
|
212
|
-
if (!workerPath) {
|
|
213
|
-
console.log(serverManifest, userOptions.build.server);
|
|
214
|
-
throw new Error(
|
|
215
|
-
`Worker path not found in server manifest, tried: ${userOptions.workerPath}, ${relative(root, userOptions.workerPath)}, ${join(root, userOptions.build.server, userOptions.workerPath)}`
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
console.log("workerPath", workerPath);
|
|
219
|
-
const resolvedClientManifest = tryManifest({
|
|
220
|
-
root,
|
|
221
|
-
outDir: userOptions.build.client,
|
|
222
|
-
ssrManifest: false
|
|
223
|
-
});
|
|
224
|
-
if (resolvedClientManifest.type === "error") {
|
|
225
|
-
console.error(
|
|
226
|
-
"[vite-react-stream] Server Build failed, can not build without a client manifest. Make sure to run the client build before the server build and set `manifest: true` in your vite config.",
|
|
227
|
-
resolvedClientManifest.error
|
|
228
|
-
);
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
const { manifest: clientManifest } = resolvedClientManifest;
|
|
232
|
-
if (!worker)
|
|
233
|
-
worker = await createWorker({
|
|
234
|
-
workerPath: join(root, userOptions.build.server, workerPath),
|
|
235
|
-
nodePath: process.env["NODE_PATH"] ?? resolve(root, "node_modules"),
|
|
236
|
-
mode: process.env["NODE_ENV"] === "development" ? "development" : "production"
|
|
237
|
-
});
|
|
238
|
-
const routes = Array.from(files.pageMap.keys());
|
|
239
|
-
const indexEntry = clientManifest["index.html"];
|
|
240
|
-
if (!indexEntry) {
|
|
241
|
-
throw new Error("root /index.html not found");
|
|
242
|
-
}
|
|
243
|
-
await renderPages(routes, {
|
|
244
|
-
pipableStreamOptions: {
|
|
245
|
-
bootstrapModules: ["/" + indexEntry.file]
|
|
246
|
-
},
|
|
247
|
-
outDir: config.build.outDir,
|
|
248
|
-
clientCss: indexEntry.css?.map((css) => "/" + css) ?? [],
|
|
249
|
-
pluginOptions: {
|
|
250
|
-
Page: userOptions.Page,
|
|
251
|
-
props: userOptions.props,
|
|
252
|
-
build: userOptions.build,
|
|
253
|
-
Html: userOptions.Html,
|
|
254
|
-
pageExportName: userOptions.pageExportName,
|
|
255
|
-
propsExportName: userOptions.propsExportName,
|
|
256
|
-
moduleBase: userOptions.moduleBase,
|
|
257
|
-
moduleBasePath: userOptions.moduleBasePath,
|
|
258
|
-
moduleBaseURL: userOptions.moduleBaseURL,
|
|
259
|
-
projectRoot: root
|
|
260
|
-
},
|
|
261
|
-
worker,
|
|
262
|
-
manifest: clientManifest,
|
|
263
|
-
loader: createPageLoader({
|
|
264
|
-
manifest: clientManifest,
|
|
265
|
-
root: config.root,
|
|
266
|
-
outDir: config.build.outDir,
|
|
267
|
-
moduleBase: userOptions.moduleBase,
|
|
268
|
-
alwaysRegisterServer: false,
|
|
269
|
-
alwaysRegisterClient: false,
|
|
270
|
-
registerServer: [],
|
|
271
|
-
registerClient: Object.keys(resolvedClientManifest).filter(
|
|
272
|
-
(key) => key.endsWith(".client.tsx") && clientManifest[key].isEntry
|
|
273
|
-
)
|
|
274
|
-
}),
|
|
275
|
-
onCssFile: (path) => buildCssFiles.add(path)
|
|
276
|
-
});
|
|
277
|
-
console.log("[vite-react-stream] Render complete");
|
|
278
|
-
console.log("[vite-react-stream] Terminating worker");
|
|
279
|
-
if (worker) await worker.terminate();
|
|
280
|
-
timing.renderEnd = performance.now();
|
|
281
|
-
timing.total = (timing.renderEnd - timing.start) / 1e3;
|
|
282
|
-
const stats = {
|
|
283
|
-
htmlFiles: routes.length,
|
|
284
|
-
clientComponents: clientComponents.size,
|
|
285
|
-
cssFiles: cssModules.size,
|
|
286
|
-
totalRoutes: routes.length,
|
|
287
|
-
timing: {
|
|
288
|
-
config: ((timing.configResolved ?? 0) - timing.start) / 1e3,
|
|
289
|
-
build: ((timing.buildStart ?? 0) - (timing.configResolved ?? 0)) / 1e3,
|
|
290
|
-
render: ((timing.renderEnd ?? 0) - (timing.renderStart ?? 0)) / 1e3,
|
|
291
|
-
total: (timing.renderEnd ?? 0 - timing.start) / 1e3
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
const formatDuration = (seconds) => {
|
|
295
|
-
if (seconds < 1e-3) {
|
|
296
|
-
return `${(seconds * 1e6).toFixed(0)}μs`;
|
|
297
|
-
}
|
|
298
|
-
if (seconds < 1) {
|
|
299
|
-
return `${(seconds * 1e3).toFixed(0)}ms`;
|
|
300
|
-
}
|
|
301
|
-
return `${seconds.toFixed(2)}s`;
|
|
302
|
-
};
|
|
303
|
-
console.log("\n[vite-react-stream] Build Summary:");
|
|
304
|
-
console.log("─".repeat(50));
|
|
305
|
-
console.log(`📄 Generated ${stats.htmlFiles} HTML files`);
|
|
306
|
-
console.log(`🎯 Processed ${stats.clientComponents} client components`);
|
|
307
|
-
console.log(`🎨 Included ${stats.cssFiles} CSS files`);
|
|
308
|
-
console.log(`🛣️ Total routes: ${stats.totalRoutes}`);
|
|
309
|
-
console.log("─".repeat(50));
|
|
310
|
-
console.log("⏱️ Timing:");
|
|
311
|
-
console.log(` Config: ${formatDuration(stats.timing.config)}`);
|
|
312
|
-
console.log(` Build: ${formatDuration(stats.timing.build)}`);
|
|
313
|
-
console.log(` Render: ${formatDuration(stats.timing.render)}`);
|
|
314
|
-
console.log(" ".repeat(12));
|
|
315
|
-
console.log(` Total: ${formatDuration(stats.timing.total)}`);
|
|
316
|
-
console.log("─".repeat(50));
|
|
317
|
-
} catch (error) {
|
|
318
|
-
console.error("[vite-react-stream] Build failed:", error);
|
|
319
|
-
throw error;
|
|
320
|
-
}
|
|
321
|
-
},
|
|
322
|
-
async buildEnd(error) {
|
|
323
|
-
if (error) {
|
|
324
|
-
console.error("[vite-react-stream] Build error:", error);
|
|
325
|
-
}
|
|
326
|
-
if (worker) await worker.terminate();
|
|
327
|
-
},
|
|
328
|
-
handleHotUpdate({ file }) {
|
|
329
|
-
if (file.endsWith(".css")) {
|
|
330
|
-
cssModules.add(file);
|
|
331
|
-
}
|
|
332
|
-
},
|
|
333
|
-
transform(code, id) {
|
|
334
|
-
if ((id.includes(".client") || code.startsWith('"use client"') || code.startsWith("use client")) && !id.includes("node_modules")) {
|
|
335
|
-
console.log("[vite-react-stream] Client component added", id);
|
|
336
|
-
clientComponents.set(id, code);
|
|
337
|
-
}
|
|
338
|
-
return { code };
|
|
339
|
-
}
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
export {
|
|
343
|
-
reactStreamPlugin
|
|
344
|
-
};
|
|
345
|
-
//# sourceMappingURL=plugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["../../src/react-server/plugin.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport type { ServerResponse } from \"node:http\";\nimport { join, relative, resolve, resolve as resolvePath } from \"node:path\";\nimport { performance } from \"node:perf_hooks\";\nimport { Worker } from \"node:worker_threads\";\nimport type { Plugin as RollupPlugin } from \"rollup\";\nimport type { Manifest, Plugin as VitePlugin } from \"vite\";\nimport {\n createLogger,\n type ResolvedConfig,\n type UserConfig,\n type ViteDevServer,\n} from \"vite\";\nimport { createBuildConfig } from \"../build/createBuildConfig.js\";\nimport { checkFilesExist } from \"../checkFilesExist.js\";\nimport { getEnv } from \"../getEnv.js\";\nimport { createPageLoader } from \"../html/createPageLoader.js\";\nimport { renderPages } from \"../worker/renderPages.js\";\nimport { resolveOptions, resolvePages, resolveUserConfig } from \"../options.js\";\nimport type { BuildTiming, ReactStreamPluginMeta } from \"../types.js\";\nimport { type StreamPluginOptions } from \"../types.js\";\nimport { createWorker } from \"../worker/createWorker.js\";\nimport { createHandler } from \"./createHandler.js\";\nimport { tryManifest } from \"../helpers/tryManifest.js\";\nimport { createNormalizedRelativePath } from \"../helpers/normalizedRelativePath.js\";\n\nlet files: Awaited<ReturnType<typeof checkFilesExist>>;\nlet env: Awaited<ReturnType<typeof getEnv>>;\nlet worker: Worker;\nlet config: ResolvedConfig;\nlet cssModules = new Set<string>();\nlet clientComponents = new Map<string, string>();\nlet define: Record<string, string>;\nlet buildCssFiles = new Set<string>();\nlet root: string = process.cwd();\n\ninterface BuildStats {\n htmlFiles: number;\n clientComponents: number;\n cssFiles: number;\n totalRoutes: number;\n timing: {\n config: number;\n build: number;\n render: number;\n total: number;\n };\n}\n\nexport async function reactStreamPlugin(\n options: StreamPluginOptions = {} as StreamPluginOptions\n): Promise<VitePlugin & RollupPlugin & { meta: ReactStreamPluginMeta }> {\n const timing: BuildTiming = {\n start: performance.now(),\n };\n const resolvedOptions = resolveOptions(options);\n if (resolvedOptions.type === \"error\") {\n console.error(\n \"[vite-react-stream:server] Error resolving userOptions. Please check your userOptions.\"\n );\n throw resolvedOptions.error;\n }\n const { userOptions } = resolvedOptions;\n return {\n name: \"vite:react-stream\",\n meta: {\n timing,\n } as ReactStreamPluginMeta,\n api: {\n addCssFile(path: string) {\n buildCssFiles.add(path);\n },\n },\n configResolved(resolvedConfig) {\n if (resolvedConfig.command === \"build\") {\n timing.configResolved = performance.now();\n console.log(\"[vite-react-stream] Starting build...\");\n }\n config = resolvedConfig;\n },\n async configureServer(server: ViteDevServer) {\n if (server.config.root) {\n console.log(\n \"[vite-react-stream] Root dir changed\",\n server.config.root,\n server.config.root\n );\n }\n\n const activeStreams = new Set<ServerResponse>();\n\n // Handle Vite server restarts\n server.ws.on(\"restart\", (path) => {\n console.log(\n \"[vite-react-stream] 🔧 Plugin changed, preparing for restart:\",\n path\n );\n\n // Close streams with restart message\n for (const res of activeStreams) {\n res.writeHead(503, {\n \"Content-Type\": \"text/x-component\",\n \"Retry-After\": \"1\",\n });\n res.end('{\"error\":\"Server restarting...\"}');\n }\n activeStreams.clear();\n });\n\n server.ws.on(\"connection\", (socket, req) => {\n console.log(\"[vite-react-stream] hooking up ws connection\");\n });\n\n server.ws.on(\"listening\", () => {\n console.log(\"[vite-react-stream] hooking up ws listening\");\n });\n\n server.middlewares.use(async (req, res, next) => {\n if (req.headers.accept !== \"text/x-component\") return next();\n console.log(\"[vite-react-stream] middleware called\");\n try {\n const handler = await createHandler(\n req.url ?? \"\",\n {\n Page: userOptions.Page,\n props: userOptions.props,\n build: userOptions.build,\n Html: ({ children }) => children,\n pageExportName: userOptions.pageExportName,\n propsExportName: userOptions.propsExportName,\n moduleBase: userOptions.moduleBase,\n moduleBasePath: userOptions.moduleBasePath,\n projectRoot: server.config.root ?? userOptions.projectRoot,\n },\n {\n cssFiles: Array.from(cssModules),\n logger: createLogger(),\n loader: server.ssrLoadModule,\n moduleGraph: server.moduleGraph,\n }\n );\n handler?.stream?.pipe(res);\n } finally {\n res.on(\"close\", () => {\n console.log(\"[vite-react-stream] ➖ Stream closed for:\", req.url);\n activeStreams.delete(res);\n });\n }\n });\n },\n\n async config(config, configEnv): Promise<UserConfig> {\n const resolvedPages = await resolvePages(userOptions.build.pages);\n if (resolvedPages.type === \"error\") {\n throw resolvedPages.error;\n }\n const { pages } = resolvedPages;\n env = getEnv(config, configEnv);\n define = env.define;\n files = await checkFilesExist(\n pages,\n userOptions,\n config.root ?? userOptions.projectRoot\n );\n root = config.root ?? userOptions.projectRoot;\n const resolvedConfig = resolveUserConfig(\n \"react-server\",\n [...pages, userOptions.workerPath, userOptions.loaderPath],\n config,\n configEnv,\n userOptions\n );\n if (resolvedConfig.type === \"error\") {\n throw resolvedConfig.error;\n }\n const { userConfig } = resolvedConfig;\n console.log({\n worker: userOptions.workerPath,\n loader: userOptions.loaderPath,\n });\n const entriesClient = Object.fromEntries([\n ...Array.from(files.pageMap.entries()).map(([key, value]) => [\n key,\n relative(root, value),\n ]),\n ...Array.from(files.propsMap.entries()).map(([key, value]) => [\n key,\n relative(root, value),\n ]),\n ]);\n const entriesResolved = Object.fromEntries(\n (Object.entries(entriesClient) as [string, string][]).map(\n ([key, entry]) => {\n if (typeof entry !== \"string\") {\n return [key, entry];\n }\n\n return [key, entry];\n }\n )\n );\n const serverEntries = {\n ...entriesResolved,\n [\"worker/worker\"]: userOptions.workerPath,\n [\"worker/loader\"]: userOptions.loaderPath,\n };\n\n const buildConfig = createBuildConfig({\n input: serverEntries,\n userConfig: userConfig,\n userOptions: userOptions,\n root,\n moduleBaseExceptions: [\n userOptions.workerPath,\n userOptions.loaderPath,\n ...userOptions.moduleBaseExceptions,\n ],\n });\n return {\n ...buildConfig,\n define,\n plugins: config.plugins,\n };\n },\n async buildStart() {\n timing.buildStart = performance.now();\n },\n async closeBundle() {\n if (!config) return;\n console.log(\"RSC CLOSE BUNDLE CALLED\");\n if (!files.pageSet.size) return;\n timing.renderStart = performance.now();\n\n try {\n const resolvedServerManifest = tryManifest({\n root,\n outDir: userOptions.build.server,\n ssrManifest: false,\n });\n if (resolvedServerManifest.type === \"error\") {\n console.error(\n \"[vite-react-stream] Server Build failed, can not build without a server manifest. Please set `manifest: true` in your vite config.\",\n resolvedServerManifest.error\n );\n return;\n }\n const { manifest: serverManifest } = resolvedServerManifest;\n\n // get worker path from server manifest\n const workerPath =\n serverManifest[userOptions.workerPath]?.file ??\n serverManifest[relative(root, userOptions.workerPath)]?.file ??\n serverManifest[\n relative(\n join(root, userOptions.build.server),\n userOptions.workerPath\n )\n ]?.file;\n if (!workerPath) {\n console.log(serverManifest, userOptions.build.server);\n throw new Error(\n `Worker path not found in server manifest, tried: ${userOptions.workerPath}, ${relative(root, userOptions.workerPath)}, ${join(root, userOptions.build.server, userOptions.workerPath)}`\n );\n }\n console.log(\"workerPath\", workerPath);\n // client\n const resolvedClientManifest = tryManifest({\n root,\n outDir: userOptions.build.client,\n ssrManifest: false,\n });\n if (resolvedClientManifest.type === \"error\") {\n console.error(\n \"[vite-react-stream] Server Build failed, can not build without a client manifest. Make sure to run the client build before the server build and set `manifest: true` in your vite config.\",\n resolvedClientManifest.error\n );\n return;\n }\n const { manifest: clientManifest } = resolvedClientManifest;\n\n // Create a single worker for all routes\n if (!worker)\n worker = await createWorker({\n workerPath: join(root, userOptions.build.server, workerPath),\n nodePath: process.env[\"NODE_PATH\"] ?? resolve(root, \"node_modules\"),\n mode:\n process.env[\"NODE_ENV\"] === \"development\"\n ? \"development\"\n : \"production\",\n });\n // this is based on the user config - the routes should lead to a page and props but the rendering is agnostic of that\n const routes = Array.from(files.pageMap.keys());\n const indexEntry = clientManifest[\"index.html\"];\n if (!indexEntry) {\n throw new Error(\"root /index.html not found\");\n }\n await renderPages(routes, {\n pipableStreamOptions: {\n bootstrapModules: [\"/\" + indexEntry.file],\n },\n outDir: config.build.outDir,\n clientCss: indexEntry.css?.map((css) => \"/\" + css) ?? [],\n pluginOptions: {\n Page: userOptions.Page,\n props: userOptions.props,\n build: userOptions.build,\n Html: userOptions.Html,\n pageExportName: userOptions.pageExportName,\n propsExportName: userOptions.propsExportName,\n moduleBase: userOptions.moduleBase,\n moduleBasePath: userOptions.moduleBasePath,\n moduleBaseURL: userOptions.moduleBaseURL,\n projectRoot: root,\n },\n worker: worker,\n manifest: clientManifest,\n loader: createPageLoader({\n manifest: clientManifest,\n root: config.root,\n outDir: config.build.outDir,\n moduleBase: userOptions.moduleBase,\n alwaysRegisterServer: false,\n alwaysRegisterClient: false,\n registerServer: [],\n registerClient: Object.keys(resolvedClientManifest).filter(\n (key) =>\n key.endsWith(\".client.tsx\") && clientManifest[key].isEntry\n ),\n }),\n onCssFile: (path) => buildCssFiles.add(path),\n });\n console.log(\"[vite-react-stream] Render complete\");\n console.log(\"[vite-react-stream] Terminating worker\");\n if (worker) await worker.terminate();\n\n timing.renderEnd = performance.now();\n timing.total = (timing.renderEnd - timing.start) / 1000;\n\n // Collect stats\n const stats: BuildStats = {\n htmlFiles: routes.length,\n clientComponents: clientComponents.size,\n cssFiles: cssModules.size,\n totalRoutes: routes.length,\n timing: {\n config: ((timing.configResolved ?? 0) - timing.start) / 1000,\n build:\n ((timing.buildStart ?? 0) - (timing.configResolved ?? 0)) / 1000,\n render:\n ((timing.renderEnd ?? 0) - (timing.renderStart ?? 0)) / 1000,\n total: (timing.renderEnd ?? 0 - timing.start) / 1000,\n },\n };\n\n // Format duration helper\n const formatDuration = (seconds: number) => {\n if (seconds < 0.001) {\n return `${(seconds * 1000000).toFixed(0)}μs`;\n }\n if (seconds < 1) {\n return `${(seconds * 1000).toFixed(0)}ms`;\n }\n return `${seconds.toFixed(2)}s`;\n };\n\n console.log(\"\\n[vite-react-stream] Build Summary:\");\n console.log(\"─\".repeat(50));\n console.log(`📄 Generated ${stats.htmlFiles} HTML files`);\n console.log(`🎯 Processed ${stats.clientComponents} client components`);\n console.log(`🎨 Included ${stats.cssFiles} CSS files`);\n console.log(`🛣️ Total routes: ${stats.totalRoutes}`);\n console.log(\"─\".repeat(50));\n console.log(\"⏱️ Timing:\");\n console.log(` Config: ${formatDuration(stats.timing.config)}`);\n console.log(` Build: ${formatDuration(stats.timing.build)}`);\n console.log(` Render: ${formatDuration(stats.timing.render)}`);\n console.log(\" \".repeat(12));\n console.log(` Total: ${formatDuration(stats.timing.total)}`);\n console.log(\"─\".repeat(50));\n } catch (error) {\n console.error(\"[vite-react-stream] Build failed:\", error);\n throw error;\n }\n },\n async buildEnd(error) {\n if (error) {\n console.error(\"[vite-react-stream] Build error:\", error);\n }\n if (worker) await worker.terminate();\n },\n handleHotUpdate({ file }) {\n if (file.endsWith(\".css\")) {\n cssModules.add(file);\n }\n },\n transform(code: string, id: string) {\n if (\n (id.includes(\".client\") ||\n code.startsWith('\"use client\"') ||\n code.startsWith(\"use client\")) &&\n !id.includes(\"node_modules\")\n ) {\n console.log(\"[vite-react-stream] Client component added\", id);\n clientComponents.set(id, code);\n }\n return { code };\n },\n };\n}\n"],"names":["config"],"mappings":";;;;;;;;;;;;;;AA0BA,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI,iCAAiB,IAAY;AACjC,IAAI,uCAAuB,IAAoB;AAC/C,IAAI;AACJ,IAAI,oCAAoB,IAAY;AACpC,IAAI,OAAe,QAAQ,IAAI;AAeT,eAAA,kBACpB,UAA+B,IACuC;AACtE,QAAM,SAAsB;AAAA,IAC1B,OAAO,YAAY,IAAI;AAAA,EACzB;AACM,QAAA,kBAAkB,eAAe,OAAO;AAC1C,MAAA,gBAAgB,SAAS,SAAS;AAC5B,YAAA;AAAA,MACN;AAAA,IACF;AACA,UAAM,gBAAgB;AAAA,EAAA;AAElB,QAAA,EAAE,gBAAgB;AACjB,SAAA;AAAA,IACL,MAAM;AAAA,IACN,MAAM;AAAA,MACJ;AAAA,IACF;AAAA,IACA,KAAK;AAAA,MACH,WAAW,MAAc;AACvB,sBAAc,IAAI,IAAI;AAAA,MAAA;AAAA,IAE1B;AAAA,IACA,eAAe,gBAAgB;AACzB,UAAA,eAAe,YAAY,SAAS;AAC/B,eAAA,iBAAiB,YAAY,IAAI;AACxC,gBAAQ,IAAI,uCAAuC;AAAA,MAAA;AAE5C,eAAA;AAAA,IACX;AAAA,IACA,MAAM,gBAAgB,QAAuB;AACvC,UAAA,OAAO,OAAO,MAAM;AACd,gBAAA;AAAA,UACN;AAAA,UACA,OAA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Y,MAC9B,CAAC,GAAG,SAAS,cAAc,GAC3B;AACQ,gBAAA,IAAI,8CAA8C,EAAE;AAC3C,yBAAA,IAAI,IAAI,IAAI;AAAA,MAAA;AAE/B,aAAO,EAAE,KAAK;AAAA,IAAA;AAAA,EAElB;AACF;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolvePage.d.ts","sourceRoot":"","sources":["../src/resolvePage.ts"],"names":[],"mappings":"AAAA,KAAK,kBAAkB,GAAG;IACxB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,iBAAiB,GAClB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAAE,GAC3C;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAErB,wBAAsB,WAAW,CAAC,EAChC,UAAU,EACV,IAAI,EACJ,GAAG,EACH,UAAU,GACX,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA+CjD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveProps.d.ts","sourceRoot":"","sources":["../src/resolveProps.ts"],"names":[],"mappings":"AAAA,KAAK,mBAAmB,GAAG;IACzB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,KAAK,kBAAkB,GACnB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,GAAG,CAAA;CAAE,GAC5C;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAMrB,wBAAsB,YAAY,CAAC,EACjC,WAAW,EACX,IAAI,EACJ,UAAU,EACV,GAAG,GACJ,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAoGnD"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { mergeInputs } from "./mergeInputs.js";
|
|
2
|
-
import { createInputNormalizer } from "../helpers/inputNormalizer.js";
|
|
3
|
-
function createBuildConfig({
|
|
4
|
-
root,
|
|
5
|
-
input,
|
|
6
|
-
userOptions,
|
|
7
|
-
userConfig,
|
|
8
|
-
moduleBaseExceptions
|
|
9
|
-
}) {
|
|
10
|
-
const { output, input: inputConfig, ...restRollupOptions } = userConfig.build.rollupOptions ?? {};
|
|
11
|
-
let mergedInputs = mergeInputs(input, inputConfig);
|
|
12
|
-
let inputNormalizer = createInputNormalizer({
|
|
13
|
-
root
|
|
14
|
-
});
|
|
15
|
-
if (typeof mergedInputs === "object" && mergedInputs != null) {
|
|
16
|
-
mergedInputs = Object.fromEntries(Object.entries(mergedInputs).map(inputNormalizer));
|
|
17
|
-
}
|
|
18
|
-
const config = {
|
|
19
|
-
configFile: false,
|
|
20
|
-
...userConfig,
|
|
21
|
-
build: {
|
|
22
|
-
...userConfig.build,
|
|
23
|
-
rollupOptions: {
|
|
24
|
-
input: mergedInputs,
|
|
25
|
-
output: {
|
|
26
|
-
format: "esm",
|
|
27
|
-
preserveModules: true,
|
|
28
|
-
hoistTransitiveImports: false,
|
|
29
|
-
esModule: true,
|
|
30
|
-
entryFileNames: "[name].js",
|
|
31
|
-
chunkFileNames: "[name].js",
|
|
32
|
-
assetFileNames: "[name][extname]",
|
|
33
|
-
...output
|
|
34
|
-
},
|
|
35
|
-
...restRollupOptions
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
return config;
|
|
40
|
-
}
|
|
41
|
-
export {
|
|
42
|
-
createBuildConfig
|
|
43
|
-
};
|
|
44
|
-
//# sourceMappingURL=createBuildConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createBuildConfig.js","sources":["../../../src/build/createBuildConfig.ts"],"sourcesContent":["import type { InlineConfig } from \"vite\";\nimport type { ResolvedUserConfig, ResolvedUserOptions } from \"../types.js\";\nimport type { InputOption } from \"rollup\";\nimport { mergeInputs } from \"./mergeInputs.js\";\nimport { createInputNormalizer } from \"../helpers/inputNormalizer.js\";\n\ntype CreateBuildConfigOptions = {\n input: InputOption;\n userOptions: ResolvedUserOptions;\n userConfig: ResolvedUserConfig;\n root: string;\n moduleBaseExceptions: string[];\n};\n\n\nexport function createBuildConfig({\n root,\n input,\n userOptions,\n userConfig,\n moduleBaseExceptions\n}: CreateBuildConfigOptions) {\n const { output, input: inputConfig, ...restRollupOptions } =\n userConfig.build.rollupOptions ?? {};\n\n let mergedInputs = mergeInputs(input, inputConfig);\n\n let inputNormalizer = createInputNormalizer({\n root,\n });\n if(typeof mergedInputs === 'object' && mergedInputs != null) {\n mergedInputs = Object.fromEntries(Object.entries(mergedInputs).map(inputNormalizer));\n }\n const config: InlineConfig = {\n configFile: false,\n ...userConfig,\n build: {\n ...userConfig.build,\n rollupOptions: {\n input: mergedInputs,\n output: {\n format: \"esm\",\n preserveModules: true,\n hoistTransitiveImports: false,\n esModule: true,\n entryFileNames: \"[name].js\",\n chunkFileNames: \"[name].js\",\n assetFileNames: \"[name][extname]\",\n ...output,\n },\n ...restRollupOptions,\n },\n },\n };\n\n return config;\n}\n"],"names":[],"mappings":";;AAeO,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA6B;AACrB,QAAA,EAAE,QAAQ,OAAO,aAAa,GAAG,sBACrC,WAAW,MAAM,iBAAiB,CAAC;AAEjC,MAAA,eAAe,YAAY,OAAO,WAAW;AAEjD,MAAI,kBAAkB,sBAAsB;AAAA,IAC1C;AAAA,EAAA,CACD;AACD,MAAG,OAAO,iBAAiB,YAAY,gBAAgB,MAAM;AAC5C,mBAAA,OAAO,YAAY,OAAO,QAAQ,YAAY,EAAE,IAAI,eAAe,CAAC;AAAA,EAAA;AAErF,QAAM,SAAuB;AAAA,IAC3B,YAAY;AAAA,IACZ,GAAG;AAAA,IACH,OAAO;AAAA,MACL,GAAG,WAAW;AAAA,MACd,eAAe;AAAA,QACb,OAAO;AAAA,QACP,QAAQ;AAAA,UACN,QAAQ;AAAA,UACR,iBAAiB;AAAA,UACjB,wBAAwB;AAAA,UACxB,UAAU;AAAA,UACV,gBAAgB;AAAA,UAChB,gBAAgB;AAAA,UAChB,gBAAgB;AAAA,UAChB,GAAG;AAAA,QACL;AAAA,QACA,GAAG;AAAA,MAAA;AAAA,IACL;AAAA,EAEJ;AAEO,SAAA;AACT;"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const mergeAsArray = (entries) => {
|
|
2
|
-
return Array.isArray(entries) ? entries : typeof entries === "object" && entries != null ? Object.values(entries) : typeof entries === "string" ? [entries] : [];
|
|
3
|
-
};
|
|
4
|
-
const mergeAsObject = (entries) => {
|
|
5
|
-
return Array.isArray(entries) ? Object.fromEntries(entries.map((entry) => [entry, entry])) : typeof entries === "object" && entries != null ? entries : typeof entries === "string" ? { [entries]: entries } : {};
|
|
6
|
-
};
|
|
7
|
-
const mergeInputs = (input, input2) => {
|
|
8
|
-
if (!input2) return input;
|
|
9
|
-
return Array.isArray(input) ? [...input, ...mergeAsArray(input2)] : typeof input === "string" ? [input, ...mergeAsArray(input2)] : input != null && typeof input2 === "object" && input2 != null ? { ...input, ...mergeAsObject(input2) } : input != null ? input : Array.isArray(input2) ? input2 : typeof input2 === "object" && input2 != null ? input2 : typeof input2 === "string" ? input2 : [];
|
|
10
|
-
};
|
|
11
|
-
export {
|
|
12
|
-
mergeAsArray,
|
|
13
|
-
mergeAsObject,
|
|
14
|
-
mergeInputs
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=mergeInputs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mergeInputs.js","sources":["../../../src/build/mergeInputs.ts"],"sourcesContent":["import type { InputOption } from \"rollup\";\n\nexport const mergeAsArray = (entries: InputOption) => {\n return Array.isArray(entries)\n ? entries\n : typeof entries === \"object\" && entries != null\n ? Object.values(entries)\n : typeof entries === \"string\"\n ? [entries]\n : [];\n};\nexport const mergeAsObject = (entries: InputOption) => {\n return Array.isArray(entries)\n ? Object.fromEntries(entries.map((entry) => [entry, entry]))\n : typeof entries === \"object\" && entries != null\n ? entries\n : typeof entries === \"string\"\n ? { [entries]: entries }\n : {};\n};\n\nexport const mergeInputs = (\n input: InputOption,\n input2: InputOption | undefined\n) => {\n if (!input2) return input;\n return Array.isArray(input)\n ? [...input, ...mergeAsArray(input2)]\n : typeof input === \"string\"\n ? [input, ...mergeAsArray(input2)]\n : input != null && typeof input2 === \"object\" && input2 != null\n ? { ...input, ...mergeAsObject(input2) }\n : input != null\n ? input\n : Array.isArray(input2)\n ? input2\n : typeof input2 === \"object\" && input2 != null\n ? input2\n : typeof input2 === \"string\"\n ? input2\n : [];\n};\n"],"names":[],"mappings":"AAEa,MAAA,eAAe,CAAC,YAAyB;AAC7C,SAAA,MAAM,QAAQ,OAAO,IACxB,UACA,OAAO,YAAY,YAAY,WAAW,OAC1C,OAAO,OAAO,OAAO,IACrB,OAAO,YAAY,WACnB,CAAC,OAAO,IACR,CAAC;AACP;AACa,MAAA,gBAAgB,CAAC,YAAyB;AACrD,SAAO,MAAM,QAAQ,OAAO,IACxB,OAAO,YAAY,QAAQ,IAAI,CAAC,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,IACzD,OAAO,YAAY,YAAY,WAAW,OAC1C,UACA,OAAO,YAAY,WACnB,EAAE,CAAC,OAAO,GAAG,YACb,CAAC;AACP;AAEa,MAAA,cAAc,CACzB,OACA,WACG;AACC,MAAA,CAAC,OAAe,QAAA;AACb,SAAA,MAAM,QAAQ,KAAK,IACtB,CAAC,GAAG,OAAO,GAAG,aAAa,MAAM,CAAC,IAClC,OAAO,UAAU,WACjB,CAAC,OAAO,GAAG,aAAa,MAAM,CAAC,IAC/B,SAAS,QAAQ,OAAO,WAAW,YAAY,UAAU,OACzD,EAAE,GAAG,OAAO,GAAG,cAAc,MAAM,EAAA,IACnC,SAAS,OACT,QACA,MAAM,QAAQ,MAAM,IACpB,SACA,OAAO,WAAW,YAAY,UAAU,OACxC,SACA,OAAO,WAAW,WAClB,SACA,CAAC;AACP;"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
2
|
-
import { resolve } from "node:path";
|
|
3
|
-
async function checkFilesExist(pages, options, root) {
|
|
4
|
-
const errors = [];
|
|
5
|
-
const pageSet = /* @__PURE__ */ new Set();
|
|
6
|
-
const pageMap = /* @__PURE__ */ new Map();
|
|
7
|
-
if (typeof options.Page === "string") {
|
|
8
|
-
const pagePath = resolve(root, options.Page);
|
|
9
|
-
pageMap.set(options.Page, pagePath);
|
|
10
|
-
if (!pageSet.has(pagePath)) {
|
|
11
|
-
if (!existsSync(pagePath)) {
|
|
12
|
-
errors.push(`Page file not found: ${pagePath}`);
|
|
13
|
-
}
|
|
14
|
-
pageSet.add(pagePath);
|
|
15
|
-
}
|
|
16
|
-
} else if (typeof options.Page === "function" && pages) {
|
|
17
|
-
for (const page of pages) {
|
|
18
|
-
const pagePath = options.Page(resolve(root, page));
|
|
19
|
-
pageMap.set(page, pagePath);
|
|
20
|
-
if (pageSet.has(pagePath)) {
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
if (!existsSync(pagePath)) {
|
|
24
|
-
errors.push(`Page file not found: ${pagePath}`);
|
|
25
|
-
}
|
|
26
|
-
pageSet.add(pagePath);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
const propsSet = /* @__PURE__ */ new Set();
|
|
30
|
-
const propsMap = /* @__PURE__ */ new Map();
|
|
31
|
-
if (typeof options.props === "string") {
|
|
32
|
-
const propsPath = resolve(root, options.props);
|
|
33
|
-
propsMap.set(options.props, propsPath);
|
|
34
|
-
if (!propsSet.has(propsPath)) {
|
|
35
|
-
if (!existsSync(propsPath)) {
|
|
36
|
-
errors.push(`Props file not found: ${propsPath}`);
|
|
37
|
-
}
|
|
38
|
-
propsSet.add(propsPath);
|
|
39
|
-
}
|
|
40
|
-
} else if (typeof options.props === "function" && pages) {
|
|
41
|
-
for (const page of pages) {
|
|
42
|
-
const propsPath = options.props(resolve(root, page));
|
|
43
|
-
propsMap.set(page, propsPath);
|
|
44
|
-
if (propsSet.has(propsPath)) {
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
if (!existsSync(propsPath)) {
|
|
48
|
-
errors.push(`Props file not found: ${propsPath}`);
|
|
49
|
-
}
|
|
50
|
-
propsSet.add(propsPath);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
if (errors.length) {
|
|
54
|
-
throw new Error("React Stream Plugin Validation:\n" + errors.join("\n"));
|
|
55
|
-
}
|
|
56
|
-
return { pageMap, pageSet, propsMap, propsSet };
|
|
57
|
-
}
|
|
58
|
-
export {
|
|
59
|
-
checkFilesExist
|
|
60
|
-
};
|
|
61
|
-
//# sourceMappingURL=checkFilesExist.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"checkFilesExist.js","sources":["../../src/checkFilesExist.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport type { StreamPluginOptions } from \"./types.js\";\n\nexport async function checkFilesExist(\n pages: string[],\n options: Pick<StreamPluginOptions, \"Page\" | \"props\">,\n root: string\n) {\n const errors: string[] = [];\n const pageSet = new Set<string>();\n const pageMap = new Map<string, string>();\n // Check if files exist when string paths are provided\n if (typeof options.Page === \"string\") {\n const pagePath = resolve(root, options.Page);\n pageMap.set(options.Page, pagePath);\n if (!pageSet.has(pagePath)) {\n if (!existsSync(pagePath)) {\n errors.push(`Page file not found: ${pagePath}`);\n }\n pageSet.add(pagePath);\n }\n } else if (typeof options.Page === \"function\" && pages) {\n for (const page of pages) {\n const pagePath = options.Page(resolve(root, page));\n pageMap.set(page, pagePath);\n if (pageSet.has(pagePath)) {\n continue;\n }\n if (!existsSync(pagePath)) {\n errors.push(`Page file not found: ${pagePath}`);\n }\n pageSet.add(pagePath);\n }\n }\n\n const propsSet = new Set<string>();\n const propsMap = new Map<string, string>();\n if (typeof options.props === \"string\") {\n const propsPath = resolve(root, options.props);\n propsMap.set(options.props, propsPath);\n if (!propsSet.has(propsPath)) {\n if (!existsSync(propsPath)) {\n errors.push(`Props file not found: ${propsPath}`);\n }\n propsSet.add(propsPath);\n }\n } else if (typeof options.props === \"function\" && pages) {\n for (const page of pages) {\n const propsPath = options.props(resolve(root, page));\n propsMap.set(page, propsPath);\n if (propsSet.has(propsPath)) {\n continue;\n }\n if (!existsSync(propsPath)) {\n errors.push(`Props file not found: ${propsPath}`);\n }\n propsSet.add(propsPath);\n }\n }\n\n if (errors.length) {\n throw new Error(\"React Stream Plugin Validation:\\n\" + errors.join(\"\\n\"));\n }\n\n return { pageMap, pageSet, propsMap, propsSet };\n}\n"],"names":[],"mappings":";;AAIsB,eAAA,gBACpB,OACA,SACA,MACA;AACA,QAAM,SAAmB,CAAC;AACpB,QAAA,8BAAc,IAAY;AAC1B,QAAA,8BAAc,IAAoB;AAEpC,MAAA,OAAO,QAAQ,SAAS,UAAU;AACpC,UAAM,WAAW,QAAQ,MAAM,QAAQ,IAAI;AACnC,YAAA,IAAI,QAAQ,MAAM,QAAQ;AAClC,QAAI,CAAC,QAAQ,IAAI,QAAQ,GAAG;AACtB,UAAA,CAAC,WAAW,QAAQ,GAAG;AAClB,eAAA,KAAK,wBAAwB,QAAQ,EAAE;AAAA,MA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ChD;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collect-css-manifest.js","sources":["../../src/collect-css-manifest.ts"],"sourcesContent":["import type { Manifest, ModuleGraph } from \"vite\";\n\nexport async function collectModuleGraphCss(\n moduleGraph: ModuleGraph,\n pagePath: string\n) {\n if (!pagePath) return new Map<string, string>();\n\n const cssFiles = new Map<string, string>();\n const pageModule = await moduleGraph.getModuleByUrl(pagePath, true);\n if (!pageModule) {\n return new Map<string, string>();\n }\n const seen = new Set<string>();\n const walkModule = (mod: any) => {\n if (!mod?.id || seen.has(mod.id)) return;\n seen.add(mod.id);\n if (mod?.id?.endsWith(\".css\")) {\n cssFiles.set(mod?.url, mod?.id);\n }\n mod?.importedModules?.forEach((imp: any) => walkModule(imp));\n };\n walkModule(pageModule);\n return cssFiles;\n}\n\nexport function collectManifestCss(\n manifest: Manifest,\n root: string,\n pagePath: string,\n onCss?: (path: string) => void\n) {\n const relativePagePath = pagePath.startsWith(root + \"/\")\n ? pagePath.slice(root.length + 1)\n : pagePath;\n if (!relativePagePath) return new Map<string, string>();\n const cssFiles = new Map<string, string>();\n const seen = new Set<string>();\n\n const walkManifestEntry = (id: string) => {\n if (seen.has(id)) return;\n seen.add(id);\n if (id.endsWith(\".css\")) {\n cssFiles.set(id, id);\n onCss?.(id);\n return;\n }\n // Get the manifest entry\n const entry = manifest[id];\n if (!entry) return;\n\n // Add direct CSS\n if (entry.css) {\n entry.css.forEach((css: string) => {\n cssFiles.set(entry.file, css);\n onCss?.(css);\n });\n }\n\n // Walk imports recursively\n if (entry.imports) {\n entry.imports.forEach((imp: string) => walkManifestEntry(imp));\n }\n\n // Also check dynamicImports\n if (entry.dynamicImports) {\n entry.dynamicImports.forEach((imp: string) => walkManifestEntry(imp));\n }\n };\n\n if (manifest[relativePagePath]) {\n walkManifestEntry(relativePagePath);\n }\n\n return cssFiles;\n}\n"],"names":[],"mappings":"AAEsB,eAAA,sBACpB,aACA,UACA;AACA,MAAI,CAAC,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D,QAAI,MAAM,gBAAgB;AACxB,YAAM,eAAe,QAAQ,CAAC,QAAgB,kBAAkB,GAAG,CAAC;AAAA,IAAA;AAAA,EAExE;AAEI,MAAA,SAAS,gBAAgB,GAAG;AAC9B,sBAAkB,gBAAgB;AAAA,EAAA;AAG7B,SAAA;AACT;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sources":["../../src/components.tsx"],"sourcesContent":["import { createElement } from 'react';\n\n/**\n * A component that emits <link> tags for CSS files during streaming.\n * The high precedence ensures they bubble up to the document head.\n */\nexport function CssCollector({ url }: { url: string }) {\n return createElement('link', {\n key: url,\n rel: 'stylesheet',\n href: url,\n precedence: 'high'\n });\n} "],"names":[],"mappings":";AAMgB,SAAA,aAAa,EAAE,OAAwB;AACrD,SAAO,cAAc,QAAQ;AAAA,IAC3B,KAAK;AAAA,IACL,KAAK;AAAA,IACL,MAAM;AAAA,IACN,YAAY;AAAA,EAAA,CACb;AACH;"}
|
package/dist/src/getEnv.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
import { resolve } from "node:path";
|
|
3
|
-
import { loadEnv } from "vite";
|
|
4
|
-
import { DEFAULT_CONFIG } from "./options.js";
|
|
5
|
-
function getEnv(config, configEnv) {
|
|
6
|
-
const isLocal = config.mode === "development";
|
|
7
|
-
const envName = isLocal ? `${config.mode}.local` : config.mode ? config.mode : "production";
|
|
8
|
-
const environmentName = config.mode ?? envName ?? "production";
|
|
9
|
-
const env = loadEnv(
|
|
10
|
-
environmentName,
|
|
11
|
-
config.envDir ?? config.root ?? process.cwd(),
|
|
12
|
-
config.envPrefix ?? DEFAULT_CONFIG.ENV_PREFIX ?? "VITE_"
|
|
13
|
-
);
|
|
14
|
-
const serverConfig = config.server || {};
|
|
15
|
-
const previewConfig = config.preview || {};
|
|
16
|
-
const host = configEnv.isPreview ? previewConfig.host ?? DEFAULT_CONFIG.PREVIEW_HOST : serverConfig.host ?? DEFAULT_CONFIG.DEV_HOST;
|
|
17
|
-
let previewPort = previewConfig.port ?? DEFAULT_CONFIG.PREVIEW_PORT;
|
|
18
|
-
let devPort = serverConfig.port ?? DEFAULT_CONFIG.DEV_PORT;
|
|
19
|
-
let homepage = env["VITE_BASE_URL"];
|
|
20
|
-
if (configEnv.command === "build" && (!homepage || homepage === "")) {
|
|
21
|
-
try {
|
|
22
|
-
const packageJson = JSON.parse(
|
|
23
|
-
readFileSync(resolve(config.root ?? "", "package.json"), "utf-8")
|
|
24
|
-
);
|
|
25
|
-
homepage = packageJson.homepage ?? "";
|
|
26
|
-
if (!homepage || homepage === "") {
|
|
27
|
-
console.warn(
|
|
28
|
-
"[RSC] 🔧 For production builds, please set 'homepage' in package.json, or set VITE_BASE_URL in your environment"
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
} catch (e) {
|
|
32
|
-
console.error(e);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
let baseUrl = env["VITE_BASE_URL"] && env["VITE_PUBLIC_URL"] !== "" ? env["VITE_BASE_URL"] : configEnv.isPreview ? `http://${host}:${previewPort}` : configEnv.command === "serve" ? `http://${host}:${devPort}` : homepage;
|
|
36
|
-
let publicUrl = env["VITE_PUBLIC_URL"] && env["VITE_PUBLIC_URL"] !== "" ? env["VITE_PUBLIC_URL"] : "";
|
|
37
|
-
const port = configEnv.isPreview ? previewConfig.port || DEFAULT_CONFIG.PREVIEW_PORT : serverConfig.port || DEFAULT_CONFIG.DEV_PORT;
|
|
38
|
-
if (configEnv.isPreview && `http://${host}:${port}` !== baseUrl) {
|
|
39
|
-
console.log(
|
|
40
|
-
`VITE_BASE_URL: "${baseUrl}" wasn't configured correctly for this server, overriding to: "http://${host}:${port}"`
|
|
41
|
-
);
|
|
42
|
-
baseUrl = `http://${host}:${port}`;
|
|
43
|
-
}
|
|
44
|
-
const envPrefix = typeof config.envPrefix === "string" ? config.envPrefix : Array.isArray(config.envPrefix) ? config.envPrefix[0] : DEFAULT_CONFIG.ENV_PREFIX;
|
|
45
|
-
const nodeProcessEnv = {
|
|
46
|
-
NODE_ENV: configEnv.command === "build" ? "production" : "development"
|
|
47
|
-
};
|
|
48
|
-
const defineProcess = Object.entries(nodeProcessEnv).map(([key, value]) => {
|
|
49
|
-
switch (key) {
|
|
50
|
-
case "NODE_ENV":
|
|
51
|
-
const isDev = value === "" ? configEnv.command === "build" ? false : true : value === "development";
|
|
52
|
-
return [`import.meta.env.DEV`, JSON.stringify(isDev)];
|
|
53
|
-
default:
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
}).filter(Array.isArray);
|
|
57
|
-
const defineImportMeta = Object.entries(env).map(([key, value]) => [
|
|
58
|
-
`import.meta.env.${key}`,
|
|
59
|
-
key === "VITE_BASE_URL" ? value ? JSON.stringify(value) : JSON.stringify(baseUrl) : key === "VITE_PUBLIC_URL" ? value ? JSON.stringify(value) : JSON.stringify(publicUrl) : JSON.stringify(value)
|
|
60
|
-
]);
|
|
61
|
-
const define = Object.fromEntries([...defineProcess, ...defineImportMeta]);
|
|
62
|
-
return {
|
|
63
|
-
baseUrl,
|
|
64
|
-
publicUrl,
|
|
65
|
-
port,
|
|
66
|
-
host,
|
|
67
|
-
envPrefix,
|
|
68
|
-
environmentName,
|
|
69
|
-
env,
|
|
70
|
-
define
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
export {
|
|
74
|
-
getEnv
|
|
75
|
-
};
|
|
76
|
-
//# sourceMappingURL=getEnv.js.map
|