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
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import type { PreRenderedAsset } from "rollup";
|
|
2
2
|
import type { PreRenderedChunk } from "rollup";
|
|
3
|
-
import type { StreamPluginOptions, ResolvedUserOptions
|
|
3
|
+
import type { StreamPluginOptions, ResolvedUserOptions } from "../types.js";
|
|
4
4
|
import { DEFAULT_CONFIG } from "./defaults.js";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { pluginRoot } from "../root.js";
|
|
7
|
-
import { InlineCssCollector } from "../css-collector-inline.js";
|
|
8
7
|
import { CssCollector } from "../css-collector.js";
|
|
8
|
+
import { createInputNormalizer } from "../helpers/inputNormalizer.js";
|
|
9
9
|
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Utility Functions
|
|
12
|
+
// ============================================================================
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Resolves a matcher pattern to a function that tests paths
|
|
16
|
+
*/
|
|
10
17
|
const resolveAutoDiscoverMatcher = (
|
|
11
18
|
options: undefined | string | RegExp | ((path: string) => boolean),
|
|
12
19
|
fallback: RegExp | ((path: string) => boolean)
|
|
@@ -28,77 +35,103 @@ const resolveAutoDiscoverMatcher = (
|
|
|
28
35
|
}
|
|
29
36
|
};
|
|
30
37
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Ensures a path ends with .js extension
|
|
40
|
+
*/
|
|
41
|
+
const addExtension = (path: string, extension: string = "js") => {
|
|
42
|
+
if (path.endsWith(`.${extension}`)) return path;
|
|
43
|
+
if (path.endsWith("/.")) return path.slice(0, -2) + "." + extension;
|
|
44
|
+
if (path.endsWith(".")) return path + "." + extension;
|
|
45
|
+
return path + "." + extension;
|
|
36
46
|
};
|
|
37
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Handles search query parameters in file paths
|
|
50
|
+
*/
|
|
38
51
|
const handleSearchQuery = (path: string) => {
|
|
39
|
-
// make the query part of the name of the file so it's not ending up like index1, index2, etc.
|
|
40
52
|
const searchQuery = path.split("?")[1];
|
|
41
53
|
if (!searchQuery) return path;
|
|
42
|
-
// add the folder before the filename
|
|
43
54
|
const folder = path.split("/").slice(0, -1).join("/");
|
|
44
55
|
const filename = path.split("/").pop();
|
|
45
56
|
return `${folder}/${filename}?${searchQuery}`;
|
|
46
57
|
};
|
|
47
58
|
|
|
48
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Applies pattern matching to file paths
|
|
61
|
+
*/
|
|
62
|
+
const registerPath = (
|
|
49
63
|
path: string,
|
|
50
64
|
_pattern?: string | RegExp | ((path: string) => boolean) | undefined,
|
|
51
65
|
_fallback?: string | undefined
|
|
52
66
|
) => {
|
|
53
|
-
// TODO: What to actually do here? I guess we could replace the extension, but it's not needed since we map them from the manifest anyway.
|
|
54
67
|
return path;
|
|
55
68
|
};
|
|
56
69
|
|
|
57
|
-
|
|
70
|
+
// ============================================================================
|
|
71
|
+
// Main Options Resolver
|
|
72
|
+
// ============================================================================
|
|
73
|
+
|
|
74
|
+
export const resolveOptions = <
|
|
75
|
+
InlineCSS extends boolean | undefined = boolean | undefined
|
|
76
|
+
>(
|
|
58
77
|
options: StreamPluginOptions<InlineCSS>,
|
|
59
|
-
isClient: boolean
|
|
60
78
|
):
|
|
61
79
|
| { type: "success"; userOptions: ResolvedUserOptions<InlineCSS> }
|
|
62
80
|
| { type: "error"; error: Error } => {
|
|
81
|
+
// Basic configuration
|
|
63
82
|
const projectRoot = options.projectRoot ?? process.cwd();
|
|
64
83
|
const {
|
|
65
84
|
pageExportName = DEFAULT_CONFIG.PAGE_EXPORT_NAME,
|
|
66
85
|
propsExportName = DEFAULT_CONFIG.PROPS_EXPORT_NAME,
|
|
67
86
|
} = options;
|
|
87
|
+
|
|
88
|
+
// Build configuration
|
|
68
89
|
const pages =
|
|
69
90
|
typeof options.build?.pages === "function"
|
|
70
91
|
? options.build.pages
|
|
71
92
|
: Array.isArray(options.build?.pages)
|
|
72
93
|
? options.build.pages
|
|
73
94
|
: DEFAULT_CONFIG.BUILD.pages;
|
|
95
|
+
|
|
74
96
|
let client = options.build?.client ?? DEFAULT_CONFIG.BUILD.client;
|
|
75
97
|
let server = options.build?.server ?? DEFAULT_CONFIG.BUILD.server;
|
|
76
|
-
|
|
77
98
|
const api = options.build?.api ?? DEFAULT_CONFIG.BUILD.api;
|
|
78
99
|
const staticBuild = options.build?.static ?? DEFAULT_CONFIG.BUILD.static;
|
|
79
100
|
const outDir = options.build?.outDir ?? DEFAULT_CONFIG.BUILD.outDir;
|
|
80
101
|
const assetsDir =
|
|
81
102
|
options.build?.assetsDir ?? `${DEFAULT_CONFIG.CLIENT_ASSETS_DIR}`;
|
|
82
103
|
|
|
104
|
+
// Path normalization helpers
|
|
83
105
|
const ensureModuleBase = (n: string | null) => {
|
|
84
106
|
if (!n) return "";
|
|
85
107
|
return n.startsWith(moduleBase + "/") ? n.slice(moduleBase.length + 1) : n;
|
|
86
108
|
};
|
|
109
|
+
|
|
87
110
|
const hasWrongRoot = !projectRoot.startsWith("/");
|
|
88
111
|
if (hasWrongRoot) {
|
|
89
112
|
console.warn("projectRoot is not a full path", projectRoot);
|
|
90
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* If the defined project root is already wrong, we keep it as is.
|
|
116
|
+
* Otherwise, we remove the leading slash as a representation of the wrong root.
|
|
117
|
+
*/
|
|
91
118
|
const wrongRoot = !hasWrongRoot ? projectRoot.slice(1) : projectRoot;
|
|
119
|
+
|
|
92
120
|
const ensureNoRoot = (n: string | null) => {
|
|
93
|
-
if (
|
|
121
|
+
if (typeof n !== "string" || n === "") {
|
|
122
|
+
return "";
|
|
123
|
+
}
|
|
124
|
+
// if the path starts with the wrong root, we remove the wrong root
|
|
94
125
|
if (n.startsWith(wrongRoot)) {
|
|
95
126
|
return n.slice(wrongRoot.length + 1);
|
|
96
127
|
}
|
|
128
|
+
// if the path starts with the project root, we remove the project root
|
|
97
129
|
return n.startsWith(projectRoot + "/")
|
|
98
130
|
? n.slice(projectRoot.length + 1)
|
|
99
131
|
: n;
|
|
100
132
|
};
|
|
101
133
|
|
|
134
|
+
// Auto-discovery pattern matchers
|
|
102
135
|
const testModulePattern = resolveAutoDiscoverMatcher(
|
|
103
136
|
options.autoDiscover?.modulePattern,
|
|
104
137
|
DEFAULT_CONFIG.AUTO_DISCOVER.modulePattern
|
|
@@ -113,50 +146,96 @@ export const resolveOptions = <InlineCSS extends boolean = boolean>(
|
|
|
113
146
|
options.autoDiscover?.cssPattern,
|
|
114
147
|
DEFAULT_CONFIG.AUTO_DISCOVER.cssPattern
|
|
115
148
|
);
|
|
149
|
+
|
|
116
150
|
const testHtml = resolveAutoDiscoverMatcher(
|
|
117
151
|
options.autoDiscover?.htmlPattern,
|
|
118
152
|
DEFAULT_CONFIG.AUTO_DISCOVER.htmlPattern
|
|
119
153
|
);
|
|
154
|
+
|
|
155
|
+
const testRsc = resolveAutoDiscoverMatcher(
|
|
156
|
+
options.autoDiscover?.rscPattern,
|
|
157
|
+
DEFAULT_CONFIG.AUTO_DISCOVER.rscPattern
|
|
158
|
+
);
|
|
159
|
+
|
|
120
160
|
const testClientComponents = resolveAutoDiscoverMatcher(
|
|
121
161
|
options.autoDiscover?.clientComponents,
|
|
122
162
|
DEFAULT_CONFIG.AUTO_DISCOVER.clientComponents
|
|
123
163
|
);
|
|
164
|
+
|
|
124
165
|
const testServerFunctions = resolveAutoDiscoverMatcher(
|
|
125
166
|
options.autoDiscover?.serverFunctions,
|
|
126
167
|
DEFAULT_CONFIG.AUTO_DISCOVER.serverFunctions
|
|
127
168
|
);
|
|
169
|
+
|
|
170
|
+
const testNodeOnly = resolveAutoDiscoverMatcher(
|
|
171
|
+
options.autoDiscover?.nodeOnly,
|
|
172
|
+
DEFAULT_CONFIG.AUTO_DISCOVER.nodeOnly
|
|
173
|
+
);
|
|
174
|
+
|
|
128
175
|
const testPropsPattern = resolveAutoDiscoverMatcher(
|
|
129
176
|
options.autoDiscover?.propsPattern,
|
|
130
177
|
DEFAULT_CONFIG.AUTO_DISCOVER.propsPattern
|
|
131
178
|
);
|
|
179
|
+
|
|
132
180
|
const testPagePattern = resolveAutoDiscoverMatcher(
|
|
133
181
|
options.autoDiscover?.pagePattern,
|
|
134
182
|
DEFAULT_CONFIG.AUTO_DISCOVER.pagePattern
|
|
135
183
|
);
|
|
184
|
+
|
|
136
185
|
const testCssModule = resolveAutoDiscoverMatcher(
|
|
137
186
|
options.autoDiscover?.cssModulePattern,
|
|
138
187
|
DEFAULT_CONFIG.AUTO_DISCOVER.cssModulePattern
|
|
139
188
|
);
|
|
189
|
+
|
|
140
190
|
const testVendor = resolveAutoDiscoverMatcher(
|
|
141
191
|
options.autoDiscover?.vendorPattern,
|
|
142
192
|
DEFAULT_CONFIG.AUTO_DISCOVER.vendorPattern
|
|
143
193
|
);
|
|
194
|
+
|
|
195
|
+
const testVirtual = resolveAutoDiscoverMatcher(
|
|
196
|
+
options.autoDiscover?.virtualPattern,
|
|
197
|
+
DEFAULT_CONFIG.AUTO_DISCOVER.virtualPattern
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
const testDotFiles = resolveAutoDiscoverMatcher(
|
|
201
|
+
options.autoDiscover?.dotFiles,
|
|
202
|
+
DEFAULT_CONFIG.AUTO_DISCOVER.dotFiles
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
// Build options
|
|
144
206
|
const preserveModulesRoot =
|
|
145
207
|
options.build?.preserveModulesRoot ??
|
|
146
208
|
DEFAULT_CONFIG.BUILD.preserveModulesRoot;
|
|
209
|
+
|
|
147
210
|
const hashOption =
|
|
148
211
|
typeof options.build?.hash === "string"
|
|
149
212
|
? options.build.hash
|
|
150
213
|
: DEFAULT_CONFIG.BUILD.hash;
|
|
214
|
+
|
|
151
215
|
const hashString = hashOption === "" ? "" : `-[${hashOption}]`;
|
|
152
|
-
|
|
216
|
+
|
|
217
|
+
const addModuleExtension = (path: string) => {
|
|
218
|
+
const isAsset =
|
|
219
|
+
autoDiscover.cssPattern(path) || autoDiscover.jsonPattern(path);
|
|
220
|
+
if (isAsset) {
|
|
221
|
+
return path;
|
|
222
|
+
}
|
|
223
|
+
return addExtension(path);
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
// File naming and hashing
|
|
227
|
+
|
|
228
|
+
const hash = (n: string | null, ssr: boolean) => {
|
|
153
229
|
if (!n) return "";
|
|
154
|
-
if
|
|
230
|
+
if(ssr) return n;
|
|
231
|
+
if (
|
|
232
|
+
hashString === "" ||
|
|
233
|
+
autoDiscover.nodeOnly(n)
|
|
234
|
+
) {
|
|
155
235
|
return n;
|
|
156
236
|
}
|
|
157
237
|
const extensionIndex = n.lastIndexOf(".");
|
|
158
238
|
if (extensionIndex !== -1) {
|
|
159
|
-
// put hash between extension and filename
|
|
160
239
|
const extension = n.slice(extensionIndex);
|
|
161
240
|
const filename = n.slice(0, extensionIndex);
|
|
162
241
|
return filename + hashString + extension;
|
|
@@ -165,174 +244,190 @@ export const resolveOptions = <InlineCSS extends boolean = boolean>(
|
|
|
165
244
|
}
|
|
166
245
|
};
|
|
167
246
|
|
|
247
|
+
// Output path resolution
|
|
168
248
|
const getOutputPath = (n: string | null) => {
|
|
169
249
|
if (!n) return "";
|
|
170
250
|
let path = handleSearchQuery(n);
|
|
171
|
-
// Remove src/ prefix if present
|
|
172
251
|
path = path.startsWith(moduleBase + "/")
|
|
173
252
|
? path.slice(moduleBase.length + 1)
|
|
174
253
|
: path;
|
|
175
254
|
|
|
176
|
-
if (testVendor(path))
|
|
177
|
-
return path;
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
if (testCssModule(path)) {
|
|
181
|
-
// For CSS modules, keep the .css.js extension
|
|
182
|
-
return applyPattern(
|
|
255
|
+
if (testVendor(path))
|
|
256
|
+
return registerPath(path, options.autoDiscover?.vendorPattern, "vendor");
|
|
257
|
+
if (testCssModule(path))
|
|
258
|
+
return registerPath(
|
|
183
259
|
path,
|
|
184
260
|
options.autoDiscover?.cssModulePattern,
|
|
185
261
|
".css.js"
|
|
186
262
|
);
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (
|
|
190
|
-
|
|
191
|
-
return applyPattern(path, options.autoDiscover?.cssPattern, ".css");
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
if (testClientComponents(path)) {
|
|
195
|
-
return applyPattern(
|
|
263
|
+
if (testCss(path))
|
|
264
|
+
return registerPath(path, options.autoDiscover?.cssPattern, ".css");
|
|
265
|
+
if (testClientComponents(path))
|
|
266
|
+
return registerPath(
|
|
196
267
|
path,
|
|
197
268
|
options.autoDiscover?.clientComponents,
|
|
198
269
|
"client"
|
|
199
270
|
);
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
if (
|
|
205
|
-
return
|
|
206
|
-
}
|
|
207
|
-
if (testPropsPattern(path)) {
|
|
208
|
-
return applyPattern(
|
|
271
|
+
if (testHtml(path))
|
|
272
|
+
return registerPath(path, options.autoDiscover?.htmlPattern, ".html");
|
|
273
|
+
if (testJson(path))
|
|
274
|
+
return registerPath(path, options.autoDiscover?.jsonPattern, ".json");
|
|
275
|
+
if (testPropsPattern(path))
|
|
276
|
+
return registerPath(
|
|
209
277
|
path,
|
|
210
278
|
options.autoDiscover?.propsPattern,
|
|
211
279
|
options.propsExportName?.toLowerCase() ??
|
|
212
280
|
DEFAULT_CONFIG.PROPS_EXPORT_NAME.toLowerCase()
|
|
213
281
|
);
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
return applyPattern(
|
|
282
|
+
if (testPagePattern(path))
|
|
283
|
+
return registerPath(
|
|
217
284
|
path,
|
|
218
285
|
options.autoDiscover?.pagePattern,
|
|
219
286
|
options.pageExportName?.toLowerCase() ??
|
|
220
287
|
DEFAULT_CONFIG.PAGE_EXPORT_NAME.toLowerCase()
|
|
221
288
|
);
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
return applyPattern(
|
|
289
|
+
if (testServerFunctions(path))
|
|
290
|
+
return registerPath(
|
|
225
291
|
path,
|
|
226
292
|
options.autoDiscover?.serverFunctions,
|
|
227
293
|
"server"
|
|
228
294
|
);
|
|
229
|
-
|
|
230
|
-
if (testModulePattern(path)) {
|
|
231
|
-
return path;
|
|
232
|
-
}
|
|
295
|
+
if (testModulePattern(path)) return path;
|
|
233
296
|
return path;
|
|
234
297
|
};
|
|
235
298
|
|
|
236
|
-
|
|
299
|
+
// File naming functions
|
|
300
|
+
const entryFile = (n: PreRenderedChunk, ssr: boolean) => {
|
|
237
301
|
if (testVendor(n.name)) {
|
|
238
302
|
const search = n.facadeModuleId?.split("?")[1];
|
|
239
303
|
if (search) {
|
|
240
|
-
return hash(`${n.name}.${search}.js
|
|
304
|
+
return hash(`${n.name}.${search}.js`, ssr);
|
|
241
305
|
} else {
|
|
242
|
-
return hash(`${n.name}.js
|
|
306
|
+
return hash(`${n.name}.js`, ssr);
|
|
243
307
|
}
|
|
244
308
|
}
|
|
245
|
-
return hash(
|
|
309
|
+
return hash(
|
|
310
|
+
addModuleExtension(getOutputPath(ensureModuleBase(ensureNoRoot(n.name)))),
|
|
311
|
+
ssr
|
|
312
|
+
);
|
|
246
313
|
};
|
|
247
314
|
|
|
248
|
-
const chunkFile = (n: PreRenderedChunk) => {
|
|
249
|
-
|
|
250
|
-
|
|
315
|
+
const chunkFile = (n: PreRenderedChunk, ssr: boolean) => {
|
|
316
|
+
return hash(
|
|
317
|
+
addModuleExtension(
|
|
318
|
+
getOutputPath(ensureModuleBase(ensureNoRoot("_" + n.name)))),
|
|
319
|
+
ssr
|
|
320
|
+
);
|
|
251
321
|
};
|
|
252
322
|
|
|
253
|
-
const assetFile = (n: PreRenderedAsset) => {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
323
|
+
const assetFile = (n: PreRenderedAsset, ssr: boolean) => {
|
|
324
|
+
return hash(
|
|
325
|
+
getOutputPath(ensureModuleBase(ensureNoRoot(n.names[0]))),
|
|
326
|
+
ssr
|
|
327
|
+
);
|
|
328
|
+
};
|
|
329
|
+
const rscOutputPath = options.build?.rscOutputPath ?? DEFAULT_CONFIG.BUILD.rscOutputPath;
|
|
330
|
+
const htmlOutputPath = options.build?.htmlOutputPath ?? DEFAULT_CONFIG.BUILD.htmlOutputPath;
|
|
257
331
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
pages,
|
|
285
|
-
client,
|
|
286
|
-
server,
|
|
287
|
-
static: staticBuild,
|
|
288
|
-
outDir,
|
|
289
|
-
assetsDir,
|
|
290
|
-
api,
|
|
291
|
-
hash: hashOption,
|
|
292
|
-
preserveModulesRoot,
|
|
293
|
-
entryFile,
|
|
294
|
-
chunkFile,
|
|
295
|
-
assetFile,
|
|
296
|
-
};
|
|
332
|
+
// Build configuration object
|
|
333
|
+
const build = {
|
|
334
|
+
pages,
|
|
335
|
+
client,
|
|
336
|
+
server,
|
|
337
|
+
static: staticBuild,
|
|
338
|
+
outDir,
|
|
339
|
+
assetsDir,
|
|
340
|
+
api,
|
|
341
|
+
hash: hashOption,
|
|
342
|
+
preserveModulesRoot,
|
|
343
|
+
rscOutputPath,
|
|
344
|
+
htmlOutputPath,
|
|
345
|
+
entryFile:
|
|
346
|
+
typeof options.build?.entryFile === "function"
|
|
347
|
+
? options.build.entryFile
|
|
348
|
+
: entryFile,
|
|
349
|
+
chunkFile:
|
|
350
|
+
typeof options.build?.chunkFile === "function"
|
|
351
|
+
? options.build.chunkFile
|
|
352
|
+
: chunkFile,
|
|
353
|
+
assetFile:
|
|
354
|
+
typeof options.build?.assetFile === "function"
|
|
355
|
+
? options.build.assetFile
|
|
356
|
+
: assetFile,
|
|
357
|
+
};
|
|
297
358
|
|
|
359
|
+
// Module path configuration
|
|
298
360
|
const moduleBase =
|
|
299
361
|
typeof options.moduleBase === "string"
|
|
300
362
|
? options.moduleBase
|
|
301
363
|
: DEFAULT_CONFIG.MODULE_BASE;
|
|
364
|
+
|
|
302
365
|
const moduleBasePath =
|
|
303
366
|
typeof options.moduleBasePath === "string"
|
|
304
367
|
? options.moduleBasePath
|
|
305
368
|
: DEFAULT_CONFIG.MODULE_BASE_PATH;
|
|
369
|
+
|
|
306
370
|
const moduleBaseURL =
|
|
307
371
|
typeof options.moduleBaseURL === "string"
|
|
308
372
|
? options.moduleBaseURL
|
|
309
373
|
: DEFAULT_CONFIG.MODULE_BASE_URL;
|
|
374
|
+
|
|
375
|
+
const moduleRootPath =
|
|
376
|
+
typeof options.moduleRootPath === "string"
|
|
377
|
+
? options.moduleRootPath.startsWith(projectRoot)
|
|
378
|
+
? options.moduleRootPath
|
|
379
|
+
: join(projectRoot, options.moduleRootPath)
|
|
380
|
+
: join(projectRoot, outDir, client)
|
|
381
|
+
// Worker and loader paths
|
|
310
382
|
const rscWorkerPath =
|
|
311
383
|
typeof options.rscWorkerPath === "string"
|
|
312
384
|
? join(projectRoot, options.rscWorkerPath)
|
|
313
385
|
: join(pluginRoot, DEFAULT_CONFIG.RSC_WORKER_PATH);
|
|
386
|
+
|
|
314
387
|
const htmlWorkerPath =
|
|
315
388
|
typeof options.htmlWorkerPath === "string"
|
|
316
389
|
? join(projectRoot, options.htmlWorkerPath)
|
|
317
390
|
: join(pluginRoot, DEFAULT_CONFIG.HTML_WORKER_PATH);
|
|
391
|
+
|
|
318
392
|
const loaderPath =
|
|
319
393
|
typeof options.loaderPath === "string"
|
|
320
394
|
? join(projectRoot, options.loaderPath)
|
|
321
395
|
: join(pluginRoot, DEFAULT_CONFIG.LOADER_PATH);
|
|
322
396
|
|
|
397
|
+
// Auto-discovery configuration
|
|
323
398
|
const autoDiscover = {
|
|
399
|
+
moduleExtension:
|
|
400
|
+
options.autoDiscover?.moduleExtension ?? DEFAULT_CONFIG.MODULE_EXTENSION,
|
|
324
401
|
modulePattern: testModulePattern,
|
|
325
402
|
cssPattern: testCss,
|
|
326
403
|
jsonPattern: testJson,
|
|
327
404
|
clientComponents: testClientComponents,
|
|
328
405
|
serverFunctions: testServerFunctions,
|
|
406
|
+
nodeOnly: testNodeOnly,
|
|
329
407
|
propsPattern: testPropsPattern,
|
|
330
408
|
pagePattern: testPagePattern,
|
|
331
409
|
cssModulePattern: testCssModule,
|
|
332
410
|
vendorPattern: testVendor,
|
|
411
|
+
dotFiles: testDotFiles,
|
|
412
|
+
virtualPattern: testVirtual,
|
|
413
|
+
htmlPattern: testHtml,
|
|
414
|
+
rscPattern: testRsc,
|
|
333
415
|
};
|
|
334
|
-
|
|
335
|
-
const
|
|
416
|
+
|
|
417
|
+
const normalizer =
|
|
418
|
+
options.normalizer ??
|
|
419
|
+
createInputNormalizer({
|
|
420
|
+
root: projectRoot,
|
|
421
|
+
preserveModulesRoot:
|
|
422
|
+
preserveModulesRoot === true ? moduleBase : undefined,
|
|
423
|
+
removeExtension: true,
|
|
424
|
+
});
|
|
425
|
+
const pipeableStreamOptions =
|
|
426
|
+
options.pipeableStreamOptions
|
|
427
|
+
? options.pipeableStreamOptions
|
|
428
|
+
: {}
|
|
429
|
+
|
|
430
|
+
// Return resolved options
|
|
336
431
|
try {
|
|
337
432
|
return {
|
|
338
433
|
type: "success",
|
|
@@ -341,16 +436,27 @@ export const resolveOptions = <InlineCSS extends boolean = boolean>(
|
|
|
341
436
|
moduleBase,
|
|
342
437
|
moduleBasePath,
|
|
343
438
|
moduleBaseURL,
|
|
439
|
+
moduleRootPath,
|
|
344
440
|
build: build,
|
|
345
|
-
|
|
346
|
-
|
|
441
|
+
onMetrics: options.onMetrics ?? DEFAULT_CONFIG.ON_METRICS,
|
|
442
|
+
onEvent: options.onEvent,
|
|
443
|
+
Page: options.Page ?? undefined,
|
|
444
|
+
props: options.props ?? undefined,
|
|
347
445
|
Html: options.Html ?? DEFAULT_CONFIG.HTML,
|
|
348
|
-
CssCollector:
|
|
446
|
+
CssCollector: options.CssCollector ?? CssCollector,
|
|
447
|
+
normalizer: normalizer,
|
|
349
448
|
pageExportName: pageExportName,
|
|
350
449
|
propsExportName: propsExportName,
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
450
|
+
css: {
|
|
451
|
+
inlineCss: options.css?.inlineCss ?? DEFAULT_CONFIG.CSS.inlineCss,
|
|
452
|
+
inlineThreshold:
|
|
453
|
+
options.css?.inlineThreshold ?? DEFAULT_CONFIG.CSS.inlineThreshold,
|
|
454
|
+
purgeCss: options.css?.purgeCss ?? DEFAULT_CONFIG.CSS.purgeCss,
|
|
455
|
+
inlinePatterns:
|
|
456
|
+
options.css?.inlinePatterns ?? DEFAULT_CONFIG.CSS.inlinePatterns,
|
|
457
|
+
linkPatterns:
|
|
458
|
+
options.css?.linkPatterns ?? DEFAULT_CONFIG.CSS.linkPatterns,
|
|
459
|
+
},
|
|
354
460
|
htmlWorkerPath: htmlWorkerPath,
|
|
355
461
|
rscWorkerPath: rscWorkerPath,
|
|
356
462
|
loaderPath: loaderPath,
|
|
@@ -358,12 +464,8 @@ export const resolveOptions = <InlineCSS extends boolean = boolean>(
|
|
|
358
464
|
serverEntry: options.serverEntry ?? DEFAULT_CONFIG.SERVER_ENTRY,
|
|
359
465
|
moduleBaseExceptions: options.moduleBaseExceptions ?? [],
|
|
360
466
|
autoDiscover: autoDiscover,
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
options.clientEntry ?? DEFAULT_CONFIG.CLIENT_ENTRY,
|
|
364
|
-
],
|
|
365
|
-
},
|
|
366
|
-
},
|
|
467
|
+
pipeableStreamOptions,
|
|
468
|
+
} as ResolvedUserOptions<InlineCSS>,
|
|
367
469
|
};
|
|
368
470
|
} catch (error) {
|
|
369
471
|
return {
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import type { ResolvedUserOptions } from '../types.js';
|
|
2
2
|
|
|
3
|
-
export let stashedPages: string[] = [];
|
|
4
3
|
export async function resolvePages(
|
|
5
4
|
pages: ResolvedUserOptions["build"]["pages"]
|
|
6
5
|
): Promise<{ type: "success"; error?:never; pages: string[] } | { type: "error"; error: Error; pages?:never }> {
|
|
7
|
-
if(stashedPages.length > 0){
|
|
8
|
-
return { type: "success", pages: stashedPages };
|
|
9
|
-
}
|
|
10
6
|
if (!pages) {
|
|
11
7
|
return { type: "success", pages: [] };
|
|
12
8
|
}
|
|
@@ -14,7 +10,11 @@ export async function resolvePages(
|
|
|
14
10
|
try {
|
|
15
11
|
// Handle function
|
|
16
12
|
if (typeof pages === "function") {
|
|
17
|
-
|
|
13
|
+
const result = pages();
|
|
14
|
+
if(result instanceof Promise) {
|
|
15
|
+
return resolvePages(await result);
|
|
16
|
+
}
|
|
17
|
+
return resolvePages(result);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
// Handle Promise
|
|
@@ -24,14 +24,12 @@ export async function resolvePages(
|
|
|
24
24
|
|
|
25
25
|
// Handle string
|
|
26
26
|
if (typeof pages === "string") {
|
|
27
|
-
stashedPages = [pages];
|
|
28
27
|
return { type: "success", pages: [pages] };
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
// Handle array
|
|
32
31
|
if (Array.isArray(pages)) {
|
|
33
32
|
if (pages.every(page => typeof page === "string")) {
|
|
34
|
-
stashedPages = pages;
|
|
35
33
|
return { type: "success", pages };
|
|
36
34
|
}
|
|
37
35
|
throw new Error('All pages must be strings');
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ResolvedUserOptions } from '../types.js';
|
|
2
|
+
|
|
3
|
+
type ResolvePageAndPropsOptionsSuccess<T extends "Page" | "props"> = {
|
|
4
|
+
[optionName in T]: string;
|
|
5
|
+
} & {type: "success"; error?:never}
|
|
6
|
+
|
|
7
|
+
type ResolvePageAndPropsOptionsError<T extends "Page" | "props"> = {
|
|
8
|
+
[optionName in T]?: never;
|
|
9
|
+
} & { type: "error"; error: Error }
|
|
10
|
+
|
|
11
|
+
export async function resolveUrlOption<T extends "Page" | "props">(
|
|
12
|
+
options: Pick<ResolvedUserOptions, T>,
|
|
13
|
+
optionName: T,
|
|
14
|
+
url: string
|
|
15
|
+
): Promise<ResolvePageAndPropsOptionsSuccess<T> | ResolvePageAndPropsOptionsError<T>> {
|
|
16
|
+
try {
|
|
17
|
+
switch (typeof options[optionName]) {
|
|
18
|
+
case "function":
|
|
19
|
+
const result = options[optionName](url);
|
|
20
|
+
if(typeof result === "string") {
|
|
21
|
+
return { type: "success", [optionName]: result };
|
|
22
|
+
}
|
|
23
|
+
if(result instanceof Promise) {
|
|
24
|
+
try {
|
|
25
|
+
const promiseResult = await result;
|
|
26
|
+
if(typeof promiseResult === "string") {
|
|
27
|
+
return { type: "success", [optionName]: promiseResult };
|
|
28
|
+
}
|
|
29
|
+
} catch (error) {
|
|
30
|
+
return { type: "error", error: error as Error };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
break;
|
|
34
|
+
case "string":
|
|
35
|
+
return { type: "success", [optionName]: options[optionName] };
|
|
36
|
+
default:
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
return { type: "error", error: new Error("Page must return a string") };
|
|
40
|
+
} catch (error) {
|
|
41
|
+
return { type: "error", error: error as Error };
|
|
42
|
+
}
|
|
43
|
+
}
|