vite-plugin-react-server 0.3.4 → 0.3.6
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/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 +7 -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/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 +130 -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 +38 -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 +3 -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 +3 -0
- package/dist/plugin/react-server/index.d.ts.map +1 -0
- package/dist/plugin/react-server/index.js +10 -0
- package/dist/plugin/react-server/plugin.d.ts +7 -0
- package/dist/plugin/react-server/plugin.d.ts.map +1 -0
- package/dist/plugin/react-server/plugin.js +377 -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 -4
- package/dist/plugin/transformer/plugin.d.ts.map +1 -0
- package/dist/plugin/transformer/plugin.js +94 -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 +123 -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 +42 -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 +44 -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 +109 -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 +12 -0
- package/plugin/react-server/plugin.ts +464 -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 +141 -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 +188 -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/check-react-version.mjs +48 -30
- 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 +11354 -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 +0 -8
- 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/scripts/check-react-version.js +0 -34
- package/dist/scripts/check-react-version.js.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,20 @@
|
|
|
1
|
+
import { copyFileSync, mkdirSync, readdirSync, statSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
export async function copyDir(src, dest, options) {
|
|
4
|
+
const entries = readdirSync(src);
|
|
5
|
+
mkdirSync(dest, { recursive: true });
|
|
6
|
+
for (const entry of entries) {
|
|
7
|
+
const srcPath = join(src, entry);
|
|
8
|
+
const destPath = join(dest, entry);
|
|
9
|
+
const stat = statSync(srcPath);
|
|
10
|
+
if (options?.filter && !options.filter(srcPath)) {
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
if (stat.isDirectory()) {
|
|
14
|
+
await copyDir(srcPath, destPath, options);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
copyFileSync(srcPath, destPath);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCondition.d.ts","sourceRoot":"","sources":["../../plugin/getCondition.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEnv.d.ts","sourceRoot":"","sources":["../../plugin/getEnv.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAIlD;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS;;;;;;;;;EAyH9D"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { loadEnv } from "vite";
|
|
4
|
+
import { DEFAULT_CONFIG } from "./config/defaults.js";
|
|
5
|
+
/**
|
|
6
|
+
* Get environment variables for Vite, sets defaults to ensure the server can start with BASE_URL and PUBLIC_URL
|
|
7
|
+
*
|
|
8
|
+
* @param config - Vite configuration object
|
|
9
|
+
* @param { isPreview: boolean } - Object containing a boolean indicating if the environment is for preview
|
|
10
|
+
* @returns An object containing the environment variables
|
|
11
|
+
*/
|
|
12
|
+
export function getEnv(config, configEnv) {
|
|
13
|
+
const isLocal = config.mode === "development";
|
|
14
|
+
const envName = isLocal
|
|
15
|
+
? `${config.mode}.local`
|
|
16
|
+
: config.mode
|
|
17
|
+
? config.mode
|
|
18
|
+
: "production";
|
|
19
|
+
const environmentName = config.mode ?? envName ?? "production";
|
|
20
|
+
const env = loadEnv(environmentName, config.envDir ?? config.root ?? process.cwd(), config.envPrefix ?? DEFAULT_CONFIG.ENV_PREFIX ?? "VITE_");
|
|
21
|
+
// Get server config
|
|
22
|
+
const serverConfig = config.server || {};
|
|
23
|
+
const previewConfig = config.preview || {};
|
|
24
|
+
const host = configEnv.isPreview
|
|
25
|
+
? previewConfig.host ?? DEFAULT_CONFIG.PREVIEW_HOST
|
|
26
|
+
: serverConfig.host ?? DEFAULT_CONFIG.DEV_HOST;
|
|
27
|
+
let previewPort = previewConfig.port ?? DEFAULT_CONFIG.PREVIEW_PORT;
|
|
28
|
+
let devPort = serverConfig.port ?? DEFAULT_CONFIG.DEV_PORT;
|
|
29
|
+
let homepage = env["VITE_BASE_URL"];
|
|
30
|
+
if (configEnv.command === "build" && (!homepage || homepage === "")) {
|
|
31
|
+
try {
|
|
32
|
+
const packageJson = JSON.parse(readFileSync(resolve(config.root ?? "", "package.json"), "utf-8"));
|
|
33
|
+
homepage = packageJson.homepage ?? "";
|
|
34
|
+
if (!homepage || homepage === "") {
|
|
35
|
+
console.warn("[RSC] 🔧 For production builds, please set 'homepage' in package.json, or set VITE_BASE_URL in your environment");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
console.error(e);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
let baseUrl = env["VITE_BASE_URL"] && env["VITE_PUBLIC_URL"] !== ""
|
|
43
|
+
? env["VITE_BASE_URL"]
|
|
44
|
+
: configEnv.isPreview
|
|
45
|
+
? `http://${host}:${previewPort}`
|
|
46
|
+
: configEnv.command === "serve"
|
|
47
|
+
? `http://${host}:${devPort}`
|
|
48
|
+
: homepage;
|
|
49
|
+
let publicUrl = env["VITE_PUBLIC_URL"] && env["VITE_PUBLIC_URL"] !== ""
|
|
50
|
+
? env["VITE_PUBLIC_URL"]
|
|
51
|
+
: "";
|
|
52
|
+
// Determine port and host based on mode
|
|
53
|
+
const port = configEnv.isPreview
|
|
54
|
+
? previewConfig.port || DEFAULT_CONFIG.PREVIEW_PORT // Preview server
|
|
55
|
+
: serverConfig.port || DEFAULT_CONFIG.DEV_PORT; // Dev server
|
|
56
|
+
// Build base URL
|
|
57
|
+
if (configEnv.isPreview && `http://${host}:${port}` !== baseUrl) {
|
|
58
|
+
console.log(`VITE_BASE_URL: \"${baseUrl}\" wasn't configured correctly for this server, overriding to: \"http://${host}:${port}\"`);
|
|
59
|
+
baseUrl = `http://${host}:${port}`;
|
|
60
|
+
}
|
|
61
|
+
const envPrefix = typeof config.envPrefix === "string"
|
|
62
|
+
? config.envPrefix
|
|
63
|
+
: Array.isArray(config.envPrefix)
|
|
64
|
+
? config.envPrefix[0]
|
|
65
|
+
: DEFAULT_CONFIG.ENV_PREFIX;
|
|
66
|
+
const nodeProcessEnv = {
|
|
67
|
+
NODE_ENV: configEnv.command === "build" ? "production" : "development",
|
|
68
|
+
};
|
|
69
|
+
const defineProcess = Object.entries(nodeProcessEnv)
|
|
70
|
+
.map(([key, value]) => {
|
|
71
|
+
switch (key) {
|
|
72
|
+
case "NODE_ENV":
|
|
73
|
+
const isDev = value === ""
|
|
74
|
+
? configEnv.command === "build"
|
|
75
|
+
? false
|
|
76
|
+
: true
|
|
77
|
+
: value === "development";
|
|
78
|
+
return [`import.meta.env.DEV`, JSON.stringify(isDev)];
|
|
79
|
+
default:
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
.filter(Array.isArray);
|
|
84
|
+
const defineImportMeta = Object.entries(env).map(([key, value]) => [
|
|
85
|
+
`import.meta.env.${key}`,
|
|
86
|
+
key === "VITE_BASE_URL"
|
|
87
|
+
? value
|
|
88
|
+
? JSON.stringify(value)
|
|
89
|
+
: JSON.stringify(baseUrl)
|
|
90
|
+
: key === "VITE_PUBLIC_URL"
|
|
91
|
+
? value
|
|
92
|
+
? JSON.stringify(value)
|
|
93
|
+
: JSON.stringify(publicUrl)
|
|
94
|
+
: JSON.stringify(value),
|
|
95
|
+
]);
|
|
96
|
+
const define = Object.fromEntries([...defineProcess, ...defineImportMeta]);
|
|
97
|
+
return {
|
|
98
|
+
baseUrl,
|
|
99
|
+
publicUrl,
|
|
100
|
+
port,
|
|
101
|
+
host,
|
|
102
|
+
envPrefix,
|
|
103
|
+
environmentName,
|
|
104
|
+
env,
|
|
105
|
+
define,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Worker } from 'worker_threads';
|
|
2
|
+
import type { InputNormalizerWorker } from '../types.js';
|
|
3
|
+
type ClientNormalizerOptions = {
|
|
4
|
+
rscWorker: Worker;
|
|
5
|
+
};
|
|
6
|
+
export declare const createClientInputNormalizer: ({ rscWorker }: ClientNormalizerOptions) => InputNormalizerWorker;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=createClientInputNormalizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createClientInputNormalizer.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/createClientInputNormalizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD,KAAK,uBAAuB,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,2BAA2B,kBAErC,uBAAuB,KAAG,qBAsC5B,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const createClientInputNormalizer = ({ rscWorker }) => {
|
|
2
|
+
return async (input) => {
|
|
3
|
+
// Handle string
|
|
4
|
+
if (typeof input === "string") {
|
|
5
|
+
return [input, input];
|
|
6
|
+
}
|
|
7
|
+
// Handle React component
|
|
8
|
+
if (typeof input === "function") {
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
const handler = (message) => {
|
|
11
|
+
if (message.type === "CLIENT_REFERENCE") {
|
|
12
|
+
rscWorker.off('message', handler);
|
|
13
|
+
resolve([message.ref.$$id, message.ref.$$location]);
|
|
14
|
+
}
|
|
15
|
+
if (message.type === "ERROR") {
|
|
16
|
+
rscWorker.off('message', handler);
|
|
17
|
+
reject(new Error(message.error));
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
rscWorker.on('message', handler);
|
|
21
|
+
rscWorker.postMessage({
|
|
22
|
+
type: "CLIENT_REFERENCE",
|
|
23
|
+
id: input.name || 'AnonymousComponent',
|
|
24
|
+
location: input.toString(),
|
|
25
|
+
key: input.name
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
// Handle arrays
|
|
30
|
+
if (Array.isArray(input)) {
|
|
31
|
+
return [input[0], input[0]];
|
|
32
|
+
}
|
|
33
|
+
throw new Error('Invalid client input type');
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Worker } from "node:worker_threads";
|
|
2
|
+
import type { InputNormalizerWorker } from "../types.js";
|
|
3
|
+
interface ServerNormalizerOptions {
|
|
4
|
+
root: string;
|
|
5
|
+
htmlWorker: Worker;
|
|
6
|
+
}
|
|
7
|
+
export declare function createServerInputNormalizer({ root, htmlWorker }: ServerNormalizerOptions): InputNormalizerWorker;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=createServerInputNormalizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createServerInputNormalizer.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/createServerInputNormalizer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD,UAAU,uBAAuB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,2BAA2B,CAAC,EAC1C,IAAI,EACJ,UAAU,EACX,EAAE,uBAAuB,GAAG,qBAAqB,CAuCjD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
export function createServerInputNormalizer({ root, htmlWorker }) {
|
|
3
|
+
return async (input) => {
|
|
4
|
+
// Handle React components with worker
|
|
5
|
+
if (typeof input === "function") {
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
const handler = (message) => {
|
|
8
|
+
if (message.type === "CLIENT_REFERENCE") {
|
|
9
|
+
htmlWorker.off('message', handler);
|
|
10
|
+
resolve([message.ref.$$id, message.ref.$$location]);
|
|
11
|
+
}
|
|
12
|
+
if (message.type === "ERROR") {
|
|
13
|
+
htmlWorker.off('message', handler);
|
|
14
|
+
reject(new Error(message.error));
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
htmlWorker.on('message', handler);
|
|
18
|
+
htmlWorker.postMessage({
|
|
19
|
+
type: "CLIENT_REFERENCE",
|
|
20
|
+
id: input.name || 'AnonymousComponent',
|
|
21
|
+
location: input.toString(),
|
|
22
|
+
key: input.name
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
// Handle tuple input [key, path]
|
|
27
|
+
if (Array.isArray(input)) {
|
|
28
|
+
const [key, path] = input;
|
|
29
|
+
return [key, join(root, path)];
|
|
30
|
+
}
|
|
31
|
+
// Handle string input
|
|
32
|
+
if (typeof input === "string") {
|
|
33
|
+
return [input, join(root, input)];
|
|
34
|
+
}
|
|
35
|
+
throw new Error(`Invalid input type: ${typeof input}`);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { InputNormalizer } from "../types.js";
|
|
2
|
+
interface StaticNormalizerOptions {
|
|
3
|
+
root: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function createStaticInputNormalizer({ root }: StaticNormalizerOptions): InputNormalizer;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=createStaticInputNormalizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createStaticInputNormalizer.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/createStaticInputNormalizer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,UAAU,uBAAuB;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,2BAA2B,CAAC,EAAE,IAAI,EAAE,EAAE,uBAAuB,GAAG,eAAe,CAkB9F"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
export function createStaticInputNormalizer({ root }) {
|
|
3
|
+
return (input) => {
|
|
4
|
+
// Handle tuple input [key, path]
|
|
5
|
+
if (Array.isArray(input)) {
|
|
6
|
+
const [key, path] = input;
|
|
7
|
+
// Keep the key as-is for Rollup entry point naming
|
|
8
|
+
// Just resolve the path relative to root
|
|
9
|
+
return [key, join(root, path)];
|
|
10
|
+
}
|
|
11
|
+
// Handle string input
|
|
12
|
+
if (typeof input === "string") {
|
|
13
|
+
// For single string inputs, let Rollup handle the naming
|
|
14
|
+
return [input, join(root, input)];
|
|
15
|
+
}
|
|
16
|
+
throw new Error(`Invalid input type: ${typeof input}`);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PluginContext } from 'rollup';
|
|
2
|
+
interface ModuleManifestEntry {
|
|
3
|
+
file: string;
|
|
4
|
+
name: string;
|
|
5
|
+
src?: string;
|
|
6
|
+
isEntry?: boolean;
|
|
7
|
+
imports?: string[];
|
|
8
|
+
dynamicImports?: string[];
|
|
9
|
+
}
|
|
10
|
+
export declare function getModuleManifest(this: PluginContext): Record<string, ModuleManifestEntry>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=getModuleManifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getModuleManifest.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/getModuleManifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,aAAa,EAAE,MAAM,QAAQ,CAAC;AAExD,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAmB1F"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vite-plugin-react-server
|
|
3
|
+
* Copyright (c) Nico Brinkkemper
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
function getModuleManifest() {
|
|
7
|
+
const manifest = {};
|
|
8
|
+
for (const id of this.getModuleIds()) {
|
|
9
|
+
const info = this.getModuleInfo(id);
|
|
10
|
+
if (!info) continue;
|
|
11
|
+
manifest[id] = {
|
|
12
|
+
file: info.id,
|
|
13
|
+
src: info.id,
|
|
14
|
+
name: id,
|
|
15
|
+
isEntry: info.isEntry,
|
|
16
|
+
imports: Array.from(info.importedIds),
|
|
17
|
+
dynamicImports: Array.from(info.dynamicallyImportedIds)
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return manifest;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { getModuleManifest };
|
|
24
|
+
//# sourceMappingURL=getModuleManifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getModuleManifest.js","sources":["../../../plugin/helpers/getModuleManifest.ts"],"sourcesContent":["import type { ModuleInfo, PluginContext } from 'rollup';\n\ninterface ModuleManifestEntry {\n file: string;\n name: string;\n src?: string;\n isEntry?: boolean;\n imports?: string[];\n dynamicImports?: string[];\n}\n\nexport function getModuleManifest(this: PluginContext): Record<string, ModuleManifestEntry> {\n const manifest: Record<string, ModuleManifestEntry> = {};\n\n // Build module graph from plugin context\n for (const id of this.getModuleIds()) {\n const info: ModuleInfo | null = this.getModuleInfo(id);\n if (!info) continue;\n \n manifest[id] = {\n file: info.id,\n src: info.id,\n name: id,\n isEntry: info.isEntry,\n imports: Array.from(info.importedIds),\n dynamicImports: Array.from(info.dynamicallyImportedIds)\n };\n }\n\n return manifest;\n}"],"names":[],"mappings":";;;;;AAWO,SAAS,iBAA4E,GAAA;AAC1F,EAAA,MAAM,WAAgD,EAAC;AAGvD,EAAW,KAAA,MAAA,EAAA,IAAM,IAAK,CAAA,YAAA,EAAgB,EAAA;AACpC,IAAM,MAAA,IAAA,GAA0B,IAAK,CAAA,aAAA,CAAc,EAAE,CAAA;AACrD,IAAA,IAAI,CAAC,IAAM,EAAA;AAEX,IAAA,QAAA,CAAS,EAAE,CAAI,GAAA;AAAA,MACb,MAAM,IAAK,CAAA,EAAA;AAAA,MACX,KAAK,IAAK,CAAA,EAAA;AAAA,MACV,IAAM,EAAA,EAAA;AAAA,MACN,SAAS,IAAK,CAAA,OAAA;AAAA,MACd,OAAS,EAAA,KAAA,CAAM,IAAK,CAAA,IAAA,CAAK,WAAW,CAAA;AAAA,MACpC,cAAgB,EAAA,KAAA,CAAM,IAAK,CAAA,IAAA,CAAK,sBAAsB;AAAA,KACxD;AAAA;AAGF,EAAO,OAAA,QAAA;AACT;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputNormalizer.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/inputNormalizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,aAAa,CAAC;AAKpE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAiCnE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vite-plugin-react-server
|
|
3
|
+
* Copyright (c) Nico Brinkkemper
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { DEFAULT_CONFIG } from '../config/defaults.js';
|
|
7
|
+
import { normalizePath } from 'vite';
|
|
8
|
+
import { join } from 'path';
|
|
9
|
+
|
|
10
|
+
function createInputNormalizer(root) {
|
|
11
|
+
const normalizeKey = (key) => {
|
|
12
|
+
return key.replace(DEFAULT_CONFIG.FILE_REGEX, "").replace(/^\/+/, "");
|
|
13
|
+
};
|
|
14
|
+
return (input) => {
|
|
15
|
+
if (Array.isArray(input)) {
|
|
16
|
+
const [key, path] = input;
|
|
17
|
+
const normalized = [
|
|
18
|
+
normalizeKey(key),
|
|
19
|
+
normalizePath(join(root, path))
|
|
20
|
+
];
|
|
21
|
+
console.log("[inputNormalizer] Normalized input:", normalized, input);
|
|
22
|
+
return normalized;
|
|
23
|
+
}
|
|
24
|
+
if (typeof input === "string") {
|
|
25
|
+
const key = normalizeKey(input);
|
|
26
|
+
const path = normalizePath(join(root, input));
|
|
27
|
+
console.log("[inputNormalizer] Normalized input:", [key, path], input);
|
|
28
|
+
return [key, path];
|
|
29
|
+
}
|
|
30
|
+
throw new Error(`Invalid input type: ${typeof input}`);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { createInputNormalizer };
|
|
35
|
+
//# sourceMappingURL=inputNormalizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputNormalizer.js","sources":["../../../plugin/helpers/inputNormalizer.ts"],"sourcesContent":["import type { InputNormalizer, NormalizerInput } from \"../types.js\";\nimport { DEFAULT_CONFIG } from \"../config/defaults.js\";\nimport { normalizePath } from \"vite\";\nimport { join } from \"path\";\n\nexport function createInputNormalizer(root: string): InputNormalizer {\n\n // Normalize a key by removing file extensions and leading slashes\n const normalizeKey = (key: string): string => {\n return key\n .replace(DEFAULT_CONFIG.FILE_REGEX, \"\") // Remove TypeScript/JavaScript extensions\n .replace(/^\\/+/, \"\"); // Remove leading slashes\n };\n\n // Main normalize function\n return (input: NormalizerInput): [string, string] => {\n \n // Handle tuple input [key, path]\n if (Array.isArray(input)) {\n const [key, path] = input;\n const normalized: [string, string] = [\n normalizeKey(key),\n normalizePath(join(root, path))\n ] \n console.log(\"[inputNormalizer] Normalized input:\", normalized, input);\n return normalized;\n }\n\n // Handle string input\n if (typeof input === \"string\") {\n const key = normalizeKey(input);\n const path = normalizePath( join(root, input));\n console.log(\"[inputNormalizer] Normalized input:\", [key, path], input);\n return [key, path];\n }\n\n throw new Error(`Invalid input type: ${typeof input}`);\n };\n}\n"],"names":[],"mappings":";;;;;;;;;AAKO,SAAS,sBAAsB,IAA+B,EAAA;AAGnE,EAAM,MAAA,YAAA,GAAe,CAAC,GAAwB,KAAA;AAC5C,IAAO,OAAA,GAAA,CACJ,QAAQ,cAAe,CAAA,UAAA,EAAY,EAAE,CACrC,CAAA,OAAA,CAAQ,QAAQ,EAAE,CAAA;AAAA,GACvB;AAGA,EAAA,OAAO,CAAC,KAA6C,KAAA;AAGnD,IAAI,IAAA,KAAA,CAAM,OAAQ,CAAA,KAAK,CAAG,EAAA;AACxB,MAAM,MAAA,CAAC,GAAK,EAAA,IAAI,CAAI,GAAA,KAAA;AACpB,MAAA,MAAM,UAA+B,GAAA;AAAA,QACnC,aAAa,GAAG,CAAA;AAAA,QAChB,aAAc,CAAA,IAAA,CAAK,IAAM,EAAA,IAAI,CAAC;AAAA,OAChC;AACA,MAAQ,OAAA,CAAA,GAAA,CAAI,qCAAuC,EAAA,UAAA,EAAY,KAAK,CAAA;AACpE,MAAO,OAAA,UAAA;AAAA;AAIT,IAAI,IAAA,OAAO,UAAU,QAAU,EAAA;AAC7B,MAAM,MAAA,GAAA,GAAM,aAAa,KAAK,CAAA;AAC9B,MAAA,MAAM,IAAO,GAAA,aAAA,CAAe,IAAK,CAAA,IAAA,EAAM,KAAK,CAAC,CAAA;AAC7C,MAAA,OAAA,CAAQ,IAAI,qCAAuC,EAAA,CAAC,GAAK,EAAA,IAAI,GAAG,KAAK,CAAA;AACrE,MAAO,OAAA,CAAC,KAAK,IAAI,CAAA;AAAA;AAGnB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAuB,oBAAA,EAAA,OAAO,KAAK,CAAE,CAAA,CAAA;AAAA,GACvD;AACF;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Worker } from "node:worker_threads";
|
|
2
|
+
import type { InputNormalizerWorker } from "../types.js";
|
|
3
|
+
interface WorkerNormalizerOptions {
|
|
4
|
+
root: string;
|
|
5
|
+
moduleBase: string;
|
|
6
|
+
worker: Worker;
|
|
7
|
+
moduleBaseExceptions?: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare function createInputNormalizerWorker({ root, worker, }: WorkerNormalizerOptions): InputNormalizerWorker;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=inputNormalizerWorker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputNormalizerWorker.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/inputNormalizerWorker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,qBAAqB,EAAmB,MAAM,aAAa,CAAC;AAG1E,UAAU,uBAAuB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;CACjC;AAED,wBAAgB,2BAA2B,CAAC,EAC1C,IAAI,EACJ,MAAM,GACP,EAAE,uBAAuB,GAAG,qBAAqB,CAgCjD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createInputNormalizer } from "./inputNormalizer.js";
|
|
2
|
+
export function createInputNormalizerWorker({ root, worker, }) {
|
|
3
|
+
const baseNormalizer = createInputNormalizer(root);
|
|
4
|
+
return async (input) => {
|
|
5
|
+
// Handle React components specially with worker
|
|
6
|
+
if (typeof input === "function") {
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
const handler = (message) => {
|
|
9
|
+
if (message.type === "CLIENT_REFERENCE") {
|
|
10
|
+
worker.off('message', handler);
|
|
11
|
+
resolve([message.ref.$$id, message.ref.$$location]);
|
|
12
|
+
}
|
|
13
|
+
if (message.type === "ERROR") {
|
|
14
|
+
worker.off('message', handler);
|
|
15
|
+
reject(new Error(message.error));
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
worker.on('message', handler);
|
|
19
|
+
worker.postMessage({
|
|
20
|
+
type: "CLIENT_REFERENCE",
|
|
21
|
+
id: input.name || 'AnonymousComponent',
|
|
22
|
+
location: input.toString(),
|
|
23
|
+
key: input.name
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
// For all other types, use the base normalizer
|
|
28
|
+
return baseNormalizer(input);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizedRelativePath.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/normalizedRelativePath.ts"],"names":[],"mappings":"AAEA,KAAK,6BAA6B,GAAG;IAEnC,IAAI,EAAE,MAAM,CAAC;IAEb,MAAM,EAAE,MAAM,CAAC;IAEf,UAAU,EAAE,MAAM,CAAC;IAEnB,cAAc,EAAE,OAAO,CAAC;IAExB,eAAe,EAAE,OAAO,CAAC;IAEzB,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,4BAA4B,aAC9B,6BAA6B,YAuCxB,MAAM,WACrB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { normalizePath } from "vite";
|
|
2
|
+
export const createNormalizedRelativePath = (options = {
|
|
3
|
+
root: process.cwd(),
|
|
4
|
+
outDir: "dist",
|
|
5
|
+
moduleBase: "src",
|
|
6
|
+
noLeadingSlash: false,
|
|
7
|
+
noTrailingSlash: false,
|
|
8
|
+
moduleBaseExceptions: [],
|
|
9
|
+
}) => {
|
|
10
|
+
let base = options.noLeadingSlash && options.moduleBase.startsWith("/")
|
|
11
|
+
? options.moduleBase.slice(1)
|
|
12
|
+
: options.moduleBase;
|
|
13
|
+
if (options.noTrailingSlash && base.endsWith("/")) {
|
|
14
|
+
base = base.slice(0, -1);
|
|
15
|
+
}
|
|
16
|
+
const removeOutDir = (path) => options.outDir === path
|
|
17
|
+
? path.slice(options.outDir.length)
|
|
18
|
+
: path;
|
|
19
|
+
const removeRoot = (path) => {
|
|
20
|
+
const relative = path.startsWith(options.root)
|
|
21
|
+
? path.slice(options.root.length)
|
|
22
|
+
: path;
|
|
23
|
+
return relative;
|
|
24
|
+
};
|
|
25
|
+
const ensureModuleBase = (path) => {
|
|
26
|
+
let transformed = path;
|
|
27
|
+
if (options.noLeadingSlash && path.startsWith("/")) {
|
|
28
|
+
transformed = path.slice(1);
|
|
29
|
+
}
|
|
30
|
+
if (options.noTrailingSlash && transformed.endsWith("/")) {
|
|
31
|
+
transformed = transformed.slice(0, -1);
|
|
32
|
+
}
|
|
33
|
+
return transformed;
|
|
34
|
+
};
|
|
35
|
+
return (path) => ensureModuleBase(removeOutDir(removeRoot(normalizePath(path))));
|
|
36
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type ResolveOptions = {
|
|
2
|
+
projectRoot?: string;
|
|
3
|
+
nodePath?: string;
|
|
4
|
+
pluginRoot?: string;
|
|
5
|
+
filePath: string;
|
|
6
|
+
subDir?: string;
|
|
7
|
+
normalize?: boolean;
|
|
8
|
+
distDir?: string;
|
|
9
|
+
mode?: "production" | "development" | "test";
|
|
10
|
+
};
|
|
11
|
+
export declare function resolveFilePath({ projectRoot, nodePath, mode, pluginRoot, distDir, filePath, subDir, normalize, }: ResolveOptions): Promise<string>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=resolveFilePath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveFilePath.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/resolveFilePath.ts"],"names":[],"mappings":"AAMA,KAAK,cAAc,GAAG;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,YAAY,GAAG,aAAa,GAAG,MAAM,CAAC;CAC9C,CAAC;AAEF,wBAAsB,eAAe,CAAC,EACpC,WAA2B,EAC3B,QAAmC,EACnC,IAAgB,EAChB,UAA4B,EAC5B,OAA0B,EAC1B,QAAQ,EACR,MAAM,EACN,SAAiB,GAClB,EAAE,cAAc,mBAiFhB"}
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
export async function resolveFilePath({ projectRoot = process.cwd(), nodePath = getNodePath(projectRoot), mode = getMode(), pluginRoot = getPluginRoot(), distDir = getDistDir(mode), filePath, subDir, normalize = false, }) {
|
|
7
|
+
try {
|
|
8
|
+
let resolvedPath;
|
|
9
|
+
// Helper to check if file exists
|
|
10
|
+
const exists = async (path) => {
|
|
11
|
+
try {
|
|
12
|
+
await access(path);
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
// If it's a plugin export (like '/rsc-worker'), use exports map
|
|
20
|
+
if (filePath.startsWith('/') && filePath.slice(1) in pkg.exports) {
|
|
21
|
+
const exportPath = filePath.slice(1);
|
|
22
|
+
const pluginPath = pkg.exports[exportPath];
|
|
23
|
+
return join(process.cwd(), pluginRoot, pluginPath); // Make absolute
|
|
24
|
+
}
|
|
25
|
+
// In test mode, preserve relative paths
|
|
26
|
+
if (mode === 'test' && !filePath.startsWith('/')) {
|
|
27
|
+
return filePath;
|
|
28
|
+
}
|
|
29
|
+
// For all other paths, try relative to project root first
|
|
30
|
+
const projectPath = join(projectRoot, filePath);
|
|
31
|
+
if (await exists(projectPath)) {
|
|
32
|
+
return normalize ? normalizePath(projectPath) : projectPath;
|
|
33
|
+
}
|
|
34
|
+
// 1. Try dist folder
|
|
35
|
+
const distPath = join(distDir, subDir ?? '', basename(filePath));
|
|
36
|
+
if (await exists(distPath)) {
|
|
37
|
+
resolvedPath = await realpath(distPath);
|
|
38
|
+
}
|
|
39
|
+
// 2. Try node_modules path
|
|
40
|
+
if (!resolvedPath && filePath.startsWith('/node_modules/')) {
|
|
41
|
+
const npmPath = join(nodePath, filePath.slice('/node_modules/'.length));
|
|
42
|
+
if (await exists(npmPath)) {
|
|
43
|
+
resolvedPath = await realpath(npmPath);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// 3. Try direct path
|
|
47
|
+
if (!resolvedPath && await exists(filePath)) {
|
|
48
|
+
resolvedPath = await realpath(filePath);
|
|
49
|
+
}
|
|
50
|
+
// 4. Try relative to project root
|
|
51
|
+
if (!resolvedPath) {
|
|
52
|
+
const projectPath = join(projectRoot, filePath);
|
|
53
|
+
if (await exists(projectPath)) {
|
|
54
|
+
resolvedPath = await realpath(projectPath);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (!resolvedPath) {
|
|
58
|
+
throw new Error(`Could not resolve path. Tried:\n` +
|
|
59
|
+
`- ${distPath}\n` +
|
|
60
|
+
`- ${join(nodePath, filePath.slice('/node_modules/'.length))}\n` +
|
|
61
|
+
`- ${filePath}\n` +
|
|
62
|
+
`- ${join(projectRoot, filePath)}`);
|
|
63
|
+
}
|
|
64
|
+
return normalize ? normalizePath(resolvedPath
|
|
65
|
+
.replace(pluginRoot, "/node_modules/vite-plugin-react-server")
|
|
66
|
+
.replace(projectRoot, "/")
|
|
67
|
+
.replace(nodePath, "/node_modules")
|
|
68
|
+
.replace(/^(?!\/)/, '/')) : resolvedPath;
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
// If realpath fails, return normalized input path
|
|
72
|
+
return normalize ? normalizePath(filePath) : filePath;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveWorkerModule.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/resolveWorkerModule.ts"],"names":[],"mappings":"AAEA,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,EACnC,OAAO,EAAE;IACP,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAA;CACnB,mBAgCF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { tryManifest } from "./tryManifest.js";
|
|
2
|
+
export async function resolveWorkerModule(moduleGraph, options) {
|
|
3
|
+
console.log('Resolving worker module:', {
|
|
4
|
+
moduleGraph: Array.from(moduleGraph),
|
|
5
|
+
options
|
|
6
|
+
});
|
|
7
|
+
// Try module graph first
|
|
8
|
+
const workerModule = Array.from(moduleGraph).find(id => id.includes(options.workerPath));
|
|
9
|
+
console.log('Found in module graph:', workerModule);
|
|
10
|
+
if (workerModule) {
|
|
11
|
+
return workerModule;
|
|
12
|
+
}
|
|
13
|
+
// Fallback to manifest
|
|
14
|
+
const resolvedManifest = tryManifest({
|
|
15
|
+
root: options.root,
|
|
16
|
+
outDir: options.outDir,
|
|
17
|
+
ssrManifest: false
|
|
18
|
+
});
|
|
19
|
+
console.log('Manifest result:', resolvedManifest);
|
|
20
|
+
if (resolvedManifest.type === "error") {
|
|
21
|
+
throw new Error(`Could not find worker path in module graph or manifest: ${options.workerPath}`);
|
|
22
|
+
}
|
|
23
|
+
return resolvedManifest.manifest[options.workerPath]?.file;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tryManifest.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/tryManifest.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAErC,KAAK,kBAAkB,CAAC,GAAG,SAAS,OAAO,IAAI;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,GAAG,CAAC;CAClB,CAAC;AAEF,wBAAgB,WAAW,CAAC,GAAG,SAAS,OAAO,EAAE,OAAO,EAAE,kBAAkB,CAAC,GAAG,CAAC,GAAG;IAClF,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,GAAG,SAAS,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,QAAQ,CAAC;CAClE,GAAG;IACF,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;CACd,CAoBA"}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* vite-plugin-react-server
|
|
3
|
+
* Copyright (c) Nico Brinkkemper
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { readFileSync } from 'node:fs';
|
|
7
|
+
import { resolve } from 'node:path';
|
|
8
|
+
|
|
3
9
|
function tryManifest(options) {
|
|
4
10
|
const manifestPath = resolve(
|
|
5
11
|
options.root,
|
|
6
12
|
options.outDir,
|
|
7
13
|
".vite",
|
|
8
|
-
|
|
14
|
+
"manifest.json"
|
|
9
15
|
);
|
|
10
16
|
try {
|
|
11
17
|
const result = JSON.parse(readFileSync(manifestPath, "utf-8"));
|
|
@@ -21,7 +27,6 @@ function tryManifest(options) {
|
|
|
21
27
|
};
|
|
22
28
|
}
|
|
23
29
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
30
|
+
|
|
31
|
+
export { tryManifest };
|
|
27
32
|
//# sourceMappingURL=tryManifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tryManifest.js","sources":["../../../plugin/helpers/tryManifest.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport type { Manifest } from \"vite\";\n\ntype TryManifestOptions<SSR extends boolean> = {\n root: string;\n outDir: string;\n ssrManifest: SSR;\n};\n\nexport function tryManifest<SSR extends boolean>(options: TryManifestOptions<SSR>): {\n type: \"success\";\n manifest: SSR extends true ? Record<string, string[]> : Manifest;\n} | {\n type: \"error\";\n error: Error;\n} {\n const manifestPath = resolve(\n options.root,\n options.outDir,\n \".vite\",\n options.ssrManifest ? \"ssr-manifest.json\" : \"manifest.json\"\n );\n try {\n const result= JSON.parse(readFileSync(manifestPath, \"utf-8\"));\n return {\n type: \"success\",\n manifest: result,\n }\n } catch (e) {\n console.log(\"No manifest found\", manifestPath);\n return {\n type: \"error\",\n error: e as Error,\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAUO,SAAS,YAAiC,OAM/C,EAAA;AACA,EAAA,MAAM,YAAe,GAAA,OAAA;AAAA,IACnB,OAAQ,CAAA,IAAA;AAAA,IACR,OAAQ,CAAA,MAAA;AAAA,IACR,OAAA;AAAA,IAC4C;AAAA,GAC9C;AACA,EAAI,IAAA;AACF,IAAA,MAAM,SAAS,IAAK,CAAA,KAAA,CAAM,YAAa,CAAA,YAAA,EAAc,OAAO,CAAC,CAAA;AAC7D,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,SAAA;AAAA,MACN,QAAU,EAAA;AAAA,KACZ;AAAA,WACO,CAAG,EAAA;AACV,IAAQ,OAAA,CAAA,GAAA,CAAI,qBAAqB,YAAY,CAAA;AAC7C,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,OAAA;AAAA,MACN,KAAO,EAAA;AAAA,KACT;AAAA;AAEJ;;;;"}
|