vite-plugin-react-server 0.3.18 → 1.0.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 +220 -141
- package/bin/patch.mjs +8 -2
- package/dist/package.json +15 -8
- package/dist/plugin/checkFilesExist.d.ts.map +1 -1
- package/dist/plugin/checkFilesExist.js +6 -2
- package/dist/plugin/checkFilesExist.js.map +1 -1
- package/dist/plugin/collect-manifest-client-files.d.ts +23 -0
- package/dist/plugin/collect-manifest-client-files.d.ts.map +1 -0
- package/dist/plugin/collect-manifest-client-files.js +131 -0
- package/dist/plugin/collect-manifest-client-files.js.map +1 -0
- package/dist/plugin/components.d.ts +3 -13
- package/dist/plugin/components.d.ts.map +1 -1
- package/dist/plugin/components.js +3 -13
- package/dist/plugin/config/defaults.d.ts +14 -6
- package/dist/plugin/config/defaults.d.ts.map +1 -1
- package/dist/plugin/config/defaults.js +9 -5
- package/dist/plugin/config/defaults.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 +2 -7
- package/dist/plugin/config/getPaths.js.map +1 -1
- package/dist/plugin/config/mimeTypes.d.ts +2 -0
- package/dist/plugin/config/mimeTypes.d.ts.map +1 -0
- package/dist/plugin/config/mimeTypes.js +24 -0
- package/dist/plugin/config/mimeTypes.js.map +1 -0
- package/dist/plugin/config/resolveOptions.d.ts +2 -2
- package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
- package/dist/plugin/config/resolveOptions.js +47 -28
- package/dist/plugin/config/resolveOptions.js.map +1 -1
- package/dist/plugin/config/resolvePages.d.ts +1 -0
- package/dist/plugin/config/resolvePages.d.ts.map +1 -1
- package/dist/plugin/config/resolvePages.js +9 -5
- package/dist/plugin/config/resolvePages.js.map +1 -1
- package/dist/plugin/config/resolveUserConfig.d.ts +2 -1
- package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
- package/dist/plugin/config/resolveUserConfig.js +181 -147
- package/dist/plugin/config/resolveUserConfig.js.map +1 -1
- package/dist/plugin/copy-dir.js +23 -18
- package/dist/plugin/copy-dir.js.map +1 -0
- package/dist/plugin/css-collector-inline.d.ts +10 -0
- package/dist/plugin/css-collector-inline.d.ts.map +1 -0
- package/dist/plugin/css-collector-inline.js +55 -0
- package/dist/plugin/css-collector-inline.js.map +1 -0
- package/dist/plugin/css-collector.d.ts +14 -0
- package/dist/plugin/css-collector.d.ts.map +1 -0
- package/dist/plugin/css-collector.js +49 -0
- package/dist/plugin/css-collector.js.map +1 -0
- package/dist/plugin/helpers/createHandler.d.ts +17 -0
- package/dist/plugin/helpers/createHandler.d.ts.map +1 -0
- package/dist/plugin/helpers/createHandler.js +111 -0
- package/dist/plugin/helpers/createHandler.js.map +1 -0
- package/dist/plugin/helpers/createRscStream.d.ts +27 -0
- package/dist/plugin/helpers/createRscStream.d.ts.map +1 -0
- package/dist/plugin/helpers/createRscStream.js +80 -0
- package/dist/plugin/helpers/createRscStream.js.map +1 -0
- package/dist/plugin/helpers/getBundleManifest.d.ts.map +1 -1
- package/dist/plugin/helpers/getBundleManifest.js +12 -4
- package/dist/plugin/helpers/getBundleManifest.js.map +1 -1
- package/dist/plugin/html.d.ts +5 -0
- package/dist/plugin/html.d.ts.map +1 -0
- package/dist/plugin/html.js +11 -0
- package/dist/plugin/html.js.map +1 -0
- 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 +8 -5
- package/dist/plugin/loader/createBuildLoader.js.map +1 -1
- package/dist/plugin/loader/css-loader.d.ts.map +1 -1
- package/dist/plugin/loader/css-loader.js.map +1 -1
- package/dist/plugin/loader/react-loader.js +2 -2
- package/dist/plugin/loader/react-loader.js.map +1 -1
- package/dist/plugin/preserver/plugin.d.ts.map +1 -1
- package/dist/plugin/preserver/plugin.js +49 -14
- package/dist/plugin/preserver/plugin.js.map +1 -1
- package/dist/plugin/react-client/plugin.d.ts.map +1 -1
- package/dist/plugin/react-client/plugin.js +21 -78
- package/dist/plugin/react-client/plugin.js.map +1 -1
- package/dist/plugin/react-server/index.d.ts.map +1 -1
- package/dist/plugin/react-server/index.js +2 -0
- package/dist/plugin/react-server/index.js.map +1 -1
- package/dist/plugin/react-server/plugin.d.ts +2 -1
- package/dist/plugin/react-server/plugin.d.ts.map +1 -1
- package/dist/plugin/react-server/plugin.js +92 -225
- package/dist/plugin/react-server/plugin.js.map +1 -1
- package/dist/plugin/react-static/index.d.ts +2 -0
- package/dist/plugin/react-static/index.d.ts.map +1 -0
- package/dist/plugin/react-static/index.js +1 -0
- package/dist/plugin/react-static/plugin.d.ts +7 -0
- package/dist/plugin/react-static/plugin.d.ts.map +1 -0
- package/dist/plugin/react-static/plugin.js +207 -0
- package/dist/plugin/react-static/plugin.js.map +1 -0
- package/dist/plugin/react-static/types.d.ts +2 -0
- package/dist/plugin/react-static/types.d.ts.map +1 -0
- package/dist/plugin/resolvePage.d.ts.map +1 -1
- package/dist/plugin/resolvePage.js +9 -0
- package/dist/plugin/resolvePage.js.map +1 -1
- package/dist/plugin/root.d.ts +2 -0
- package/dist/plugin/root.d.ts.map +1 -0
- package/dist/plugin/root.js +12 -0
- package/dist/plugin/root.js.map +1 -0
- package/dist/plugin/transformer/plugin.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.js +32 -23
- package/dist/plugin/transformer/plugin.js.map +1 -1
- package/dist/plugin/transformer/types.d.ts +1 -18
- package/dist/plugin/transformer/types.d.ts.map +1 -1
- package/dist/plugin/types.d.ts +70 -15
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/worker/createWorker.js +0 -1
- package/dist/plugin/worker/createWorker.js.map +1 -1
- package/dist/plugin/worker/html/html-worker.development.d.ts +30 -0
- package/dist/plugin/worker/html/html-worker.development.d.ts.map +1 -1
- package/dist/plugin/worker/html/html-worker.development.js +30 -2
- package/dist/plugin/worker/html/html-worker.development.js.map +1 -1
- package/dist/plugin/worker/html/html-worker.production.js +3 -5
- package/dist/plugin/worker/html/html-worker.production.js.map +1 -1
- package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/html/messageHandler.js +12 -3
- package/dist/plugin/worker/html/messageHandler.js.map +1 -1
- package/dist/plugin/worker/html/renderPages.d.ts +13 -26
- package/dist/plugin/worker/html/renderPages.d.ts.map +1 -1
- package/dist/plugin/worker/html/renderPages.js +138 -86
- package/dist/plugin/worker/html/renderPages.js.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.js +104 -84
- package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.development.js +13 -18
- package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.production.js +4 -1
- package/dist/plugin/worker/rsc/rsc-worker.production.js.map +1 -1
- package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/state.js.map +1 -1
- package/dist/plugin/worker/types.d.ts +3 -0
- package/dist/plugin/worker/types.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -6
- package/plugin/checkFilesExist.ts +7 -3
- package/plugin/collect-manifest-client-files.ts +167 -0
- package/plugin/components.ts +3 -0
- package/plugin/config/defaults.tsx +70 -0
- package/plugin/config/getPaths.ts +1 -7
- package/plugin/config/mimeTypes.ts +17 -0
- package/plugin/config/resolveOptions.ts +58 -45
- package/plugin/config/resolvePages.ts +8 -4
- package/plugin/config/resolveUserConfig.ts +220 -176
- package/plugin/css-collector-inline.tsx +60 -0
- package/plugin/css-collector.tsx +62 -0
- package/plugin/helpers/createHandler.ts +135 -0
- package/plugin/helpers/createRscStream.ts +109 -0
- package/plugin/helpers/getBundleManifest.ts +14 -5
- package/plugin/html.tsx +9 -0
- package/plugin/loader/createBuildLoader.ts +9 -6
- package/plugin/loader/css-loader.ts +0 -2
- package/plugin/loader/react-loader.ts +2 -2
- package/plugin/preserver/plugin.ts +64 -17
- package/plugin/react-client/plugin.ts +23 -93
- package/plugin/react-server/index.ts +2 -0
- package/plugin/react-server/plugin.ts +111 -302
- package/plugin/react-static/index.ts +1 -0
- package/plugin/react-static/plugin.ts +256 -0
- package/plugin/react-static/types.ts +3 -0
- package/plugin/resolvePage.ts +9 -0
- package/plugin/root.ts +4 -0
- package/plugin/transformer/plugin.ts +40 -31
- package/plugin/transformer/types.ts +0 -19
- package/plugin/types.ts +77 -16
- package/plugin/worker/createWorker.ts +1 -1
- package/plugin/worker/html/README.md +63 -0
- package/plugin/worker/html/html-worker.development.tsx +89 -2
- package/plugin/worker/html/html-worker.production.tsx +8 -10
- package/plugin/worker/html/messageHandler.ts +12 -3
- package/plugin/worker/html/renderPages.ts +178 -138
- package/plugin/worker/rsc/README.md +58 -0
- package/plugin/worker/rsc/messageHandler.tsx +112 -113
- package/plugin/worker/rsc/rsc-worker.development.ts +12 -22
- package/plugin/worker/rsc/rsc-worker.production.ts +5 -1
- package/plugin/worker/rsc/state.ts +0 -3
- package/plugin/worker/types.ts +3 -0
- package/scripts/react+0.0.0-experimental-eda36a1c-20250228.patch +114 -12
- package/scripts/react-dom+0.0.0-experimental-eda36a1c-20250228.patch +10571 -121
- package/tsconfig.json +2 -2
- package/dist/plugin/collect-css-manifest.d.ts +0 -4
- package/dist/plugin/collect-css-manifest.d.ts.map +0 -1
- package/dist/plugin/collect-css-manifest.js +0 -65
- package/dist/plugin/collect-css-manifest.js.map +0 -1
- package/dist/plugin/config/createModuleIdGenerator.d.ts +0 -11
- package/dist/plugin/config/createModuleIdGenerator.d.ts.map +0 -1
- package/dist/plugin/config/createModuleIdGenerator.js +0 -44
- package/dist/plugin/config/createModuleIdGenerator.js.map +0 -1
- package/dist/plugin/getEnv.d.ts +0 -19
- package/dist/plugin/getEnv.d.ts.map +0 -1
- package/dist/plugin/getEnv.js +0 -107
- package/dist/plugin/loader/createCssLoader.d.ts +0 -30
- package/dist/plugin/loader/createCssLoader.d.ts.map +0 -1
- package/dist/plugin/loader/createCssLoader.js +0 -35
- package/dist/plugin/loader/createPageLoader.d.ts +0 -24
- package/dist/plugin/loader/createPageLoader.d.ts.map +0 -1
- package/dist/plugin/loader/createPageLoader.js +0 -50
- package/dist/plugin/loader/rsc/messageHandler.d.ts +0 -2
- package/dist/plugin/loader/rsc/messageHandler.d.ts.map +0 -1
- package/dist/plugin/loader/rsc/rsc-worker.development.d.ts +0 -2
- package/dist/plugin/loader/rsc/rsc-worker.development.d.ts.map +0 -1
- package/dist/plugin/loader/rsc/rsc-worker.development.js +0 -1
- package/dist/plugin/module-graph.d.ts +0 -10
- package/dist/plugin/module-graph.d.ts.map +0 -1
- package/dist/plugin/module-graph.js +0 -35
- package/dist/plugin/react-server/createHandler.d.ts +0 -17
- package/dist/plugin/react-server/createHandler.d.ts.map +0 -1
- package/dist/plugin/react-server/createHandler.js +0 -126
- package/dist/plugin/react-server/createHandler.js.map +0 -1
- package/dist/plugin/react-server/createRscStream.d.ts +0 -16
- package/dist/plugin/react-server/createRscStream.d.ts.map +0 -1
- package/dist/plugin/react-server/createRscStream.js +0 -70
- package/dist/plugin/react-server/createRscStream.js.map +0 -1
- package/dist/plugin/react-server/createSsrHandler.d.ts +0 -4
- package/dist/plugin/react-server/createSsrHandler.d.ts.map +0 -1
- package/dist/plugin/react-server/createSsrHandler.js +0 -95
- package/dist/plugin/utils/logger.d.ts +0 -9
- package/dist/plugin/utils/logger.d.ts.map +0 -1
- package/dist/plugin/utils/logger.js +0 -68
- package/dist/plugin/utils/logger.js.map +0 -1
- package/dist/plugin/worker/html/plugin.d.ts +0 -4
- package/dist/plugin/worker/html/plugin.d.ts.map +0 -1
- package/dist/plugin/worker/html/plugin.js +0 -94
- package/dist/plugin/worker/plugin.d.ts +0 -19
- package/dist/plugin/worker/plugin.d.ts.map +0 -1
- package/dist/plugin/worker/plugin.js +0 -23
- package/dist/plugin/worker/rsc/plugin.d.ts +0 -4
- package/dist/plugin/worker/rsc/plugin.d.ts.map +0 -1
- package/dist/plugin/worker/rsc/plugin.js +0 -76
- package/plugin/collect-css-manifest.ts +0 -82
- package/plugin/components.tsx +0 -14
- package/plugin/config/createModuleIdGenerator.ts +0 -52
- package/plugin/config/defaults.ts +0 -51
- package/plugin/getEnv.ts +0 -135
- package/plugin/loader/createCssLoader.ts +0 -73
- package/plugin/loader/createPageLoader.ts +0 -103
- package/plugin/loader/rsc/messageHandler.tsx +0 -1
- package/plugin/loader/rsc/rsc-worker.development.ts +0 -1
- package/plugin/module-graph.ts +0 -48
- package/plugin/react-server/createHandler.ts +0 -162
- package/plugin/react-server/createRscStream.ts +0 -86
- package/plugin/react-server/createSsrHandler.ts +0 -125
- package/plugin/utils/logger.ts +0 -52
- package/plugin/worker/html/plugin.ts +0 -101
- package/plugin/worker/plugin.ts +0 -26
- package/plugin/worker/rsc/plugin.ts +0 -84
- /package/dist/plugin/{loader/rsc/messageHandler.js → react-static/types.js} +0 -0
package/tsconfig.json
CHANGED
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
// We don't allow property access from index signatures. In this case we prefer to write record['images'] instead of record.images
|
|
25
25
|
"noPropertyAccessFromIndexSignature": true,
|
|
26
26
|
// You'll get an error if you forget to remove a variable. Toggle on when you want to clean up code, turn off when you are working on a new feature.
|
|
27
|
-
"noUnusedLocals":
|
|
27
|
+
"noUnusedLocals": true,
|
|
28
28
|
// Same as above, but for function parameters.
|
|
29
|
-
"noUnusedParameters":
|
|
29
|
+
"noUnusedParameters": true,
|
|
30
30
|
// We allow JSON imports. In fact we promote using them. We need to use the `with {type: 'json'}` which is the most recent way to do it.
|
|
31
31
|
"resolveJsonModule": true,
|
|
32
32
|
// If you are having issues with libraries, you can disable this and it won't check the types of the libraries.
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Manifest, ModuleGraph } from 'vite';
|
|
2
|
-
export declare function collectModuleGraphCss(moduleGraph: ModuleGraph, pagePath: string, onCss?: (path: string) => void): Promise<Map<string, string>>;
|
|
3
|
-
export declare function collectManifestCss(manifest: Manifest, root: string, pagePath: string, onCss?: (path: string, parentUrl: string) => void, parentUrl?: string): Map<string, string>;
|
|
4
|
-
//# sourceMappingURL=collect-css-manifest.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collect-css-manifest.d.ts","sourceRoot":"","sources":["../../plugin/collect-css-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAElD,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,gCAqB/B;AAED,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,EACjD,SAAS,CAAC,EAAE,MAAM,uBAgDnB"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vite-plugin-react-server
|
|
3
|
-
* Copyright (c) Nico Brinkkemper
|
|
4
|
-
* MIT License
|
|
5
|
-
*/
|
|
6
|
-
async function collectModuleGraphCss(moduleGraph, pagePath, onCss) {
|
|
7
|
-
if (!pagePath) return /* @__PURE__ */ new Map();
|
|
8
|
-
const cssFiles = /* @__PURE__ */ new Map();
|
|
9
|
-
const pageModule = await moduleGraph.getModuleByUrl(pagePath, true);
|
|
10
|
-
if (!pageModule) {
|
|
11
|
-
return /* @__PURE__ */ new Map();
|
|
12
|
-
}
|
|
13
|
-
const seen = /* @__PURE__ */ new Set();
|
|
14
|
-
const walkModule = (mod) => {
|
|
15
|
-
if (!mod?.id || seen.has(mod.id)) return;
|
|
16
|
-
seen.add(mod.id);
|
|
17
|
-
if (mod?.id?.endsWith(".css")) {
|
|
18
|
-
cssFiles.set(mod?.url, mod?.id);
|
|
19
|
-
}
|
|
20
|
-
mod?.importedModules?.forEach((imp) => walkModule(imp));
|
|
21
|
-
};
|
|
22
|
-
walkModule(pageModule);
|
|
23
|
-
return cssFiles;
|
|
24
|
-
}
|
|
25
|
-
function collectManifestCss(manifest, root, pagePath, onCss, parentUrl) {
|
|
26
|
-
const relativePagePath = root !== "" && pagePath.startsWith(root.endsWith("/") ? root : root + "/") ? pagePath.slice(root.length + (root.endsWith("/") ? 0 : 1)) : pagePath;
|
|
27
|
-
const cssFiles = /* @__PURE__ */ new Map();
|
|
28
|
-
const seen = /* @__PURE__ */ new Set();
|
|
29
|
-
const manifestValues = Object.values(manifest);
|
|
30
|
-
const walkManifestEntry = (id) => {
|
|
31
|
-
if (seen.has(id)) return;
|
|
32
|
-
seen.add(id);
|
|
33
|
-
if (id.endsWith(".css")) {
|
|
34
|
-
cssFiles.set(id, id);
|
|
35
|
-
onCss?.(id, parentUrl ?? pagePath);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
if (id.endsWith(".css.js")) {
|
|
39
|
-
cssFiles.set(id.slice(0, -3), id.slice(0, -3));
|
|
40
|
-
onCss?.(id.slice(0, -3), parentUrl ?? pagePath);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const entry = manifest[id] ?? manifestValues.find((e) => e.file === id);
|
|
44
|
-
if (!entry) return;
|
|
45
|
-
if (entry.css) {
|
|
46
|
-
entry.css.forEach((css) => {
|
|
47
|
-
cssFiles.set(entry.src ?? entry.file ?? "", css);
|
|
48
|
-
onCss?.(css, parentUrl ?? pagePath);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
if (entry.imports) {
|
|
52
|
-
entry.imports.forEach((imp) => walkManifestEntry(imp));
|
|
53
|
-
}
|
|
54
|
-
if (entry.dynamicImports) {
|
|
55
|
-
entry.dynamicImports.forEach((imp) => walkManifestEntry(imp));
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
if (manifest[relativePagePath]) {
|
|
59
|
-
walkManifestEntry(relativePagePath);
|
|
60
|
-
}
|
|
61
|
-
return cssFiles;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export { collectManifestCss, collectModuleGraphCss };
|
|
65
|
-
//# sourceMappingURL=collect-css-manifest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collect-css-manifest.js","sources":["../../plugin/collect-css-manifest.ts"],"sourcesContent":["import type { Manifest, ModuleGraph } from 'vite';\n\nexport async function collectModuleGraphCss(\n moduleGraph: ModuleGraph,\n pagePath: string,\n onCss?: (path: string) => void\n) {\n if (!pagePath) return new Map<string, string>();\n\n const cssFiles = new Map<string, string>();\n const pageModule = await moduleGraph.getModuleByUrl(pagePath, true);\n if (!pageModule) {\n return new Map<string, string>();\n }\n const seen = new Set<string>();\n const walkModule = (mod: any) => {\n if (!mod?.id || seen.has(mod.id)) return;\n seen.add(mod.id);\n if (mod?.id?.endsWith(\".css\")) {\n cssFiles.set(mod?.url, mod?.id);\n onCss?.(mod?.url);\n }\n mod?.importedModules?.forEach((imp: any) => walkModule(imp));\n };\n walkModule(pageModule);\n return cssFiles;\n}\n\nexport function collectManifestCss(\n manifest: Manifest,\n root: string,\n pagePath: string,\n onCss?: (path: string, parentUrl: string) => void,\n parentUrl?: string\n) {\n const relativePagePath = root !== \"\" && pagePath.startsWith(root.endsWith('/') ? root : root + '/')\n ? pagePath.slice(root.length + (root.endsWith('/') ? 0 : 1))\n : pagePath;\n const cssFiles = new Map<string, string>();\n const seen = new Set<string>();\n const manifestValues = Object.values(manifest);\n const walkManifestEntry = (id: string) => {\n if (seen.has(id)) return;\n seen.add(id);\n if (id.endsWith(\".css\")) {\n cssFiles.set(id, id);\n onCss?.(id, parentUrl ?? pagePath);\n return;\n }\n if (id.endsWith(\".css.js\")) {\n cssFiles.set(id.slice(0, -3), id.slice(0, -3));\n onCss?.(id.slice(0, -3), parentUrl ?? pagePath);\n return;\n }\n // Get the manifest entry\n const entry = manifest[id] ?? manifestValues.find(e => e.file === id);\n if (!entry) return;\n\n // Add direct CSS\n if (entry.css) {\n entry.css.forEach((css: string) => {\n cssFiles.set(entry.src ?? entry.file ?? '', css);\n onCss?.(css, parentUrl ?? pagePath);\n });\n }\n\n // Walk imports recursively\n if (entry.imports) {\n entry.imports.forEach((imp: string) => walkManifestEntry(imp));\n }\n\n // Also check dynamicImports\n if (entry.dynamicImports) {\n entry.dynamicImports.forEach((imp: string) => walkManifestEntry(imp));\n }\n };\n\n if (manifest[relativePagePath]) {\n walkManifestEntry(relativePagePath);\n }\n return cssFiles;\n}\n"],"names":[],"mappings":"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"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare const createModuleIdGenerator: ({ inputRoot, client, server, moduleBase, isProduction, preserveModulesRoot, imports, removeExtension }: {
|
|
2
|
-
isProduction: boolean;
|
|
3
|
-
inputRoot: string;
|
|
4
|
-
client: string;
|
|
5
|
-
server: string;
|
|
6
|
-
moduleBase: string;
|
|
7
|
-
preserveModulesRoot: boolean;
|
|
8
|
-
removeExtension: ((path: string) => boolean) | string | RegExp;
|
|
9
|
-
imports: Record<string, string>;
|
|
10
|
-
}) => (moduleIdPath: string, ssr?: boolean) => string;
|
|
11
|
-
//# sourceMappingURL=createModuleIdGenerator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createModuleIdGenerator.d.ts","sourceRoot":"","sources":["../../../plugin/config/createModuleIdGenerator.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,uBAAuB,2GASjC;IACD,YAAY,EAAE,OAAO,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,eAAe,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC;IAC/D,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC,oBAMuB,MAAM,0BAyB7B,CAAC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vite-plugin-react-server
|
|
3
|
-
* Copyright (c) Nico Brinkkemper
|
|
4
|
-
* MIT License
|
|
5
|
-
*/
|
|
6
|
-
import { createInputNormalizer } from '../helpers/inputNormalizer.js';
|
|
7
|
-
|
|
8
|
-
const createModuleIdGenerator = ({
|
|
9
|
-
inputRoot,
|
|
10
|
-
client,
|
|
11
|
-
server,
|
|
12
|
-
moduleBase,
|
|
13
|
-
isProduction,
|
|
14
|
-
preserveModulesRoot,
|
|
15
|
-
imports,
|
|
16
|
-
removeExtension
|
|
17
|
-
}) => {
|
|
18
|
-
const normalizer = createInputNormalizer({
|
|
19
|
-
root: inputRoot,
|
|
20
|
-
removeExtension,
|
|
21
|
-
preserveModulesRoot: preserveModulesRoot === true ? moduleBase : undefined
|
|
22
|
-
});
|
|
23
|
-
return (moduleIdPath, ssr = isProduction) => {
|
|
24
|
-
const [moduleId, modulePath] = normalizer(moduleIdPath);
|
|
25
|
-
const key = preserveModulesRoot ? `${moduleBase}/${moduleId}` : moduleId;
|
|
26
|
-
const hasImports = key in imports;
|
|
27
|
-
if (hasImports) {
|
|
28
|
-
const mappedImport = imports[key];
|
|
29
|
-
const noRoot = mappedImport.startsWith(inputRoot) ? mappedImport.slice(inputRoot.length + 1) : mappedImport;
|
|
30
|
-
const noModuleBase = preserveModulesRoot ? noRoot.startsWith(moduleBase) ? noRoot.slice(moduleBase.length) : noRoot : noRoot;
|
|
31
|
-
return noModuleBase;
|
|
32
|
-
} else if (ssr && isProduction) {
|
|
33
|
-
const availableImports = Object.keys(imports).length > 0 ? Object.keys(imports).join(", ") : "none";
|
|
34
|
-
throw new Error(
|
|
35
|
-
`${availableImports === "none" ? "No imports." : `Module ID ${key}, ${modulePath} is not in imports. Available imports: ${availableImports}`}`
|
|
36
|
-
);
|
|
37
|
-
} else {
|
|
38
|
-
return moduleId;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export { createModuleIdGenerator };
|
|
44
|
-
//# sourceMappingURL=createModuleIdGenerator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createModuleIdGenerator.js","sources":["../../../plugin/config/createModuleIdGenerator.ts"],"sourcesContent":["import { createInputNormalizer } from \"../helpers/inputNormalizer.js\";\n\nexport const createModuleIdGenerator = ({\n inputRoot,\n client,\n server,\n moduleBase,\n isProduction,\n preserveModulesRoot,\n imports,\n removeExtension\n}: {\n isProduction: boolean;\n inputRoot: string;\n client: string;\n server: string;\n moduleBase: string;\n preserveModulesRoot: boolean;\n removeExtension: ((path: string) => boolean) | string | RegExp;\n imports: Record<string, string>;\n}) => {\n const normalizer = createInputNormalizer({\n root: inputRoot,\n removeExtension: removeExtension,\n preserveModulesRoot: preserveModulesRoot === true ? moduleBase : undefined,\n });\n return (moduleIdPath: string, ssr = isProduction) => {\n const [moduleId, modulePath] = normalizer(moduleIdPath);\n const key = preserveModulesRoot ? `${moduleBase}/${moduleId}` : moduleId;\n const hasImports = key in imports;\n\n if (hasImports) {\n // Return the actual file path from the manifest\n const mappedImport = imports[key];\n const noRoot = mappedImport.startsWith(inputRoot) ? mappedImport.slice(inputRoot.length +1) : mappedImport;\n const noModuleBase = preserveModulesRoot ? noRoot.startsWith(moduleBase) ? noRoot.slice(moduleBase.length) : noRoot : noRoot;\n return noModuleBase;\n } else if (ssr && isProduction) {\n // Only throw in production SSR builds\n const availableImports =\n Object.keys(imports).length > 0\n ? Object.keys(imports).join(\", \")\n : \"none\";\n throw new Error(\n `${availableImports === \"none\" ? \"No imports.\" : `Module ID ${key}, ${modulePath} is not in imports. Available imports: ${availableImports}`}`\n );\n } else {\n // For development or non-SSR builds, use the module ID\n return moduleId;\n }\n };\n};\n"],"names":[],"mappings":";;;;;;;AAEO,MAAM,0BAA0B,CAAC;AAAA,EACtC,SAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,mBAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CASM,KAAA;AACJ,EAAA,MAAM,aAAa,qBAAsB,CAAA;AAAA,IACvC,IAAM,EAAA,SAAA;AAAA,IACN,eAAA;AAAA,IACA,mBAAA,EAAqB,mBAAwB,KAAA,IAAA,GAAO,UAAa,GAAA;AAAA,GAClE,CAAA;AACD,EAAO,OAAA,CAAC,YAAsB,EAAA,GAAA,GAAM,YAAiB,KAAA;AACnD,IAAA,MAAM,CAAC,QAAA,EAAU,UAAU,CAAA,GAAI,WAAW,YAAY,CAAA;AACtD,IAAA,MAAM,MAAM,mBAAsB,GAAA,CAAA,EAAG,UAAU,CAAA,CAAA,EAAI,QAAQ,CAAK,CAAA,GAAA,QAAA;AAChE,IAAA,MAAM,aAAa,GAAO,IAAA,OAAA;AAE1B,IAAA,IAAI,UAAY,EAAA;AAEd,MAAM,MAAA,YAAA,GAAe,QAAQ,GAAG,CAAA;AAChC,MAAM,MAAA,MAAA,GAAS,YAAa,CAAA,UAAA,CAAW,SAAS,CAAA,GAAI,aAAa,KAAM,CAAA,SAAA,CAAU,MAAQ,GAAA,CAAC,CAAI,GAAA,YAAA;AAC9F,MAAM,MAAA,YAAA,GAAe,mBAAsB,GAAA,MAAA,CAAO,UAAW,CAAA,UAAU,CAAI,GAAA,MAAA,CAAO,KAAM,CAAA,UAAA,CAAW,MAAM,CAAA,GAAI,MAAS,GAAA,MAAA;AACtH,MAAO,OAAA,YAAA;AAAA,KACT,MAAA,IAAW,OAAO,YAAc,EAAA;AAE9B,MAAA,MAAM,gBACJ,GAAA,MAAA,CAAO,IAAK,CAAA,OAAO,CAAE,CAAA,MAAA,GAAS,CAC1B,GAAA,MAAA,CAAO,IAAK,CAAA,OAAO,CAAE,CAAA,IAAA,CAAK,IAAI,CAC9B,GAAA,MAAA;AACN,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,EAAG,gBAAqB,KAAA,MAAA,GAAS,aAAgB,GAAA,CAAA,UAAA,EAAa,GAAG,CAAK,EAAA,EAAA,UAAU,CAA0C,uCAAA,EAAA,gBAAgB,CAAE,CAAA,CAAA;AAAA,OAC9I;AAAA,KACK,MAAA;AAEL,MAAO,OAAA,QAAA;AAAA;AACT,GACF;AACF;;;;"}
|
package/dist/plugin/getEnv.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ConfigEnv, UserConfig } from "vite";
|
|
2
|
-
/**
|
|
3
|
-
* Get environment variables for Vite, sets defaults to ensure the server can start with BASE_URL and PUBLIC_URL
|
|
4
|
-
*
|
|
5
|
-
* @param config - Vite configuration object
|
|
6
|
-
* @param { isPreview: boolean } - Object containing a boolean indicating if the environment is for preview
|
|
7
|
-
* @returns An object containing the environment variables
|
|
8
|
-
*/
|
|
9
|
-
export declare function getEnv(config: UserConfig, configEnv: ConfigEnv): {
|
|
10
|
-
baseUrl: string;
|
|
11
|
-
publicUrl: string;
|
|
12
|
-
port: number;
|
|
13
|
-
host: string | boolean;
|
|
14
|
-
envPrefix: string;
|
|
15
|
-
environmentName: string;
|
|
16
|
-
env: Record<string, string>;
|
|
17
|
-
define: any;
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=getEnv.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getEnv.d.ts","sourceRoot":"","sources":["../../plugin/getEnv.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAIlD;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS;;;;;;;;;EAyH9D"}
|
package/dist/plugin/getEnv.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
import { resolve } from "node:path";
|
|
3
|
-
import { loadEnv } from "vite";
|
|
4
|
-
import { DEFAULT_CONFIG } from "./config/defaults.js";
|
|
5
|
-
/**
|
|
6
|
-
* Get environment variables for Vite, sets defaults to ensure the server can start with BASE_URL and PUBLIC_URL
|
|
7
|
-
*
|
|
8
|
-
* @param config - Vite configuration object
|
|
9
|
-
* @param { isPreview: boolean } - Object containing a boolean indicating if the environment is for preview
|
|
10
|
-
* @returns An object containing the environment variables
|
|
11
|
-
*/
|
|
12
|
-
export function getEnv(config, configEnv) {
|
|
13
|
-
const isLocal = config.mode === "development";
|
|
14
|
-
const envName = isLocal
|
|
15
|
-
? `${config.mode}.local`
|
|
16
|
-
: config.mode
|
|
17
|
-
? config.mode
|
|
18
|
-
: "production";
|
|
19
|
-
const environmentName = config.mode ?? envName ?? "production";
|
|
20
|
-
const env = loadEnv(environmentName, config.envDir ?? config.root ?? process.cwd(), config.envPrefix ?? DEFAULT_CONFIG.ENV_PREFIX ?? "VITE_");
|
|
21
|
-
// Get server config
|
|
22
|
-
const serverConfig = config.server || {};
|
|
23
|
-
const previewConfig = config.preview || {};
|
|
24
|
-
const host = configEnv.isPreview
|
|
25
|
-
? previewConfig.host ?? DEFAULT_CONFIG.PREVIEW_HOST
|
|
26
|
-
: serverConfig.host ?? DEFAULT_CONFIG.DEV_HOST;
|
|
27
|
-
let previewPort = previewConfig.port ?? DEFAULT_CONFIG.PREVIEW_PORT;
|
|
28
|
-
let devPort = serverConfig.port ?? DEFAULT_CONFIG.DEV_PORT;
|
|
29
|
-
let homepage = env["VITE_BASE_URL"];
|
|
30
|
-
if (configEnv.command === "build" && (!homepage || homepage === "")) {
|
|
31
|
-
try {
|
|
32
|
-
const packageJson = JSON.parse(readFileSync(resolve(config.root ?? "", "package.json"), "utf-8"));
|
|
33
|
-
homepage = packageJson.homepage ?? "";
|
|
34
|
-
if (!homepage || homepage === "") {
|
|
35
|
-
console.warn("[RSC] 🔧 For production builds, please set 'homepage' in package.json, or set VITE_BASE_URL in your environment");
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
catch (e) {
|
|
39
|
-
console.error(e);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
let baseUrl = env["VITE_BASE_URL"] && env["VITE_PUBLIC_URL"] !== ""
|
|
43
|
-
? env["VITE_BASE_URL"]
|
|
44
|
-
: configEnv.isPreview
|
|
45
|
-
? `http://${host}:${previewPort}`
|
|
46
|
-
: configEnv.command === "serve"
|
|
47
|
-
? `http://${host}:${devPort}`
|
|
48
|
-
: homepage;
|
|
49
|
-
let publicUrl = env["VITE_PUBLIC_URL"] && env["VITE_PUBLIC_URL"] !== ""
|
|
50
|
-
? env["VITE_PUBLIC_URL"]
|
|
51
|
-
: "";
|
|
52
|
-
// Determine port and host based on mode
|
|
53
|
-
const port = configEnv.isPreview
|
|
54
|
-
? previewConfig.port || DEFAULT_CONFIG.PREVIEW_PORT // Preview server
|
|
55
|
-
: serverConfig.port || DEFAULT_CONFIG.DEV_PORT; // Dev server
|
|
56
|
-
// Build base URL
|
|
57
|
-
if (configEnv.isPreview && `http://${host}:${port}` !== baseUrl) {
|
|
58
|
-
console.log(`VITE_BASE_URL: \"${baseUrl}\" wasn't configured correctly for this server, overriding to: \"http://${host}:${port}\"`);
|
|
59
|
-
baseUrl = `http://${host}:${port}`;
|
|
60
|
-
}
|
|
61
|
-
const envPrefix = typeof config.envPrefix === "string"
|
|
62
|
-
? config.envPrefix
|
|
63
|
-
: Array.isArray(config.envPrefix)
|
|
64
|
-
? config.envPrefix[0]
|
|
65
|
-
: DEFAULT_CONFIG.ENV_PREFIX;
|
|
66
|
-
const nodeProcessEnv = {
|
|
67
|
-
NODE_ENV: configEnv.command === "build" ? "production" : "development",
|
|
68
|
-
};
|
|
69
|
-
const defineProcess = Object.entries(nodeProcessEnv)
|
|
70
|
-
.map(([key, value]) => {
|
|
71
|
-
switch (key) {
|
|
72
|
-
case "NODE_ENV":
|
|
73
|
-
const isDev = value === ""
|
|
74
|
-
? configEnv.command === "build"
|
|
75
|
-
? false
|
|
76
|
-
: true
|
|
77
|
-
: value === "development";
|
|
78
|
-
return [`import.meta.env.DEV`, JSON.stringify(isDev)];
|
|
79
|
-
default:
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
|
-
.filter(Array.isArray);
|
|
84
|
-
const defineImportMeta = Object.entries(env).map(([key, value]) => [
|
|
85
|
-
`import.meta.env.${key}`,
|
|
86
|
-
key === "VITE_BASE_URL"
|
|
87
|
-
? value
|
|
88
|
-
? JSON.stringify(value)
|
|
89
|
-
: JSON.stringify(baseUrl)
|
|
90
|
-
: key === "VITE_PUBLIC_URL"
|
|
91
|
-
? value
|
|
92
|
-
? JSON.stringify(value)
|
|
93
|
-
: JSON.stringify(publicUrl)
|
|
94
|
-
: JSON.stringify(value),
|
|
95
|
-
]);
|
|
96
|
-
const define = Object.fromEntries([...defineProcess, ...defineImportMeta]);
|
|
97
|
-
return {
|
|
98
|
-
baseUrl,
|
|
99
|
-
publicUrl,
|
|
100
|
-
port,
|
|
101
|
-
host,
|
|
102
|
-
envPrefix,
|
|
103
|
-
environmentName,
|
|
104
|
-
env,
|
|
105
|
-
define,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { ModuleGraph, type Manifest } from "vite";
|
|
2
|
-
type BaseCssLoaderOptions = {
|
|
3
|
-
/** callback to add css files to the stream */
|
|
4
|
-
onCssFile: (css: string) => void;
|
|
5
|
-
/** loader to load the module */
|
|
6
|
-
loader: (id: string) => Promise<Record<string, any>>;
|
|
7
|
-
/** url of the page */
|
|
8
|
-
url: string;
|
|
9
|
-
/** manually provided css files to add */
|
|
10
|
-
cssFiles: string[];
|
|
11
|
-
};
|
|
12
|
-
type CreateCssLoaderOptions = (BaseCssLoaderOptions & {
|
|
13
|
-
/** manifest to collect css from */
|
|
14
|
-
manifest: Manifest;
|
|
15
|
-
/** when manifest is given, moduleGraph is not needed */
|
|
16
|
-
moduleGraph?: never;
|
|
17
|
-
}) | (BaseCssLoaderOptions & {
|
|
18
|
-
/** when moduleGraph is given, manifest is not needed, manual cssFiles can still be provided */
|
|
19
|
-
manifest?: never;
|
|
20
|
-
/** when moduleGraph is given, manifest is not needed, manual cssFiles can still be provided */
|
|
21
|
-
moduleGraph: ModuleGraph;
|
|
22
|
-
});
|
|
23
|
-
/**
|
|
24
|
-
* create a loader that can be used to load css files from a manifest or a moduleGraph
|
|
25
|
-
* @param options
|
|
26
|
-
* @returns
|
|
27
|
-
*/
|
|
28
|
-
export declare function createCssLoader(options: CreateCssLoaderOptions): Promise<(id: string) => Promise<Record<string, any>>>;
|
|
29
|
-
export {};
|
|
30
|
-
//# sourceMappingURL=createCssLoader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createCssLoader.d.ts","sourceRoot":"","sources":["../../../plugin/loader/createCssLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,MAAM,MAAM,CAAC;AAMlD,KAAK,oBAAoB,GAAG;IAC1B,8CAA8C;IAC9C,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,gCAAgC;IAChC,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IACrD,sBAAsB;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,yCAAyC;IACzC,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,KAAK,sBAAsB,GACvB,CAAC,oBAAoB,GAAG;IACtB,mCAAmC;IACnC,QAAQ,EAAE,QAAQ,CAAC;IACnB,wDAAwD;IACxD,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB,CAAC,GACF,CAAC,oBAAoB,GAAG;IACtB,+FAA+F;IAC/F,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,+FAA+F;IAC/F,WAAW,EAAE,WAAW,CAAC;CAC1B,CAAC,CAAC;AAEP;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,sBAAsB,gBAkBpC,MAAM,mCAkBtC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ModuleGraph } from "vite";
|
|
2
|
-
import { collectManifestCss, collectModuleGraphCss, } from "../collect-css-manifest.js";
|
|
3
|
-
/**
|
|
4
|
-
* create a loader that can be used to load css files from a manifest or a moduleGraph
|
|
5
|
-
* @param options
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
export async function createCssLoader(options) {
|
|
9
|
-
const root = process.cwd();
|
|
10
|
-
const cssModules = new Set();
|
|
11
|
-
if (!(options.manifest || options.moduleGraph))
|
|
12
|
-
throw new Error("Missing manifest or moduleGraph, pass it to options.");
|
|
13
|
-
const getCss = options.manifest
|
|
14
|
-
? (id) => collectManifestCss(options.manifest, root, id, options.onCssFile)
|
|
15
|
-
: (id) => collectModuleGraphCss(options.moduleGraph, id, options.onCssFile);
|
|
16
|
-
const loadWithCss = async (id) => {
|
|
17
|
-
if (!id)
|
|
18
|
-
return {};
|
|
19
|
-
try {
|
|
20
|
-
const mod = await options.loader(id);
|
|
21
|
-
const pageCss = await Promise.resolve(getCss(id));
|
|
22
|
-
Array.from(pageCss.keys()).forEach((css) => cssModules.add(css));
|
|
23
|
-
return mod;
|
|
24
|
-
}
|
|
25
|
-
catch (e) {
|
|
26
|
-
if (e.message?.includes("module runner has been closed")) {
|
|
27
|
-
return { type: "skip" };
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return { type: "error", error: e };
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
return loadWithCss;
|
|
35
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
type CreatePageLoaderOptions = {
|
|
2
|
-
manifest: Record<string, {
|
|
3
|
-
file: string;
|
|
4
|
-
src?: string;
|
|
5
|
-
}>;
|
|
6
|
-
root: string;
|
|
7
|
-
outDir: string;
|
|
8
|
-
moduleBase: string;
|
|
9
|
-
registerServer?: string[];
|
|
10
|
-
registerClient?: string[];
|
|
11
|
-
alwaysRegisterServer?: boolean;
|
|
12
|
-
alwaysRegisterClient?: boolean;
|
|
13
|
-
};
|
|
14
|
-
type CreateDefaultLoaderOptions = {
|
|
15
|
-
id: string;
|
|
16
|
-
registerServer?: string[];
|
|
17
|
-
registerClient?: string[];
|
|
18
|
-
alwaysRegisterServer?: boolean;
|
|
19
|
-
alwaysRegisterClient?: boolean;
|
|
20
|
-
};
|
|
21
|
-
export declare const createDefaultLoader: ({ id, registerServer, registerClient, alwaysRegisterServer, alwaysRegisterClient, }: CreateDefaultLoaderOptions) => (url: string) => Promise<any>;
|
|
22
|
-
export declare function createPageLoader({ manifest, root, outDir, moduleBase, alwaysRegisterServer, alwaysRegisterClient, registerServer, registerClient, }: CreatePageLoaderOptions): (id: string) => Promise<any>;
|
|
23
|
-
export {};
|
|
24
|
-
//# sourceMappingURL=createPageLoader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createPageLoader.d.ts","sourceRoot":"","sources":["../../../plugin/loader/createPageLoader.ts"],"names":[],"mappings":"AAaA,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,mBAAmB,wFAM7B,0BAA0B,WAqBR,MAAM,iBAM1B,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,UAAU,EACV,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,cAAc,GACf,EAAE,uBAAuB,QACS,MAAM,kBAyBxC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { resolve as resolvePath } from "node:path";
|
|
2
|
-
import { load
|
|
3
|
-
// @ts-ignore
|
|
4
|
-
} from "react-server-dom-esm/node-loader";
|
|
5
|
-
import { registerClientReference, registerServerReference,
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
} from "react-server-dom-esm/server.node";
|
|
8
|
-
export const createDefaultLoader = ({ id, registerServer, registerClient, alwaysRegisterServer = false, alwaysRegisterClient = false, }) => {
|
|
9
|
-
const mapper = ([key, value]) => {
|
|
10
|
-
try {
|
|
11
|
-
if (registerClient?.includes(key) ||
|
|
12
|
-
(alwaysRegisterClient && typeof value === "function")) {
|
|
13
|
-
return [key, registerClientReference(value, id, key)];
|
|
14
|
-
}
|
|
15
|
-
if (registerServer?.includes(key) ||
|
|
16
|
-
(alwaysRegisterServer && typeof value === "function")) {
|
|
17
|
-
return [key, registerServerReference(value, id, key)];
|
|
18
|
-
}
|
|
19
|
-
return [key, value];
|
|
20
|
-
}
|
|
21
|
-
catch (e) {
|
|
22
|
-
console.error("[RSC] Error registering reference:", key, value, e);
|
|
23
|
-
return [key, value];
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
return async (url) => {
|
|
27
|
-
console.log("[createDefaultLoader] Loading:", url);
|
|
28
|
-
const result = await import(url);
|
|
29
|
-
console.log("[createDefaultLoader] Result:", result);
|
|
30
|
-
return Object.fromEntries(Object.entries(result).map(mapper));
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
export function createPageLoader({ manifest, root, outDir, moduleBase, alwaysRegisterServer, alwaysRegisterClient, registerServer, registerClient, }) {
|
|
34
|
-
return async function loader(id) {
|
|
35
|
-
// Try to find the entry directly or by source file
|
|
36
|
-
const manifestEntry = manifest[id] ||
|
|
37
|
-
Object.values(manifest).find(entry => entry.src === id);
|
|
38
|
-
if (!manifestEntry) {
|
|
39
|
-
throw new Error(`Could not find manifest entry for ${id} from ${root}. Available entries: ${Object.keys(manifest).join(', ')}`);
|
|
40
|
-
}
|
|
41
|
-
const loaderResult = await load(resolvePath(root, outDir, manifestEntry.file), { format: "module" }, createDefaultLoader({
|
|
42
|
-
id,
|
|
43
|
-
registerServer,
|
|
44
|
-
registerClient,
|
|
45
|
-
alwaysRegisterServer,
|
|
46
|
-
alwaysRegisterClient,
|
|
47
|
-
}));
|
|
48
|
-
return loaderResult;
|
|
49
|
-
};
|
|
50
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"messageHandler.d.ts","sourceRoot":"","sources":["../../../../plugin/loader/rsc/messageHandler.tsx"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rsc-worker.development.d.ts","sourceRoot":"","sources":["../../../../plugin/loader/rsc/rsc-worker.development.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ViteDevServer } from "vite";
|
|
2
|
-
export interface ModuleWithDeps {
|
|
3
|
-
id: string;
|
|
4
|
-
deps: Set<string>;
|
|
5
|
-
css: Set<string>;
|
|
6
|
-
}
|
|
7
|
-
export declare function getModuleGraph(server: ViteDevServer): {
|
|
8
|
-
getModuleWithDeps(id: string): Promise<ModuleWithDeps>;
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=module-graph.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module-graph.d.ts","sourceRoot":"","sources":["../../plugin/module-graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,aAAa,EAAE,MAAM,MAAM,CAAC;AAEtD,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClB,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAClB;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa;0BAEpB,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;EAqC/D"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export function getModuleGraph(server) {
|
|
2
|
-
return {
|
|
3
|
-
async getModuleWithDeps(id) {
|
|
4
|
-
// Load module first to ensure it's in the module graph
|
|
5
|
-
await server.ssrLoadModule(id);
|
|
6
|
-
const resolvedId = await server.pluginContainer.resolveId(id, undefined, {
|
|
7
|
-
// Add ssr and react-server conditions
|
|
8
|
-
ssr: true,
|
|
9
|
-
});
|
|
10
|
-
if (!resolvedId)
|
|
11
|
-
throw new Error(`Module not found: ${id}`);
|
|
12
|
-
const moduleNode = server.moduleGraph.getModuleById(resolvedId.id);
|
|
13
|
-
if (!moduleNode)
|
|
14
|
-
throw new Error(`Module node not found: ${id}`);
|
|
15
|
-
const deps = new Set();
|
|
16
|
-
const css = new Set();
|
|
17
|
-
// Recursively collect dependencies
|
|
18
|
-
const collectDeps = (node) => {
|
|
19
|
-
// Track CSS imports
|
|
20
|
-
if (node.id?.endsWith(".css") && node.id) {
|
|
21
|
-
css.add(node.id);
|
|
22
|
-
}
|
|
23
|
-
// Track all dependencies
|
|
24
|
-
for (const dep of node.importedModules) {
|
|
25
|
-
if (dep.id && !deps.has(dep.id)) {
|
|
26
|
-
deps.add(dep.id);
|
|
27
|
-
collectDeps(dep);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
collectDeps(moduleNode);
|
|
32
|
-
return { id: moduleNode.id ?? "", deps, css };
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { PipeableStream } from "react-dom/server";
|
|
2
|
-
import type { CreateHandlerOptions, ResolvedUserOptions } from "../types.js";
|
|
3
|
-
type CreateHandlerResult = {
|
|
4
|
-
type: "success";
|
|
5
|
-
controller: AbortController;
|
|
6
|
-
stream: PipeableStream;
|
|
7
|
-
assets: any;
|
|
8
|
-
clientPath: string;
|
|
9
|
-
} | {
|
|
10
|
-
type: "error";
|
|
11
|
-
error: Error;
|
|
12
|
-
} | {
|
|
13
|
-
type: "skip";
|
|
14
|
-
};
|
|
15
|
-
export declare function createHandler<T>(url: string, pluginOptions: ResolvedUserOptions, streamOptions: CreateHandlerOptions<T>): Promise<CreateHandlerResult>;
|
|
16
|
-
export {};
|
|
17
|
-
//# sourceMappingURL=createHandler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,mBAAmB,EAClC,aAAa,EAAE,oBAAoB,CAAC,CAAC,CAAC,GACrC,OAAO,CAAC,mBAAmB,CAAC,CAuI9B"}
|