vite-plugin-react-server 0.3.7 → 0.3.8
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/dist/package.json +1 -1
- package/dist/plugin/components.d.ts +2 -1
- package/dist/plugin/components.d.ts.map +1 -1
- package/dist/plugin/components.js +2 -2
- package/dist/plugin/components.js.map +1 -1
- package/dist/plugin/config/defaults.d.ts +4 -4
- package/dist/plugin/config/defaults.js +4 -4
- package/dist/plugin/config/defaults.js.map +1 -1
- package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
- package/dist/plugin/config/resolveOptions.js +6 -3
- package/dist/plugin/config/resolveOptions.js.map +1 -1
- package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
- package/dist/plugin/config/resolveUserConfig.js +0 -1
- package/dist/plugin/config/resolveUserConfig.js.map +1 -1
- package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
- package/dist/plugin/helpers/inputNormalizer.js +2 -4
- package/dist/plugin/helpers/inputNormalizer.js.map +1 -1
- package/dist/plugin/loader/createBuildLoader.d.ts +1 -1
- package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -1
- package/dist/plugin/loader/createBuildLoader.js +5 -20
- package/dist/plugin/loader/createBuildLoader.js.map +1 -1
- package/dist/plugin/react-server/createHandler.d.ts +1 -1
- package/dist/plugin/react-server/createHandler.d.ts.map +1 -1
- package/dist/plugin/react-server/createHandler.js +1 -2
- package/dist/plugin/react-server/createHandler.js.map +1 -1
- package/dist/plugin/react-server/createRscStream.d.ts +1 -1
- package/dist/plugin/react-server/createRscStream.d.ts.map +1 -1
- package/dist/plugin/react-server/createRscStream.js +2 -1
- package/dist/plugin/react-server/createRscStream.js.map +1 -1
- package/dist/plugin/react-server/plugin.d.ts.map +1 -1
- package/dist/plugin/react-server/plugin.js +11 -34
- package/dist/plugin/react-server/plugin.js.map +1 -1
- package/dist/plugin/resolveProps.d.ts.map +1 -1
- package/dist/plugin/resolveProps.js +0 -1
- package/dist/plugin/resolveProps.js.map +1 -1
- package/dist/plugin/worker/createWorker.js +2 -1
- package/dist/plugin/worker/createWorker.js.map +1 -1
- package/dist/plugin/worker/html/renderPages.d.ts.map +1 -1
- package/dist/plugin/worker/html/renderPages.js +3 -9
- package/dist/plugin/worker/html/renderPages.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/plugin/components.tsx +2 -2
- package/plugin/config/defaults.ts +4 -4
- package/plugin/config/resolveOptions.ts +35 -12
- package/plugin/config/resolveUserConfig.ts +0 -1
- package/plugin/helpers/inputNormalizer.ts +4 -6
- package/plugin/loader/createBuildLoader.ts +6 -27
- package/plugin/react-server/createHandler.ts +2 -3
- package/plugin/react-server/createRscStream.ts +3 -2
- package/plugin/react-server/plugin.ts +18 -39
- package/plugin/resolveProps.ts +0 -1
- package/plugin/worker/createWorker.ts +2 -2
- package/plugin/worker/html/renderPages.ts +4 -10
- package/scripts/check-react-version.mjs +0 -0
package/dist/package.json
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* A component that emits <link> tags for CSS files during streaming.
|
|
3
3
|
* The high precedence ensures they bubble up to the document head.
|
|
4
4
|
*/
|
|
5
|
-
export declare function CssCollector({ url }: {
|
|
5
|
+
export declare function CssCollector({ url, moduleBasePath }: {
|
|
6
6
|
url: string;
|
|
7
|
+
moduleBasePath: string;
|
|
7
8
|
}): import("react").DetailedReactHTMLElement<{
|
|
8
9
|
key: string;
|
|
9
10
|
rel: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../plugin/components.tsx"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,GAAG,EAAE,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE;;;;;
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../plugin/components.tsx"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,GAAG,EAAE,cAAc,EAAE,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE;;;;;gBAO5F"}
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { createElement } from 'react';
|
|
7
7
|
|
|
8
|
-
function CssCollector({ url }) {
|
|
8
|
+
function CssCollector({ url, moduleBasePath }) {
|
|
9
9
|
return createElement("link", {
|
|
10
10
|
key: url,
|
|
11
11
|
rel: "stylesheet",
|
|
12
|
-
href: url,
|
|
12
|
+
href: url.replace(moduleBasePath, ""),
|
|
13
13
|
precedence: "high"
|
|
14
14
|
});
|
|
15
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sources":["../../plugin/components.tsx"],"sourcesContent":["import { createElement } from 'react';\n\n/**\n * A component that emits <link> tags for CSS files during streaming.\n * The high precedence ensures they bubble up to the document head.\n */\nexport function CssCollector({ url }: { url: string }) {\n return createElement('link', {\n key: url,\n rel: 'stylesheet',\n href: url,\n precedence: 'high'\n });\n} "],"names":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"components.js","sources":["../../plugin/components.tsx"],"sourcesContent":["import { createElement } from 'react';\n\n/**\n * A component that emits <link> tags for CSS files during streaming.\n * The high precedence ensures they bubble up to the document head.\n */\nexport function CssCollector({ url, moduleBasePath }: { url: string, moduleBasePath: string }) {\n return createElement('link', {\n key: url,\n rel: 'stylesheet',\n href: url.replace(moduleBasePath, \"\"),\n precedence: 'high'\n });\n} "],"names":[],"mappings":";;;;;;;AAMO,SAAS,YAAa,CAAA,EAAE,GAAK,EAAA,cAAA,EAA2D,EAAA;AAC7F,EAAA,OAAO,cAAc,MAAQ,EAAA;AAAA,IAC3B,GAAK,EAAA,GAAA;AAAA,IACL,GAAK,EAAA,YAAA;AAAA,IACL,IAAM,EAAA,GAAA,CAAI,OAAQ,CAAA,cAAA,EAAgB,EAAE,CAAA;AAAA,IACpC,UAAY,EAAA;AAAA,GACb,CAAA;AACH;;;;"}
|
|
@@ -5,14 +5,14 @@ export declare const DEFAULT_CONFIG: {
|
|
|
5
5
|
readonly MODULE_BASE: "src";
|
|
6
6
|
readonly MODULE_BASE_PATH: "/src";
|
|
7
7
|
readonly MODULE_BASE_URL: "/src";
|
|
8
|
-
readonly PAGE: "src/page/page.tsx";
|
|
9
|
-
readonly PROPS: "src/page/props.ts";
|
|
8
|
+
readonly PAGE: "/src/page/page.tsx";
|
|
9
|
+
readonly PROPS: "/src/page/props.ts";
|
|
10
10
|
readonly CLIENT_ENTRY: "/src/client.tsx";
|
|
11
11
|
readonly SERVER_ENTRY: "/src/server.tsx";
|
|
12
12
|
readonly PAGE_EXPORT: "Page";
|
|
13
13
|
readonly PROPS_EXPORT: "props";
|
|
14
|
-
readonly HTML_WORKER_PATH: "worker/html/
|
|
15
|
-
readonly RSC_WORKER_PATH: "worker/rsc/
|
|
14
|
+
readonly HTML_WORKER_PATH: "worker/html/html-worker.js";
|
|
15
|
+
readonly RSC_WORKER_PATH: "worker/rsc/rsc-worker.js";
|
|
16
16
|
readonly LOADER_PATH: "worker/loader.js";
|
|
17
17
|
readonly RSC_EXTENSION: ".rsc";
|
|
18
18
|
readonly HTML: ({ children }: {
|
|
@@ -12,14 +12,14 @@ const DEFAULT_CONFIG = {
|
|
|
12
12
|
MODULE_BASE: "src",
|
|
13
13
|
MODULE_BASE_PATH: "/src",
|
|
14
14
|
MODULE_BASE_URL: "/src",
|
|
15
|
-
PAGE: "src/page/page.tsx",
|
|
16
|
-
PROPS: "src/page/props.ts",
|
|
15
|
+
PAGE: "/src/page/page.tsx",
|
|
16
|
+
PROPS: "/src/page/props.ts",
|
|
17
17
|
CLIENT_ENTRY: "/src/client.tsx",
|
|
18
18
|
SERVER_ENTRY: "/src/server.tsx",
|
|
19
19
|
PAGE_EXPORT: "Page",
|
|
20
20
|
PROPS_EXPORT: "props",
|
|
21
|
-
HTML_WORKER_PATH: "worker/html/
|
|
22
|
-
RSC_WORKER_PATH: "worker/rsc/
|
|
21
|
+
HTML_WORKER_PATH: "worker/html/html-worker.js",
|
|
22
|
+
RSC_WORKER_PATH: "worker/rsc/rsc-worker.js",
|
|
23
23
|
LOADER_PATH: "worker/loader.js",
|
|
24
24
|
RSC_EXTENSION: ".rsc",
|
|
25
25
|
HTML: ({ children }) => children,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.js","sources":["../../../plugin/config/defaults.ts"],"sourcesContent":["import { moduleIdDefault } from \"./moduleIdDefault.js\";\n\nexport const DEFAULT_CONFIG = {\n FILE_REGEX: /\\.(m|c)?(j|t)sx?$/,\n CLIENT_ASSETS_DIR: \"assets\",\n RSC_DIR: \"rsc\",\n MODULE_BASE: \"src\",\n MODULE_BASE_PATH: \"/src\",\n MODULE_BASE_URL: \"/src\",\n PAGE: \"src/page/page.tsx\",\n PROPS: \"src/page/props.ts\",\n CLIENT_ENTRY: \"/src/client.tsx\",\n SERVER_ENTRY: \"/src/server.tsx\",\n PAGE_EXPORT: \"Page\",\n PROPS_EXPORT: \"props\",\n HTML_WORKER_PATH: 'worker/html/
|
|
1
|
+
{"version":3,"file":"defaults.js","sources":["../../../plugin/config/defaults.ts"],"sourcesContent":["import { moduleIdDefault } from \"./moduleIdDefault.js\";\n\nexport const DEFAULT_CONFIG = {\n FILE_REGEX: /\\.(m|c)?(j|t)sx?$/,\n CLIENT_ASSETS_DIR: \"assets\",\n RSC_DIR: \"rsc\",\n MODULE_BASE: \"src\",\n MODULE_BASE_PATH: \"/src\",\n MODULE_BASE_URL: \"/src\",\n PAGE: \"/src/page/page.tsx\",\n PROPS: \"/src/page/props.ts\",\n CLIENT_ENTRY: \"/src/client.tsx\",\n SERVER_ENTRY: \"/src/server.tsx\",\n PAGE_EXPORT: \"Page\",\n PROPS_EXPORT: \"props\",\n HTML_WORKER_PATH: 'worker/html/html-worker.js',\n RSC_WORKER_PATH: 'worker/rsc/rsc-worker.js',\n LOADER_PATH: 'worker/loader.js',\n RSC_EXTENSION: \".rsc\",\n HTML: ({ children }: { children: any }) => children,\n COLLECT_CSS: true,\n COLLECT_ASSETS: true,\n PAGE_PATTERN: \"/src/page/**/*.page.tsx\",\n PROPS_PATTERN: \"/src/page/**/*.props.ts\",\n DEV_PORT: 5173,\n PREVIEW_PORT: 4173,\n DEV_HOST: \"localhost\",\n PREVIEW_HOST: \"localhost\",\n ENV_PREFIX: \"VITE_\",\n BUILD: {\n pages: () => [\"/\"],\n client: \"dist/client\",\n server: \"dist/server\",\n static: \"dist/static\",\n },\n MODULE_BASE_EXCEPTIONS: [] as string[],\n AUTO_DISCOVER: {\n pagePattern: /page\\.(m|c)?(j|t)sx?/,\n propsPattern: /props\\.(m|c)?(j|t)sx?/,\n clientComponents: /client\\.(m|c)?(j|t)sx?/,\n serverFunctions: /server\\.(m|c)?(j|t)sx?/,\n },\n MODULE_ID: moduleIdDefault\n} as const; "],"names":[],"mappings":";;;;;;;AAEO,MAAM,cAAiB,GAAA;AAAA,EAC5B,UAAY,EAAA,mBAAA;AAAA,EACZ,iBAAmB,EAAA,QAAA;AAAA,EACnB,OAAS,EAAA,KAAA;AAAA,EACT,WAAa,EAAA,KAAA;AAAA,EACb,gBAAkB,EAAA,MAAA;AAAA,EAClB,eAAiB,EAAA,MAAA;AAAA,EACjB,IAAM,EAAA,oBAAA;AAAA,EACN,KAAO,EAAA,oBAAA;AAAA,EACP,YAAc,EAAA,iBAAA;AAAA,EACd,YAAc,EAAA,iBAAA;AAAA,EACd,WAAa,EAAA,MAAA;AAAA,EACb,YAAc,EAAA,OAAA;AAAA,EACd,gBAAkB,EAAA,4BAAA;AAAA,EAClB,eAAiB,EAAA,0BAAA;AAAA,EACjB,WAAa,EAAA,kBAAA;AAAA,EACb,aAAe,EAAA,MAAA;AAAA,EACf,IAAM,EAAA,CAAC,EAAE,QAAA,EAAkC,KAAA,QAAA;AAAA,EAC3C,WAAa,EAAA,IAAA;AAAA,EACb,cAAgB,EAAA,IAAA;AAAA,EAChB,YAAc,EAAA,yBAAA;AAAA,EACd,aAAe,EAAA,yBAAA;AAAA,EACf,QAAU,EAAA,IAAA;AAAA,EACV,YAAc,EAAA,IAAA;AAAA,EACd,QAAU,EAAA,WAAA;AAAA,EACV,YAAc,EAAA,WAAA;AAAA,EACd,UAAY,EAAA,OAAA;AAAA,EACZ,KAAO,EAAA;AAAA,IACL,KAAA,EAAO,MAAM,CAAC,GAAG,CAAA;AAAA,IACjB,MAAQ,EAAA,aAAA;AAAA,IACR,MAAQ,EAAA,aAAA;AAAA,IACR,MAAQ,EAAA;AAAA,GACV;AAAA,EACA,wBAAwB,EAAC;AAAA,EACzB,aAAe,EAAA;AAAA,IACb,WAAa,EAAA,sBAAA;AAAA,IACb,YAAc,EAAA,uBAAA;AAAA,IACd,gBAAkB,EAAA,wBAAA;AAAA,IAClB,eAAiB,EAAA;AAAA,GACnB;AAAA,EACA,SAAW,EAAA;AACb;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveOptions.d.ts","sourceRoot":"","sources":["../../../plugin/config/resolveOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAG5E,eAAO,MAAM,cAAc,YAChB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"resolveOptions.d.ts","sourceRoot":"","sources":["../../../plugin/config/resolveOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAG5E,eAAO,MAAM,cAAc,YAChB,mBAAmB,KAE1B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,WAAW,EAAE,mBAAmB,CAAA;CAAE,GACrD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAoEhC,CAAC"}
|
|
@@ -8,14 +8,17 @@ import { DEFAULT_CONFIG } from './defaults.js';
|
|
|
8
8
|
const resolveOptions = (options) => {
|
|
9
9
|
const projectRoot = options.projectRoot ?? process.cwd();
|
|
10
10
|
const build = options.build ?? DEFAULT_CONFIG.BUILD;
|
|
11
|
+
const moduleBase = typeof options.moduleBase === "string" ? options.moduleBase : DEFAULT_CONFIG.MODULE_BASE;
|
|
12
|
+
const moduleBasePath = typeof options.moduleBasePath === "string" ? options.moduleBasePath : options.moduleBase.startsWith("/") ? options.moduleBase : "/" + options.moduleBase;
|
|
13
|
+
const moduleBaseURL = typeof options.moduleBaseURL === "string" ? options.moduleBaseURL : moduleBasePath ?? DEFAULT_CONFIG.MODULE_BASE_URL;
|
|
11
14
|
try {
|
|
12
15
|
return {
|
|
13
16
|
type: "success",
|
|
14
17
|
userOptions: {
|
|
15
18
|
projectRoot,
|
|
16
|
-
moduleBase
|
|
17
|
-
moduleBasePath
|
|
18
|
-
moduleBaseURL
|
|
19
|
+
moduleBase,
|
|
20
|
+
moduleBasePath,
|
|
21
|
+
moduleBaseURL,
|
|
19
22
|
build: {
|
|
20
23
|
pages: build.pages ?? DEFAULT_CONFIG.BUILD.pages,
|
|
21
24
|
client: build.client ?? DEFAULT_CONFIG.BUILD.client,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveOptions.js","sources":["../../../plugin/config/resolveOptions.ts"],"sourcesContent":["import type { StreamPluginOptions, ResolvedUserOptions } from \"../types.js\";\nimport { DEFAULT_CONFIG } from \"./defaults.js\";\n\nexport const resolveOptions = (\n options: StreamPluginOptions\n)
|
|
1
|
+
{"version":3,"file":"resolveOptions.js","sources":["../../../plugin/config/resolveOptions.ts"],"sourcesContent":["import type { StreamPluginOptions, ResolvedUserOptions } from \"../types.js\";\nimport { DEFAULT_CONFIG } from \"./defaults.js\";\n\nexport const resolveOptions = (\n options: StreamPluginOptions\n):\n | { type: \"success\"; userOptions: ResolvedUserOptions }\n | { type: \"error\"; error: Error } => {\n const projectRoot = options.projectRoot ?? process.cwd();\n\n const build = options.build ?? DEFAULT_CONFIG.BUILD;\n\n const moduleBase = typeof options.moduleBase === \"string\" ? options.moduleBase : DEFAULT_CONFIG.MODULE_BASE;\n const moduleBasePath =\n typeof options.moduleBasePath === \"string\"\n ? options.moduleBasePath\n : options.moduleBase.startsWith(\"/\")\n ? options.moduleBase\n : \"/\" + options.moduleBase;\n const moduleBaseURL =\n typeof options.moduleBaseURL === \"string\"\n ? options.moduleBaseURL\n : moduleBasePath ?? DEFAULT_CONFIG.MODULE_BASE_URL;\n try {\n return {\n type: \"success\",\n userOptions: {\n projectRoot,\n moduleBase,\n moduleBasePath,\n moduleBaseURL,\n build: {\n pages: build.pages ?? DEFAULT_CONFIG.BUILD.pages,\n client: build.client ?? DEFAULT_CONFIG.BUILD.client,\n server: build.server ?? DEFAULT_CONFIG.BUILD.server,\n static: build.static ?? DEFAULT_CONFIG.BUILD.static,\n },\n Page: options.Page ?? DEFAULT_CONFIG.PAGE,\n props: options.props ?? DEFAULT_CONFIG.PROPS,\n Html: options.Html ?? DEFAULT_CONFIG.HTML,\n pageExportName: options.pageExportName ?? DEFAULT_CONFIG.PAGE_EXPORT,\n propsExportName: options.propsExportName ?? DEFAULT_CONFIG.PROPS_EXPORT,\n collectCss: options.collectCss ?? DEFAULT_CONFIG.COLLECT_CSS,\n collectAssets: options.collectAssets ?? DEFAULT_CONFIG.COLLECT_ASSETS,\n assetsDir: options.assetsDir ?? DEFAULT_CONFIG.CLIENT_ASSETS_DIR,\n htmlWorkerPath:\n options.htmlWorkerPath ?? DEFAULT_CONFIG.HTML_WORKER_PATH,\n rscWorkerPath: options.rscWorkerPath ?? DEFAULT_CONFIG.RSC_WORKER_PATH,\n loaderPath: options.loaderPath ?? DEFAULT_CONFIG.LOADER_PATH,\n clientEntry: options.clientEntry ?? DEFAULT_CONFIG.CLIENT_ENTRY,\n serverEntry: options.serverEntry ?? DEFAULT_CONFIG.SERVER_ENTRY,\n moduleBaseExceptions: options.moduleBaseExceptions ?? [],\n autoDiscover: {\n pagePattern:\n options.autoDiscover?.pagePattern ??\n DEFAULT_CONFIG.AUTO_DISCOVER.pagePattern,\n propsPattern:\n options.autoDiscover?.propsPattern ??\n DEFAULT_CONFIG.AUTO_DISCOVER.propsPattern,\n clientComponents:\n options.autoDiscover?.clientComponents ??\n DEFAULT_CONFIG.AUTO_DISCOVER.clientComponents,\n serverFunctions:\n options.autoDiscover?.serverFunctions ??\n DEFAULT_CONFIG.AUTO_DISCOVER.serverFunctions,\n },\n },\n };\n } catch (error) {\n return {\n type: \"error\",\n error:\n error instanceof Error ? error : new Error(\"Failed to resolve options\"),\n };\n }\n};\n"],"names":[],"mappings":";;;;;;;AAGa,MAAA,cAAA,GAAiB,CAC5B,OAGqC,KAAA;AACrC,EAAA,MAAM,WAAc,GAAA,OAAA,CAAQ,WAAe,IAAA,OAAA,CAAQ,GAAI,EAAA;AAEvD,EAAM,MAAA,KAAA,GAAQ,OAAQ,CAAA,KAAA,IAAS,cAAe,CAAA,KAAA;AAE9C,EAAA,MAAM,aAAa,OAAO,OAAA,CAAQ,eAAe,QAAW,GAAA,OAAA,CAAQ,aAAa,cAAe,CAAA,WAAA;AAChG,EAAA,MAAM,cACJ,GAAA,OAAO,OAAQ,CAAA,cAAA,KAAmB,WAC9B,OAAQ,CAAA,cAAA,GACR,OAAQ,CAAA,UAAA,CAAW,WAAW,GAAG,CAAA,GACjC,OAAQ,CAAA,UAAA,GACR,MAAM,OAAQ,CAAA,UAAA;AACpB,EAAM,MAAA,aAAA,GACJ,OAAO,OAAQ,CAAA,aAAA,KAAkB,WAC7B,OAAQ,CAAA,aAAA,GACR,kBAAkB,cAAe,CAAA,eAAA;AACvC,EAAI,IAAA;AACF,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,SAAA;AAAA,MACN,WAAa,EAAA;AAAA,QACX,WAAA;AAAA,QACA,UAAA;AAAA,QACA,cAAA;AAAA,QACA,aAAA;AAAA,QACA,KAAO,EAAA;AAAA,UACL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AAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAEpC,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,EACT,MAAM,EACN,SAAS,EACT,WAAW,EACX,KAAK,EACN,EAAE,sBAAsB,GAAG,uBAAuB,
|
|
1
|
+
{"version":3,"file":"resolveUserConfig.d.ts","sourceRoot":"","sources":["../../../plugin/config/resolveUserConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClD,OAAO,KAAK,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAIlG,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,cAAc,GAAG,cAAc,GAAG,EAAE,CAAC;IAChD,MAAM,EAAE,UAAU,CAAC;IACnB,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,mBAAmB,CAAC;IACjC,KAAK,CAAC,EAAE,qBAAqB,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAC/B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,UAAU,EAAE,kBAAkB,CAAA;CAAE,GACnD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAEpC,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,EACT,MAAM,EACN,SAAS,EACT,WAAW,EACX,KAAK,EACN,EAAE,sBAAsB,GAAG,uBAAuB,CAwElD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveUserConfig.js","sources":["../../../plugin/config/resolveUserConfig.ts"],"sourcesContent":["import type { ConfigEnv, UserConfig } from \"vite\";\nimport type { CheckFilesExistReturn, ResolvedUserConfig, ResolvedUserOptions } from \"../types.js\";\nimport { DEFAULT_CONFIG } from \"./defaults.js\";\nimport { createInputNormalizer } from \"../helpers/inputNormalizer.js\";\n\nexport type ResolveUserConfigProps = {\n condition: \"react-client\" | \"react-server\" | \"\";\n config: UserConfig;\n configEnv: ConfigEnv;\n userOptions: ResolvedUserOptions;\n files?: CheckFilesExistReturn;\n};\n\nexport type ResolveUserConfigReturn = \n | { type: \"success\"; userConfig: ResolvedUserConfig }\n | { type: \"error\"; error: Error };\n\nexport function resolveUserConfig({\n condition,\n config,\n configEnv,\n userOptions,\n files\n}: ResolveUserConfigProps): ResolveUserConfigReturn {\n\n\n try {\n // Get existing inputs\n const root = config.root ?? userOptions.projectRoot ?? process.cwd();\n const existingInput = config.build?.rollupOptions?.input || {};\n const currentInputs = typeof existingInput === 'string' ? { default: existingInput } : existingInput;\n const normalizer = createInputNormalizer(root);\n\n const serverEntry = userOptions.serverEntry ? [userOptions.serverEntry, userOptions.serverEntry] : [];\n // Add inputs based on condition\n const inputs = {\n ...currentInputs,\n ...(condition === 'react-server' && files ? {\n 'index.html': '/index.html',\n ...Object.fromEntries([\n ...serverEntry,\n ...Array.from(files.pageMap.entries()),\n ...Array.from(files.propsMap.entries())\n ].map(normalizer))\n } : {\n client: userOptions.clientEntry\n })\n };\n\n const userConfig = {\n ...config,\n root: root,\n mode: configEnv.command === 'build' ? 'production' : 'development',\n build: {\n ...config.build,\n outDir: condition === 'react-server' ? userOptions.build.server : userOptions.build.client,\n assetsDir: condition === 'react-server' ? \"\" : DEFAULT_CONFIG.CLIENT_ASSETS_DIR,\n ssr: condition === 'react-server',\n target: condition === 'react-server' ? 'node18' : 'es2020',\n minify: condition === 'react-server' ? false : true,\n manifest: true,\n ssrManifest: false,\n ssrEmitAssets: true,\n rollupOptions: {\n ...config.build?.rollupOptions,\n input: inputs,\n preserveEntrySignatures: 'strict',\n output: condition === 'react-server' ? {\n preserveModules: true,\n entryFileNames: '[name].js',\n assetFileNames: '[name].[ext]',\n chunkFileNames: '[name].[ext]',\n format: 'esm',\n exports: 'named',\n
|
|
1
|
+
{"version":3,"file":"resolveUserConfig.js","sources":["../../../plugin/config/resolveUserConfig.ts"],"sourcesContent":["import type { ConfigEnv, UserConfig } from \"vite\";\nimport type { CheckFilesExistReturn, ResolvedUserConfig, ResolvedUserOptions } from \"../types.js\";\nimport { DEFAULT_CONFIG } from \"./defaults.js\";\nimport { createInputNormalizer } from \"../helpers/inputNormalizer.js\";\n\nexport type ResolveUserConfigProps = {\n condition: \"react-client\" | \"react-server\" | \"\";\n config: UserConfig;\n configEnv: ConfigEnv;\n userOptions: ResolvedUserOptions;\n files?: CheckFilesExistReturn;\n};\n\nexport type ResolveUserConfigReturn = \n | { type: \"success\"; userConfig: ResolvedUserConfig }\n | { type: \"error\"; error: Error };\n\nexport function resolveUserConfig({\n condition,\n config,\n configEnv,\n userOptions,\n files\n}: ResolveUserConfigProps): ResolveUserConfigReturn {\n\n\n try {\n // Get existing inputs\n const root = config.root ?? userOptions.projectRoot ?? process.cwd();\n const existingInput = config.build?.rollupOptions?.input || {};\n const currentInputs = typeof existingInput === 'string' ? { default: existingInput } : existingInput;\n const normalizer = createInputNormalizer(root);\n\n const serverEntry = userOptions.serverEntry ? [userOptions.serverEntry, userOptions.serverEntry] : [];\n // Add inputs based on condition\n const inputs = {\n ...currentInputs,\n ...(condition === 'react-server' && files ? {\n 'index.html': '/index.html',\n ...Object.fromEntries([\n ...serverEntry,\n ...Array.from(files.pageMap.entries()),\n ...Array.from(files.propsMap.entries())\n ].map(normalizer))\n } : {\n client: userOptions.clientEntry\n })\n };\n\n const userConfig = {\n ...config,\n root: root,\n mode: configEnv.command === 'build' ? 'production' : 'development',\n build: {\n ...config.build,\n outDir: condition === 'react-server' ? userOptions.build.server : userOptions.build.client,\n assetsDir: condition === 'react-server' ? \"\" : DEFAULT_CONFIG.CLIENT_ASSETS_DIR,\n ssr: condition === 'react-server',\n target: condition === 'react-server' ? 'node18' : 'es2020',\n minify: condition === 'react-server' ? false : true,\n manifest: true,\n ssrManifest: false,\n ssrEmitAssets: true,\n rollupOptions: {\n ...config.build?.rollupOptions,\n input: inputs,\n preserveEntrySignatures: 'strict',\n output: condition === 'react-server' ? {\n preserveModules: true,\n entryFileNames: '[name].js',\n assetFileNames: '[name].[ext]',\n chunkFileNames: '[name].[ext]',\n format: 'esm',\n exports: 'named',\n hoistTransitiveImports: false,\n generatedCode: {\n constBindings: true,\n objectShorthand: true\n },\n interop: 'auto'\n } : undefined\n }\n }\n };\n\n return {\n type: \"success\",\n userConfig: userConfig as ResolvedUserConfig\n };\n } catch (error) {\n return {\n type: \"error\",\n error: error instanceof Error ? error : new Error(\"Failed to resolve config\")\n };\n }\n} "],"names":[],"mappings":";;;;;;;;AAiBO,SAAS,iBAAkB,CAAA;AAAA,EAChC,SAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF,CAAoD,EAAA;AAGlD,EAAI,IAAA;AAEF,IAAA,MAAM,OAAO,MAAO,CAAA,IAAA,IAAQ,WAAY,CAAA,WAAA,IAAe,QAAQ,GAAI,EAAA;AACnE,IAAA,MAAM,aAAgB,GAAA,MAAA,CAAO,KAAO,EAAA,aAAA,EAAe,SAAS,EAAC;AAC7D,IAAA,MAAM,gBAAgB,OAAO,aAAA,KAAkB,WAAW,EAAE,OAAA,EAAS,eAAkB,GAAA,aAAA;AACvF,IAAM,MAAA,UAAA,GAAa,sBAAsB,IAAI,CAAA;AAE7C,IAAM,MAAA,WAAA,GAAc,YAAY,WAAc,GAAA,CAAC,YAAY,WAAa,EAAA,WAAA,CAAY,WAAW,CAAA,GAAI,EAAC;AAEpG,IAAA,MAAM,MAAS,GAAA;AAAA,MACb,GAAG,aAAA;AAAA,MACH,GAAI,SAAc,KAAA,cAAA,IAAkB,KAAQ,GAAA;AAAA,QAC1C,YAAc,EAAA,aAAA;AAAA,QACd,GAAG,OAAO,WAAY,CAAA;AAAA,UACpB,GAAG,WAAA;AAAA,UACH,GAAG,KAAM,CAAA,IAAA,CAAK,KAAM,CAAA,OAAA,CAAQ,SAAS,CAAA;AAAA,UACrC,GAAG,KAAM,CAAA,IAA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;AAAA,cACf,eAAiB,EAAA;AAAA,aACnB;AAAA,YACA,OAAS,EAAA;AAAA,WACP,GAAA,KAAA;AAAA;AACN;AACF,KACF;AAEA,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,SAAA;AAAA,MACN;AAAA,KACF;AAAA,WACO,KAAO,EAAA;AACd,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,OAAA;AAAA,MACN,OAAO,KAAiB,YAAA,KAAA,GAAQ,KAAQ,GAAA,IAAI,MAAM,0BAA0B;AAAA,KAC9E;AAAA;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputNormalizer.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/inputNormalizer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"inputNormalizer.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/inputNormalizer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,aAAa,CAAC;AAEpE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CA+BnE"}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Copyright (c) Nico Brinkkemper
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
6
|
-
import { DEFAULT_CONFIG } from '../config/defaults.js';
|
|
7
|
-
import { normalizePath } from 'vite';
|
|
8
6
|
import { join } from 'path';
|
|
7
|
+
import { normalizePath } from 'vite';
|
|
8
|
+
import { DEFAULT_CONFIG } from '../config/defaults.js';
|
|
9
9
|
|
|
10
10
|
function createInputNormalizer(root) {
|
|
11
11
|
const normalizeKey = (key) => {
|
|
@@ -18,13 +18,11 @@ function createInputNormalizer(root) {
|
|
|
18
18
|
normalizeKey(key),
|
|
19
19
|
normalizePath(join(root, path))
|
|
20
20
|
];
|
|
21
|
-
console.log("[inputNormalizer] Normalized input:", normalized, input);
|
|
22
21
|
return normalized;
|
|
23
22
|
}
|
|
24
23
|
if (typeof input === "string") {
|
|
25
24
|
const key = normalizeKey(input);
|
|
26
25
|
const path = normalizePath(join(root, input));
|
|
27
|
-
console.log("[inputNormalizer] Normalized input:", [key, path], input);
|
|
28
26
|
return [key, path];
|
|
29
27
|
}
|
|
30
28
|
throw new Error(`Invalid input type: ${typeof input}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputNormalizer.js","sources":["../../../plugin/helpers/inputNormalizer.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"inputNormalizer.js","sources":["../../../plugin/helpers/inputNormalizer.ts"],"sourcesContent":["import { join } from \"path\";\nimport { normalizePath } from \"vite\";\nimport { DEFAULT_CONFIG } from \"../config/defaults.js\";\nimport type { InputNormalizer, NormalizerInput } from \"../types.js\";\n\nexport function createInputNormalizer(root: string): InputNormalizer {\n\n // Normalize a key by removing file extensions and leading slashes\n const normalizeKey = (key: string): string => {\n return key\n .replace(DEFAULT_CONFIG.FILE_REGEX, \"\") // Remove TypeScript/JavaScript extensions\n .replace(/^\\/+/, \"\"); // Remove leading slashes\n };\n\n // Main normalize function\n return (input: NormalizerInput): [string, string] => {\n \n // Handle tuple input [key, path]\n if (Array.isArray(input)) {\n const [key, path] = input;\n const normalized: [string, string] = [\n normalizeKey(key),\n normalizePath(join(root, path))\n ] \n return normalized;\n }\n\n // Handle string input\n if (typeof input === \"string\") {\n const key = normalizeKey(input);\n const path = normalizePath(join(root, input)); \n return [key, path];\n }\n\n throw new Error(`Invalid input type: ${typeof input}`);\n };\n}\n"],"names":[],"mappings":";;;;;;;;;AAKO,SAAS,sBAAsB,IAA+B,EAAA;AAGnE,EAAM,MAAA,YAAA,GAAe,CAAC,GAAwB,KAAA;AAC5C,IAAO,OAAA,GAAA,CACJ,QAAQ,cAAe,CAAA,UAAA,EAAY,EAAE,CACrC,CAAA,OAAA,CAAQ,QAAQ,EAAE,CAAA;AAAA,GACvB;AAGA,EAAA,OAAO,CAAC,KAA6C,KAAA;AAGnD,IAAI,IAAA,KAAA,CAAM,OAAQ,CAAA,KAAK,CAAG,EAAA;AACxB,MAAM,MAAA,CAAC,GAAK,EAAA,IAAI,CAAI,GAAA,KAAA;AACpB,MAAA,MAAM,UAA+B,GAAA;AAAA,QACnC,aAAa,GAAG,CAAA;AAAA,QAChB,aAAc,CAAA,IAAA,CAAK,IAAM,EAAA,IAAI,CAAC;AAAA,OAChC;AACA,MAAO,OAAA,UAAA;AAAA;AAIT,IAAI,IAAA,OAAO,UAAU,QAAU,EAAA;AAC7B,MAAM,MAAA,GAAA,GAAM,aAAa,KAAK,CAAA;AAC9B,MAAA,MAAM,IAAO,GAAA,aAAA,CAAc,IAAK,CAAA,IAAA,EAAM,KAAK,CAAC,CAAA;AAC5C,MAAO,OAAA,CAAC,KAAK,IAAI,CAAA;AAAA;AAGnB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAuB,oBAAA,EAAA,OAAO,KAAK,CAAE,CAAA,CAAA;AAAA,GACvD;AACF;;;;"}
|
|
@@ -5,5 +5,5 @@ export interface BuildLoaderOptions {
|
|
|
5
5
|
pluginContext: PluginContext;
|
|
6
6
|
userConfig: ResolvedUserConfig;
|
|
7
7
|
}
|
|
8
|
-
export declare function createBuildLoader({ root,
|
|
8
|
+
export declare function createBuildLoader({ root, userConfig, }: BuildLoaderOptions): (id: string) => Promise<any>;
|
|
9
9
|
//# sourceMappingURL=createBuildLoader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBuildLoader.d.ts","sourceRoot":"","sources":["../../../plugin/loader/createBuildLoader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"createBuildLoader.d.ts","sourceRoot":"","sources":["../../../plugin/loader/createBuildLoader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAG1D,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,EAAE,kBAAkB,CAAC;CAChC;AAED,wBAAgB,iBAAiB,CAAC,EAChC,IAAI,EACJ,UAAU,GACX,EAAE,kBAAkB,QACD,MAAM,kBAOzB"}
|
|
@@ -5,32 +5,17 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { join } from 'path';
|
|
7
7
|
import { DEFAULT_CONFIG } from '../config/defaults.js';
|
|
8
|
-
import 'node:fs/promises';
|
|
9
|
-
import 'node:path';
|
|
10
8
|
|
|
11
9
|
function createBuildLoader({
|
|
12
10
|
root,
|
|
13
|
-
pluginContext,
|
|
14
11
|
userConfig
|
|
15
12
|
}) {
|
|
16
13
|
return async (id) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
const result = await pluginContext.load({ id: moduleId });
|
|
24
|
-
if (!result) {
|
|
25
|
-
throw new Error(`Failed to load module: ${id}`);
|
|
26
|
-
}
|
|
27
|
-
let destination = id.replace(DEFAULT_CONFIG.FILE_REGEX, "") + ".js";
|
|
28
|
-
let fullDestination = join(root, userConfig.build.outDir, destination);
|
|
29
|
-
try {
|
|
30
|
-
return import(fullDestination);
|
|
31
|
-
} catch (error) {
|
|
32
|
-
import(id);
|
|
33
|
-
}
|
|
14
|
+
return import(join(
|
|
15
|
+
root,
|
|
16
|
+
userConfig.build.outDir,
|
|
17
|
+
id.replace(DEFAULT_CONFIG.FILE_REGEX, "") + ".js"
|
|
18
|
+
));
|
|
34
19
|
};
|
|
35
20
|
}
|
|
36
21
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBuildLoader.js","sources":["../../../plugin/loader/createBuildLoader.ts"],"sourcesContent":["import { join
|
|
1
|
+
{"version":3,"file":"createBuildLoader.js","sources":["../../../plugin/loader/createBuildLoader.ts"],"sourcesContent":["import { join } from \"path\";\nimport type { PluginContext } from \"rollup\";\nimport type { ResolvedUserConfig } from \"../../server.js\";\nimport { DEFAULT_CONFIG } from \"../config/defaults.js\";\n\nexport interface BuildLoaderOptions {\n root: string;\n pluginContext: PluginContext;\n userConfig: ResolvedUserConfig;\n}\n\nexport function createBuildLoader({\n root,\n userConfig,\n}: BuildLoaderOptions) {\n return async (id: string) => {\n return import(join(\n root,\n userConfig.build.outDir,\n id.replace(DEFAULT_CONFIG.FILE_REGEX, \"\") + \".js\"\n ));\n };\n}\n"],"names":[],"mappings":";;;;;;;;AAWO,SAAS,iBAAkB,CAAA;AAAA,EAChC,IAAA;AAAA,EACA;AACF,CAAuB,EAAA;AACrB,EAAA,OAAO,OAAO,EAAe,KAAA;AAC3B,IAAA,OAAO,OAAO,IAAA;AAAA,MACZ,IAAA;AAAA,MACA,WAAW,KAAM,CAAA,MAAA;AAAA,MACjB,EAAG,CAAA,OAAA,CAAQ,cAAe,CAAA,UAAA,EAAY,EAAE,CAAI,GAAA;AAAA,KAC9C,CAAA;AAAA,GACF;AACF;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CreateHandlerOptions, StreamPluginOptions } from "../types.js";
|
|
2
1
|
import type { PipeableStream } from "react-dom/server";
|
|
2
|
+
import type { CreateHandlerOptions, StreamPluginOptions } from "../types.js";
|
|
3
3
|
type CreateHandlerResult = {
|
|
4
4
|
type: "success";
|
|
5
5
|
controller: AbortController;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createHandler.d.ts","sourceRoot":"","sources":["../../../plugin/react-server/createHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createHandler.d.ts","sourceRoot":"","sources":["../../../plugin/react-server/createHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AASvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAG7E,KAAK,mBAAmB,GACpB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,UAAU,EAAE,eAAe,CAAC;IAAC,MAAM,EAAE,cAAc,CAAC;IAAC,MAAM,EAAE,GAAG,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACzG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAOrB,wBAAsB,aAAa,CAAC,CAAC,EACnC,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,IAAI,CACjB,mBAAmB,EACnB,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,gBAAgB,GAAG,iBAAiB,CAC3E,GACC,QAAQ,CACN,IAAI,CAAC,mBAAmB,EAAE,YAAY,GAAG,gBAAgB,GAAG,aAAa,CAAC,CAC3E,EACH,aAAa,EAAE,oBAAoB,CAAC,CAAC,CAAC,GACrC,OAAO,CAAC,mBAAmB,CAAC,CAmI9B"}
|
|
@@ -29,11 +29,10 @@ async function createHandler(url, pluginOptions, streamOptions) {
|
|
|
29
29
|
streamOptions.onCssFile
|
|
30
30
|
) : (id) => collectModuleGraphCss(streamOptions.moduleGraph, id);
|
|
31
31
|
const loadWithCss = async (id) => {
|
|
32
|
-
console.log("[RSC] Loading module:", id);
|
|
33
32
|
try {
|
|
34
33
|
const mod = await streamOptions.loader(id);
|
|
35
34
|
const pageCss = await Promise.resolve(getCss(id));
|
|
36
|
-
Array.from(pageCss.keys()).forEach((css) => cssModules.add(css));
|
|
35
|
+
Array.from(pageCss.keys()).forEach((css) => cssModules.add(css.replace(pluginOptions.moduleBasePath, "")));
|
|
37
36
|
return mod;
|
|
38
37
|
} catch (e) {
|
|
39
38
|
if (e.message?.includes("module runner has been closed")) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createHandler.js","sources":["../../../plugin/react-server/createHandler.ts"],"sourcesContent":["import { createLogger } from \"vite\";\nimport {\n collectManifestCss,\n collectModuleGraphCss,\n} from \"../collect-css-manifest.js\";\nimport { DEFAULT_CONFIG } from \"../config/defaults.js\";\nimport { resolvePage } from \"../resolvePage.js\";\nimport { resolveProps } from \"../resolveProps.js\";\nimport type { CreateHandlerOptions, StreamPluginOptions } from \"../types.js\";\nimport { createRscStream } from \"./createRscStream.js\";\
|
|
1
|
+
{"version":3,"file":"createHandler.js","sources":["../../../plugin/react-server/createHandler.ts"],"sourcesContent":["import type { PipeableStream } from \"react-dom/server\";\nimport { createLogger } from \"vite\";\nimport {\n collectManifestCss,\n collectModuleGraphCss,\n} from \"../collect-css-manifest.js\";\nimport { DEFAULT_CONFIG } from \"../config/defaults.js\";\nimport { resolvePage } from \"../resolvePage.js\";\nimport { resolveProps } from \"../resolveProps.js\";\nimport type { CreateHandlerOptions, StreamPluginOptions } from \"../types.js\";\nimport { createRscStream } from \"./createRscStream.js\";\n\ntype CreateHandlerResult = \n | { type: \"success\"; controller: AbortController; stream: PipeableStream; assets: any; clientPath: string }\n | { type: \"error\"; error: Error }\n | { type: \"skip\" };\n\ninterface HandlerAssets {\n css: Set<string>;\n clientPath: string;\n}\n\nexport async function createHandler<T>(\n url: string,\n pluginOptions: Pick<\n StreamPluginOptions,\n \"Page\" | \"props\" | \"build\" | \"Html\" | \"pageExportName\" | \"propsExportName\"\n > &\n Required<\n Pick<StreamPluginOptions, \"moduleBase\" | \"moduleBasePath\" | \"projectRoot\">\n >,\n streamOptions: CreateHandlerOptions<T>\n): Promise<CreateHandlerResult> {\n const root = pluginOptions.projectRoot ?? process.cwd();\n\n const Html = pluginOptions.Html ?? DEFAULT_CONFIG.HTML;\n const pageExportName =\n pluginOptions.pageExportName ?? DEFAULT_CONFIG.PAGE_EXPORT;\n const propsExportName =\n pluginOptions.propsExportName ?? DEFAULT_CONFIG.PROPS_EXPORT;\n const controller = new AbortController();\n\n const cssFiles = streamOptions.cssFiles;\n const propsPath =\n typeof pluginOptions.props === \"function\"\n ? pluginOptions.props(url)\n : pluginOptions.props;\n const pagePath =\n typeof pluginOptions.Page === \"function\"\n ? pluginOptions.Page(url)\n : pluginOptions.Page;\n\n const cssModules = new Set<string>();\n\n if (!(streamOptions.manifest || streamOptions.moduleGraph))\n throw new Error(\"Missing manifest or moduleGraph, pass it to options.\");\n\n const getCss = streamOptions.manifest\n ? (id: string) =>\n collectManifestCss(\n streamOptions.manifest!,\n root,\n id,\n streamOptions.onCssFile\n )\n : (id: string) => collectModuleGraphCss(streamOptions.moduleGraph!, id);\n\n const loadWithCss = async (id: string) => {\n try {\n const mod = await streamOptions.loader(id);\n const pageCss = await Promise.resolve(getCss(id));\n Array.from(pageCss.keys()).forEach((css) => cssModules.add(css.replace(pluginOptions.moduleBasePath, \"\")));\n return mod as Record<string, any>;\n } catch (e: any) {\n if (e.message?.includes(\"module runner has been closed\")) {\n return { type: \"skip\" } as Record<string, any>;\n } else {\n return { type: \"error\", error: e } as Record<string, any>;\n }\n }\n };\n\n const PropsModule = await resolveProps({\n propsModule: await loadWithCss(propsPath ?? pagePath),\n path: String(propsPath ?? pagePath),\n exportName: propsExportName,\n url,\n });\n if (PropsModule.type === \"error\")\n return { type: PropsModule.type, error: PropsModule?.error };\n if (PropsModule.type === \"skip\") return { type: PropsModule.type };\n const props = PropsModule[propsExportName as keyof typeof PropsModule] as any;\n if (props?.type === \"error\") return { type: props.type, error: props.error };\n if (props?.type === \"skip\") return { type: props.type };\n\n const PageModule = await resolvePage({\n pageModule: await loadWithCss(pagePath),\n path: pagePath,\n exportName: pageExportName,\n url,\n });\n if (PageModule.type === \"error\")\n return { type: PageModule.type, error: PageModule.error };\n if (PageModule.type === \"skip\") return { type: PageModule.type };\n const Page = PageModule[pageExportName as keyof typeof PageModule] as any;\n if (Page?.type === \"error\") return { type: Page.type, error: Page.error };\n if (Page?.type === \"skip\") return { type: Page.type };\n if (!(typeof Page === \"function\")) {\n return {\n type: \"error\",\n error: new Error(\"Invalid Page component: \" + pagePath, {\n cause: Page,\n }),\n };\n }\n if (!(typeof props === \"object\")) {\n return {\n type: \"error\",\n error: new Error(\"Invalid props: \" + propsPath, {\n cause: props,\n }),\n } \n }\n\n // Add any additional CSS files\n if (streamOptions.cssFiles) {\n streamOptions.cssFiles.forEach((css) => cssModules.add(css));\n }\n\n const stream = createRscStream({\n Html: Html,\n Page: Page,\n props: props,\n moduleBasePath: pluginOptions.moduleBasePath,\n logger: streamOptions.logger ?? createLogger(),\n cssFiles: Array.from(cssModules),\n route: url,\n url,\n pipableStreamOptions: streamOptions.pipableStreamOptions,\n htmlProps: {\n pageProps: props,\n route: url,\n url: url,\n },\n });\n\n if (!stream) {\n console.log(\"[createHandler] No stream created for route:\", url);\n return { type: \"skip\" as const };\n }\n\n const assets: HandlerAssets = {\n css: new Set(cssFiles ?? []),\n clientPath: pagePath ?? ''\n };\n\n return {\n type: \"success\",\n controller,\n stream,\n assets,\n clientPath: assets.clientPath,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAsBsB,eAAA,aAAA,CACpB,GACA,EAAA,aAAA,EAOA,aAC8B,EAAA;AAC9B,EAAA,MAAM,IAAO,GAAA,aAAA,CAAc,WAAe,IAAA,OAAA,CAAQ,GAAI,EAAA;AAEtD,EAAM,MAAA,IAAA,GAAO,aAAc,CAAA,IAAA,IAAQ,cAAe,CAAA,IAAA;AAClD,EAAM,MAAA,cAAA,GACJ,aAAc,CAAA,cAAA,IAAkB,cAAe,CAAA,WAAA;AACjD,EAAM,MAAA,eAAA,GACJ,aAAc,CAAA,eAAA,IAAmB,cAAe,CAAA,YAAA;AAClD,EAAM,MAAA,UAAA,GAAa,IAAI,eAAgB,EAAA;AAEvC,EAAA,MAAM,WAAW,aAAc,CAAA,QAAA;AAC/B,EAAM,MAAA,SAAA,GACJ,OAAO,aAAc,CAAA,KA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AED,EAAA,IAAI,CAAC,MAAQ,EAAA;AACX,IAAQ,OAAA,CAAA,GAAA,CAAI,gDAAgD,GAAG,CAAA;AAC/D,IAAO,OAAA,EAAE,MAAM,MAAgB,EAAA;AAAA;AAGjC,EAAA,MAAM,MAAwB,GAAA;AAAA,IAC5B,GAAK,EAAA,IAAI,GAAI,CAAA,QAAA,IAAY,EAAE,CAAA;AAAA,IAC3B,YAAY,QAAY,IAAA;AAAA,GAC1B;AAEA,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,SAAA;AAAA,IACN,UAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,YAAY,MAAO,CAAA;AAAA,GACrB;AACF;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RscStreamOptions } from "../types.js";
|
|
2
1
|
import type { PipeableStream } from "react-dom/server";
|
|
2
|
+
import type { RscStreamOptions } from "../types.js";
|
|
3
3
|
export declare function createRscStream(streamOptions: RscStreamOptions): PipeableStream;
|
|
4
4
|
//# sourceMappingURL=createRscStream.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRscStream.d.ts","sourceRoot":"","sources":["../../../plugin/react-server/createRscStream.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createRscStream.d.ts","sourceRoot":"","sources":["../../../plugin/react-server/createRscStream.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,wBAAgB,eAAe,CAC7B,aAAa,EAAE,gBAAgB,GAC9B,cAAc,CAuChB"}
|
|
@@ -21,7 +21,8 @@ function createRscStream(streamOptions) {
|
|
|
21
21
|
const css = Array.isArray(cssFiles) ? cssFiles.map(
|
|
22
22
|
(css2, index) => React.createElement(CssCollector, {
|
|
23
23
|
key: `css-${index}`,
|
|
24
|
-
url: css2
|
|
24
|
+
url: css2.startsWith("/") ? css2 : `/${css2}`,
|
|
25
|
+
moduleBasePath
|
|
25
26
|
})
|
|
26
27
|
) : [];
|
|
27
28
|
return renderToPipeableStream(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRscStream.js","sources":["../../../plugin/react-server/createRscStream.ts"],"sourcesContent":["import * as React from \"react\";\n// @ts-ignore\nimport { renderToPipeableStream } from \"react-server-dom-esm/server.node\";\nimport { CssCollector } from \"../components.js\";\nimport type { RscStreamOptions } from \"../types.js\";\
|
|
1
|
+
{"version":3,"file":"createRscStream.js","sources":["../../../plugin/react-server/createRscStream.ts"],"sourcesContent":["import * as React from \"react\";\nimport type { PipeableStream } from \"react-dom/server\";\n// @ts-ignore\nimport { renderToPipeableStream } from \"react-server-dom-esm/server.node\";\nimport { CssCollector } from \"../components.js\";\nimport type { RscStreamOptions } from \"../types.js\";\n\nexport function createRscStream(\n streamOptions: RscStreamOptions\n): PipeableStream {\n const {\n Html,\n Page,\n props,\n logger,\n cssFiles,\n moduleBasePath,\n pipableStreamOptions,\n htmlProps,\n } = streamOptions;\n\n const css = Array.isArray(cssFiles)\n ? cssFiles.map((css, index) =>\n React.createElement(CssCollector, {\n key: `css-${index}`,\n url: css.startsWith(\"/\") ? css : `/${css}`,\n moduleBasePath,\n })\n )\n : [];\n return renderToPipeableStream(\n React.createElement(\n Html,\n {\n key: \"html\",\n ...htmlProps\n },\n React.createElement(Page, { key: \"page\", ...props }),\n ...css\n ),\n moduleBasePath,\n {\n onError: logger?.error ?? console.error,\n onPostpone: logger?.info ?? console.info,\n environmentName: \"Server\",\n ...pipableStreamOptions\n }\n );\n}\n"],"names":["css"],"mappings":";;;;;;;;;AAOO,SAAS,gBACd,aACgB,EAAA;AAChB,EAAM,MAAA;AAAA,IACJ,IAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,MAAA;AAAA,IACA,QAAA;AAAA,IACA,cAAA;AAAA,IACA,oBAAA;AAAA,IACA;AAAA,GACE,GAAA,aAAA;AAEJ,EAAA,MAAM,GAAM,GAAA,KAAA,CAAM,OAAQ,CAAA,QAAQ,IAC9B,QAAS,CAAA,GAAA;AAAA,IAAI,CAACA,IAAAA,EAAK,KACjB,KAAA,KAAA,CAAM,cAAc,YAAc,EAAA;AAAA,MAChC,GAAA,EAAK,OAAO,KAAK,CAAA,CAAA;AAAA,MACjB,KAAKA,IAAI,CAAA,UAAA,CAAW,GAAG,CAAIA,GAAAA,IAAAA,GAAM,IAAIA,IAAG,CAAA,CAAA;AAAA,MACxC;AAAA,KACD;AAAA,MAEH,EAAC;AACL,EAAO,OAAA,sBAAA;AAAA,IACL,KAAM,CAAA,aAAA;AAAA,MACJ,IAAA;AAAA,MACA;AAAA,QACE,GAAK,EAAA,MAAA;AAAA,QACL,GAAG;AAAA,OACL;AAAA,MACA,KAAA,CAAM,cAAc,IAAM,EAAA,EAAE,KAAK,MAAQ,EAAA,GAAG,OAAO,CAAA;AAAA,MACnD,GAAG;AAAA,KACL;AAAA,IACA,cAAA;AAAA,IACA;AAAA,MACE,OAAA,EAAS,MAAQ,EAAA,KAAA,IAAS,OAAQ,CAAA,KAAA;AAAA,MAClC,UAAA,EAAY,MAAQ,EAAA,IAAA,IAAQ,OAAQ,CAAA,IAAA;AAAA,MACpC,eAAiB,EAAA,QAAA;AAAA,MACjB,GAAG;AAAA;AACL,GACF;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../plugin/react-server/plugin.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAGV,qBAAqB,EAGtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAKvD,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,mBAAmB,GAC3B,OAAO,MAAM,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../plugin/react-server/plugin.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAGV,qBAAqB,EAGtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAKvD,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,mBAAmB,GAC3B,OAAO,MAAM,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,qBAAqB,CAAC;IAC5B,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC,CAAC,CAoZD"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright (c) Nico Brinkkemper
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
6
|
-
import
|
|
6
|
+
import 'fs';
|
|
7
7
|
import { resolve, join } from 'node:path';
|
|
8
8
|
import { performance } from 'node:perf_hooks';
|
|
9
9
|
import 'node:worker_threads';
|
|
@@ -146,12 +146,7 @@ function reactServerPlugin(options) {
|
|
|
146
146
|
});
|
|
147
147
|
},
|
|
148
148
|
async config(config, configEnv) {
|
|
149
|
-
if (typeof config.root === "string" && config.root !== root) {
|
|
150
|
-
console.log(
|
|
151
|
-
"[vite-plugin-react-server] Root dir changed",
|
|
152
|
-
config.root,
|
|
153
|
-
root
|
|
154
|
-
);
|
|
149
|
+
if (typeof config.root === "string" && config.root !== root && config.root !== process.cwd() && config.root !== "") {
|
|
155
150
|
root = config.root;
|
|
156
151
|
}
|
|
157
152
|
const resolvedPages = await resolvePages(userOptions.build.pages);
|
|
@@ -191,21 +186,16 @@ function reactServerPlugin(options) {
|
|
|
191
186
|
const serverManifest = resolvedServerManifest.type === "error" ? getModuleManifest.bind(this)() : resolvedServerManifest.manifest;
|
|
192
187
|
let htmlWorkerPath = serverManifest["html-worker"]?.file;
|
|
193
188
|
if (options.htmlWorkerPath) {
|
|
194
|
-
htmlWorkerPath =
|
|
189
|
+
htmlWorkerPath = options.htmlWorkerPath;
|
|
195
190
|
} else {
|
|
196
191
|
htmlWorkerPath = join(
|
|
197
192
|
getPluginRoot(),
|
|
198
193
|
DEFAULT_CONFIG.HTML_WORKER_PATH
|
|
199
194
|
);
|
|
200
195
|
}
|
|
201
|
-
const workerPath = resolve(
|
|
202
|
-
root,
|
|
203
|
-
userOptions.build.server,
|
|
204
|
-
htmlWorkerPath
|
|
205
|
-
);
|
|
206
196
|
worker = await createWorker({
|
|
207
|
-
projectRoot:
|
|
208
|
-
workerPath,
|
|
197
|
+
projectRoot: root,
|
|
198
|
+
workerPath: htmlWorkerPath,
|
|
209
199
|
condition: "react-server",
|
|
210
200
|
reverseCondition: true,
|
|
211
201
|
mode: finalConfig.mode,
|
|
@@ -216,7 +206,6 @@ function reactServerPlugin(options) {
|
|
|
216
206
|
throw resolvedPages.error;
|
|
217
207
|
}
|
|
218
208
|
const routes = resolvedPages.pages;
|
|
219
|
-
console.log("[plugin] Routes to render:", routes);
|
|
220
209
|
const entries = Object.values(serverManifest).filter(
|
|
221
210
|
(entry) => entry.isEntry
|
|
222
211
|
);
|
|
@@ -228,11 +217,13 @@ function reactServerPlugin(options) {
|
|
|
228
217
|
});
|
|
229
218
|
const { failedRoutes, completedRoutes } = await renderPages(routes, {
|
|
230
219
|
pipableStreamOptions: {
|
|
231
|
-
bootstrapModules: entries.
|
|
220
|
+
bootstrapModules: entries.filter(
|
|
221
|
+
(entry) => userOptions.autoDiscover.clientComponents.test(entry.file)
|
|
222
|
+
).filter((t) => typeof t === "object" && t != null && "file" in t).map((entry) => "/" + entry.file.replace(userOptions.moduleBasePath, ""))
|
|
232
223
|
},
|
|
233
224
|
moduleBasePath: userOptions.moduleBasePath,
|
|
234
225
|
moduleBaseURL: userOptions.moduleBaseURL,
|
|
235
|
-
clientCss: css?.map((css2) => "/" + css2) ?? [],
|
|
226
|
+
clientCss: css?.filter((css2) => typeof css2 === "string").map((css2) => "/" + css2.replace(userOptions.moduleBasePath, "")) ?? [],
|
|
236
227
|
userConfig,
|
|
237
228
|
pluginOptions: userOptions,
|
|
238
229
|
worker,
|
|
@@ -240,22 +231,16 @@ function reactServerPlugin(options) {
|
|
|
240
231
|
loader,
|
|
241
232
|
onCssFile: (path) => {
|
|
242
233
|
if (buildCssFiles && path.endsWith(".css")) {
|
|
243
|
-
buildCssFiles.add(path);
|
|
234
|
+
buildCssFiles.add(path.replace(userOptions.moduleBasePath, ""));
|
|
244
235
|
}
|
|
245
236
|
}
|
|
246
237
|
});
|
|
247
|
-
console.log("[vite-plugin-react-server] Render results:", {
|
|
248
|
-
failedRoutes,
|
|
249
|
-
completedRoutes
|
|
250
|
-
});
|
|
251
238
|
if (failedRoutes.size) {
|
|
252
239
|
console.error(
|
|
253
240
|
"[vite-plugin-react-server] Failed to render routes:",
|
|
254
241
|
failedRoutes
|
|
255
242
|
);
|
|
256
243
|
}
|
|
257
|
-
console.log("[vite-plugin-react-server] Render complete");
|
|
258
|
-
console.log("[vite-plugin-react-server] Terminating worker");
|
|
259
244
|
if (worker) await worker.terminate();
|
|
260
245
|
timing.renderEnd = performance.now();
|
|
261
246
|
timing.total = (timing.renderEnd - timing.start) / 1e3;
|
|
@@ -351,15 +336,7 @@ function reactServerPlugin(options) {
|
|
|
351
336
|
...fallbackManifestEntries
|
|
352
337
|
};
|
|
353
338
|
if (chunk.fileName.includes("html-worker")) {
|
|
354
|
-
const workerPath = resolve(
|
|
355
|
-
root,
|
|
356
|
-
userOptions.build.server,
|
|
357
|
-
chunk.fileName
|
|
358
|
-
);
|
|
359
|
-
console.log("Files in output dir:", {
|
|
360
|
-
files: readdirSync(resolve(root, userOptions.build.server)),
|
|
361
|
-
workerPath
|
|
362
|
-
});
|
|
339
|
+
const workerPath = resolve(root, chunk.fileName);
|
|
363
340
|
if (finalConfig.command === "build") {
|
|
364
341
|
return null;
|
|
365
342
|
}
|