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
package/src/options.ts
DELETED
|
@@ -1,423 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import type { ConfigEnv, ResolvedConfig, UserConfig } from "vite";
|
|
3
|
-
import type { ResolvedUserConfig, ResolvedUserOptions, StreamPluginOptions } from "./types.js";
|
|
4
|
-
import type { InputOption } from "rollup";
|
|
5
|
-
// Default configuration values
|
|
6
|
-
export const DEFAULT_CONFIG = {
|
|
7
|
-
FILE_REGEX: /\.(m|c)?(j|t)sx?$/,
|
|
8
|
-
CLIENT_ASSETS_DIR: "assets",
|
|
9
|
-
RSC_DIR: "rsc",
|
|
10
|
-
MODULE_BASE: "src",
|
|
11
|
-
MODULE_BASE_PATH: "/src",
|
|
12
|
-
MODULE_BASE_URL: "/src",
|
|
13
|
-
PAGE: "/src/page/page.tsx",
|
|
14
|
-
PROPS: "/src/page/props.ts",
|
|
15
|
-
CLIENT_ENTRY: "/src/client.tsx",
|
|
16
|
-
PAGE_EXPORT: "Page",
|
|
17
|
-
PROPS_EXPORT: "props",
|
|
18
|
-
// Use package name paths instead of relative paths
|
|
19
|
-
WORKER_PATH: "vite-plugin-react-server/worker",
|
|
20
|
-
LOADER_PATH: "vite-plugin-react-server/loader",
|
|
21
|
-
RSC_EXTENSION: ".rsc",
|
|
22
|
-
HTML: ({ children }: { children: any }) => children,
|
|
23
|
-
COLLECT_CSS: true,
|
|
24
|
-
COLLECT_ASSETS: true,
|
|
25
|
-
PAGE_PATTERN: "/src/page/**/*.page.tsx",
|
|
26
|
-
PROPS_PATTERN: "/src/page/**/*.props.ts",
|
|
27
|
-
DEV_PORT: 5173,
|
|
28
|
-
PREVIEW_PORT: 4173,
|
|
29
|
-
DEV_HOST: "localhost",
|
|
30
|
-
PREVIEW_HOST: "localhost",
|
|
31
|
-
ENV_PREFIX: "VITE_",
|
|
32
|
-
BUILD: {
|
|
33
|
-
pages: () => ["/"],
|
|
34
|
-
client: "dist/client",
|
|
35
|
-
server: "dist/server",
|
|
36
|
-
},
|
|
37
|
-
AUTO_DISCOVER: {
|
|
38
|
-
pagePattern: "**/*.page.tsx",
|
|
39
|
-
propsPattern: "**/*.props.ts",
|
|
40
|
-
},
|
|
41
|
-
} as const;
|
|
42
|
-
|
|
43
|
-
export const resolveConfig = <T extends ResolvedConfig>(
|
|
44
|
-
config: T,
|
|
45
|
-
resolvedUserConfig: UserConfig,
|
|
46
|
-
userOptions: ResolvedUserOptions
|
|
47
|
-
) => {
|
|
48
|
-
return {
|
|
49
|
-
...config,
|
|
50
|
-
build: {
|
|
51
|
-
...config.build,
|
|
52
|
-
assetsDir: config.build?.assetsDir ?? DEFAULT_CONFIG.CLIENT_ASSETS_DIR,
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export const resolveUserConfig = (
|
|
58
|
-
condition: "react-client" | "react-server",
|
|
59
|
-
input: InputOption,
|
|
60
|
-
config: UserConfig,
|
|
61
|
-
configEnv: ConfigEnv,
|
|
62
|
-
userOptions: ResolvedUserOptions
|
|
63
|
-
):
|
|
64
|
-
| { type: "error"; error: Error }
|
|
65
|
-
| {
|
|
66
|
-
type: "success";
|
|
67
|
-
userConfig: ResolvedUserConfig;
|
|
68
|
-
} => {
|
|
69
|
-
const isReactServer = condition === "react-server";
|
|
70
|
-
const isViteServer = configEnv.command === "serve";
|
|
71
|
-
const isVitePreview = configEnv.isPreview;
|
|
72
|
-
|
|
73
|
-
if (isReactServer && configEnv.command === "build") {
|
|
74
|
-
if (!config.build?.rollupOptions?.input) {
|
|
75
|
-
config = {
|
|
76
|
-
...config,
|
|
77
|
-
build: {
|
|
78
|
-
...config.build,
|
|
79
|
-
rollupOptions: {
|
|
80
|
-
...config.build?.rollupOptions,
|
|
81
|
-
input: input,
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (
|
|
89
|
-
typeof config.build?.assetsDir === "string" &&
|
|
90
|
-
userOptions.assetsDir !== config.build?.assetsDir
|
|
91
|
-
) {
|
|
92
|
-
return {
|
|
93
|
-
type: "error",
|
|
94
|
-
error: new Error(
|
|
95
|
-
`assetsDir cannot be changed after the config has been resolved, before: ${userOptions.assetsDir}, after: ${config.build?.assetsDir}`
|
|
96
|
-
),
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (isReactServer) {
|
|
101
|
-
if (configEnv.command === "build") {
|
|
102
|
-
if (!configEnv.isSsrBuild) {
|
|
103
|
-
return {
|
|
104
|
-
type: "error",
|
|
105
|
-
error: new Error(
|
|
106
|
-
"ssr must be true when using the server plugin, NODE_OPTIONS='--conditions react-server' vite build --ssr"
|
|
107
|
-
),
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
} else if (!isViteServer) {
|
|
111
|
-
return {
|
|
112
|
-
type: "error",
|
|
113
|
-
error: new Error(
|
|
114
|
-
isViteServer
|
|
115
|
-
? `react-server condition was not set. Please use \`NODE_OPTIONS='--conditions react-server' vite${
|
|
116
|
-
isVitePreview ? " preview" : ""
|
|
117
|
-
}\``
|
|
118
|
-
: "react-server condition was not set. Please use `NODE_OPTIONS='--conditions react-server' vite build --ssr`"
|
|
119
|
-
),
|
|
120
|
-
};
|
|
121
|
-
} else if (!configEnv.isSsrBuild && configEnv.command !== "serve") {
|
|
122
|
-
return {
|
|
123
|
-
type: "error",
|
|
124
|
-
error: new Error(
|
|
125
|
-
"Vite was run with the react-server condition, but is making a client build."
|
|
126
|
-
),
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const { root: configRoot, mode: configMode, ...configRest } = config;
|
|
132
|
-
const {
|
|
133
|
-
outDir: configOutDir,
|
|
134
|
-
assetsDir: configAssetsDir,
|
|
135
|
-
ssr: configSsr,
|
|
136
|
-
manifest: configManifest,
|
|
137
|
-
ssrManifest: configSsrManifest,
|
|
138
|
-
ssrEmitAssets: configSsrEmitAssets,
|
|
139
|
-
target: configTarget,
|
|
140
|
-
...configBuildRest
|
|
141
|
-
} = config.build ?? {};
|
|
142
|
-
|
|
143
|
-
return {
|
|
144
|
-
type: "success",
|
|
145
|
-
userConfig: {
|
|
146
|
-
...configRest,
|
|
147
|
-
root: configRoot ?? userOptions.projectRoot ?? process.cwd(),
|
|
148
|
-
mode: configMode ?? process.env["NODE_ENV"] ?? "production",
|
|
149
|
-
build: {
|
|
150
|
-
...configBuildRest,
|
|
151
|
-
ssr: configSsr ?? isReactServer,
|
|
152
|
-
manifest: configManifest ?? true,
|
|
153
|
-
ssrManifest: configSsrManifest ?? true,
|
|
154
|
-
ssrEmitAssets: configSsrEmitAssets ?? true,
|
|
155
|
-
target: configTarget ?? "es2020",
|
|
156
|
-
outDir:
|
|
157
|
-
typeof configOutDir === "string"
|
|
158
|
-
? configOutDir
|
|
159
|
-
: isReactServer
|
|
160
|
-
? userOptions.build.server
|
|
161
|
-
: userOptions.build.client,
|
|
162
|
-
assetsDir:
|
|
163
|
-
typeof configAssetsDir === "string"
|
|
164
|
-
? configAssetsDir
|
|
165
|
-
: isReactServer
|
|
166
|
-
? ""
|
|
167
|
-
: DEFAULT_CONFIG.CLIENT_ASSETS_DIR,
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
};
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
export const resolveOptions = (
|
|
174
|
-
options: StreamPluginOptions
|
|
175
|
-
):
|
|
176
|
-
| {
|
|
177
|
-
type: "success";
|
|
178
|
-
userOptions: ResolvedUserOptions;
|
|
179
|
-
}
|
|
180
|
-
| {
|
|
181
|
-
type: "error";
|
|
182
|
-
error: Error;
|
|
183
|
-
} => {
|
|
184
|
-
const {
|
|
185
|
-
workerPath: optionsWorkerPath,
|
|
186
|
-
loaderPath: optionsLoaderPath,
|
|
187
|
-
projectRoot: optionsProjectRoot,
|
|
188
|
-
moduleBase: optionsModuleBase,
|
|
189
|
-
moduleBasePath: optionsModuleBasePath,
|
|
190
|
-
moduleBaseURL: optionsModuleBaseURL,
|
|
191
|
-
build: optionsBuild,
|
|
192
|
-
Page: optionsPage,
|
|
193
|
-
props: optionsProps,
|
|
194
|
-
Html: optionsHtml,
|
|
195
|
-
pageExportName: optionsPageExportName,
|
|
196
|
-
propsExportName: optionsPropsExportName,
|
|
197
|
-
collectCss: optionsCollectCss,
|
|
198
|
-
collectAssets: optionsCollectAssets,
|
|
199
|
-
assetsDir: optionsAssetsDir,
|
|
200
|
-
clientEntry: optionsClientEntry,
|
|
201
|
-
serverOutDir: optionsServerOutDir,
|
|
202
|
-
clientOutDir: optionsClientOutDir,
|
|
203
|
-
autoDiscover: optionsAutoDiscover,
|
|
204
|
-
moduleBaseExceptions: optionsModuleBaseExceptions,
|
|
205
|
-
...restOptions
|
|
206
|
-
} = options;
|
|
207
|
-
const projectRoot = optionsProjectRoot ?? process.cwd();
|
|
208
|
-
/** the module base can be assumed to not have a leading slash */
|
|
209
|
-
const moduleBase =
|
|
210
|
-
typeof optionsModuleBase === "string"
|
|
211
|
-
? optionsModuleBase.startsWith(path.sep)
|
|
212
|
-
? optionsModuleBase.slice(path.sep.length)
|
|
213
|
-
: optionsModuleBase
|
|
214
|
-
: DEFAULT_CONFIG.MODULE_BASE;
|
|
215
|
-
|
|
216
|
-
if (
|
|
217
|
-
typeof optionsModuleBase === "string" &&
|
|
218
|
-
optionsModuleBase !== moduleBase
|
|
219
|
-
) {
|
|
220
|
-
return {
|
|
221
|
-
type: "error",
|
|
222
|
-
error: new Error(
|
|
223
|
-
`moduleBase ${optionsModuleBase} is invalid, should be like ${moduleBase}`
|
|
224
|
-
),
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
const moduleBasePath =
|
|
229
|
-
typeof optionsModuleBasePath === "string"
|
|
230
|
-
? !optionsModuleBasePath.startsWith(path.sep)
|
|
231
|
-
? `${path.sep}${optionsModuleBasePath}`
|
|
232
|
-
: optionsModuleBasePath
|
|
233
|
-
: `${path.sep}${moduleBase}`;
|
|
234
|
-
|
|
235
|
-
if (!moduleBasePath.includes(moduleBase)) {
|
|
236
|
-
return {
|
|
237
|
-
type: "error",
|
|
238
|
-
error: new Error(
|
|
239
|
-
`moduleBasePath ${moduleBasePath} is invalid, should include moduleBase ${moduleBase}`
|
|
240
|
-
),
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
const moduleBaseURL =
|
|
245
|
-
typeof optionsModuleBaseURL === "string"
|
|
246
|
-
? !optionsModuleBaseURL.endsWith(moduleBasePath)
|
|
247
|
-
? path.join(optionsModuleBaseURL, moduleBasePath)
|
|
248
|
-
: optionsModuleBaseURL
|
|
249
|
-
: moduleBasePath;
|
|
250
|
-
|
|
251
|
-
if (!moduleBaseURL.includes(moduleBasePath)) {
|
|
252
|
-
return {
|
|
253
|
-
type: "error",
|
|
254
|
-
error: new Error(
|
|
255
|
-
`moduleBaseURL ${moduleBaseURL} is invalid, should include moduleBasePath ${moduleBasePath}`
|
|
256
|
-
),
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
if (
|
|
261
|
-
typeof optionsModuleBaseURL === "string" &&
|
|
262
|
-
optionsModuleBaseURL !== moduleBaseURL
|
|
263
|
-
) {
|
|
264
|
-
return {
|
|
265
|
-
type: "error",
|
|
266
|
-
error: new Error(
|
|
267
|
-
`moduleBaseURL ${optionsModuleBaseURL} is invalid, should be like ${moduleBaseURL}`
|
|
268
|
-
),
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
const build = optionsBuild
|
|
273
|
-
? {
|
|
274
|
-
client: optionsBuild.client ?? DEFAULT_CONFIG.BUILD.client,
|
|
275
|
-
pages: optionsBuild.pages ?? DEFAULT_CONFIG.BUILD.pages,
|
|
276
|
-
server: optionsBuild.server ?? DEFAULT_CONFIG.BUILD.server,
|
|
277
|
-
}
|
|
278
|
-
: DEFAULT_CONFIG.BUILD;
|
|
279
|
-
|
|
280
|
-
const autoDiscover =
|
|
281
|
-
typeof optionsAutoDiscover === "object"
|
|
282
|
-
? {
|
|
283
|
-
pagePattern:
|
|
284
|
-
typeof optionsAutoDiscover.pagePattern === "string"
|
|
285
|
-
? optionsAutoDiscover.pagePattern
|
|
286
|
-
: DEFAULT_CONFIG.AUTO_DISCOVER.pagePattern,
|
|
287
|
-
propsPattern:
|
|
288
|
-
typeof optionsAutoDiscover.propsPattern === "string"
|
|
289
|
-
? optionsAutoDiscover.propsPattern
|
|
290
|
-
: DEFAULT_CONFIG.AUTO_DISCOVER.propsPattern,
|
|
291
|
-
}
|
|
292
|
-
: DEFAULT_CONFIG.AUTO_DISCOVER;
|
|
293
|
-
|
|
294
|
-
const workerPath = typeof optionsWorkerPath === "string" ? optionsWorkerPath : DEFAULT_CONFIG.WORKER_PATH;
|
|
295
|
-
const loaderPath = typeof optionsLoaderPath === "string" ? optionsLoaderPath : DEFAULT_CONFIG.LOADER_PATH;
|
|
296
|
-
return {
|
|
297
|
-
type: "success",
|
|
298
|
-
userOptions: {
|
|
299
|
-
...DEFAULT_CONFIG,
|
|
300
|
-
...restOptions,
|
|
301
|
-
moduleBase,
|
|
302
|
-
moduleBasePath,
|
|
303
|
-
moduleBaseURL,
|
|
304
|
-
build,
|
|
305
|
-
Page: optionsPage ?? DEFAULT_CONFIG.PAGE,
|
|
306
|
-
props: optionsProps ?? DEFAULT_CONFIG.PROPS,
|
|
307
|
-
Html: optionsHtml ?? DEFAULT_CONFIG.HTML,
|
|
308
|
-
pageExportName: optionsPageExportName ?? DEFAULT_CONFIG.PAGE_EXPORT,
|
|
309
|
-
propsExportName: optionsPropsExportName ?? DEFAULT_CONFIG.PROPS_EXPORT,
|
|
310
|
-
collectCss: optionsCollectCss ?? DEFAULT_CONFIG.COLLECT_CSS,
|
|
311
|
-
collectAssets: optionsCollectAssets ?? DEFAULT_CONFIG.COLLECT_ASSETS,
|
|
312
|
-
projectRoot: projectRoot,
|
|
313
|
-
assetsDir: optionsAssetsDir ?? DEFAULT_CONFIG.CLIENT_ASSETS_DIR,
|
|
314
|
-
workerPath: workerPath,
|
|
315
|
-
loaderPath: loaderPath,
|
|
316
|
-
clientEntry: optionsClientEntry ?? DEFAULT_CONFIG.CLIENT_ENTRY,
|
|
317
|
-
serverOutDir: optionsServerOutDir ?? DEFAULT_CONFIG.BUILD.server,
|
|
318
|
-
clientOutDir: optionsClientOutDir ?? DEFAULT_CONFIG.BUILD.client,
|
|
319
|
-
autoDiscover: autoDiscover,
|
|
320
|
-
moduleBaseExceptions: [
|
|
321
|
-
workerPath,
|
|
322
|
-
loaderPath,
|
|
323
|
-
...(optionsModuleBaseExceptions ?? []),
|
|
324
|
-
],
|
|
325
|
-
} satisfies ResolvedUserOptions,
|
|
326
|
-
};
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
export async function resolvePages(
|
|
330
|
-
pages: ResolvedUserOptions["build"]["pages"]
|
|
331
|
-
): Promise<
|
|
332
|
-
| {
|
|
333
|
-
type: "success";
|
|
334
|
-
pages: string[];
|
|
335
|
-
}
|
|
336
|
-
| {
|
|
337
|
-
type: "error";
|
|
338
|
-
error: Error;
|
|
339
|
-
}
|
|
340
|
-
> {
|
|
341
|
-
if (!pages) {
|
|
342
|
-
return {
|
|
343
|
-
type: "success",
|
|
344
|
-
pages: [],
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
if (typeof pages === "function") {
|
|
348
|
-
try {
|
|
349
|
-
return resolvePages(await Promise.resolve(pages()));
|
|
350
|
-
} catch (error) {
|
|
351
|
-
return {
|
|
352
|
-
type: "error",
|
|
353
|
-
error:
|
|
354
|
-
error instanceof Error
|
|
355
|
-
? error
|
|
356
|
-
: new Error(
|
|
357
|
-
`build.pages must be a array of strings, or a (async) function that returns a string or an array of strings. Got "${JSON.stringify(
|
|
358
|
-
pages
|
|
359
|
-
)}"`,
|
|
360
|
-
{
|
|
361
|
-
cause: error,
|
|
362
|
-
}
|
|
363
|
-
),
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
try {
|
|
368
|
-
const result = pages;
|
|
369
|
-
const awaited = "then" in result ? await result : result;
|
|
370
|
-
if (typeof awaited === "string") {
|
|
371
|
-
return {
|
|
372
|
-
type: "success",
|
|
373
|
-
pages: [awaited],
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
|
-
if (Array.isArray(awaited)) {
|
|
377
|
-
if (awaited.every((page) => typeof page === "string")) {
|
|
378
|
-
return {
|
|
379
|
-
type: "success",
|
|
380
|
-
pages: awaited,
|
|
381
|
-
};
|
|
382
|
-
} else {
|
|
383
|
-
return {
|
|
384
|
-
type: "error",
|
|
385
|
-
error: new Error(
|
|
386
|
-
`build.pages must be a array of strings, or a (async) function that returns a string or an array of strings. Got "${JSON.stringify(
|
|
387
|
-
awaited.find((page) => typeof page !== "string")
|
|
388
|
-
)}"`,
|
|
389
|
-
{
|
|
390
|
-
cause: awaited,
|
|
391
|
-
}
|
|
392
|
-
),
|
|
393
|
-
};
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
return {
|
|
397
|
-
type: "error",
|
|
398
|
-
error: new Error(
|
|
399
|
-
`build.pages must be a array of strings, or a (async) function that returns a string or an array of strings. Got "${JSON.stringify(
|
|
400
|
-
pages
|
|
401
|
-
)}"`,
|
|
402
|
-
{
|
|
403
|
-
cause: pages,
|
|
404
|
-
}
|
|
405
|
-
),
|
|
406
|
-
};
|
|
407
|
-
} catch (error) {
|
|
408
|
-
return {
|
|
409
|
-
type: "error",
|
|
410
|
-
error:
|
|
411
|
-
error instanceof Error
|
|
412
|
-
? error
|
|
413
|
-
: new Error(
|
|
414
|
-
`build.pages must be a array of strings, or a (async) function that returns a string or an array of strings. Got "${JSON.stringify(
|
|
415
|
-
error
|
|
416
|
-
)}"`,
|
|
417
|
-
{
|
|
418
|
-
cause: error,
|
|
419
|
-
}
|
|
420
|
-
),
|
|
421
|
-
};
|
|
422
|
-
}
|
|
423
|
-
}
|
package/src/plugin.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import "./assertServerCondition.js";
|
|
2
|
-
export { reactStreamPlugin } from "./react-server/plugin.js";
|
|
3
|
-
|
|
4
|
-
// the main plugin is version is the server version, if you want the client version, use the `vite-plugin-react-server/client` import
|
|
5
|
-
// this is because the workflow assumes main thread = react server condition
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from "vite";
|
|
2
|
-
import {
|
|
3
|
-
resolveOptions,
|
|
4
|
-
resolvePages,
|
|
5
|
-
resolveUserConfig,
|
|
6
|
-
} from "../options.js";
|
|
7
|
-
import type { StreamPluginOptions } from "../types.js";
|
|
8
|
-
|
|
9
|
-
export async function reactStreamPlugin(
|
|
10
|
-
options: StreamPluginOptions
|
|
11
|
-
): Promise<Plugin> {
|
|
12
|
-
const resolvedOptions = resolveOptions(options);
|
|
13
|
-
if (resolvedOptions.type === "error") {
|
|
14
|
-
throw resolvedOptions.error;
|
|
15
|
-
}
|
|
16
|
-
const { userOptions } = resolvedOptions;
|
|
17
|
-
|
|
18
|
-
const resolvedPages = await resolvePages(userOptions.build.pages)
|
|
19
|
-
if(resolvedPages.type === "error") {
|
|
20
|
-
throw resolvedPages.error
|
|
21
|
-
}
|
|
22
|
-
const { pages } = resolvedPages
|
|
23
|
-
return {
|
|
24
|
-
name: "vite:react-stream",
|
|
25
|
-
config(config, configEnv) {
|
|
26
|
-
const resolvedConfig = resolveUserConfig("react-client", pages, config, configEnv, userOptions);
|
|
27
|
-
if (resolvedConfig.type === "error") {
|
|
28
|
-
throw resolvedConfig.error;
|
|
29
|
-
}
|
|
30
|
-
const { userConfig } = resolvedConfig;
|
|
31
|
-
return userConfig
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
}
|