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,54 @@
|
|
|
1
|
+
import { register } from "node:module";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
import type { MessagePort } from "node:worker_threads";
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
|
+
|
|
6
|
+
export type LoaderRegistration = {
|
|
7
|
+
key: string;
|
|
8
|
+
path: string;
|
|
9
|
+
port: MessagePort;
|
|
10
|
+
importMap?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export function registerLoaders(loaders: LoaderRegistration[]) {
|
|
14
|
+
for (const { path, port, importMap } of loaders) {
|
|
15
|
+
const loaderURL = pathToFileURL(path);
|
|
16
|
+
|
|
17
|
+
// If import map is provided, register it first
|
|
18
|
+
if (importMap) {
|
|
19
|
+
try {
|
|
20
|
+
const importMapContent = readFileSync(importMap, 'utf-8');
|
|
21
|
+
const { imports } = JSON.parse(importMapContent);
|
|
22
|
+
|
|
23
|
+
register(loaderURL, {
|
|
24
|
+
parentURL: import.meta.url,
|
|
25
|
+
data: {
|
|
26
|
+
port,
|
|
27
|
+
resolve: (specifier: string, context: any, nextResolve: any) => {
|
|
28
|
+
if (Object.hasOwn(imports, specifier)) {
|
|
29
|
+
return nextResolve(imports[specifier], context);
|
|
30
|
+
}
|
|
31
|
+
return nextResolve(specifier, context);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
transferList: [port]
|
|
35
|
+
});
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error(`Failed to load import map from ${importMap}:`, error);
|
|
38
|
+
// Fallback to basic registration if import map fails
|
|
39
|
+
register(loaderURL, {
|
|
40
|
+
parentURL: import.meta.url,
|
|
41
|
+
data: { port },
|
|
42
|
+
transferList: [port]
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
// Basic registration without import map
|
|
47
|
+
register(loaderURL, {
|
|
48
|
+
parentURL: import.meta.url,
|
|
49
|
+
data: { port },
|
|
50
|
+
transferList: [port]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
RscChunkOutputMessage,
|
|
3
|
+
RscEndMessage,
|
|
4
|
+
RscMetricsMessage,
|
|
5
|
+
RscWorkerOutputMessage,
|
|
6
|
+
} from "../types.js";
|
|
7
|
+
import { resolvePageAndProps } from "../../helpers/resolvePageAndProps.js";
|
|
8
|
+
import type { RscRenderMessage } from "../types.js";
|
|
9
|
+
import { activeStreams, cssFiles } from "./state.js";
|
|
10
|
+
import { createRscStream } from "../../helpers/createRscStream.js";
|
|
11
|
+
import { CssCollector } from "../../css-collector.js";
|
|
12
|
+
import { PassThrough } from "node:stream";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import { parentPort, workerData, type MessagePort } from "node:worker_threads";
|
|
15
|
+
import { React } from "../../vendor.server.js";
|
|
16
|
+
import { hmrState } from "./state.js";
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
export async function handleRender(
|
|
20
|
+
msg: RscRenderMessage,
|
|
21
|
+
port = parentPort,
|
|
22
|
+
_reactLoaderPort: MessagePort,
|
|
23
|
+
_cssLoaderPort: MessagePort
|
|
24
|
+
) {
|
|
25
|
+
const postError = process.env["DEV"]
|
|
26
|
+
? (error: any, errorInfo?: any) => {
|
|
27
|
+
if (!(error instanceof Error)) {
|
|
28
|
+
error = new Error(String(error));
|
|
29
|
+
}
|
|
30
|
+
port?.postMessage({
|
|
31
|
+
type: "ERROR",
|
|
32
|
+
id: msg.id,
|
|
33
|
+
errorInfo,
|
|
34
|
+
error: {
|
|
35
|
+
message: error.message,
|
|
36
|
+
stack: error.stack,
|
|
37
|
+
name: error.name,
|
|
38
|
+
cause: error.cause,
|
|
39
|
+
},
|
|
40
|
+
} satisfies RscWorkerOutputMessage);
|
|
41
|
+
}
|
|
42
|
+
: (error: Error, errorInfo?: any) => {
|
|
43
|
+
port?.postMessage({
|
|
44
|
+
type: "ERROR",
|
|
45
|
+
id: msg.id,
|
|
46
|
+
errorInfo,
|
|
47
|
+
error: error.message,
|
|
48
|
+
} satisfies RscWorkerOutputMessage);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
let {
|
|
52
|
+
id = workerData.id,
|
|
53
|
+
route = workerData.route,
|
|
54
|
+
pagePath = workerData.pagePath,
|
|
55
|
+
propsPath = workerData.propsPath,
|
|
56
|
+
pageExportName = workerData.userOptions.pageExportName,
|
|
57
|
+
propsExportName = workerData.userOptions.propsExportName,
|
|
58
|
+
projectRoot = workerData.userOptions.projectRoot,
|
|
59
|
+
moduleRootPath = workerData.userOptions.moduleRootPath,
|
|
60
|
+
moduleBaseURL = workerData.userOptions.moduleBaseURL,
|
|
61
|
+
moduleBasePath = workerData.userOptions.moduleBasePath,
|
|
62
|
+
moduleBase = workerData.userOptions.moduleBase,
|
|
63
|
+
pipeableStreamOptions = workerData.userOptions.pipeableStreamOptions,
|
|
64
|
+
cssFiles: messageCssFiles,
|
|
65
|
+
globalCss = workerData.globalCss,
|
|
66
|
+
} = msg;
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
// Load modules
|
|
70
|
+
const pageAndPropsResult = await resolvePageAndProps({
|
|
71
|
+
pagePath,
|
|
72
|
+
propsPath,
|
|
73
|
+
pageExportName,
|
|
74
|
+
propsExportName,
|
|
75
|
+
route,
|
|
76
|
+
loader: async (id: string) => {
|
|
77
|
+
// Check if module is invalidated
|
|
78
|
+
if (hmrState.get(id)?.invalidated) {
|
|
79
|
+
// Clear the HMR state for this module
|
|
80
|
+
hmrState.delete(id);
|
|
81
|
+
// Force a reload by using a unique query parameter
|
|
82
|
+
return import(join(projectRoot, id) + `?t=${Date.now()}`);
|
|
83
|
+
}
|
|
84
|
+
return import(join(projectRoot, id));
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
if (pageAndPropsResult.type !== "success") {
|
|
89
|
+
if (pageAndPropsResult.type === "error") {
|
|
90
|
+
postError(pageAndPropsResult.error);
|
|
91
|
+
}
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const { PageComponent, pageProps } = pageAndPropsResult;
|
|
96
|
+
|
|
97
|
+
const adaptedOnEvent = (event: "error" | "postpone", data: any) => {
|
|
98
|
+
if (event === "error") {
|
|
99
|
+
postError(data.error, data.errorInfo);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
if (messageCssFiles && messageCssFiles.size > 0) {
|
|
104
|
+
// if any css is added to the message, add it to the cssFiles map
|
|
105
|
+
for (const [id, cssContent] of messageCssFiles.entries()) {
|
|
106
|
+
cssFiles.set(id, cssContent);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Create stream
|
|
111
|
+
const streamResult = createRscStream({
|
|
112
|
+
projectRoot: projectRoot,
|
|
113
|
+
Html: React.Fragment,
|
|
114
|
+
PageComponent: PageComponent,
|
|
115
|
+
CssCollector: CssCollector,
|
|
116
|
+
pageProps,
|
|
117
|
+
moduleBase,
|
|
118
|
+
moduleRootPath,
|
|
119
|
+
moduleBasePath,
|
|
120
|
+
moduleBaseURL,
|
|
121
|
+
manifest: {},
|
|
122
|
+
route,
|
|
123
|
+
// this is a stateful object, which at this point we assume contains all the css files
|
|
124
|
+
cssFiles,
|
|
125
|
+
globalCss,
|
|
126
|
+
onEvent: adaptedOnEvent,
|
|
127
|
+
pipeableStreamOptions: pipeableStreamOptions,
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
if (streamResult.type !== "success") {
|
|
131
|
+
postError(streamResult.error);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const { stream, metrics } = streamResult;
|
|
136
|
+
|
|
137
|
+
// Create pass-through stream
|
|
138
|
+
const passThrough = new PassThrough();
|
|
139
|
+
activeStreams.set(id, passThrough);
|
|
140
|
+
|
|
141
|
+
// Pipe stream to pass-through
|
|
142
|
+
stream.pipe(passThrough);
|
|
143
|
+
|
|
144
|
+
// Handle data chunks
|
|
145
|
+
passThrough.on("data", (chunk) => {
|
|
146
|
+
port?.postMessage({
|
|
147
|
+
type: "RSC_CHUNK",
|
|
148
|
+
id,
|
|
149
|
+
chunk,
|
|
150
|
+
} satisfies RscChunkOutputMessage);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// Handle stream end
|
|
154
|
+
passThrough.on("end", () => {
|
|
155
|
+
port?.postMessage({
|
|
156
|
+
type: "RSC_END",
|
|
157
|
+
id,
|
|
158
|
+
} satisfies RscEndMessage);
|
|
159
|
+
if (activeStreams.has(id)) {
|
|
160
|
+
port?.postMessage({
|
|
161
|
+
type: "RSC_METRICS",
|
|
162
|
+
id,
|
|
163
|
+
metrics,
|
|
164
|
+
} satisfies RscMetricsMessage);
|
|
165
|
+
activeStreams.delete(id);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// Handle errors
|
|
170
|
+
passThrough.on("error", (error) => {
|
|
171
|
+
postError(error as Error);
|
|
172
|
+
activeStreams.delete(id);
|
|
173
|
+
});
|
|
174
|
+
} catch (error) {
|
|
175
|
+
if (process.env["DEV"]) {
|
|
176
|
+
console.error(`[Stream ${id}] Error:`, error);
|
|
177
|
+
}
|
|
178
|
+
postError(error as Error);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -1,137 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export async function messageHandler(message: RscWorkerMessage) {
|
|
16
|
-
switch (message.type) {
|
|
1
|
+
import { parentPort, workerData, type MessagePort } from "node:worker_threads";
|
|
2
|
+
import { addCssFileContent, hmrState } from "./state.js";
|
|
3
|
+
import { handleRender } from "./handleRender.js";
|
|
4
|
+
|
|
5
|
+
export function messageHandler(
|
|
6
|
+
msg: any,
|
|
7
|
+
port = parentPort,
|
|
8
|
+
reactLoaderPort: MessagePort,
|
|
9
|
+
cssLoaderPort: MessagePort
|
|
10
|
+
) {
|
|
11
|
+
if (!port) {
|
|
12
|
+
throw new Error("No port found");
|
|
13
|
+
}
|
|
14
|
+
switch (msg.type) {
|
|
17
15
|
case "RSC_RENDER":
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
moduleRootPath,
|
|
59
|
-
moduleBasePath,
|
|
60
|
-
moduleBaseURL,
|
|
61
|
-
logger: createLogger(),
|
|
62
|
-
inlineCss: true,
|
|
63
|
-
cssFiles: Array.from(cssFiles.values()).map((css) => ({
|
|
64
|
-
type: "text/css",
|
|
65
|
-
content: css,
|
|
66
|
-
path: css,
|
|
67
|
-
})),
|
|
68
|
-
route: url,
|
|
69
|
-
url: typeof moduleBaseURL === "string" && moduleBaseURL !== "" ? new URL(url, moduleBaseURL).toString() : url,
|
|
70
|
-
root: projectRoot,
|
|
71
|
-
pipableStreamOptions: {
|
|
72
|
-
...pipableStreamOptions,
|
|
73
|
-
onError: (error: unknown) => {
|
|
74
|
-
if (typeof pipableStreamOptions.onError === "function") {
|
|
75
|
-
pipableStreamOptions.onError(error);
|
|
76
|
-
}
|
|
77
|
-
parentPort?.postMessage({
|
|
78
|
-
type: "ERROR",
|
|
79
|
-
id,
|
|
80
|
-
error: error instanceof Error ? error.message : String(error),
|
|
81
|
-
});
|
|
82
|
-
},
|
|
83
|
-
onPostpone: (reason: string) => {
|
|
84
|
-
if (typeof pipableStreamOptions.onPostpone === "function") {
|
|
85
|
-
pipableStreamOptions.onPostpone(reason);
|
|
86
|
-
}
|
|
87
|
-
parentPort?.postMessage({
|
|
88
|
-
type: "POSTPONE",
|
|
89
|
-
id,
|
|
90
|
-
reason,
|
|
91
|
-
});
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
if (!stream) {
|
|
97
|
-
throw new Error("Failed to create stream");
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Listen for data and end events
|
|
101
|
-
const passThrough = new PassThrough();
|
|
102
|
-
stream.pipe(passThrough);
|
|
103
|
-
|
|
104
|
-
passThrough.on("data", (chunk) => {
|
|
105
|
-
// Send to parent
|
|
106
|
-
parentPort?.postMessage({
|
|
107
|
-
type: "RSC_CHUNK",
|
|
108
|
-
id,
|
|
109
|
-
chunk: chunk.toString(),
|
|
110
|
-
moduleRootPath: moduleBasePath,
|
|
111
|
-
moduleBaseURL,
|
|
112
|
-
outDir,
|
|
113
|
-
rscOutputPath: `${outDir}/${id}.rsc`,
|
|
114
|
-
cssFiles: Array.from(cssFiles.entries()),
|
|
115
|
-
} satisfies RscChunkMessage);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
passThrough.on("end", () => {
|
|
119
|
-
parentPort?.postMessage({
|
|
120
|
-
type: "RSC_END",
|
|
121
|
-
id,
|
|
122
|
-
} satisfies RscEndMessage);
|
|
123
|
-
});
|
|
124
|
-
} catch (error) {
|
|
125
|
-
console.trace(error);
|
|
126
|
-
parentPort?.postMessage({
|
|
127
|
-
type: "ERROR",
|
|
128
|
-
id,
|
|
129
|
-
error: error instanceof Error ? error.message : String(error),
|
|
16
|
+
return handleRender(msg, port, reactLoaderPort, cssLoaderPort);
|
|
17
|
+
case "INITIALIZED_REACT_LOADER":
|
|
18
|
+
return;
|
|
19
|
+
case "INITIALIZED_CSS_LOADER":
|
|
20
|
+
return;
|
|
21
|
+
case "HMR_UPDATE":
|
|
22
|
+
// Mark the module as invalidated
|
|
23
|
+
hmrState.set(msg.path, {
|
|
24
|
+
timestamp: msg.timestamp || Date.now(),
|
|
25
|
+
invalidated: true,
|
|
26
|
+
routes: msg.routes || [],
|
|
27
|
+
});
|
|
28
|
+
// Notify the main thread that we've processed the update
|
|
29
|
+
port.postMessage({
|
|
30
|
+
type: "HMR_ACCEPT",
|
|
31
|
+
path: msg.path,
|
|
32
|
+
routes: msg.routes,
|
|
33
|
+
});
|
|
34
|
+
return;
|
|
35
|
+
case "HMR_CLEANUP":
|
|
36
|
+
// Clear the invalidation state
|
|
37
|
+
hmrState.delete(msg.path);
|
|
38
|
+
// Notify the main thread that we've processed the cleanup
|
|
39
|
+
port.postMessage({
|
|
40
|
+
type: "HMR_ACCEPT",
|
|
41
|
+
path: msg.path,
|
|
42
|
+
});
|
|
43
|
+
return;
|
|
44
|
+
case "CSS_FILE":
|
|
45
|
+
if (msg.id) {
|
|
46
|
+
const cssOptions = workerData.userOptions.css || {
|
|
47
|
+
inlineThreshold: 1000,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
addCssFileContent(msg.id, msg.content, {
|
|
51
|
+
projectRoot: workerData.userOptions.projectRoot || process.cwd(),
|
|
52
|
+
moduleBaseURL: workerData.userOptions.moduleBaseURL || "",
|
|
53
|
+
moduleBasePath: workerData.userOptions.moduleBasePath || "",
|
|
54
|
+
moduleRootPath: workerData.userOptions.moduleRootPath || "",
|
|
55
|
+
css: cssOptions,
|
|
130
56
|
});
|
|
131
57
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
58
|
+
return;
|
|
59
|
+
default: {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
136
62
|
}
|
|
137
63
|
}
|
|
@@ -1,97 +1,83 @@
|
|
|
1
|
-
|
|
2
|
-
declare module 'node:module' {
|
|
3
|
-
export interface ImportAttributes {
|
|
4
|
-
[key: string]: string | undefined;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface ResolveHookContext {
|
|
8
|
-
conditions: string[];
|
|
9
|
-
parentURL: string | undefined;
|
|
10
|
-
importAttributes: ImportAttributes;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface LoadHookContext {
|
|
14
|
-
conditions: string[];
|
|
15
|
-
format: ModuleFormat | null | undefined;
|
|
16
|
-
importAttributes: ImportAttributes;
|
|
17
|
-
shortCircuit?: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface ResolveResult {
|
|
21
|
-
url: string;
|
|
22
|
-
shortCircuit: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface LoadResult {
|
|
26
|
-
format: string;
|
|
27
|
-
source: string | SharedArrayBuffer | Uint8Array;
|
|
28
|
-
shortCircuit: boolean;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface HooksAPI {
|
|
32
|
-
resolve?: (
|
|
33
|
-
specifier: string,
|
|
34
|
-
context: ResolveHookContext,
|
|
35
|
-
nextResolve: (specifier: string, context: ResolveHookContext) => ResolveResult
|
|
36
|
-
) => ResolveResult;
|
|
37
|
-
|
|
38
|
-
load?: (
|
|
39
|
-
url: string,
|
|
40
|
-
context: LoadHookContext,
|
|
41
|
-
nextLoad: (url: string, context: LoadHookContext) => LoadResult
|
|
42
|
-
) => LoadResult;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function registerHooks(hooks: HooksAPI): void;
|
|
46
|
-
}
|
|
47
|
-
//
|
|
48
|
-
import { parentPort, MessageChannel } from "node:worker_threads";
|
|
1
|
+
import { parentPort, MessageChannel, workerData } from "node:worker_threads";
|
|
49
2
|
import { messageHandler } from "./messageHandler.js";
|
|
50
|
-
import {
|
|
51
|
-
register,
|
|
52
|
-
} from 'node:module';
|
|
3
|
+
import { register } from "node:module";
|
|
53
4
|
import { register as registerTsx } from "tsx/esm/api";
|
|
54
|
-
import { join } from
|
|
5
|
+
import { join } from "node:path";
|
|
55
6
|
import { pluginRoot } from "../../root.js";
|
|
7
|
+
import { deserializeRegExp } from "../../helpers/serializeUserOptions.js";
|
|
56
8
|
|
|
57
9
|
// Initialize worker
|
|
58
10
|
if (!parentPort) {
|
|
59
11
|
throw new Error("This module must be run as a worker");
|
|
60
12
|
}
|
|
61
13
|
|
|
14
|
+
// Deserialize workerData to restore RegExp objects
|
|
15
|
+
if (workerData) {
|
|
16
|
+
workerData.userOptions = deserializeRegExp(workerData.userOptions);
|
|
17
|
+
}
|
|
18
|
+
|
|
62
19
|
// Create channels for each loader
|
|
63
20
|
const reactLoaderChannel = new MessageChannel();
|
|
64
21
|
const cssLoaderChannel = new MessageChannel();
|
|
65
22
|
|
|
66
23
|
// Listen for messages from loaders
|
|
67
|
-
reactLoaderChannel.port2.on(
|
|
68
|
-
cssLoaderChannel.port2.on(
|
|
24
|
+
reactLoaderChannel.port2.on("message", messageHandler);
|
|
25
|
+
cssLoaderChannel.port2.on("message", messageHandler);
|
|
69
26
|
|
|
70
|
-
const loaderPath =
|
|
71
|
-
const cssLoaderPath =
|
|
27
|
+
const loaderPath = "file://" + join(pluginRoot, "loader/react-loader.js");
|
|
28
|
+
const cssLoaderPath =
|
|
29
|
+
"file://" + join(pluginRoot, "loader/css-loader.development.js");
|
|
72
30
|
|
|
73
31
|
// Register react-loader
|
|
74
32
|
register(loaderPath, {
|
|
75
33
|
parentURL: pluginRoot,
|
|
76
34
|
data: { port: reactLoaderChannel.port1 },
|
|
77
|
-
transferList: [reactLoaderChannel.port1]
|
|
35
|
+
transferList: [reactLoaderChannel.port1],
|
|
78
36
|
});
|
|
79
37
|
register(cssLoaderPath, {
|
|
80
38
|
parentURL: pluginRoot,
|
|
81
|
-
data: { port: cssLoaderChannel.port1 },
|
|
82
|
-
transferList: [cssLoaderChannel.port1]
|
|
39
|
+
data: { port: cssLoaderChannel.port1, resolvedConfig: workerData.resolvedConfig },
|
|
40
|
+
transferList: [cssLoaderChannel.port1],
|
|
83
41
|
});
|
|
84
42
|
|
|
85
43
|
// Register loaders
|
|
86
44
|
registerTsx();
|
|
87
45
|
|
|
88
46
|
// Set up message handling
|
|
89
|
-
parentPort
|
|
47
|
+
parentPort!.on("message", messageHandler);
|
|
48
|
+
|
|
49
|
+
const { hmrPort } = workerData;
|
|
50
|
+
if (hmrPort) {
|
|
51
|
+
// Start the message port
|
|
52
|
+
hmrPort.start();
|
|
53
|
+
|
|
54
|
+
// Listen for file changes
|
|
55
|
+
hmrPort.on("message", (message: any) => {
|
|
56
|
+
if (message.type === "HMR_UPDATE") {
|
|
57
|
+
// Invalidate the module in the worker
|
|
58
|
+
parentPort!.postMessage({
|
|
59
|
+
type: "HMR_UPDATE",
|
|
60
|
+
path: message.path,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Listen for HMR updates
|
|
66
|
+
hmrPort.on("message", (message: any) => {
|
|
67
|
+
// Handle the update
|
|
68
|
+
parentPort!.postMessage({
|
|
69
|
+
type: "HMR_ACCEPT",
|
|
70
|
+
path: message.path,
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
90
74
|
|
|
91
|
-
//
|
|
92
|
-
parentPort
|
|
75
|
+
// Notify parent that we're ready
|
|
76
|
+
parentPort!.postMessage({
|
|
77
|
+
type: "READY",
|
|
78
|
+
env: process.env["NODE_ENV"],
|
|
79
|
+
});
|
|
93
80
|
|
|
94
81
|
if (process.env["NODE_ENV"] !== "development") {
|
|
95
82
|
throw new Error("This module must be run in development mode");
|
|
96
83
|
}
|
|
97
|
-
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
// Check environment before any imports
|
|
2
|
+
if (process.env["NODE_ENV"] !== "production") {
|
|
3
|
+
process.exit(1);
|
|
4
|
+
}
|
|
5
|
+
|
|
1
6
|
import { parentPort } from "node:worker_threads";
|
|
2
7
|
import { messageHandler } from "./messageHandler.js";
|
|
3
8
|
|
|
4
|
-
|
|
5
9
|
if (!parentPort) {
|
|
6
10
|
throw new Error("This module must be run as a worker");
|
|
7
11
|
}
|
|
@@ -11,7 +15,3 @@ parentPort.on("message", messageHandler);
|
|
|
11
15
|
|
|
12
16
|
// Signal ready
|
|
13
17
|
parentPort.postMessage({ type: "READY", env: process.env["NODE_ENV"] });
|
|
14
|
-
|
|
15
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
16
|
-
throw new Error("This module must be run in production mode");
|
|
17
|
-
}
|