vite-plugin-react-server 1.0.2 → 1.1.0
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 +49 -76
- package/bin/patch.mjs +27 -20
- package/dist/_virtual/dynamic-import-helper.js +24 -0
- package/dist/_virtual/dynamic-import-helper.js.map +1 -0
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -26
- package/dist/index.js.map +1 -1
- package/dist/package.json +24 -14
- package/dist/plugin/components.d.ts +1 -1
- package/dist/plugin/components.d.ts.map +1 -1
- package/dist/plugin/components.js +1 -1
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.d.ts +6 -0
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.d.ts.map +1 -0
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.js +30 -0
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.js.map +1 -0
- package/dist/plugin/config/autoDiscover/customWorkerFiles.d.ts +13 -0
- package/dist/plugin/config/autoDiscover/customWorkerFiles.d.ts.map +1 -0
- package/dist/plugin/config/autoDiscover/customWorkerFiles.js +24 -0
- package/dist/plugin/config/autoDiscover/customWorkerFiles.js.map +1 -0
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.d.ts +11 -0
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.d.ts.map +1 -0
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.js +29 -0
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.js.map +1 -0
- package/dist/plugin/config/autoDiscover/resolveBuildPages.d.ts +6 -0
- package/dist/plugin/config/autoDiscover/resolveBuildPages.d.ts.map +1 -0
- package/dist/plugin/config/autoDiscover/resolveBuildPages.js +83 -0
- package/dist/plugin/config/autoDiscover/resolveBuildPages.js.map +1 -0
- package/dist/plugin/config/defaults.d.ts +18 -14
- package/dist/plugin/config/defaults.d.ts.map +1 -1
- package/dist/plugin/config/defaults.js +42 -21
- package/dist/plugin/config/defaults.js.map +1 -1
- package/dist/plugin/config/getCondition.d.ts +1 -1
- package/dist/plugin/config/getCondition.d.ts.map +1 -1
- package/dist/plugin/config/getCondition.js +2 -2
- package/dist/plugin/config/getCondition.js.map +1 -1
- package/dist/plugin/config/getPaths.d.ts +0 -1
- package/dist/plugin/config/getPaths.d.ts.map +1 -1
- package/dist/plugin/config/getPaths.js.map +1 -1
- package/dist/plugin/config/index.d.ts +0 -1
- package/dist/plugin/config/index.d.ts.map +1 -1
- package/dist/plugin/config/index.js +0 -1
- package/dist/plugin/config/resolveAutoDiscover.d.ts +20 -0
- package/dist/plugin/config/resolveAutoDiscover.d.ts.map +1 -0
- package/dist/plugin/config/resolveAutoDiscover.js +128 -0
- package/dist/plugin/config/resolveAutoDiscover.js.map +1 -0
- package/dist/plugin/config/resolveOptions.d.ts +1 -1
- package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
- package/dist/plugin/config/resolveOptions.js +109 -77
- package/dist/plugin/config/resolveOptions.js.map +1 -1
- package/dist/plugin/config/resolvePages.d.ts +0 -1
- package/dist/plugin/config/resolvePages.d.ts.map +1 -1
- package/dist/plugin/config/resolvePages.js +6 -8
- package/dist/plugin/config/resolvePages.js.map +1 -1
- package/dist/plugin/config/resolveUrlOption.d.ts +16 -0
- package/dist/plugin/config/resolveUrlOption.d.ts.map +1 -0
- package/dist/plugin/config/resolveUrlOption.js +37 -0
- package/dist/plugin/config/resolveUrlOption.js.map +1 -0
- package/dist/plugin/config/resolveUserConfig.d.ts +4 -5
- package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
- package/dist/plugin/config/resolveUserConfig.js +80 -132
- package/dist/plugin/config/resolveUserConfig.js.map +1 -1
- package/dist/plugin/copy.d.ts +7 -0
- package/dist/plugin/copy.d.ts.map +1 -0
- package/dist/plugin/copy.js +30 -0
- package/dist/plugin/css-collector-elements.d.ts +4 -0
- package/dist/plugin/css-collector-elements.d.ts.map +1 -0
- package/dist/plugin/css-collector-elements.js +19 -0
- package/dist/plugin/css-collector-elements.js.map +1 -0
- package/dist/plugin/css-collector.d.ts +2 -8
- package/dist/plugin/css-collector.d.ts.map +1 -1
- package/dist/plugin/css-collector.js +9 -36
- package/dist/plugin/css-collector.js.map +1 -1
- package/dist/plugin/helpers/cleanObject.d.ts +3 -0
- package/dist/plugin/helpers/cleanObject.d.ts.map +1 -0
- package/dist/plugin/helpers/cleanObject.js +47 -0
- package/dist/plugin/helpers/cleanObject.js.map +1 -0
- package/dist/plugin/helpers/collectBundleManifestCss.d.ts +8 -0
- package/dist/plugin/helpers/collectBundleManifestCss.d.ts.map +1 -0
- package/dist/plugin/helpers/collectBundleManifestCss.js +110 -0
- package/dist/plugin/helpers/collectManifestCss.d.ts +7 -0
- package/dist/plugin/helpers/collectManifestCss.d.ts.map +1 -0
- package/dist/plugin/helpers/collectManifestCss.js +44 -0
- package/dist/plugin/helpers/collectManifestCss.js.map +1 -0
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts +31 -0
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts.map +1 -0
- package/dist/plugin/helpers/collectViteModuleGraphCss.js +104 -0
- package/dist/plugin/helpers/collectViteModuleGraphCss.js.map +1 -0
- package/dist/plugin/helpers/createCssProps.d.ts +25 -0
- package/dist/plugin/helpers/createCssProps.d.ts.map +1 -0
- package/dist/plugin/helpers/createCssProps.js +57 -0
- package/dist/plugin/helpers/createCssProps.js.map +1 -0
- package/dist/plugin/helpers/createEventHandler.d.ts +22 -0
- package/dist/plugin/helpers/createEventHandler.d.ts.map +1 -0
- package/dist/plugin/helpers/createEventHandler.js +36 -0
- package/dist/plugin/helpers/createEventHandler.js.map +1 -0
- package/dist/plugin/helpers/createHandler.d.ts +7 -13
- package/dist/plugin/helpers/createHandler.d.ts.map +1 -1
- package/dist/plugin/helpers/createHandler.js +54 -96
- package/dist/plugin/helpers/createHandler.js.map +1 -1
- package/dist/plugin/helpers/createRscStream.d.ts +12 -26
- package/dist/plugin/helpers/createRscStream.d.ts.map +1 -1
- package/dist/plugin/helpers/createRscStream.js +105 -51
- package/dist/plugin/helpers/createRscStream.js.map +1 -1
- package/dist/plugin/helpers/defaultFileWriter.d.ts +2 -0
- package/dist/plugin/helpers/defaultFileWriter.d.ts.map +1 -0
- package/dist/plugin/helpers/defaultFileWriter.js +1 -0
- package/dist/plugin/helpers/getBundleManifest.d.ts +10 -16
- package/dist/plugin/helpers/getBundleManifest.d.ts.map +1 -1
- package/dist/plugin/helpers/getBundleManifest.js +30 -22
- package/dist/plugin/helpers/getBundleManifest.js.map +1 -1
- package/dist/plugin/helpers/getRouteFiles.d.ts +14 -0
- package/dist/plugin/helpers/getRouteFiles.d.ts.map +1 -0
- package/dist/plugin/helpers/getRouteFiles.js +36 -0
- package/dist/plugin/helpers/getRouteFiles.js.map +1 -0
- package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
- package/dist/plugin/helpers/inputNormalizer.js +38 -32
- package/dist/plugin/helpers/inputNormalizer.js.map +1 -1
- package/dist/plugin/helpers/metrics.d.ts +11 -0
- package/dist/plugin/helpers/metrics.d.ts.map +1 -0
- package/dist/plugin/helpers/metrics.js +35 -0
- package/dist/plugin/helpers/metrics.js.map +1 -0
- package/dist/plugin/helpers/resolvePageAndProps.d.ts +27 -0
- package/dist/plugin/helpers/resolvePageAndProps.d.ts.map +1 -0
- package/dist/plugin/helpers/resolvePageAndProps.js +51 -0
- package/dist/plugin/helpers/resolvePageAndProps.js.map +1 -0
- package/dist/plugin/helpers/serializeUserOptions.d.ts +8 -0
- package/dist/plugin/helpers/serializeUserOptions.d.ts.map +1 -0
- package/dist/plugin/helpers/serializeUserOptions.js +182 -0
- package/dist/plugin/helpers/serializeUserOptions.js.map +1 -0
- package/dist/plugin/helpers/stashReturnValue.d.ts +2 -0
- package/dist/plugin/helpers/stashReturnValue.d.ts.map +1 -0
- package/dist/plugin/helpers/stashReturnValue.js +14 -0
- package/dist/plugin/helpers/tryManifest.d.ts +5 -3
- package/dist/plugin/helpers/tryManifest.d.ts.map +1 -1
- package/dist/plugin/helpers/tryManifest.js +16 -7
- package/dist/plugin/helpers/tryManifest.js.map +1 -1
- package/dist/plugin/html.d.ts +2 -3
- package/dist/plugin/html.d.ts.map +1 -1
- package/dist/plugin/html.js +7 -1
- package/dist/plugin/html.js.map +1 -1
- package/dist/plugin/index.d.ts +1 -2
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +3 -1
- package/dist/plugin/loader/createBuildLoader.d.ts +26 -4
- package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -1
- package/dist/plugin/loader/createBuildLoader.js +98 -33
- package/dist/plugin/loader/createBuildLoader.js.map +1 -1
- package/dist/plugin/loader/css-loader.development.d.ts +57 -0
- package/dist/plugin/loader/css-loader.development.d.ts.map +1 -0
- package/dist/plugin/loader/css-loader.development.js +81 -0
- package/dist/plugin/loader/css-loader.development.js.map +1 -0
- package/dist/plugin/loader/css-loader.production.d.ts +31 -0
- package/dist/plugin/loader/css-loader.production.d.ts.map +1 -0
- package/dist/plugin/loader/css-loader.production.js +45 -0
- package/dist/plugin/loader/css-loader.production.js.map +1 -0
- package/dist/plugin/loader/index.d.ts +2 -0
- package/dist/plugin/loader/index.d.ts.map +1 -0
- package/dist/plugin/loader/index.js +1 -0
- package/dist/plugin/loader/plugin.d.ts +22 -0
- package/dist/plugin/loader/plugin.d.ts.map +1 -0
- package/dist/plugin/loader/plugin.js +27 -0
- package/dist/plugin/loader/react-loader.d.ts +3 -7
- package/dist/plugin/loader/react-loader.d.ts.map +1 -1
- package/dist/plugin/loader/react-loader.js +85 -30
- package/dist/plugin/loader/react-loader.js.map +1 -1
- package/dist/plugin/loader/temporaryReferences.d.ts +2 -0
- package/dist/plugin/loader/temporaryReferences.d.ts.map +1 -0
- package/dist/plugin/loader/temporaryReferences.js +11 -0
- package/dist/plugin/loader/temporaryReferences.js.map +1 -0
- package/dist/plugin/moduleRefs.d.ts +7 -0
- package/dist/plugin/moduleRefs.d.ts.map +1 -0
- package/dist/plugin/moduleRefs.js +17 -0
- package/dist/plugin/moduleRefs.js.map +1 -0
- package/dist/plugin/plugin.client.d.ts +3 -0
- package/dist/plugin/plugin.client.d.ts.map +1 -0
- package/dist/plugin/plugin.client.js +19 -0
- package/dist/plugin/plugin.client.js.map +1 -0
- package/dist/plugin/plugin.d.ts +1 -5
- package/dist/plugin/plugin.d.ts.map +1 -1
- package/dist/plugin/plugin.js +3 -9
- package/dist/plugin/plugin.server.d.ts +3 -0
- package/dist/plugin/plugin.server.d.ts.map +1 -0
- package/dist/plugin/plugin.server.js +28 -0
- package/dist/plugin/plugin.server.js.map +1 -0
- package/dist/plugin/preserver/plugin.js +1 -1
- package/dist/plugin/preserver/plugin.js.map +1 -1
- package/dist/plugin/react-client/index.d.ts +1 -2
- package/dist/plugin/react-client/index.d.ts.map +1 -1
- package/dist/plugin/react-client/index.js +1 -19
- package/dist/plugin/react-client/plugin.d.ts.map +1 -1
- package/dist/plugin/react-client/plugin.js +60 -219
- package/dist/plugin/react-client/plugin.js.map +1 -1
- package/dist/plugin/react-client/server.d.ts +27 -0
- package/dist/plugin/react-client/server.d.ts.map +1 -0
- package/dist/plugin/react-client/server.js +197 -0
- package/dist/plugin/react-client/server.js.map +1 -0
- package/dist/plugin/react-server/index.d.ts +1 -2
- package/dist/plugin/react-server/index.d.ts.map +1 -1
- package/dist/plugin/react-server/index.js +1 -21
- package/dist/plugin/react-server/plugin.d.ts +0 -1
- package/dist/plugin/react-server/plugin.d.ts.map +1 -1
- package/dist/plugin/react-server/plugin.js +60 -186
- package/dist/plugin/react-server/plugin.js.map +1 -1
- package/dist/plugin/react-server/server.d.ts +9 -0
- package/dist/plugin/react-server/server.d.ts.map +1 -0
- package/dist/plugin/react-server/server.js +120 -0
- package/dist/plugin/react-server/server.js.map +1 -0
- package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts +23 -0
- package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts.map +1 -0
- package/dist/plugin/react-static/collectHtmlWorkerContent.js +85 -0
- package/dist/plugin/react-static/collectHtmlWorkerContent.js.map +1 -0
- package/dist/plugin/react-static/collectRscContent.d.ts +24 -0
- package/dist/plugin/react-static/collectRscContent.d.ts.map +1 -0
- package/dist/plugin/react-static/collectRscContent.js +49 -0
- package/dist/plugin/react-static/collectRscContent.js.map +1 -0
- package/dist/plugin/react-static/configurePreviewServer.d.ts +7 -0
- package/dist/plugin/react-static/configurePreviewServer.d.ts.map +1 -0
- package/dist/plugin/react-static/configurePreviewServer.js +67 -0
- package/dist/plugin/react-static/configurePreviewServer.js.map +1 -0
- package/dist/plugin/react-static/fileWriter.d.ts +23 -0
- package/dist/plugin/react-static/fileWriter.d.ts.map +1 -0
- package/dist/plugin/react-static/fileWriter.js +65 -0
- package/dist/plugin/react-static/fileWriter.js.map +1 -0
- package/dist/plugin/react-static/plugin.d.ts +15 -0
- package/dist/plugin/react-static/plugin.d.ts.map +1 -1
- package/dist/plugin/react-static/plugin.js +248 -149
- package/dist/plugin/react-static/plugin.js.map +1 -1
- package/dist/plugin/react-static/renderPage.d.ts +3 -0
- package/dist/plugin/react-static/renderPage.d.ts.map +1 -0
- package/dist/plugin/react-static/renderPage.js +116 -0
- package/dist/plugin/react-static/renderPage.js.map +1 -0
- package/dist/plugin/react-static/renderPages.d.ts +3 -0
- package/dist/plugin/react-static/renderPages.d.ts.map +1 -0
- package/dist/plugin/react-static/renderPages.js +125 -0
- package/dist/plugin/react-static/renderPages.js.map +1 -0
- package/dist/plugin/react-static/renderStreams.d.ts +26 -0
- package/dist/plugin/react-static/renderStreams.d.ts.map +1 -0
- package/dist/plugin/react-static/renderStreams.js +27 -0
- package/dist/plugin/react-static/renderStreams.js.map +1 -0
- package/dist/plugin/react-static/rscToHtmlStream.d.ts +22 -0
- package/dist/plugin/react-static/rscToHtmlStream.d.ts.map +1 -0
- package/dist/plugin/react-static/rscToHtmlStream.js +54 -0
- package/dist/plugin/react-static/rscToHtmlStream.js.map +1 -0
- package/dist/plugin/react-static/streamHandler.d.ts +2 -0
- package/dist/plugin/react-static/streamHandler.d.ts.map +1 -0
- package/dist/plugin/react-static/streamHandler.js +1 -0
- package/dist/plugin/react-static/types.d.ts +11 -0
- package/dist/plugin/react-static/types.d.ts.map +1 -1
- package/dist/plugin/resolvePage.d.ts +26 -9
- package/dist/plugin/resolvePage.d.ts.map +1 -1
- package/dist/plugin/resolvePage.js +41 -39
- package/dist/plugin/resolvePage.js.map +1 -1
- package/dist/plugin/resolveProps.d.ts +40 -7
- package/dist/plugin/resolveProps.d.ts.map +1 -1
- package/dist/plugin/resolveProps.js +100 -75
- package/dist/plugin/resolveProps.js.map +1 -1
- package/dist/plugin/root.d.ts +1 -0
- package/dist/plugin/root.d.ts.map +1 -1
- package/dist/plugin/root.js +1 -0
- package/dist/plugin/root.js.map +1 -1
- package/dist/plugin/transformer/index.d.ts +2 -1
- package/dist/plugin/transformer/index.d.ts.map +1 -1
- package/dist/plugin/transformer/index.js +2 -1
- package/dist/plugin/transformer/plugin.client.d.ts +4 -0
- package/dist/plugin/transformer/plugin.client.d.ts.map +1 -0
- package/dist/plugin/transformer/plugin.client.js +83 -0
- package/dist/plugin/transformer/plugin.client.js.map +1 -0
- package/dist/plugin/transformer/plugin.d.ts +1 -27
- package/dist/plugin/transformer/plugin.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.js +3 -87
- package/dist/plugin/transformer/plugin.js.map +1 -1
- package/dist/plugin/transformer/plugin.server.d.ts +4 -0
- package/dist/plugin/transformer/plugin.server.d.ts.map +1 -0
- package/dist/plugin/transformer/plugin.server.js +76 -0
- package/dist/plugin/transformer/plugin.server.js.map +1 -0
- package/dist/plugin/transformer/upgradeCssModuleCode.d.ts +11 -0
- package/dist/plugin/transformer/upgradeCssModuleCode.d.ts.map +1 -0
- package/dist/plugin/transformer/upgradeCssModuleCode.js +38 -0
- package/dist/plugin/types/css-tracking.d.ts +6 -0
- package/dist/plugin/types/css-tracking.d.ts.map +1 -0
- package/dist/plugin/types/css-tracking.js +1 -0
- package/dist/plugin/types.d.ts +372 -86
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/types.js +1 -1
- package/dist/plugin/vendor.client.d.ts +4 -0
- package/dist/plugin/vendor.client.d.ts.map +1 -0
- package/dist/plugin/vendor.client.js +16 -0
- package/dist/plugin/vendor.client.js.map +1 -0
- package/dist/plugin/vendor.server.d.ts +4 -0
- package/dist/plugin/vendor.server.d.ts.map +1 -0
- package/dist/plugin/vendor.server.js +16 -0
- package/dist/plugin/vendor.server.js.map +1 -0
- package/dist/plugin/worker/createWorker.d.ts +25 -7
- package/dist/plugin/worker/createWorker.d.ts.map +1 -1
- package/dist/plugin/worker/createWorker.js +108 -33
- package/dist/plugin/worker/createWorker.js.map +1 -1
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts +12 -0
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts.map +1 -0
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.js +103 -0
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.js.map +1 -0
- package/dist/plugin/worker/html/html-worker.development.d.ts +0 -30
- package/dist/plugin/worker/html/html-worker.development.d.ts.map +1 -1
- package/dist/plugin/worker/html/html-worker.development.js +3 -17
- package/dist/plugin/worker/html/html-worker.development.js.map +1 -1
- package/dist/plugin/worker/html/html-worker.production.js +12 -5
- package/dist/plugin/worker/html/html-worker.production.js.map +1 -1
- package/dist/plugin/worker/html/messageHandler.d.ts +2 -2
- package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/html/messageHandler.js +87 -84
- package/dist/plugin/worker/html/messageHandler.js.map +1 -1
- package/dist/plugin/worker/html/types.d.ts +18 -0
- package/dist/plugin/worker/html/types.d.ts.map +1 -0
- package/dist/plugin/worker/html/types.js +1 -0
- package/dist/plugin/worker/registerLoaders.d.ts +9 -0
- package/dist/plugin/worker/registerLoaders.d.ts.map +1 -0
- package/dist/plugin/worker/registerLoaders.js +45 -0
- package/dist/plugin/worker/rsc/handleRender.d.ts +4 -0
- package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/handleRender.js +147 -0
- package/dist/plugin/worker/rsc/handleRender.js.map +1 -0
- package/dist/plugin/worker/rsc/messageHandler.d.ts +2 -2
- package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.js +47 -112
- package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.development.d.ts +0 -30
- package/dist/plugin/worker/rsc/rsc-worker.development.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.development.js +29 -4
- package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.production.js +3 -3
- package/dist/plugin/worker/rsc/rsc-worker.production.js.map +1 -1
- package/dist/plugin/worker/rsc/state.d.ts +73 -2
- package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/state.js +40 -3
- package/dist/plugin/worker/rsc/state.js.map +1 -1
- package/dist/plugin/worker/sendMessage.d.ts +3 -0
- package/dist/plugin/worker/sendMessage.d.ts.map +1 -0
- package/dist/plugin/worker/sendMessage.js +48 -0
- package/dist/plugin/worker/types.d.ts +218 -76
- package/dist/plugin/worker/types.d.ts.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +6 -1
- package/dist/server.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +24 -14
- package/plugin/components.ts +1 -1
- package/plugin/config/autoDiscover/createGlobAutoDiscover.ts +29 -0
- package/plugin/config/autoDiscover/customWorkerFiles.ts +27 -0
- package/plugin/config/autoDiscover/pageAndPropFiles.ts +36 -0
- package/plugin/config/autoDiscover/resolveBuildPages.ts +98 -0
- package/plugin/config/defaults.tsx +38 -29
- package/plugin/config/getCondition.ts +7 -3
- package/plugin/config/getPaths.ts +1 -7
- package/plugin/config/index.ts +0 -1
- package/plugin/config/resolveAutoDiscover.ts +177 -0
- package/plugin/config/resolveOptions.ts +220 -118
- package/plugin/config/resolvePages.ts +5 -7
- package/plugin/config/resolveUrlOption.ts +43 -0
- package/plugin/config/resolveUserConfig.ts +116 -166
- package/plugin/copy.ts +39 -0
- package/plugin/css-collector-elements.tsx +21 -0
- package/plugin/css-collector.tsx +20 -53
- package/plugin/helpers/cleanObject.ts +50 -0
- package/plugin/helpers/collectBundleManifestCss.ts +160 -0
- package/plugin/helpers/collectManifestCss.ts +61 -0
- package/plugin/helpers/collectViteModuleGraphCss.ts +158 -0
- package/plugin/helpers/createCssProps.tsx +85 -0
- package/plugin/helpers/createEventHandler.ts +44 -0
- package/plugin/helpers/createHandler.ts +57 -126
- package/plugin/helpers/createRscStream.tsx +156 -0
- package/plugin/helpers/defaultFileWriter.ts +0 -0
- package/plugin/helpers/getBundleManifest.ts +42 -37
- package/plugin/helpers/getRouteFiles.ts +47 -0
- package/plugin/helpers/inputNormalizer.ts +16 -10
- package/plugin/helpers/metrics.ts +64 -0
- package/plugin/helpers/resolvePageAndProps.ts +81 -0
- package/plugin/helpers/serializeUserOptions.ts +209 -0
- package/plugin/helpers/stashReturnValue.ts +16 -0
- package/plugin/helpers/tryManifest.ts +35 -18
- package/plugin/html.tsx +14 -3
- package/plugin/index.ts +5 -2
- package/plugin/loader/createBuildLoader.ts +152 -47
- package/plugin/loader/css-loader.development.ts +157 -0
- package/plugin/loader/css-loader.production.ts +86 -0
- package/plugin/loader/index.ts +1 -0
- package/plugin/loader/plugin.ts +33 -0
- package/plugin/loader/react-loader.ts +109 -41
- package/plugin/loader/temporaryReferences.ts +3 -0
- package/plugin/moduleRefs.ts +11 -0
- package/plugin/plugin.client.ts +12 -0
- package/plugin/plugin.server.ts +25 -0
- package/plugin/plugin.ts +5 -9
- package/plugin/preserver/plugin.ts +1 -1
- package/plugin/react-client/index.ts +1 -12
- package/plugin/react-client/plugin.ts +70 -259
- package/plugin/react-client/server.ts +276 -0
- package/plugin/react-server/index.ts +1 -14
- package/plugin/react-server/plugin.ts +69 -220
- package/plugin/react-server/server.ts +128 -0
- package/plugin/react-static/collectHtmlWorkerContent.ts +120 -0
- package/plugin/react-static/collectRscContent.ts +77 -0
- package/plugin/react-static/configurePreviewServer.ts +68 -0
- package/plugin/react-static/fileWriter.ts +103 -0
- package/plugin/react-static/plugin.ts +308 -181
- package/plugin/react-static/renderPage.ts +151 -0
- package/plugin/react-static/renderPages.ts +154 -0
- package/plugin/react-static/renderStreams.ts +48 -0
- package/plugin/react-static/rscToHtmlStream.ts +85 -0
- package/plugin/react-static/streamHandler.ts +0 -0
- package/plugin/react-static/types.ts +10 -0
- package/plugin/resolvePage.ts +67 -57
- package/plugin/resolveProps.ts +148 -104
- package/plugin/root.ts +1 -1
- package/plugin/transformer/index.ts +2 -1
- package/plugin/transformer/plugin.client.ts +109 -0
- package/plugin/transformer/plugin.server.ts +98 -0
- package/plugin/transformer/plugin.ts +2 -115
- package/plugin/transformer/upgradeCssModuleCode.ts +42 -0
- package/plugin/types/css-tracking.ts +5 -0
- package/plugin/types/react-server-dom-esm.d.ts +54 -0
- package/plugin/types.ts +508 -97
- package/plugin/vendor.client.ts +12 -0
- package/plugin/vendor.server.ts +12 -0
- package/plugin/worker/createWorker.ts +158 -53
- package/plugin/worker/html/createHtmlWorkerRenderState.tsx +112 -0
- package/plugin/worker/html/html-worker.development.tsx +5 -75
- package/plugin/worker/html/html-worker.production.tsx +18 -7
- package/plugin/worker/html/messageHandler.tsx +126 -0
- package/plugin/worker/html/types.ts +19 -0
- package/plugin/worker/registerLoaders.ts +54 -0
- package/plugin/worker/rsc/handleRender.ts +180 -0
- package/plugin/worker/rsc/messageHandler.tsx +58 -132
- package/plugin/worker/rsc/rsc-worker.development.ts +49 -63
- package/plugin/worker/rsc/rsc-worker.production.ts +5 -5
- package/plugin/worker/rsc/state.ts +79 -2
- package/plugin/worker/sendMessage.ts +49 -0
- package/plugin/worker/types.ts +299 -100
- package/scripts/check-react-version.mjs +60 -48
- package/scripts/react+0.0.0-experimental-0ca8420f-20250504.patch +57 -0
- package/scripts/react-dom+0.0.0-experimental-0ca8420f-20250504.patch +819 -0
- package/scripts/{react-server-dom-esm+0.0.0-experimental-eda36a1c-20250228.patch → react-server-dom-esm+0.0.0-experimental-0ca8420f-20250504.patch} +1702 -2820
- package/tsconfig.json +7 -2
- package/dist/plugin/assertServerCondition.d.ts +0 -6
- package/dist/plugin/assertServerCondition.d.ts.map +0 -1
- package/dist/plugin/assertServerCondition.js +0 -13
- package/dist/plugin/checkFilesExist.d.ts +0 -3
- package/dist/plugin/checkFilesExist.d.ts.map +0 -1
- package/dist/plugin/checkFilesExist.js +0 -67
- package/dist/plugin/checkFilesExist.js.map +0 -1
- package/dist/plugin/collect-manifest-client-files.d.ts +0 -23
- package/dist/plugin/collect-manifest-client-files.d.ts.map +0 -1
- package/dist/plugin/collect-manifest-client-files.js +0 -131
- package/dist/plugin/collect-manifest-client-files.js.map +0 -1
- package/dist/plugin/config/getWorkerPath.d.ts +0 -2
- package/dist/plugin/config/getWorkerPath.d.ts.map +0 -1
- package/dist/plugin/config/getWorkerPath.js +0 -4
- package/dist/plugin/copy-dir.d.ts +0 -4
- package/dist/plugin/copy-dir.d.ts.map +0 -1
- package/dist/plugin/copy-dir.js +0 -25
- package/dist/plugin/copy-dir.js.map +0 -1
- package/dist/plugin/css-collector-inline.d.ts +0 -10
- package/dist/plugin/css-collector-inline.d.ts.map +0 -1
- package/dist/plugin/css-collector-inline.js +0 -55
- package/dist/plugin/css-collector-inline.js.map +0 -1
- package/dist/plugin/loader/css-loader.d.ts +0 -16
- package/dist/plugin/loader/css-loader.d.ts.map +0 -1
- package/dist/plugin/loader/css-loader.js +0 -70
- package/dist/plugin/loader/css-loader.js.map +0 -1
- package/dist/plugin/react-client/index.js.map +0 -1
- package/dist/plugin/react-server/index.js.map +0 -1
- package/dist/plugin/worker/html/renderPages.d.ts +0 -26
- package/dist/plugin/worker/html/renderPages.d.ts.map +0 -1
- package/dist/plugin/worker/html/renderPages.js +0 -241
- package/dist/plugin/worker/html/renderPages.js.map +0 -1
- package/plugin/assertServerCondition.ts +0 -12
- package/plugin/checkFilesExist.ts +0 -66
- package/plugin/collect-manifest-client-files.ts +0 -167
- package/plugin/config/getWorkerPath.ts +0 -5
- package/plugin/copy-dir.ts +0 -27
- package/plugin/css-collector-inline.tsx +0 -60
- package/plugin/helpers/createRscStream.ts +0 -109
- package/plugin/loader/css-loader.ts +0 -94
- package/plugin/worker/html/messageHandler.ts +0 -130
- package/plugin/worker/html/renderPages.ts +0 -293
- package/scripts/react+0.0.0-experimental-eda36a1c-20250228.patch +0 -159
- package/scripts/react-dom+0.0.0-experimental-eda36a1c-20250228.patch +0 -12508
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vite-plugin-react-server
|
|
3
|
+
* Copyright (c) Nico Brinkkemper
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { workerData } from 'node:worker_threads';
|
|
7
|
+
import { createRequire } from 'node:module';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
|
|
10
|
+
const projectRoot = workerData?.projectRoot || process.cwd();
|
|
11
|
+
const nodeRequire = createRequire(join(projectRoot, "package.json"));
|
|
12
|
+
const ReactDOMServer = nodeRequire("react-dom/server");
|
|
13
|
+
nodeRequire("react");
|
|
14
|
+
|
|
15
|
+
export { ReactDOMServer };
|
|
16
|
+
//# sourceMappingURL=vendor.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vendor.client.js","sources":["../../plugin/vendor.client.ts"],"sourcesContent":["import { workerData } from \"node:worker_threads\";\nimport { createRequire } from \"node:module\";\nimport { join } from \"node:path\";\n\nconst projectRoot = workerData?.projectRoot || process.cwd();\nconst nodeRequire = createRequire(join(projectRoot, \"package.json\"));\n\n// Import ReactDOM from the project's node_modules\nconst ReactDOMServer = nodeRequire(\"react-dom/server\");\nconst React = nodeRequire(\"react\");\n\nexport { ReactDOMServer, React };\n"],"names":[],"mappings":";;;;;;;;;AAIA,MAAM,WAAc,GAAA,UAAA,EAAY,WAAe,IAAA,OAAA,CAAQ,GAAI,EAAA;AAC3D,MAAM,WAAc,GAAA,aAAA,CAAc,IAAK,CAAA,WAAA,EAAa,cAAc,CAAC,CAAA;AAG7D,MAAA,cAAA,GAAiB,YAAY,kBAAkB;AACvC,YAAY,OAAO;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vendor.server.d.ts","sourceRoot":"","sources":["../../plugin/vendor.server.ts"],"names":[],"mappings":"AAQA,QAAA,MAAM,cAAc,KAA6C,CAAC;AAClE,QAAA,MAAM,KAAK,KAAuB,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vite-plugin-react-server
|
|
3
|
+
* Copyright (c) Nico Brinkkemper
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { workerData } from 'node:worker_threads';
|
|
7
|
+
import { createRequire } from 'node:module';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
|
|
10
|
+
const projectRoot = workerData?.projectRoot || process.env["npm_config_local_prefix"] || process.cwd();
|
|
11
|
+
const nodeRequire = createRequire(join(projectRoot, "package.json"));
|
|
12
|
+
const ReactDOMServer = nodeRequire("react-server-dom-esm/server");
|
|
13
|
+
const React = nodeRequire("react");
|
|
14
|
+
|
|
15
|
+
export { React, ReactDOMServer };
|
|
16
|
+
//# sourceMappingURL=vendor.server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vendor.server.js","sources":["../../plugin/vendor.server.ts"],"sourcesContent":["import { workerData } from \"node:worker_threads\";\nimport { createRequire } from \"node:module\";\nimport { join } from \"node:path\";\n\nconst projectRoot = workerData?.projectRoot || process.env[\"npm_config_local_prefix\"] || process.cwd();\nconst nodeRequire = createRequire(join(projectRoot, \"package.json\"));\n\n// Import ReactDOM from the project's node_modules\nconst ReactDOMServer = nodeRequire(\"react-server-dom-esm/server\");\nconst React = nodeRequire(\"react\");\n\nexport { ReactDOMServer, React };\n"],"names":[],"mappings":";;;;;;;;;AAIA,MAAM,WAAA,GAAc,YAAY,WAAe,IAAA,OAAA,CAAQ,IAAI,yBAAyB,CAAA,IAAK,QAAQ,GAAI,EAAA;AACrG,MAAM,WAAc,GAAA,aAAA,CAAc,IAAK,CAAA,WAAA,EAAa,cAAc,CAAC,CAAA;AAG7D,MAAA,cAAA,GAAiB,YAAY,6BAA6B;AAC1D,MAAA,KAAA,GAAQ,YAAY,OAAO;;;;"}
|
|
@@ -1,16 +1,34 @@
|
|
|
1
|
-
import { Worker, type ResourceLimits } from "node:worker_threads";
|
|
2
|
-
type CreateWorkerOptions = {
|
|
1
|
+
import { Worker, type ResourceLimits, type TransferListItem } from "node:worker_threads";
|
|
2
|
+
export type CreateWorkerOptions = {
|
|
3
3
|
projectRoot?: string;
|
|
4
|
-
|
|
4
|
+
currentCondition?: "react-server" | "react-client";
|
|
5
5
|
nodePath?: string;
|
|
6
|
-
nodeOptions?: string;
|
|
6
|
+
nodeOptions?: string[];
|
|
7
7
|
mode?: "production" | "development";
|
|
8
|
-
reverseCondition?:
|
|
8
|
+
reverseCondition?: string;
|
|
9
9
|
maxListeners?: number;
|
|
10
|
-
workerPath
|
|
10
|
+
workerPath?: string;
|
|
11
11
|
resourceLimits?: ResourceLimits;
|
|
12
12
|
typescript?: boolean;
|
|
13
|
+
htmlChunkSize?: number;
|
|
14
|
+
workerData?: any;
|
|
15
|
+
transferList?: TransferListItem[];
|
|
16
|
+
};
|
|
17
|
+
type CreateWorkerSuccess = {
|
|
18
|
+
type: "success";
|
|
19
|
+
workerPath: string;
|
|
20
|
+
worker: Worker;
|
|
21
|
+
};
|
|
22
|
+
type CreateWorkerError = {
|
|
23
|
+
type: "error";
|
|
24
|
+
workerPath: string;
|
|
25
|
+
error: Error;
|
|
26
|
+
};
|
|
27
|
+
type CreateWorkerSkip = {
|
|
28
|
+
type: "skip";
|
|
29
|
+
reason: string;
|
|
30
|
+
workerPath: string;
|
|
13
31
|
};
|
|
14
|
-
export declare function createWorker(options: CreateWorkerOptions): Promise<
|
|
32
|
+
export declare function createWorker(options: CreateWorkerOptions): Promise<CreateWorkerSuccess | CreateWorkerError | CreateWorkerSkip>;
|
|
15
33
|
export {};
|
|
16
34
|
//# sourceMappingURL=createWorker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createWorker.d.ts","sourceRoot":"","sources":["../../../plugin/worker/createWorker.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"createWorker.d.ts","sourceRoot":"","sources":["../../../plugin/worker/createWorker.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAC;AAO7B,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,cAAc,GAAG,cAAc,CAAC;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,IAAI,CAAC,EAAE,YAAY,GAAG,aAAa,CAAC;IACpC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,YAAY,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACnC,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,IAAI,EAAE,SAAS,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAsB,YAAY,CAChC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,mBAAmB,GAAG,iBAAiB,GAAG,gBAAgB,CAAC,CA2IrE"}
|
|
@@ -6,52 +6,127 @@
|
|
|
6
6
|
import { Worker } from 'node:worker_threads';
|
|
7
7
|
import { getNodePath, getMode } from '../config/getPaths.js';
|
|
8
8
|
import { getCondition } from '../config/getCondition.js';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
import { pluginRoot } from '../root.js';
|
|
11
|
+
import * as React from 'react';
|
|
9
12
|
|
|
10
13
|
async function createWorker(options) {
|
|
11
14
|
const {
|
|
12
15
|
projectRoot = process.cwd(),
|
|
13
16
|
nodePath = getNodePath(projectRoot),
|
|
14
|
-
|
|
15
|
-
reverseCondition =
|
|
17
|
+
currentCondition = getCondition(),
|
|
18
|
+
reverseCondition = currentCondition === "react-server" ? "react-client" : "react-server",
|
|
16
19
|
maxListeners = 100,
|
|
17
20
|
mode = getMode(),
|
|
18
21
|
workerPath,
|
|
19
22
|
resourceLimits = {
|
|
20
|
-
maxOldGenerationSizeMb:
|
|
21
|
-
maxYoungGenerationSizeMb:
|
|
22
|
-
}
|
|
23
|
+
maxOldGenerationSizeMb: 128,
|
|
24
|
+
maxYoungGenerationSizeMb: 64
|
|
25
|
+
},
|
|
26
|
+
htmlChunkSize = 8 * 1024,
|
|
27
|
+
transferList = []
|
|
23
28
|
} = options;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
NODE_OPTIONS: `${reverseCondition ? condition === "react-server" ? process.env["NODE_OPTIONS"]?.includes("react-server") ? process.env["NODE_OPTIONS"]?.replace("react-server", "react-client") : `${process.env["NODE_OPTIONS"] ?? ""} --conditions=react-client` : process.env["NODE_OPTIONS"]?.includes("react-client") ? process.env["NODE_OPTIONS"]?.replace("react-client", "react-server") : `${process.env["NODE_OPTIONS"] ?? ""} --conditions=react-server` : process.env["NODE_OPTIONS"]}`
|
|
31
|
-
};
|
|
32
|
-
const worker = new Worker(
|
|
33
|
-
workerPath.startsWith("/") ? workerPath : "./" + workerPath,
|
|
34
|
-
{
|
|
35
|
-
env,
|
|
36
|
-
resourceLimits
|
|
29
|
+
let workerPathWithDefault = typeof workerPath === "string" ? workerPath : undefined;
|
|
30
|
+
if (!workerPathWithDefault) {
|
|
31
|
+
if (currentCondition === "react-server") {
|
|
32
|
+
workerPathWithDefault = join(pluginRoot, `worker/rsc`);
|
|
33
|
+
} else {
|
|
34
|
+
workerPathWithDefault = join(pluginRoot, `worker/html`);
|
|
37
35
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
36
|
+
}
|
|
37
|
+
if (!workerPathWithDefault.startsWith("/")) {
|
|
38
|
+
workerPathWithDefault = join("./", workerPathWithDefault);
|
|
39
|
+
}
|
|
40
|
+
const workerData = {
|
|
41
|
+
...options.workerData,
|
|
42
|
+
importMeta: {
|
|
43
|
+
env: {
|
|
44
|
+
DEV: mode === "development" ? "true" : "false",
|
|
45
|
+
MODE: mode,
|
|
46
|
+
PROD: mode === "production" ? "true" : "false",
|
|
47
|
+
SSR: true,
|
|
48
|
+
BASE_URL: "/"
|
|
48
49
|
}
|
|
50
|
+
},
|
|
51
|
+
reactVersion: React.version
|
|
52
|
+
};
|
|
53
|
+
try {
|
|
54
|
+
const isTestEnv = process.env["VITEST"] || process.env["NODE_ENV"] === "test";
|
|
55
|
+
const nodeEnv = isTestEnv ? "test" : mode;
|
|
56
|
+
const env = {
|
|
57
|
+
...process.env,
|
|
58
|
+
BASE_URL: "/",
|
|
59
|
+
VITE_DEV: mode === "development" ? "1" : "0",
|
|
60
|
+
VITE_MODE: mode,
|
|
61
|
+
VITE_PROD: mode === "production" ? "1" : "0",
|
|
62
|
+
VITE_SSR: "true",
|
|
63
|
+
VITE_BASE_URL: "/",
|
|
64
|
+
NODE_ENV: nodeEnv,
|
|
65
|
+
NODE_PATH: nodePath,
|
|
66
|
+
NODE_OPTIONS: process.env["NODE_OPTIONS"]?.includes(reverseCondition) ? process.env["NODE_OPTIONS"] : process.env["NODE_OPTIONS"]?.includes(currentCondition) ? process.env["NODE_OPTIONS"]?.replace(
|
|
67
|
+
currentCondition,
|
|
68
|
+
reverseCondition
|
|
69
|
+
) : `${process.env["NODE_OPTIONS"] ?? ""} --conditions ${reverseCondition}`,
|
|
70
|
+
HTML_CHUNK_SIZE: htmlChunkSize.toString()
|
|
71
|
+
};
|
|
72
|
+
const worker = new Worker(workerPathWithDefault, {
|
|
73
|
+
env,
|
|
74
|
+
resourceLimits,
|
|
75
|
+
workerData,
|
|
76
|
+
transferList
|
|
49
77
|
});
|
|
50
|
-
worker.
|
|
51
|
-
|
|
52
|
-
reject
|
|
53
|
-
|
|
54
|
-
|
|
78
|
+
worker.setMaxListeners(maxListeners);
|
|
79
|
+
return await new Promise(
|
|
80
|
+
(resolve, reject) => {
|
|
81
|
+
const timeout = setTimeout(() => {
|
|
82
|
+
reject({ type: "error", error: new Error("Worker ready timeout") });
|
|
83
|
+
}, 5e3);
|
|
84
|
+
worker.once("message", (msg) => {
|
|
85
|
+
if (msg.type === "READY") {
|
|
86
|
+
clearTimeout(timeout);
|
|
87
|
+
if (msg.env !== nodeEnv) {
|
|
88
|
+
reject({
|
|
89
|
+
type: "error",
|
|
90
|
+
error: new Error(`Worker environment mismatch: ${msg.env} !== ${nodeEnv}`),
|
|
91
|
+
workerPath: workerPathWithDefault
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
resolve({
|
|
95
|
+
type: "success",
|
|
96
|
+
worker,
|
|
97
|
+
workerPath: workerPathWithDefault
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
worker.once("exit", (code) => {
|
|
102
|
+
clearTimeout(timeout);
|
|
103
|
+
worker.removeAllListeners();
|
|
104
|
+
if (code === 0) {
|
|
105
|
+
resolve({
|
|
106
|
+
type: "skip",
|
|
107
|
+
reason: "Worker exited with code 0",
|
|
108
|
+
workerPath: workerPathWithDefault
|
|
109
|
+
});
|
|
110
|
+
} else {
|
|
111
|
+
reject({
|
|
112
|
+
type: "error",
|
|
113
|
+
error: new Error(`Worker exited with code ${code}`),
|
|
114
|
+
workerPath: workerPathWithDefault
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
} catch (error) {
|
|
121
|
+
if (error instanceof Error) {
|
|
122
|
+
return {
|
|
123
|
+
type: "error",
|
|
124
|
+
workerPath: workerPathWithDefault,
|
|
125
|
+
error
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return error;
|
|
129
|
+
}
|
|
55
130
|
}
|
|
56
131
|
|
|
57
132
|
export { createWorker };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createWorker.js","sources":["../../../plugin/worker/createWorker.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"createWorker.js","sources":["../../../plugin/worker/createWorker.ts"],"sourcesContent":["import {\n Worker,\n type ResourceLimits,\n type TransferListItem\n} from \"node:worker_threads\";\nimport { getMode, getNodePath } from \"../config/getPaths.js\";\nimport { getCondition } from \"../config/getCondition.js\";\nimport { join } from \"node:path\";\nimport { pluginRoot } from \"../root.js\";\nimport * as React from \"react\";\n\nexport type CreateWorkerOptions = {\n projectRoot?: string;\n currentCondition?: \"react-server\" | \"react-client\";\n nodePath?: string;\n nodeOptions?: string[];\n mode?: \"production\" | \"development\";\n reverseCondition?: string;\n maxListeners?: number;\n workerPath?: string;\n resourceLimits?: ResourceLimits;\n typescript?: boolean;\n htmlChunkSize?: number; // Size of HTML chunks in bytes\n workerData?: any;\n transferList?: TransferListItem[];\n};\n\ntype CreateWorkerSuccess = {\n type: \"success\";\n workerPath: string;\n worker: Worker;\n};\n\ntype CreateWorkerError = {\n type: \"error\";\n workerPath: string;\n error: Error;\n};\n\ntype CreateWorkerSkip = {\n type: \"skip\";\n reason: string;\n workerPath: string;\n};\n\nexport async function createWorker(\n options: CreateWorkerOptions\n): Promise<CreateWorkerSuccess | CreateWorkerError | CreateWorkerSkip> {\n const {\n projectRoot = process.cwd(),\n nodePath = getNodePath(projectRoot),\n currentCondition = getCondition(),\n reverseCondition = currentCondition === \"react-server\"\n ? \"react-client\"\n : \"react-server\",\n maxListeners = 100,\n mode = getMode(),\n workerPath,\n resourceLimits = {\n maxOldGenerationSizeMb: 128,\n maxYoungGenerationSizeMb: 64,\n },\n htmlChunkSize = 8 * 1024,\n transferList = []\n } = options;\n let workerPathWithDefault =\n typeof workerPath === \"string\" ? workerPath : undefined;\n if (!workerPathWithDefault) {\n if (currentCondition === \"react-server\") {\n workerPathWithDefault = join(pluginRoot, `worker/rsc`);\n } else {\n workerPathWithDefault = join(pluginRoot, `worker/html`);\n }\n }\n if (!workerPathWithDefault.startsWith(\"/\")) {\n workerPathWithDefault = join(\"./\", workerPathWithDefault);\n }\n // Ensure worker uses the same React version\n const workerData = {\n ...options.workerData,\n importMeta: {\n env: {\n DEV: mode === 'development' ? 'true' : 'false',\n MODE: mode,\n PROD: mode === 'production' ? 'true' : 'false',\n SSR: true,\n BASE_URL: '/',\n },\n },\n reactVersion: React.version,\n };\n\n try {\n\n // Ensure consistent NODE_ENV between main thread and worker\n const isTestEnv =\n process.env[\"VITEST\"] || process.env[\"NODE_ENV\"] === \"test\";\n const nodeEnv = isTestEnv ? \"test\" : mode;\n\n const env = {\n ...process.env,\n BASE_URL: '/',\n VITE_DEV: mode === 'development' ? '1' : '0',\n VITE_MODE: mode,\n VITE_PROD: mode === 'production' ? '1' : '0',\n VITE_SSR: 'true',\n VITE_BASE_URL: '/',\n NODE_ENV: nodeEnv,\n NODE_PATH: nodePath,\n NODE_OPTIONS: process.env[\"NODE_OPTIONS\"]?.includes(reverseCondition)\n ? process.env[\"NODE_OPTIONS\"]\n : process.env[\"NODE_OPTIONS\"]?.includes(currentCondition)\n ? process.env[\"NODE_OPTIONS\"]?.replace(\n currentCondition,\n reverseCondition\n )\n : `${\n process.env[\"NODE_OPTIONS\"] ?? \"\"\n } --conditions ${reverseCondition}`,\n HTML_CHUNK_SIZE: htmlChunkSize.toString(),\n };\n\n // Create worker with proper environment and loaders\n const worker = new Worker(workerPathWithDefault, {\n env,\n resourceLimits,\n workerData,\n transferList,\n });\n\n worker.setMaxListeners(maxListeners);\n\n // Wait for worker to be ready\n return await new Promise<CreateWorkerSuccess | CreateWorkerSkip>(\n (resolve, reject) => {\n const timeout = setTimeout(() => {\n reject({ type: \"error\", error: new Error(\"Worker ready timeout\") });\n }, 5000);\n\n worker.once(\"message\", (msg) => {\n if (msg.type === \"READY\") {\n clearTimeout(timeout);\n if(msg.env !== nodeEnv) {\n reject({\n type: \"error\",\n error: new Error(`Worker environment mismatch: ${msg.env} !== ${nodeEnv}`),\n workerPath: workerPathWithDefault,\n } satisfies CreateWorkerError);\n }\n resolve({\n type: \"success\",\n worker,\n workerPath: workerPathWithDefault,\n } satisfies CreateWorkerSuccess);\n }\n });\n\n worker.once(\"exit\", (code) => {\n clearTimeout(timeout);\n worker.removeAllListeners();\n if (code === 0) {\n resolve({\n type: \"skip\",\n reason: \"Worker exited with code 0\",\n workerPath: workerPathWithDefault,\n } satisfies CreateWorkerSkip);\n } else {\n reject({\n type: \"error\",\n error: new Error(`Worker exited with code ${code}`),\n workerPath: workerPathWithDefault,\n } satisfies CreateWorkerError);\n }\n });\n }\n );\n } catch (error) {\n if (error instanceof Error) {\n return {\n type: \"error\",\n workerPath: workerPathWithDefault,\n error: error,\n } satisfies CreateWorkerError;\n }\n return error as CreateWorkerError;\n }\n}\n\n"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HtmlWorkerRenderState } from "./types.js";
|
|
2
|
+
import { PassThrough } from "stream";
|
|
3
|
+
import type { SerializeableRenderToPipeableStreamOptions } from "../types.js";
|
|
4
|
+
import type { HtmlWorkerOutputMessage } from "../types.js";
|
|
5
|
+
export declare function createHtmlWorkerRenderState({ projectRoot, moduleRootPath, moduleBaseURL, pipeableStreamOptions, id, }: {
|
|
6
|
+
projectRoot?: string;
|
|
7
|
+
moduleRootPath?: string;
|
|
8
|
+
moduleBaseURL?: string;
|
|
9
|
+
pipeableStreamOptions?: SerializeableRenderToPipeableStreamOptions;
|
|
10
|
+
id?: string;
|
|
11
|
+
}, sendMessage: (msg: HtmlWorkerOutputMessage) => void, rscStream?: PassThrough): HtmlWorkerRenderState;
|
|
12
|
+
//# sourceMappingURL=createHtmlWorkerRenderState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHtmlWorkerRenderState.d.ts","sourceRoot":"","sources":["../../../../plugin/worker/html/createHtmlWorkerRenderState.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAmB,0CAA0C,EAAE,MAAM,aAAa,CAAC;AAI/F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAiB3D,wBAAgB,2BAA2B,CACzC,EACE,WAAgD,EAChD,cAAsD,EACtD,aAAoD,EACpD,qBAAoE,EACpE,EAAkB,GACnB,EAAE;IACD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qBAAqB,CAAC,EAAE,0CAA0C,CAAC;IACnE,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,EACD,WAAW,EAAE,CAAC,GAAG,EAAE,uBAAuB,KAAK,IAAI,EACnD,SAAS,cAAoB,GAC5B,qBAAqB,CAuEvB"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vite-plugin-react-server
|
|
3
|
+
* Copyright (c) Nico Brinkkemper
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { PassThrough } from 'stream';
|
|
7
|
+
import { workerData } from 'node:worker_threads';
|
|
8
|
+
import 'react';
|
|
9
|
+
import { createFromNodeStream } from 'react-server-dom-esm/client.node';
|
|
10
|
+
import { Transform } from 'node:stream';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
import { ReactDOMServer } from '../../vendor.client.js';
|
|
13
|
+
|
|
14
|
+
const createMetrics = () => {
|
|
15
|
+
return {
|
|
16
|
+
chunks: 0,
|
|
17
|
+
bytes: 0,
|
|
18
|
+
backpressureCount: 0,
|
|
19
|
+
drainCount: 0,
|
|
20
|
+
errorCount: 0,
|
|
21
|
+
duration: 0,
|
|
22
|
+
startTime: 0
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
function createHtmlWorkerRenderState({
|
|
26
|
+
projectRoot = workerData.userOptions.projectRoot,
|
|
27
|
+
moduleRootPath = workerData.userOptions.moduleRootPath,
|
|
28
|
+
moduleBaseURL = workerData.userOptions.moduleBaseURL,
|
|
29
|
+
pipeableStreamOptions = workerData.userOptions.pipeableStreamOptions,
|
|
30
|
+
id = workerData.id
|
|
31
|
+
}, sendMessage, rscStream = new PassThrough()) {
|
|
32
|
+
if (typeof moduleRootPath !== "string") {
|
|
33
|
+
throw new Error("moduleRootPath is required");
|
|
34
|
+
} else if (!moduleRootPath.startsWith(projectRoot)) {
|
|
35
|
+
moduleRootPath = join(projectRoot, moduleRootPath);
|
|
36
|
+
}
|
|
37
|
+
const elements = createFromNodeStream(rscStream, moduleRootPath, moduleBaseURL);
|
|
38
|
+
const metrics = createMetrics();
|
|
39
|
+
const htmlTransform = new Transform({
|
|
40
|
+
transform(chunk, encoding, callback) {
|
|
41
|
+
metrics.chunks++;
|
|
42
|
+
metrics.bytes += chunk.length;
|
|
43
|
+
sendMessage({
|
|
44
|
+
type: "HTML_CHUNK",
|
|
45
|
+
id,
|
|
46
|
+
chunk,
|
|
47
|
+
encoding
|
|
48
|
+
});
|
|
49
|
+
callback();
|
|
50
|
+
},
|
|
51
|
+
flush(callback) {
|
|
52
|
+
sendMessage({
|
|
53
|
+
type: "HTML_COMPLETE",
|
|
54
|
+
id,
|
|
55
|
+
success: true,
|
|
56
|
+
metrics
|
|
57
|
+
});
|
|
58
|
+
callback();
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
const stream = ReactDOMServer.renderToPipeableStream(elements, {
|
|
62
|
+
...pipeableStreamOptions,
|
|
63
|
+
onAllReady: () => {
|
|
64
|
+
rscStream.end();
|
|
65
|
+
sendMessage({
|
|
66
|
+
type: "ALL_READY",
|
|
67
|
+
id
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
onError: (error, errorInfo) => {
|
|
71
|
+
sendMessage({
|
|
72
|
+
type: "ERROR",
|
|
73
|
+
id,
|
|
74
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
75
|
+
errorInfo
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
onShellReady: () => {
|
|
79
|
+
sendMessage({
|
|
80
|
+
type: "SHELL_READY",
|
|
81
|
+
id
|
|
82
|
+
});
|
|
83
|
+
},
|
|
84
|
+
onShellError: (error) => {
|
|
85
|
+
sendMessage({
|
|
86
|
+
type: "SHELL_ERROR",
|
|
87
|
+
id,
|
|
88
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
stream.pipe(htmlTransform);
|
|
93
|
+
return {
|
|
94
|
+
rscStream,
|
|
95
|
+
metrics,
|
|
96
|
+
isReady: false,
|
|
97
|
+
htmlTransform,
|
|
98
|
+
stream
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export { createHtmlWorkerRenderState };
|
|
103
|
+
//# sourceMappingURL=createHtmlWorkerRenderState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHtmlWorkerRenderState.js","sources":["../../../../plugin/worker/html/createHtmlWorkerRenderState.tsx"],"sourcesContent":["import type { HtmlWorkerRenderState } from \"./types.js\";\nimport { PassThrough } from \"stream\";\nimport { workerData } from \"node:worker_threads\";\nimport type { AllReadyMessage, SerializeableRenderToPipeableStreamOptions } from \"../types.js\";\nimport { type ErrorInfo } from \"react\";\nimport { createFromNodeStream } from \"react-server-dom-esm/client.node\";\nimport { Transform } from \"node:stream\";\nimport type { HtmlWorkerOutputMessage } from \"../types.js\";\nimport { join } from \"node:path\";\nimport type { StreamMetrics } from \"../../types.js\";\nimport { ReactDOMServer } from \"../../vendor.client.js\";\n\n\nconst createMetrics = (): StreamMetrics => {\n return {\n chunks: 0,\n bytes: 0,\n backpressureCount: 0,\n drainCount: 0,\n errorCount: 0,\n duration: 0,\n startTime: 0,\n };\n};\nexport function createHtmlWorkerRenderState(\n {\n projectRoot = workerData.userOptions.projectRoot,\n moduleRootPath = workerData.userOptions.moduleRootPath,\n moduleBaseURL = workerData.userOptions.moduleBaseURL,\n pipeableStreamOptions = workerData.userOptions.pipeableStreamOptions,\n id = workerData.id,\n }: {\n projectRoot?: string;\n moduleRootPath?: string;\n moduleBaseURL?: string;\n pipeableStreamOptions?: SerializeableRenderToPipeableStreamOptions;\n id?: string;\n },\n sendMessage: (msg: HtmlWorkerOutputMessage) => void,\n rscStream = new PassThrough()\n): HtmlWorkerRenderState {\n if (typeof moduleRootPath !== \"string\") {\n throw new Error(\"moduleRootPath is required\");\n } else if (!moduleRootPath.startsWith(projectRoot)) {\n moduleRootPath = join(projectRoot, moduleRootPath);\n }\n const elements = createFromNodeStream(rscStream, moduleRootPath, moduleBaseURL);\n const metrics = createMetrics();\n const htmlTransform = new Transform({\n transform(chunk, encoding, callback) {\n metrics.chunks++;\n metrics.bytes += chunk.length;\n\n // Send HTML chunks\n sendMessage({\n type: \"HTML_CHUNK\",\n id: id,\n chunk: chunk,\n encoding,\n } satisfies HtmlWorkerOutputMessage);\n callback();\n },\n flush(callback) {\n sendMessage({\n type: \"HTML_COMPLETE\",\n id,\n success: true,\n metrics: metrics,\n });\n callback();\n },\n })\n const stream = ReactDOMServer.renderToPipeableStream(elements, {\n ...pipeableStreamOptions,\n onAllReady: () => {\n rscStream.end();\n sendMessage({\n type: \"ALL_READY\",\n id,\n } satisfies AllReadyMessage);\n },\n onError: (error: unknown, errorInfo: ErrorInfo) => {\n sendMessage({\n type: \"ERROR\",\n id,\n error: error instanceof Error ? error : new Error(String(error)),\n errorInfo: errorInfo,\n });\n },\n onShellReady: () => {\n sendMessage({\n type: \"SHELL_READY\",\n id,\n });\n },\n onShellError: (error: unknown) => {\n sendMessage({\n type: \"SHELL_ERROR\",\n id,\n error: error instanceof Error ? error : new Error(String(error)),\n });\n },\n });\n stream.pipe(htmlTransform);\n return {\n rscStream: rscStream,\n metrics,\n isReady: false,\n htmlTransform: htmlTransform,\n stream: stream,\n };\n}\n"],"names":[],"mappings":"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"}
|
|
@@ -1,32 +1,2 @@
|
|
|
1
|
-
declare module "node:module" {
|
|
2
|
-
interface ImportAttributes {
|
|
3
|
-
[key: string]: string | undefined;
|
|
4
|
-
}
|
|
5
|
-
interface ResolveHookContext {
|
|
6
|
-
conditions: string[];
|
|
7
|
-
parentURL: string | undefined;
|
|
8
|
-
importAttributes: ImportAttributes;
|
|
9
|
-
}
|
|
10
|
-
interface LoadHookContext {
|
|
11
|
-
conditions: string[];
|
|
12
|
-
format: ModuleFormat | null | undefined;
|
|
13
|
-
importAttributes: ImportAttributes;
|
|
14
|
-
shortCircuit?: boolean;
|
|
15
|
-
}
|
|
16
|
-
interface ResolveResult {
|
|
17
|
-
url: string;
|
|
18
|
-
shortCircuit: boolean;
|
|
19
|
-
}
|
|
20
|
-
interface LoadResult {
|
|
21
|
-
format: string;
|
|
22
|
-
source: string | SharedArrayBuffer | Uint8Array;
|
|
23
|
-
shortCircuit: boolean;
|
|
24
|
-
}
|
|
25
|
-
interface HooksAPI {
|
|
26
|
-
resolve?: (specifier: string, context: ResolveHookContext, nextResolve: (specifier: string, context: ResolveHookContext) => ResolveResult) => ResolveResult;
|
|
27
|
-
load?: (url: string, context: LoadHookContext, nextLoad: (url: string, context: LoadHookContext) => LoadResult) => LoadResult;
|
|
28
|
-
}
|
|
29
|
-
function registerHooks(hooks: HooksAPI): void;
|
|
30
|
-
}
|
|
31
1
|
export {};
|
|
32
2
|
//# sourceMappingURL=html-worker.development.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-worker.development.d.ts","sourceRoot":"","sources":["../../../../plugin/worker/html/html-worker.development.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"html-worker.development.d.ts","sourceRoot":"","sources":["../../../../plugin/worker/html/html-worker.development.tsx"],"names":[],"mappings":""}
|
|
@@ -4,37 +4,23 @@
|
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
6
6
|
import { join } from 'node:path';
|
|
7
|
-
import { pluginRoot } from '../../root.js';
|
|
8
7
|
import { messageHandler } from './messageHandler.js';
|
|
9
|
-
import {
|
|
8
|
+
import { MessageChannel, parentPort } from 'node:worker_threads';
|
|
9
|
+
import { pluginRoot } from '../../root.js';
|
|
10
10
|
import { register } from 'node:module';
|
|
11
|
-
import { register as register$1 } from 'tsx/esm/api';
|
|
12
11
|
|
|
13
|
-
if (!parentPort) throw new Error("This module must be run as a worker");
|
|
14
|
-
const reactLoaderChannel = new MessageChannel();
|
|
15
12
|
const cssLoaderChannel = new MessageChannel();
|
|
16
|
-
reactLoaderChannel.port2.on("message", messageHandler);
|
|
17
13
|
cssLoaderChannel.port2.on("message", messageHandler);
|
|
18
|
-
const
|
|
19
|
-
const cssLoaderPath = "file://" + join(pluginRoot, "loader/css-loader.js");
|
|
20
|
-
register(loaderPath, {
|
|
21
|
-
parentURL: pluginRoot,
|
|
22
|
-
data: { port: reactLoaderChannel.port1 },
|
|
23
|
-
transferList: [reactLoaderChannel.port1]
|
|
24
|
-
});
|
|
14
|
+
const cssLoaderPath = "file://" + join(pluginRoot, "loader/css-loader.development.js");
|
|
25
15
|
register(cssLoaderPath, {
|
|
26
16
|
parentURL: pluginRoot,
|
|
27
17
|
data: { port: cssLoaderChannel.port1 },
|
|
28
18
|
transferList: [cssLoaderChannel.port1]
|
|
29
19
|
});
|
|
30
|
-
register$1();
|
|
31
20
|
parentPort?.on("message", messageHandler);
|
|
32
21
|
parentPort?.postMessage({
|
|
33
22
|
type: "READY",
|
|
34
23
|
env: process.env["NODE_ENV"],
|
|
35
24
|
pid: process.pid
|
|
36
25
|
});
|
|
37
|
-
if (process.env["NODE_ENV"] !== "development") {
|
|
38
|
-
throw new Error("This module must be run in development mode");
|
|
39
|
-
}
|
|
40
26
|
//# sourceMappingURL=html-worker.development.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-worker.development.js","sources":["../../../../plugin/worker/html/html-worker.development.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"html-worker.development.js","sources":["../../../../plugin/worker/html/html-worker.development.tsx"],"sourcesContent":["import { join } from \"node:path\";\nimport { messageHandler } from \"./messageHandler.js\";\nimport { MessageChannel, parentPort } from \"node:worker_threads\";\nimport { pluginRoot } from \"../../root.js\";\nimport { register } from \"node:module\";\n\n// Create channels for each loader\nconst cssLoaderChannel = new MessageChannel();\ncssLoaderChannel.port2.on(\"message\", messageHandler);\n\nconst cssLoaderPath = \"file://\" + join(pluginRoot, \"loader/css-loader.development.js\");\nregister(cssLoaderPath, {\n parentURL: pluginRoot,\n data: { port: cssLoaderChannel.port1 },\n transferList: [cssLoaderChannel.port1],\n});\n\n\n// Signal ready with environment\nparentPort?.on(\"message\", messageHandler);\nparentPort?.postMessage({\n type: \"READY\",\n env: process.env[\"NODE_ENV\"],\n pid: process.pid,\n});"],"names":[],"mappings":";;;;;;;;;;;AAOA,MAAM,gBAAA,GAAmB,IAAI,cAAe,EAAA;AAC5C,gBAAiB,CAAA,KAAA,CAAM,EAAG,CAAA,SAAA,EAAW,cAAc,CAAA;AAEnD,MAAM,aAAgB,GAAA,SAAA,GAAY,IAAK,CAAA,UAAA,EAAY,kCAAkC,CAAA;AACrF,QAAA,CAAS,aAAe,EAAA;AAAA,EACtB,SAAW,EAAA,UAAA;AAAA,EACX,IAAM,EAAA,EAAE,IAAM,EAAA,gBAAA,CAAiB,KAAM,EAAA;AAAA,EACrC,YAAA,EAAc,CAAC,gBAAA,CAAiB,KAAK;AACvC,CAAC,CAAA;AAID,UAAY,EAAA,EAAA,CAAG,WAAW,cAAc,CAAA;AACxC,UAAA,EAAY,WAAY,CAAA;AAAA,EACtB,IAAM,EAAA,OAAA;AAAA,EACN,GAAA,EAAK,OAAQ,CAAA,GAAA,CAAI,UAAU,CAAA;AAAA,EAC3B,KAAK,OAAQ,CAAA;AACf,CAAC,CAAA"}
|
|
@@ -3,17 +3,24 @@
|
|
|
3
3
|
* Copyright (c) Nico Brinkkemper
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
6
|
+
import { join } from 'node:path';
|
|
6
7
|
import { messageHandler } from './messageHandler.js';
|
|
7
|
-
import { parentPort } from 'node:worker_threads';
|
|
8
|
+
import { MessageChannel, parentPort } from 'node:worker_threads';
|
|
9
|
+
import { pluginRoot } from '../../root.js';
|
|
10
|
+
import { register } from 'node:module';
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
const cssLoaderChannel = new MessageChannel();
|
|
13
|
+
cssLoaderChannel.port2.on("message", messageHandler);
|
|
14
|
+
const cssLoaderPath = "file://" + join(pluginRoot, "loader/css-loader.production.js");
|
|
15
|
+
register(cssLoaderPath, {
|
|
16
|
+
parentURL: pluginRoot,
|
|
17
|
+
data: { port: cssLoaderChannel.port1 },
|
|
18
|
+
transferList: [cssLoaderChannel.port1]
|
|
19
|
+
});
|
|
10
20
|
parentPort?.on("message", messageHandler);
|
|
11
21
|
parentPort?.postMessage({
|
|
12
22
|
type: "READY",
|
|
13
23
|
env: process.env["NODE_ENV"],
|
|
14
24
|
pid: process.pid
|
|
15
25
|
});
|
|
16
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
17
|
-
throw new Error("This module must be run in development mode");
|
|
18
|
-
}
|
|
19
26
|
//# sourceMappingURL=html-worker.production.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-worker.production.js","sources":["../../../../plugin/worker/html/html-worker.production.tsx"],"sourcesContent":["import { messageHandler } from \"./messageHandler.js\";\nimport { parentPort } from \"node:worker_threads\";\n\
|
|
1
|
+
{"version":3,"file":"html-worker.production.js","sources":["../../../../plugin/worker/html/html-worker.production.tsx"],"sourcesContent":["import { join } from \"node:path\";\nimport { messageHandler } from \"./messageHandler.js\";\nimport { MessageChannel, parentPort } from \"node:worker_threads\";\nimport { pluginRoot } from \"../../root.js\";\nimport { register } from \"node:module\";\n\n// Create channels for each loader\nconst cssLoaderChannel = new MessageChannel();\n\ncssLoaderChannel.port2.on(\"message\", messageHandler);\n\nconst cssLoaderPath = \"file://\" + join(pluginRoot, \"loader/css-loader.production.js\");\n\nregister(cssLoaderPath, {\n parentURL: pluginRoot,\n data: { port: cssLoaderChannel.port1 },\n transferList: [cssLoaderChannel.port1],\n});\n\n\n// Signal ready with environment\nparentPort?.on(\"message\", messageHandler);\nparentPort?.postMessage({\n type: \"READY\",\n env: process.env[\"NODE_ENV\"],\n pid: process.pid,\n});"],"names":[],"mappings":";;;;;;;;;;;AAOA,MAAM,gBAAA,GAAmB,IAAI,cAAe,EAAA;AAE5C,gBAAiB,CAAA,KAAA,CAAM,EAAG,CAAA,SAAA,EAAW,cAAc,CAAA;AAEnD,MAAM,aAAgB,GAAA,SAAA,GAAY,IAAK,CAAA,UAAA,EAAY,iCAAiC,CAAA;AAEpF,QAAA,CAAS,aAAe,EAAA;AAAA,EACtB,SAAW,EAAA,UAAA;AAAA,EACX,IAAM,EAAA,EAAE,IAAM,EAAA,gBAAA,CAAiB,KAAM,EAAA;AAAA,EACrC,YAAA,EAAc,CAAC,gBAAA,CAAiB,KAAK;AACvC,CAAC,CAAA;AAID,UAAY,EAAA,EAAA,CAAG,WAAW,cAAc,CAAA;AACxC,UAAA,EAAY,WAAY,CAAA;AAAA,EACtB,IAAM,EAAA,OAAA;AAAA,EACN,GAAA,EAAK,OAAQ,CAAA,GAAA,CAAI,UAAU,CAAA;AAAA,EAC3B,KAAK,OAAQ,CAAA;AACf,CAAC,CAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare
|
|
1
|
+
import type { HtmlWorkerInputMessage } from "../types.js";
|
|
2
|
+
export declare function messageHandler(msg: HtmlWorkerInputMessage): Promise<void>;
|
|
3
3
|
//# sourceMappingURL=messageHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageHandler.d.ts","sourceRoot":"","sources":["../../../../plugin/worker/html/messageHandler.
|
|
1
|
+
{"version":3,"file":"messageHandler.d.ts","sourceRoot":"","sources":["../../../../plugin/worker/html/messageHandler.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,EAEvB,MAAM,aAAa,CAAC;AAwCrB,wBAAsB,cAAc,CAAC,GAAG,EAAE,sBAAsB,iBAiF/D"}
|