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
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { moduleIdDefault } from "./moduleIdDefault.js";
|
|
2
|
+
|
|
3
|
+
export const DEFAULT_CONFIG = {
|
|
4
|
+
FILE_REGEX: /\.(m|c)?(j|t)sx?$/,
|
|
5
|
+
CLIENT_ASSETS_DIR: "assets",
|
|
6
|
+
RSC_DIR: "rsc",
|
|
7
|
+
MODULE_BASE: "src",
|
|
8
|
+
MODULE_BASE_PATH: "/src",
|
|
9
|
+
MODULE_BASE_URL: "/src",
|
|
10
|
+
PAGE: "src/page/page.tsx",
|
|
11
|
+
PROPS: "src/page/props.ts",
|
|
12
|
+
CLIENT_ENTRY: "/src/client.tsx",
|
|
13
|
+
SERVER_ENTRY: "/src/server.tsx",
|
|
14
|
+
PAGE_EXPORT: "Page",
|
|
15
|
+
PROPS_EXPORT: "props",
|
|
16
|
+
HTML_WORKER_PATH: 'worker/html/index.js',
|
|
17
|
+
RSC_WORKER_PATH: 'worker/rsc/index.js',
|
|
18
|
+
LOADER_PATH: 'worker/loader.js',
|
|
19
|
+
RSC_EXTENSION: ".rsc",
|
|
20
|
+
HTML: ({ children }: { children: any }) => children,
|
|
21
|
+
COLLECT_CSS: true,
|
|
22
|
+
COLLECT_ASSETS: true,
|
|
23
|
+
PAGE_PATTERN: "/src/page/**/*.page.tsx",
|
|
24
|
+
PROPS_PATTERN: "/src/page/**/*.props.ts",
|
|
25
|
+
DEV_PORT: 5173,
|
|
26
|
+
PREVIEW_PORT: 4173,
|
|
27
|
+
DEV_HOST: "localhost",
|
|
28
|
+
PREVIEW_HOST: "localhost",
|
|
29
|
+
ENV_PREFIX: "VITE_",
|
|
30
|
+
BUILD: {
|
|
31
|
+
pages: () => ["/"],
|
|
32
|
+
client: "dist/client",
|
|
33
|
+
server: "dist/server",
|
|
34
|
+
static: "dist/static",
|
|
35
|
+
},
|
|
36
|
+
MODULE_BASE_EXCEPTIONS: [] as string[],
|
|
37
|
+
AUTO_DISCOVER: {
|
|
38
|
+
pagePattern: /page\.(m|c)?(j|t)sx?/,
|
|
39
|
+
propsPattern: /props\.(m|c)?(j|t)sx?/,
|
|
40
|
+
clientComponents: /client\.(m|c)?(j|t)sx?/,
|
|
41
|
+
serverFunctions: /server\.(m|c)?(j|t)sx?/,
|
|
42
|
+
},
|
|
43
|
+
MODULE_ID: moduleIdDefault
|
|
44
|
+
} as const;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { join, dirname } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
|
|
4
|
+
export const getNodePath = (root: string = process.cwd()): string => {
|
|
5
|
+
return process.env['module_root'] ?? join(root, "node_modules");
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const getPluginRoot = (): string => {
|
|
9
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
return join(__dirname, '..');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const getMode = (): "production" | "development" | "test" => {
|
|
14
|
+
return process.env['NODE_ENV'] === "development"
|
|
15
|
+
? "development"
|
|
16
|
+
: process.env['NODE_ENV'] === "test"
|
|
17
|
+
? "test"
|
|
18
|
+
: "production";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const getDistDir = (mode: "production" | "development" | "test"): string => {
|
|
22
|
+
return mode === 'production'
|
|
23
|
+
? join(process.cwd(), 'dist')
|
|
24
|
+
: join(process.cwd(), 'test/fixtures/dist');
|
|
25
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { normalizePath } from "vite";
|
|
2
|
+
import { DEFAULT_CONFIG } from "./defaults.js";
|
|
3
|
+
|
|
4
|
+
export const moduleIdDefault =
|
|
5
|
+
({
|
|
6
|
+
projectRoot,
|
|
7
|
+
output: _,
|
|
8
|
+
isProduction,
|
|
9
|
+
}: {
|
|
10
|
+
isProduction: boolean;
|
|
11
|
+
projectRoot: string;
|
|
12
|
+
output: { dir: string };
|
|
13
|
+
}) =>
|
|
14
|
+
(moduleId: string) => {
|
|
15
|
+
const normalized = normalizePath(moduleId);
|
|
16
|
+
const noRoot = normalized.startsWith(projectRoot)
|
|
17
|
+
? normalized.slice(projectRoot.length)
|
|
18
|
+
: normalized;
|
|
19
|
+
if (!isProduction) {
|
|
20
|
+
return noRoot;
|
|
21
|
+
}
|
|
22
|
+
return noRoot.replace(DEFAULT_CONFIG.FILE_REGEX, ".js");
|
|
23
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { StreamPluginOptions, ResolvedUserOptions } from "../types.js";
|
|
2
|
+
import { DEFAULT_CONFIG } from "./defaults.js";
|
|
3
|
+
|
|
4
|
+
export const resolveOptions = (
|
|
5
|
+
options: StreamPluginOptions
|
|
6
|
+
): { type: "success"; userOptions: ResolvedUserOptions } | { type: "error"; error: Error } => {
|
|
7
|
+
const projectRoot = options.projectRoot ?? process.cwd();
|
|
8
|
+
|
|
9
|
+
const build = options.build ?? DEFAULT_CONFIG.BUILD;
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
return {
|
|
13
|
+
type: "success",
|
|
14
|
+
userOptions: {
|
|
15
|
+
projectRoot,
|
|
16
|
+
moduleBase: options.moduleBase ?? DEFAULT_CONFIG.MODULE_BASE,
|
|
17
|
+
moduleBasePath: options.moduleBasePath ?? DEFAULT_CONFIG.MODULE_BASE_PATH,
|
|
18
|
+
moduleBaseURL: options.moduleBaseURL ?? DEFAULT_CONFIG.MODULE_BASE_URL,
|
|
19
|
+
build: {
|
|
20
|
+
pages: build.pages ?? DEFAULT_CONFIG.BUILD.pages,
|
|
21
|
+
client: build.client ?? DEFAULT_CONFIG.BUILD.client,
|
|
22
|
+
server: build.server ?? DEFAULT_CONFIG.BUILD.server,
|
|
23
|
+
static: build.static ?? DEFAULT_CONFIG.BUILD.static,
|
|
24
|
+
},
|
|
25
|
+
Page: options.Page ?? DEFAULT_CONFIG.PAGE,
|
|
26
|
+
props: options.props ?? DEFAULT_CONFIG.PROPS,
|
|
27
|
+
Html: options.Html ?? DEFAULT_CONFIG.HTML,
|
|
28
|
+
pageExportName: options.pageExportName ?? DEFAULT_CONFIG.PAGE_EXPORT,
|
|
29
|
+
propsExportName: options.propsExportName ?? DEFAULT_CONFIG.PROPS_EXPORT,
|
|
30
|
+
collectCss: options.collectCss ?? DEFAULT_CONFIG.COLLECT_CSS,
|
|
31
|
+
collectAssets: options.collectAssets ?? DEFAULT_CONFIG.COLLECT_ASSETS,
|
|
32
|
+
assetsDir: options.assetsDir ?? DEFAULT_CONFIG.CLIENT_ASSETS_DIR,
|
|
33
|
+
htmlWorkerPath: options.htmlWorkerPath ?? DEFAULT_CONFIG.HTML_WORKER_PATH,
|
|
34
|
+
rscWorkerPath: options.rscWorkerPath ?? DEFAULT_CONFIG.RSC_WORKER_PATH,
|
|
35
|
+
loaderPath: options.loaderPath ?? DEFAULT_CONFIG.LOADER_PATH,
|
|
36
|
+
clientEntry: options.clientEntry ?? DEFAULT_CONFIG.CLIENT_ENTRY,
|
|
37
|
+
serverEntry: options.serverEntry ?? DEFAULT_CONFIG.SERVER_ENTRY,
|
|
38
|
+
moduleBaseExceptions: options.moduleBaseExceptions ?? [],
|
|
39
|
+
autoDiscover: {
|
|
40
|
+
pagePattern: options.autoDiscover?.pagePattern ?? DEFAULT_CONFIG.AUTO_DISCOVER.pagePattern,
|
|
41
|
+
propsPattern: options.autoDiscover?.propsPattern ?? DEFAULT_CONFIG.AUTO_DISCOVER.propsPattern,
|
|
42
|
+
clientComponents: options.autoDiscover?.clientComponents ?? DEFAULT_CONFIG.AUTO_DISCOVER.clientComponents,
|
|
43
|
+
serverFunctions: options.autoDiscover?.serverFunctions ?? DEFAULT_CONFIG.AUTO_DISCOVER.serverFunctions,
|
|
44
|
+
},
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
} catch (error) {
|
|
48
|
+
return {
|
|
49
|
+
type: "error",
|
|
50
|
+
error: error instanceof Error ? error : new Error('Failed to resolve options')
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ResolvedUserOptions } from '../types.js';
|
|
2
|
+
|
|
3
|
+
export async function resolvePages(
|
|
4
|
+
pages: ResolvedUserOptions["build"]["pages"]
|
|
5
|
+
): Promise<{ type: "success"; pages: string[] } | { type: "error"; error: Error }> {
|
|
6
|
+
if (!pages) {
|
|
7
|
+
return { type: "success", pages: [] };
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
// Handle function
|
|
12
|
+
if (typeof pages === "function") {
|
|
13
|
+
const result = await Promise.resolve(pages());
|
|
14
|
+
return resolvePages(result);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Handle Promise
|
|
18
|
+
if (pages instanceof Promise) {
|
|
19
|
+
const result = await pages;
|
|
20
|
+
return resolvePages(result);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Handle string
|
|
24
|
+
if (typeof pages === "string") {
|
|
25
|
+
return { type: "success", pages: [pages] };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Handle array
|
|
29
|
+
if (Array.isArray(pages)) {
|
|
30
|
+
if (pages.every(page => typeof page === "string")) {
|
|
31
|
+
return { type: "success", pages };
|
|
32
|
+
}
|
|
33
|
+
throw new Error('All pages must be strings');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
throw new Error('Invalid pages format');
|
|
37
|
+
} catch (error) {
|
|
38
|
+
return {
|
|
39
|
+
type: "error",
|
|
40
|
+
error: error instanceof Error ? error : new Error('Failed to resolve pages')
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { ConfigEnv, UserConfig } from "vite";
|
|
2
|
+
import type { CheckFilesExistReturn, ResolvedUserConfig, ResolvedUserOptions } from "../types.js";
|
|
3
|
+
import { DEFAULT_CONFIG } from "./defaults.js";
|
|
4
|
+
import { createInputNormalizer } from "../helpers/inputNormalizer.js";
|
|
5
|
+
|
|
6
|
+
export type ResolveUserConfigProps = {
|
|
7
|
+
condition: "react-client" | "react-server" | "";
|
|
8
|
+
config: UserConfig;
|
|
9
|
+
configEnv: ConfigEnv;
|
|
10
|
+
userOptions: ResolvedUserOptions;
|
|
11
|
+
files?: CheckFilesExistReturn;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type ResolveUserConfigReturn =
|
|
15
|
+
| { type: "success"; userConfig: ResolvedUserConfig }
|
|
16
|
+
| { type: "error"; error: Error };
|
|
17
|
+
|
|
18
|
+
export function resolveUserConfig({
|
|
19
|
+
condition,
|
|
20
|
+
config,
|
|
21
|
+
configEnv,
|
|
22
|
+
userOptions,
|
|
23
|
+
files
|
|
24
|
+
}: ResolveUserConfigProps): ResolveUserConfigReturn {
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
// Get existing inputs
|
|
29
|
+
const root = config.root ?? userOptions.projectRoot ?? process.cwd();
|
|
30
|
+
const existingInput = config.build?.rollupOptions?.input || {};
|
|
31
|
+
const currentInputs = typeof existingInput === 'string' ? { default: existingInput } : existingInput;
|
|
32
|
+
const normalizer = createInputNormalizer(root);
|
|
33
|
+
|
|
34
|
+
const serverEntry = userOptions.serverEntry ? [userOptions.serverEntry, userOptions.serverEntry] : [];
|
|
35
|
+
// Add inputs based on condition
|
|
36
|
+
const inputs = {
|
|
37
|
+
...currentInputs,
|
|
38
|
+
...(condition === 'react-server' && files ? {
|
|
39
|
+
'index.html': '/index.html',
|
|
40
|
+
...Object.fromEntries([
|
|
41
|
+
...serverEntry,
|
|
42
|
+
...Array.from(files.pageMap.entries()),
|
|
43
|
+
...Array.from(files.propsMap.entries())
|
|
44
|
+
].map(normalizer))
|
|
45
|
+
} : {
|
|
46
|
+
client: userOptions.clientEntry
|
|
47
|
+
})
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const userConfig = {
|
|
51
|
+
...config,
|
|
52
|
+
root: root,
|
|
53
|
+
mode: configEnv.command === 'build' ? 'production' : 'development',
|
|
54
|
+
build: {
|
|
55
|
+
...config.build,
|
|
56
|
+
outDir: condition === 'react-server' ? userOptions.build.server : userOptions.build.client,
|
|
57
|
+
assetsDir: condition === 'react-server' ? "" : DEFAULT_CONFIG.CLIENT_ASSETS_DIR,
|
|
58
|
+
ssr: condition === 'react-server',
|
|
59
|
+
target: condition === 'react-server' ? 'node18' : 'es2020',
|
|
60
|
+
minify: condition === 'react-server' ? false : true,
|
|
61
|
+
manifest: true,
|
|
62
|
+
ssrManifest: false,
|
|
63
|
+
ssrEmitAssets: true,
|
|
64
|
+
rollupOptions: {
|
|
65
|
+
...config.build?.rollupOptions,
|
|
66
|
+
input: inputs,
|
|
67
|
+
preserveEntrySignatures: 'strict',
|
|
68
|
+
output: condition === 'react-server' ? {
|
|
69
|
+
preserveModules: true,
|
|
70
|
+
entryFileNames: '[name].js',
|
|
71
|
+
assetFileNames: '[name].[ext]',
|
|
72
|
+
chunkFileNames: '[name].[ext]',
|
|
73
|
+
format: 'esm',
|
|
74
|
+
exports: 'named',
|
|
75
|
+
preserveModulesRoot: userOptions.moduleBase,
|
|
76
|
+
hoistTransitiveImports: false,
|
|
77
|
+
generatedCode: {
|
|
78
|
+
constBindings: true,
|
|
79
|
+
objectShorthand: true
|
|
80
|
+
},
|
|
81
|
+
interop: 'auto'
|
|
82
|
+
} : undefined
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
type: "success",
|
|
89
|
+
userConfig: userConfig as ResolvedUserConfig
|
|
90
|
+
};
|
|
91
|
+
} catch (error) {
|
|
92
|
+
return {
|
|
93
|
+
type: "error",
|
|
94
|
+
error: error instanceof Error ? error : new Error("Failed to resolve config")
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
package/{src → plugin}/getEnv.ts
RENAMED
|
@@ -2,7 +2,7 @@ import { readFileSync } from "node:fs";
|
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import type { ConfigEnv, UserConfig } from "vite";
|
|
4
4
|
import { loadEnv } from "vite";
|
|
5
|
-
import { DEFAULT_CONFIG } from "./
|
|
5
|
+
import { DEFAULT_CONFIG } from "./config/defaults.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Get environment variables for Vite, sets defaults to ensure the server can start with BASE_URL and PUBLIC_URL
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Worker } from 'worker_threads';
|
|
2
|
+
import type { InputNormalizerWorker } from '../types.js';
|
|
3
|
+
|
|
4
|
+
type ClientNormalizerOptions = {
|
|
5
|
+
rscWorker: Worker;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const createClientInputNormalizer = ({
|
|
9
|
+
rscWorker
|
|
10
|
+
}: ClientNormalizerOptions): InputNormalizerWorker => {
|
|
11
|
+
return async (input): Promise<[string, string]> => {
|
|
12
|
+
// Handle string
|
|
13
|
+
if(typeof input === "string") {
|
|
14
|
+
return [input, input];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Handle React component
|
|
18
|
+
if(typeof input === "function") {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
const handler = (message: any) => {
|
|
21
|
+
if (message.type === "CLIENT_REFERENCE") {
|
|
22
|
+
rscWorker.off('message', handler);
|
|
23
|
+
resolve([message.ref.$$id, message.ref.$$location]);
|
|
24
|
+
}
|
|
25
|
+
if (message.type === "ERROR") {
|
|
26
|
+
rscWorker.off('message', handler);
|
|
27
|
+
reject(new Error(message.error));
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
rscWorker.on('message', handler);
|
|
32
|
+
rscWorker.postMessage({
|
|
33
|
+
type: "CLIENT_REFERENCE",
|
|
34
|
+
id: input.name || 'AnonymousComponent',
|
|
35
|
+
location: input.toString(),
|
|
36
|
+
key: input.name
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Handle arrays
|
|
42
|
+
if(Array.isArray(input)) {
|
|
43
|
+
return [input[0], input[0]];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
throw new Error('Invalid client input type');
|
|
47
|
+
};
|
|
48
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import type { Worker } from "node:worker_threads";
|
|
3
|
+
import type { InputNormalizerWorker } from "../types.js";
|
|
4
|
+
|
|
5
|
+
interface ServerNormalizerOptions {
|
|
6
|
+
root: string;
|
|
7
|
+
htmlWorker: Worker;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function createServerInputNormalizer({
|
|
11
|
+
root,
|
|
12
|
+
htmlWorker
|
|
13
|
+
}: ServerNormalizerOptions): InputNormalizerWorker {
|
|
14
|
+
return async (input) => {
|
|
15
|
+
// Handle React components with worker
|
|
16
|
+
if (typeof input === "function") {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
const handler = (message: any) => {
|
|
19
|
+
if (message.type === "CLIENT_REFERENCE") {
|
|
20
|
+
htmlWorker.off('message', handler);
|
|
21
|
+
resolve([message.ref.$$id, message.ref.$$location]);
|
|
22
|
+
}
|
|
23
|
+
if (message.type === "ERROR") {
|
|
24
|
+
htmlWorker.off('message', handler);
|
|
25
|
+
reject(new Error(message.error));
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
htmlWorker.on('message', handler);
|
|
30
|
+
htmlWorker.postMessage({
|
|
31
|
+
type: "CLIENT_REFERENCE",
|
|
32
|
+
id: input.name || 'AnonymousComponent',
|
|
33
|
+
location: input.toString(),
|
|
34
|
+
key: input.name
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Handle tuple input [key, path]
|
|
40
|
+
if (Array.isArray(input)) {
|
|
41
|
+
const [key, path] = input;
|
|
42
|
+
return [key, join(root, path)];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Handle string input
|
|
46
|
+
if (typeof input === "string") {
|
|
47
|
+
return [input, join(root, input)];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
throw new Error(`Invalid input type: ${typeof input}`);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import type { InputNormalizer } from "../types.js";
|
|
3
|
+
|
|
4
|
+
interface StaticNormalizerOptions {
|
|
5
|
+
root: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function createStaticInputNormalizer({ root }: StaticNormalizerOptions): InputNormalizer {
|
|
9
|
+
return (input) => {
|
|
10
|
+
// Handle tuple input [key, path]
|
|
11
|
+
if (Array.isArray(input)) {
|
|
12
|
+
const [key, path] = input;
|
|
13
|
+
// Keep the key as-is for Rollup entry point naming
|
|
14
|
+
// Just resolve the path relative to root
|
|
15
|
+
return [key, join(root, path)];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Handle string input
|
|
19
|
+
if (typeof input === "string") {
|
|
20
|
+
// For single string inputs, let Rollup handle the naming
|
|
21
|
+
return [input, join(root, input)];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
throw new Error(`Invalid input type: ${typeof input}`);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ModuleInfo, PluginContext } from 'rollup';
|
|
2
|
+
|
|
3
|
+
interface ModuleManifestEntry {
|
|
4
|
+
file: string;
|
|
5
|
+
name: string;
|
|
6
|
+
src?: string;
|
|
7
|
+
isEntry?: boolean;
|
|
8
|
+
imports?: string[];
|
|
9
|
+
dynamicImports?: string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function getModuleManifest(this: PluginContext): Record<string, ModuleManifestEntry> {
|
|
13
|
+
const manifest: Record<string, ModuleManifestEntry> = {};
|
|
14
|
+
|
|
15
|
+
// Build module graph from plugin context
|
|
16
|
+
for (const id of this.getModuleIds()) {
|
|
17
|
+
const info: ModuleInfo | null = this.getModuleInfo(id);
|
|
18
|
+
if (!info) continue;
|
|
19
|
+
|
|
20
|
+
manifest[id] = {
|
|
21
|
+
file: info.id,
|
|
22
|
+
src: info.id,
|
|
23
|
+
name: id,
|
|
24
|
+
isEntry: info.isEntry,
|
|
25
|
+
imports: Array.from(info.importedIds),
|
|
26
|
+
dynamicImports: Array.from(info.dynamicallyImportedIds)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return manifest;
|
|
31
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { InputNormalizer, NormalizerInput } from "../types.js";
|
|
2
|
+
import { DEFAULT_CONFIG } from "../config/defaults.js";
|
|
3
|
+
import { normalizePath } from "vite";
|
|
4
|
+
import { join } from "path";
|
|
5
|
+
|
|
6
|
+
export function createInputNormalizer(root: string): InputNormalizer {
|
|
7
|
+
|
|
8
|
+
// Normalize a key by removing file extensions and leading slashes
|
|
9
|
+
const normalizeKey = (key: string): string => {
|
|
10
|
+
return key
|
|
11
|
+
.replace(DEFAULT_CONFIG.FILE_REGEX, "") // Remove TypeScript/JavaScript extensions
|
|
12
|
+
.replace(/^\/+/, ""); // Remove leading slashes
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// Main normalize function
|
|
16
|
+
return (input: NormalizerInput): [string, string] => {
|
|
17
|
+
|
|
18
|
+
// Handle tuple input [key, path]
|
|
19
|
+
if (Array.isArray(input)) {
|
|
20
|
+
const [key, path] = input;
|
|
21
|
+
const normalized: [string, string] = [
|
|
22
|
+
normalizeKey(key),
|
|
23
|
+
normalizePath(join(root, path))
|
|
24
|
+
]
|
|
25
|
+
console.log("[inputNormalizer] Normalized input:", normalized, input);
|
|
26
|
+
return normalized;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Handle string input
|
|
30
|
+
if (typeof input === "string") {
|
|
31
|
+
const key = normalizeKey(input);
|
|
32
|
+
const path = normalizePath( join(root, input));
|
|
33
|
+
console.log("[inputNormalizer] Normalized input:", [key, path], input);
|
|
34
|
+
return [key, path];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
throw new Error(`Invalid input type: ${typeof input}`);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Worker } from "node:worker_threads";
|
|
2
|
+
import type { InputNormalizerWorker, NormalizerInput } from "../types.js";
|
|
3
|
+
import { createInputNormalizer } from "./inputNormalizer.js";
|
|
4
|
+
|
|
5
|
+
interface WorkerNormalizerOptions {
|
|
6
|
+
root: string;
|
|
7
|
+
moduleBase: string;
|
|
8
|
+
worker: Worker;
|
|
9
|
+
moduleBaseExceptions?: string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function createInputNormalizerWorker({
|
|
13
|
+
root,
|
|
14
|
+
worker,
|
|
15
|
+
}: WorkerNormalizerOptions): InputNormalizerWorker {
|
|
16
|
+
|
|
17
|
+
const baseNormalizer = createInputNormalizer(root);
|
|
18
|
+
|
|
19
|
+
return async (input: NormalizerInput): Promise<[string, string]> => {
|
|
20
|
+
// Handle React components specially with worker
|
|
21
|
+
if (typeof input === "function") {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
const handler = (message: any) => {
|
|
24
|
+
if (message.type === "CLIENT_REFERENCE") {
|
|
25
|
+
worker.off('message', handler);
|
|
26
|
+
resolve([message.ref.$$id, message.ref.$$location]);
|
|
27
|
+
}
|
|
28
|
+
if (message.type === "ERROR") {
|
|
29
|
+
worker.off('message', handler);
|
|
30
|
+
reject(new Error(message.error));
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
worker.on('message', handler);
|
|
35
|
+
worker.postMessage({
|
|
36
|
+
type: "CLIENT_REFERENCE",
|
|
37
|
+
id: input.name || 'AnonymousComponent',
|
|
38
|
+
location: input.toString(),
|
|
39
|
+
key: input.name
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// For all other types, use the base normalizer
|
|
45
|
+
return baseNormalizer(input);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { join, basename } from "node:path";
|
|
2
|
+
import { access, realpath } from "node:fs/promises";
|
|
3
|
+
import { normalizePath } from "vite";
|
|
4
|
+
import { getDistDir, getMode, getNodePath, getPluginRoot } from "../config/getPaths.js";
|
|
5
|
+
import pkg from "../../package.json" with { type: 'json' };
|
|
6
|
+
|
|
7
|
+
type ResolveOptions = {
|
|
8
|
+
projectRoot?: string;
|
|
9
|
+
nodePath?: string;
|
|
10
|
+
pluginRoot?: string;
|
|
11
|
+
filePath: string;
|
|
12
|
+
subDir?: string;
|
|
13
|
+
normalize?: boolean;
|
|
14
|
+
distDir?: string;
|
|
15
|
+
mode?: "production" | "development" | "test";
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export async function resolveFilePath({
|
|
19
|
+
projectRoot = process.cwd(),
|
|
20
|
+
nodePath = getNodePath(projectRoot),
|
|
21
|
+
mode = getMode(),
|
|
22
|
+
pluginRoot = getPluginRoot(),
|
|
23
|
+
distDir = getDistDir(mode),
|
|
24
|
+
filePath,
|
|
25
|
+
subDir,
|
|
26
|
+
normalize = false,
|
|
27
|
+
}: ResolveOptions) {
|
|
28
|
+
try {
|
|
29
|
+
let resolvedPath: string | undefined;
|
|
30
|
+
|
|
31
|
+
// Helper to check if file exists
|
|
32
|
+
const exists = async (path: string) => {
|
|
33
|
+
try {
|
|
34
|
+
await access(path);
|
|
35
|
+
return true;
|
|
36
|
+
} catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// If it's a plugin export (like '/rsc-worker'), use exports map
|
|
42
|
+
if (filePath.startsWith('/') && filePath.slice(1) in pkg.exports) {
|
|
43
|
+
const exportPath = filePath.slice(1);
|
|
44
|
+
const pluginPath = pkg.exports[exportPath as keyof typeof pkg.exports];
|
|
45
|
+
return join(process.cwd(), pluginRoot, pluginPath); // Make absolute
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// In test mode, preserve relative paths
|
|
49
|
+
if (mode === 'test' && !filePath.startsWith('/')) {
|
|
50
|
+
return filePath;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// For all other paths, try relative to project root first
|
|
54
|
+
const projectPath = join(projectRoot, filePath);
|
|
55
|
+
if (await exists(projectPath)) {
|
|
56
|
+
return normalize ? normalizePath(projectPath) : projectPath;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 1. Try dist folder
|
|
60
|
+
const distPath = join(distDir, subDir ?? '', basename(filePath));
|
|
61
|
+
if (await exists(distPath)) {
|
|
62
|
+
resolvedPath = await realpath(distPath);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// 2. Try node_modules path
|
|
66
|
+
if (!resolvedPath && filePath.startsWith('/node_modules/')) {
|
|
67
|
+
const npmPath = join(nodePath, filePath.slice('/node_modules/'.length));
|
|
68
|
+
if (await exists(npmPath)) {
|
|
69
|
+
resolvedPath = await realpath(npmPath);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// 3. Try direct path
|
|
74
|
+
if (!resolvedPath && await exists(filePath)) {
|
|
75
|
+
resolvedPath = await realpath(filePath);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 4. Try relative to project root
|
|
79
|
+
if (!resolvedPath) {
|
|
80
|
+
const projectPath = join(projectRoot, filePath);
|
|
81
|
+
if (await exists(projectPath)) {
|
|
82
|
+
resolvedPath = await realpath(projectPath);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (!resolvedPath) {
|
|
87
|
+
throw new Error(
|
|
88
|
+
`Could not resolve path. Tried:\n` +
|
|
89
|
+
`- ${distPath}\n` +
|
|
90
|
+
`- ${join(nodePath, filePath.slice('/node_modules/'.length))}\n` +
|
|
91
|
+
`- ${filePath}\n` +
|
|
92
|
+
`- ${join(projectRoot, filePath)}`
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return normalize ? normalizePath(
|
|
97
|
+
resolvedPath
|
|
98
|
+
.replace(pluginRoot, "/node_modules/vite-plugin-react-server")
|
|
99
|
+
.replace(projectRoot, "/")
|
|
100
|
+
.replace(nodePath, "/node_modules")
|
|
101
|
+
.replace(/^(?!\/)/, '/')
|
|
102
|
+
) : resolvedPath;
|
|
103
|
+
|
|
104
|
+
} catch (error) {
|
|
105
|
+
// If realpath fails, return normalized input path
|
|
106
|
+
return normalize ? normalizePath(filePath) : filePath;
|
|
107
|
+
}
|
|
108
|
+
}
|