@cedarjs/vite 0.0.4
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/LICENSE +21 -0
- package/bins/rw-vite-build.mjs +61 -0
- package/bins/rw-vite-dev.mjs +57 -0
- package/bins/vite.mjs +12 -0
- package/dist/build/build.d.ts +21 -0
- package/dist/build/build.d.ts.map +1 -0
- package/dist/build/build.js +78 -0
- package/dist/buildFeServer.d.ts +6 -0
- package/dist/buildFeServer.d.ts.map +1 -0
- package/dist/buildFeServer.js +39 -0
- package/dist/buildRouteHooks.d.ts +3 -0
- package/dist/buildRouteHooks.d.ts.map +1 -0
- package/dist/buildRouteHooks.js +45 -0
- package/dist/buildRouteManifest.d.ts +6 -0
- package/dist/buildRouteManifest.d.ts.map +1 -0
- package/dist/buildRouteManifest.js +58 -0
- package/dist/buildRscClientAndServer.d.ts +4 -0
- package/dist/buildRscClientAndServer.d.ts.map +1 -0
- package/dist/buildRscClientAndServer.js +30 -0
- package/dist/bundled/react-server-dom-webpack.server.d.ts +2 -0
- package/dist/bundled/react-server-dom-webpack.server.d.ts.map +1 -0
- package/dist/bundled/react-server-dom-webpack.server.js +33529 -0
- package/dist/cjs/ClientRouter.d.ts +1 -0
- package/dist/cjs/build/build.d.ts +1 -0
- package/dist/cjs/build/build.js +116 -0
- package/dist/cjs/buildFeServer.d.ts +1 -0
- package/dist/cjs/buildFeServer.js +63 -0
- package/dist/cjs/buildRouteHooks.js +66 -0
- package/dist/cjs/buildRouteManifest.js +92 -0
- package/dist/cjs/buildRscClientAndServer.js +54 -0
- package/dist/cjs/client.d.ts +1 -0
- package/dist/cjs/clientSsr.d.ts +1 -0
- package/dist/cjs/devFeServer.js +153 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +184 -0
- package/dist/cjs/lib/StatusError.js +36 -0
- package/dist/cjs/lib/entries.js +53 -0
- package/dist/cjs/lib/envVarDefinitions.js +87 -0
- package/dist/cjs/lib/getMergedConfig.js +187 -0
- package/dist/cjs/lib/onWarn.js +36 -0
- package/dist/cjs/lib/registerFwGlobalsAndShims.js +117 -0
- package/dist/cjs/middleware/index.js +22 -0
- package/dist/cjs/middleware/invokeMiddleware.js +52 -0
- package/dist/cjs/middleware/register.js +106 -0
- package/dist/cjs/middleware/types.js +16 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/plugins/vite-plugin-jsx-loader.js +42 -0
- package/dist/cjs/plugins/vite-plugin-remove-from-bundle.js +56 -0
- package/dist/cjs/plugins/vite-plugin-rsc-analyze.js +104 -0
- package/dist/cjs/plugins/vite-plugin-rsc-reload.js +75 -0
- package/dist/cjs/plugins/vite-plugin-rsc-routes-auto-loader.js +159 -0
- package/dist/cjs/plugins/vite-plugin-rsc-routes-imports.js +125 -0
- package/dist/cjs/plugins/vite-plugin-rsc-ssr-router-import.js +75 -0
- package/dist/cjs/plugins/vite-plugin-rsc-transform-client.js +229 -0
- package/dist/cjs/plugins/vite-plugin-rsc-transform-server.js +398 -0
- package/dist/cjs/plugins/vite-plugin-swap-apollo-provider.js +41 -0
- package/dist/cjs/rsc/rscBuildAnalyze.js +116 -0
- package/dist/cjs/rsc/rscBuildClient.js +91 -0
- package/dist/cjs/rsc/rscBuildCopyCssAssets.js +56 -0
- package/dist/cjs/rsc/rscBuildEntriesFile.js +115 -0
- package/dist/cjs/rsc/rscBuildForServer.js +157 -0
- package/dist/cjs/rsc/rscBuildForSsr.js +172 -0
- package/dist/cjs/rsc/rscBuildRwEnvVars.js +56 -0
- package/dist/cjs/rsc/rscRenderer.js +165 -0
- package/dist/cjs/rsc/rscRequestHandler.js +162 -0
- package/dist/cjs/rsc/rscStudioHandlers.js +154 -0
- package/dist/cjs/runFeServer.js +166 -0
- package/dist/cjs/streaming/buildForStreamingServer.js +65 -0
- package/dist/cjs/streaming/collectCss.js +52 -0
- package/dist/cjs/streaming/createReactStreamingHandler.js +173 -0
- package/dist/cjs/streaming/streamHelpers.js +228 -0
- package/dist/cjs/streaming/transforms/bufferedTransform.js +61 -0
- package/dist/cjs/streaming/transforms/cancelTimeoutTransform.js +34 -0
- package/dist/cjs/streaming/transforms/encode-decode.js +36 -0
- package/dist/cjs/streaming/transforms/serverInjectionTransform.js +84 -0
- package/dist/cjs/streaming/triggerRouteHooks.js +96 -0
- package/dist/cjs/types.js +16 -0
- package/dist/cjs/utils.js +91 -0
- package/dist/devFeServer.d.ts +2 -0
- package/dist/devFeServer.d.ts.map +1 -0
- package/dist/devFeServer.js +134 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +154 -0
- package/dist/lib/StatusError.d.ts +8 -0
- package/dist/lib/StatusError.d.ts.map +1 -0
- package/dist/lib/StatusError.js +11 -0
- package/dist/lib/entries.d.ts +3 -0
- package/dist/lib/entries.d.ts.map +1 -0
- package/dist/lib/entries.js +32 -0
- package/dist/lib/envVarDefinitions.d.ts +14 -0
- package/dist/lib/envVarDefinitions.d.ts.map +1 -0
- package/dist/lib/envVarDefinitions.js +53 -0
- package/dist/lib/getMergedConfig.d.ts +11 -0
- package/dist/lib/getMergedConfig.d.ts.map +1 -0
- package/dist/lib/getMergedConfig.js +153 -0
- package/dist/lib/onWarn.d.ts +3 -0
- package/dist/lib/onWarn.d.ts.map +1 -0
- package/dist/lib/onWarn.js +12 -0
- package/dist/lib/registerFwGlobalsAndShims.d.ts +12 -0
- package/dist/lib/registerFwGlobalsAndShims.d.ts.map +1 -0
- package/dist/lib/registerFwGlobalsAndShims.js +83 -0
- package/dist/middleware/index.d.ts +2 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +1 -0
- package/dist/middleware/invokeMiddleware.d.ts +14 -0
- package/dist/middleware/invokeMiddleware.d.ts.map +1 -0
- package/dist/middleware/invokeMiddleware.js +32 -0
- package/dist/middleware/register.d.ts +23 -0
- package/dist/middleware/register.d.ts.map +1 -0
- package/dist/middleware/register.js +69 -0
- package/dist/middleware/types.d.ts +3 -0
- package/dist/middleware/types.d.ts.map +1 -0
- package/dist/middleware/types.js +0 -0
- package/dist/package.json +1 -0
- package/dist/plugins/vite-plugin-jsx-loader.d.ts +8 -0
- package/dist/plugins/vite-plugin-jsx-loader.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-jsx-loader.js +18 -0
- package/dist/plugins/vite-plugin-remove-from-bundle.d.ts +17 -0
- package/dist/plugins/vite-plugin-remove-from-bundle.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-remove-from-bundle.js +31 -0
- package/dist/plugins/vite-plugin-rsc-analyze.d.ts +3 -0
- package/dist/plugins/vite-plugin-rsc-analyze.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-rsc-analyze.js +70 -0
- package/dist/plugins/vite-plugin-rsc-reload.d.ts +3 -0
- package/dist/plugins/vite-plugin-rsc-reload.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-rsc-reload.js +41 -0
- package/dist/plugins/vite-plugin-rsc-routes-auto-loader.d.ts +3 -0
- package/dist/plugins/vite-plugin-rsc-routes-auto-loader.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-rsc-routes-auto-loader.js +130 -0
- package/dist/plugins/vite-plugin-rsc-routes-imports.d.ts +3 -0
- package/dist/plugins/vite-plugin-rsc-routes-imports.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-rsc-routes-imports.js +96 -0
- package/dist/plugins/vite-plugin-rsc-ssr-router-import.d.ts +7 -0
- package/dist/plugins/vite-plugin-rsc-ssr-router-import.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-rsc-ssr-router-import.js +41 -0
- package/dist/plugins/vite-plugin-rsc-transform-client.d.ts +3 -0
- package/dist/plugins/vite-plugin-rsc-transform-client.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-rsc-transform-client.js +195 -0
- package/dist/plugins/vite-plugin-rsc-transform-server.d.ts +3 -0
- package/dist/plugins/vite-plugin-rsc-transform-server.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-rsc-transform-server.js +364 -0
- package/dist/plugins/vite-plugin-swap-apollo-provider.d.ts +12 -0
- package/dist/plugins/vite-plugin-swap-apollo-provider.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-swap-apollo-provider.js +17 -0
- package/dist/rsc/rscBuildAnalyze.d.ts +16 -0
- package/dist/rsc/rscBuildAnalyze.d.ts.map +1 -0
- package/dist/rsc/rscBuildAnalyze.js +92 -0
- package/dist/rsc/rscBuildClient.d.ts +7 -0
- package/dist/rsc/rscBuildClient.d.ts.map +1 -0
- package/dist/rsc/rscBuildClient.js +67 -0
- package/dist/rsc/rscBuildCopyCssAssets.d.ts +7 -0
- package/dist/rsc/rscBuildCopyCssAssets.d.ts.map +1 -0
- package/dist/rsc/rscBuildCopyCssAssets.js +22 -0
- package/dist/rsc/rscBuildEntriesFile.d.ts +10 -0
- package/dist/rsc/rscBuildEntriesFile.d.ts.map +1 -0
- package/dist/rsc/rscBuildEntriesFile.js +81 -0
- package/dist/rsc/rscBuildForServer.d.ts +7 -0
- package/dist/rsc/rscBuildForServer.d.ts.map +1 -0
- package/dist/rsc/rscBuildForServer.js +133 -0
- package/dist/rsc/rscBuildForSsr.d.ts +9 -0
- package/dist/rsc/rscBuildForSsr.d.ts.map +1 -0
- package/dist/rsc/rscBuildForSsr.js +138 -0
- package/dist/rsc/rscBuildRwEnvVars.d.ts +10 -0
- package/dist/rsc/rscBuildRwEnvVars.d.ts.map +1 -0
- package/dist/rsc/rscBuildRwEnvVars.js +22 -0
- package/dist/rsc/rscRenderer.d.ts +9 -0
- package/dist/rsc/rscRenderer.d.ts.map +1 -0
- package/dist/rsc/rscRenderer.js +130 -0
- package/dist/rsc/rscRequestHandler.d.ts +10 -0
- package/dist/rsc/rscRequestHandler.d.ts.map +1 -0
- package/dist/rsc/rscRequestHandler.js +131 -0
- package/dist/rsc/rscStudioHandlers.d.ts +10 -0
- package/dist/rsc/rscStudioHandlers.d.ts.map +1 -0
- package/dist/rsc/rscStudioHandlers.js +120 -0
- package/dist/runFeServer.d.ts +2 -0
- package/dist/runFeServer.d.ts.map +1 -0
- package/dist/runFeServer.js +132 -0
- package/dist/streaming/buildForStreamingServer.d.ts +4 -0
- package/dist/streaming/buildForStreamingServer.d.ts.map +1 -0
- package/dist/streaming/buildForStreamingServer.js +41 -0
- package/dist/streaming/collectCss.d.ts +7 -0
- package/dist/streaming/collectCss.d.ts.map +1 -0
- package/dist/streaming/collectCss.js +27 -0
- package/dist/streaming/createReactStreamingHandler.d.ts +12 -0
- package/dist/streaming/createReactStreamingHandler.d.ts.map +1 -0
- package/dist/streaming/createReactStreamingHandler.js +139 -0
- package/dist/streaming/streamHelpers.d.ts +23 -0
- package/dist/streaming/streamHelpers.d.ts.map +1 -0
- package/dist/streaming/streamHelpers.js +192 -0
- package/dist/streaming/transforms/bufferedTransform.d.ts +2 -0
- package/dist/streaming/transforms/bufferedTransform.d.ts.map +1 -0
- package/dist/streaming/transforms/bufferedTransform.js +37 -0
- package/dist/streaming/transforms/cancelTimeoutTransform.d.ts +2 -0
- package/dist/streaming/transforms/cancelTimeoutTransform.d.ts.map +1 -0
- package/dist/streaming/transforms/cancelTimeoutTransform.js +10 -0
- package/dist/streaming/transforms/encode-decode.d.ts +3 -0
- package/dist/streaming/transforms/encode-decode.d.ts.map +1 -0
- package/dist/streaming/transforms/encode-decode.js +11 -0
- package/dist/streaming/transforms/serverInjectionTransform.d.ts +16 -0
- package/dist/streaming/transforms/serverInjectionTransform.d.ts.map +1 -0
- package/dist/streaming/transforms/serverInjectionTransform.js +60 -0
- package/dist/streaming/triggerRouteHooks.d.ts +26 -0
- package/dist/streaming/triggerRouteHooks.d.ts.map +1 -0
- package/dist/streaming/triggerRouteHooks.js +71 -0
- package/dist/types.d.ts +31 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +0 -0
- package/dist/utils.d.ts +14 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +62 -0
- package/inject/reactRefresh.js +7 -0
- package/package.json +116 -0
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var vite_plugin_rsc_transform_server_exports = {};
|
|
30
|
+
__export(vite_plugin_rsc_transform_server_exports, {
|
|
31
|
+
rscTransformUseServerPlugin: () => rscTransformUseServerPlugin
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(vite_plugin_rsc_transform_server_exports);
|
|
34
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
35
|
+
var babel = __toESM(require("@babel/core"), 1);
|
|
36
|
+
var swc = __toESM(require("@swc/core"), 1);
|
|
37
|
+
function rscTransformUseServerPlugin(outDir, serverEntryFiles) {
|
|
38
|
+
return {
|
|
39
|
+
name: "rsc-transform-use-server-plugin",
|
|
40
|
+
transform: async function(code, id) {
|
|
41
|
+
if (!code.includes("use server")) {
|
|
42
|
+
return code;
|
|
43
|
+
}
|
|
44
|
+
let mod;
|
|
45
|
+
const isTypescript = id.endsWith(".ts") || id.endsWith(".tsx");
|
|
46
|
+
try {
|
|
47
|
+
mod = swc.parseSync(code, {
|
|
48
|
+
target: "es2022",
|
|
49
|
+
syntax: isTypescript ? "typescript" : "ecmascript",
|
|
50
|
+
tsx: id.endsWith(".tsx"),
|
|
51
|
+
jsx: id.endsWith(".jsx")
|
|
52
|
+
});
|
|
53
|
+
} catch (e) {
|
|
54
|
+
console.error("Error parsing", id, e.message);
|
|
55
|
+
return code;
|
|
56
|
+
}
|
|
57
|
+
let useClient = false;
|
|
58
|
+
let moduleScopedUseServer = false;
|
|
59
|
+
for (const node of mod.body) {
|
|
60
|
+
if (node.type !== "ExpressionStatement" || node.expression.type !== "StringLiteral") {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (node.expression.value === "use client") {
|
|
64
|
+
useClient = true;
|
|
65
|
+
}
|
|
66
|
+
if (node.expression.value === "use server") {
|
|
67
|
+
moduleScopedUseServer = true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (useClient && moduleScopedUseServer) {
|
|
71
|
+
throw new Error(
|
|
72
|
+
'Cannot have both "use client" and "use server" directives in the same file.'
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
let builtFileName = id;
|
|
76
|
+
const serverEntryKey = Object.entries(serverEntryFiles).find(
|
|
77
|
+
([_key, value]) => value === id
|
|
78
|
+
)?.[0];
|
|
79
|
+
if (serverEntryKey) {
|
|
80
|
+
builtFileName = import_node_path.default.join(outDir, "assets", serverEntryKey + ".mjs");
|
|
81
|
+
if (process.platform === "win32") {
|
|
82
|
+
builtFileName = builtFileName.replaceAll("\\", "/");
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (!builtFileName) {
|
|
86
|
+
throw new Error(
|
|
87
|
+
`Could not find ${id} in serverEntryFiles: ` + JSON.stringify(serverEntryFiles)
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
let transformedCode = code;
|
|
91
|
+
if (moduleScopedUseServer) {
|
|
92
|
+
transformedCode = transformServerModule(mod, builtFileName, code);
|
|
93
|
+
} else {
|
|
94
|
+
const result = babel.transformSync(code, {
|
|
95
|
+
filename: id,
|
|
96
|
+
presets: ["@babel/preset-typescript"],
|
|
97
|
+
plugins: [[babelPluginTransformServerAction, { url: builtFileName }]]
|
|
98
|
+
});
|
|
99
|
+
if (!result) {
|
|
100
|
+
console.error("Failed to transform code", id, code);
|
|
101
|
+
throw new Error("Failed to transform code");
|
|
102
|
+
}
|
|
103
|
+
if (!result.code) {
|
|
104
|
+
console.error("Failed to transform code", id, code);
|
|
105
|
+
throw new Error("Transform didn't return any code");
|
|
106
|
+
}
|
|
107
|
+
transformedCode = result.code;
|
|
108
|
+
}
|
|
109
|
+
return transformedCode;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function transformServerModule(mod, url, code) {
|
|
114
|
+
const localNames = /* @__PURE__ */ new Map();
|
|
115
|
+
const localTypes = /* @__PURE__ */ new Map();
|
|
116
|
+
for (const node of mod.body) {
|
|
117
|
+
switch (node.type) {
|
|
118
|
+
// TODO (RSC): Add code comments with examples of each type of node
|
|
119
|
+
case "ExportDeclaration":
|
|
120
|
+
if (node.declaration.type === "FunctionDeclaration") {
|
|
121
|
+
const name = node.declaration.identifier.value;
|
|
122
|
+
localNames.set(name, name);
|
|
123
|
+
localTypes.set(name, "function");
|
|
124
|
+
} else if (node.declaration.type === "VariableDeclaration") {
|
|
125
|
+
for (const declaration of node.declaration.declarations) {
|
|
126
|
+
if (declaration.id.type === "Identifier") {
|
|
127
|
+
const name = declaration.id.value;
|
|
128
|
+
localNames.set(name, name);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
break;
|
|
133
|
+
case "ExportDefaultDeclaration":
|
|
134
|
+
if (node.decl.type === "FunctionExpression") {
|
|
135
|
+
const identifier = node.decl.identifier;
|
|
136
|
+
if (identifier) {
|
|
137
|
+
localNames.set(identifier.value, "default");
|
|
138
|
+
localTypes.set(identifier.value, "function");
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
break;
|
|
142
|
+
case "ExportNamedDeclaration":
|
|
143
|
+
for (const specifier of node.specifiers) {
|
|
144
|
+
if (specifier.type === "ExportSpecifier") {
|
|
145
|
+
const name = specifier.orig.value;
|
|
146
|
+
if (specifier.exported?.type === "Identifier") {
|
|
147
|
+
const exportedName = specifier.exported.value;
|
|
148
|
+
localNames.set(name, exportedName);
|
|
149
|
+
} else if (specifier.orig.type === "Identifier") {
|
|
150
|
+
localNames.set(name, name);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
break;
|
|
155
|
+
case "ExportDefaultExpression":
|
|
156
|
+
if (node.expression.type === "Identifier") {
|
|
157
|
+
localNames.set(node.expression.value, "default");
|
|
158
|
+
}
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
let newSrc = code + '\n\nimport {registerServerReference} from "react-server-dom-webpack/server";\n';
|
|
163
|
+
localNames.forEach(function(exported, local) {
|
|
164
|
+
if (localTypes.get(local) !== "function") {
|
|
165
|
+
newSrc += "if (typeof " + local + ' === "function") ';
|
|
166
|
+
}
|
|
167
|
+
const urlStr = JSON.stringify(url);
|
|
168
|
+
const exportedStr = JSON.stringify(exported);
|
|
169
|
+
newSrc += `registerServerReference(${local},${urlStr},${exportedStr});
|
|
170
|
+
`;
|
|
171
|
+
});
|
|
172
|
+
return newSrc;
|
|
173
|
+
}
|
|
174
|
+
function babelPluginTransformServerAction({
|
|
175
|
+
types: t
|
|
176
|
+
}) {
|
|
177
|
+
const localNames = /* @__PURE__ */ new Map();
|
|
178
|
+
const localTypes = /* @__PURE__ */ new Map();
|
|
179
|
+
const serverActionNodes = [];
|
|
180
|
+
const topLevelFunctions = [];
|
|
181
|
+
return {
|
|
182
|
+
name: "babel-plugin-redwood-transform-server-action",
|
|
183
|
+
visitor: {
|
|
184
|
+
Program: {
|
|
185
|
+
enter(path2) {
|
|
186
|
+
path2.node.body.forEach((statement) => {
|
|
187
|
+
if (t.isFunctionDeclaration(statement)) {
|
|
188
|
+
if (hasUseServerDirective(statement)) {
|
|
189
|
+
const name = statement.id?.name;
|
|
190
|
+
if (!name) {
|
|
191
|
+
throw new Error("Function declaration must have a name");
|
|
192
|
+
}
|
|
193
|
+
topLevelFunctions.push(name);
|
|
194
|
+
localTypes.set(name, "function");
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (t.isVariableDeclaration(statement)) {
|
|
198
|
+
statement.declarations.forEach((declarator) => {
|
|
199
|
+
if (t.isFunctionExpression(declarator.init)) {
|
|
200
|
+
if (hasUseServerDirective(declarator.init)) {
|
|
201
|
+
const name = declarator.id.type === "Identifier" ? declarator.id.name : void 0;
|
|
202
|
+
if (!name) {
|
|
203
|
+
throw new Error("Function declaration must have a name");
|
|
204
|
+
}
|
|
205
|
+
topLevelFunctions.push(name);
|
|
206
|
+
localTypes.set(name, "function");
|
|
207
|
+
}
|
|
208
|
+
} else if (t.isArrowFunctionExpression(declarator.init)) {
|
|
209
|
+
if (hasUseServerDirective(declarator.init)) {
|
|
210
|
+
const name = declarator.id.type === "Identifier" ? declarator.id.name : void 0;
|
|
211
|
+
if (!name) {
|
|
212
|
+
throw new Error("Function declaration must have a name");
|
|
213
|
+
}
|
|
214
|
+
topLevelFunctions.push(name);
|
|
215
|
+
localTypes.set(name, "function");
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
},
|
|
222
|
+
exit(path2, state) {
|
|
223
|
+
if (serverActionNodes.length === 0 && localTypes.size === 0) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const body = path2.node.body;
|
|
227
|
+
body.push(
|
|
228
|
+
t.importDeclaration(
|
|
229
|
+
[
|
|
230
|
+
t.importSpecifier(
|
|
231
|
+
t.identifier("registerServerReference"),
|
|
232
|
+
t.identifier("registerServerReference")
|
|
233
|
+
)
|
|
234
|
+
],
|
|
235
|
+
t.stringLiteral("react-server-dom-webpack/server")
|
|
236
|
+
)
|
|
237
|
+
);
|
|
238
|
+
serverActionNodes.forEach((functionDeclaration) => {
|
|
239
|
+
body.push(t.exportNamedDeclaration(functionDeclaration));
|
|
240
|
+
const name = functionDeclaration.id?.name || "";
|
|
241
|
+
body.push(registerServerRef(name, state.opts.url, name));
|
|
242
|
+
});
|
|
243
|
+
localNames.forEach((exportedName, localName) => {
|
|
244
|
+
if (!localTypes.get(localName)) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const localType = localTypes.get(localName);
|
|
248
|
+
if (localType === "function") {
|
|
249
|
+
body.push(
|
|
250
|
+
registerServerRef(localName, state.opts.url, exportedName)
|
|
251
|
+
);
|
|
252
|
+
} else {
|
|
253
|
+
body.push(
|
|
254
|
+
t.ifStatement(
|
|
255
|
+
t.binaryExpression(
|
|
256
|
+
"===",
|
|
257
|
+
t.unaryExpression("typeof", t.identifier(localName)),
|
|
258
|
+
t.stringLiteral("function")
|
|
259
|
+
),
|
|
260
|
+
registerServerRef(localName, state.opts.url, exportedName)
|
|
261
|
+
)
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
ExportNamedDeclaration(path2) {
|
|
268
|
+
const declaration = path2.node.declaration;
|
|
269
|
+
const specifiers = path2.node.specifiers;
|
|
270
|
+
if (t.isFunctionDeclaration(declaration)) {
|
|
271
|
+
if (hasUseServerDirective(declaration)) {
|
|
272
|
+
const identifier = declaration.id?.name;
|
|
273
|
+
if (identifier) {
|
|
274
|
+
localNames.set(identifier, identifier);
|
|
275
|
+
localTypes.set(identifier, "function");
|
|
276
|
+
}
|
|
277
|
+
} else {
|
|
278
|
+
const body = declaration.body;
|
|
279
|
+
const serverActionNodeIndex = indexOfServerActionNode(body);
|
|
280
|
+
if (serverActionNodeIndex >= 0) {
|
|
281
|
+
const serverActionNode = body.body[serverActionNodeIndex];
|
|
282
|
+
if (serverActionNode && t.isFunctionDeclaration(serverActionNode)) {
|
|
283
|
+
const name = serverActionNode.id?.name;
|
|
284
|
+
if (!name) {
|
|
285
|
+
}
|
|
286
|
+
serverActionNodes.push(serverActionNode);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
} else if (t.isVariableDeclaration(declaration)) {
|
|
291
|
+
for (const declarator of declaration.declarations) {
|
|
292
|
+
const init = declarator.init;
|
|
293
|
+
if (!t.isArrowFunctionExpression(init) || !t.isBlockStatement(init.body)) {
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
if (hasUseServerDirective(init)) {
|
|
297
|
+
if (declarator.id.type === "Identifier") {
|
|
298
|
+
localNames.set(declarator.id.name, declarator.id.name);
|
|
299
|
+
localTypes.set(declarator.id.name, "function");
|
|
300
|
+
}
|
|
301
|
+
} else {
|
|
302
|
+
const serverActionNodeIndex = indexOfServerActionNode(init.body);
|
|
303
|
+
if (serverActionNodeIndex >= 0) {
|
|
304
|
+
const serverActionNode = init.body.body[serverActionNodeIndex];
|
|
305
|
+
if (t.isFunctionDeclaration(serverActionNode)) {
|
|
306
|
+
const name = serverActionNode.id?.name;
|
|
307
|
+
if (!name) {
|
|
308
|
+
throw new Error("Server action must have a name");
|
|
309
|
+
}
|
|
310
|
+
const uniqueName = `__rwjs__rsa${serverActionNodes.length}_${name}`;
|
|
311
|
+
serverActionNode.id = t.identifier(uniqueName);
|
|
312
|
+
serverActionNodes.push(serverActionNode);
|
|
313
|
+
init.body.body[serverActionNodeIndex] = t.variableDeclaration(
|
|
314
|
+
"const",
|
|
315
|
+
[
|
|
316
|
+
t.variableDeclarator(
|
|
317
|
+
t.identifier(name),
|
|
318
|
+
t.identifier(uniqueName)
|
|
319
|
+
)
|
|
320
|
+
]
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
} else if (specifiers.length) {
|
|
327
|
+
specifiers.forEach((specifier) => {
|
|
328
|
+
if (t.isExportSpecifier(specifier)) {
|
|
329
|
+
const exportedName = t.isStringLiteral(specifier.exported) ? specifier.exported.value : specifier.exported.name;
|
|
330
|
+
localNames.set(specifier.local.name, exportedName);
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
ExportDefaultDeclaration(path2) {
|
|
336
|
+
const declaration = path2.node.declaration;
|
|
337
|
+
if (t.isFunctionDeclaration(declaration)) {
|
|
338
|
+
if (hasUseServerDirective(declaration)) {
|
|
339
|
+
const identifier = declaration.id?.name;
|
|
340
|
+
if (identifier) {
|
|
341
|
+
localNames.set(identifier, "default");
|
|
342
|
+
localTypes.set(identifier, "function");
|
|
343
|
+
}
|
|
344
|
+
} else {
|
|
345
|
+
const body = declaration.body;
|
|
346
|
+
const serverActionNodeIndex = indexOfServerActionNode(body);
|
|
347
|
+
if (serverActionNodeIndex >= 0) {
|
|
348
|
+
const serverActionNode = body.body[serverActionNodeIndex];
|
|
349
|
+
if (serverActionNode && t.isFunctionDeclaration(serverActionNode)) {
|
|
350
|
+
const name = serverActionNode.id?.name;
|
|
351
|
+
if (!name) {
|
|
352
|
+
throw new Error("Server action must have a name");
|
|
353
|
+
}
|
|
354
|
+
const uniqueName = `__rwjs__rsa${serverActionNodes.length}_${name}`;
|
|
355
|
+
serverActionNode.id = t.identifier(uniqueName);
|
|
356
|
+
serverActionNodes.push(serverActionNode);
|
|
357
|
+
body.body[serverActionNodeIndex] = t.variableDeclaration(
|
|
358
|
+
"const",
|
|
359
|
+
[
|
|
360
|
+
t.variableDeclarator(
|
|
361
|
+
t.identifier(name),
|
|
362
|
+
t.identifier(uniqueName)
|
|
363
|
+
)
|
|
364
|
+
]
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
function hasUseServerDirective(statement) {
|
|
374
|
+
return "directives" in statement.body && statement.body.directives.some(
|
|
375
|
+
(directive) => directive.value.value === "use server"
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
function indexOfServerActionNode(blockStatement) {
|
|
379
|
+
return blockStatement.body.findIndex(
|
|
380
|
+
(node) => {
|
|
381
|
+
return t.isFunctionDeclaration(node) && hasUseServerDirective(node);
|
|
382
|
+
}
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
function registerServerRef(localName, url, exportedName) {
|
|
386
|
+
return t.expressionStatement(
|
|
387
|
+
t.callExpression(t.identifier("registerServerReference"), [
|
|
388
|
+
t.identifier(localName),
|
|
389
|
+
t.stringLiteral(url),
|
|
390
|
+
t.stringLiteral(exportedName)
|
|
391
|
+
])
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
396
|
+
0 && (module.exports = {
|
|
397
|
+
rscTransformUseServerPlugin
|
|
398
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var vite_plugin_swap_apollo_provider_exports = {};
|
|
20
|
+
__export(vite_plugin_swap_apollo_provider_exports, {
|
|
21
|
+
swapApolloProvider: () => swapApolloProvider
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(vite_plugin_swap_apollo_provider_exports);
|
|
24
|
+
function swapApolloProvider() {
|
|
25
|
+
return {
|
|
26
|
+
name: "redwood-swap-apollo-provider",
|
|
27
|
+
async transform(code, id) {
|
|
28
|
+
if (/web\/src\/App\.(ts|tsx|js|jsx)$/.test(id)) {
|
|
29
|
+
return code.replace(
|
|
30
|
+
"@cedarjs/web/apollo",
|
|
31
|
+
"@cedarjs/web/dist/apollo/suspense"
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
return code;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
swapApolloProvider
|
|
41
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var rscBuildAnalyze_exports = {};
|
|
20
|
+
__export(rscBuildAnalyze_exports, {
|
|
21
|
+
rscBuildAnalyze: () => rscBuildAnalyze
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(rscBuildAnalyze_exports);
|
|
24
|
+
var import_vite = require("vite");
|
|
25
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
26
|
+
var import_entries = require("../lib/entries.js");
|
|
27
|
+
var import_onWarn = require("../lib/onWarn.js");
|
|
28
|
+
var import_vite_plugin_rsc_analyze = require("../plugins/vite-plugin-rsc-analyze.js");
|
|
29
|
+
async function rscBuildAnalyze() {
|
|
30
|
+
console.log("\n");
|
|
31
|
+
console.log("1. rscBuildAnalyze");
|
|
32
|
+
console.log("==================\n");
|
|
33
|
+
const rwPaths = (0, import_project_config.getPaths)();
|
|
34
|
+
const clientEntryFileSet = /* @__PURE__ */ new Set();
|
|
35
|
+
const serverEntryFileSet = /* @__PURE__ */ new Set();
|
|
36
|
+
if (!rwPaths.web.viteConfig) {
|
|
37
|
+
throw new Error("Vite config not found");
|
|
38
|
+
}
|
|
39
|
+
await (0, import_vite.build)({
|
|
40
|
+
configFile: rwPaths.web.viteConfig,
|
|
41
|
+
root: rwPaths.web.src,
|
|
42
|
+
// @MARK: We don't care about the build output from this step. It's just
|
|
43
|
+
// for returning the entry names. Plus, the entire RSC build is chatty
|
|
44
|
+
// enough as it is. You can enable this temporarily if you need to for
|
|
45
|
+
// debugging, but we're keeping it silent by default.
|
|
46
|
+
logLevel: "silent",
|
|
47
|
+
plugins: [
|
|
48
|
+
(0, import_vite_plugin_rsc_analyze.rscAnalyzePlugin)(
|
|
49
|
+
(id) => clientEntryFileSet.add(id),
|
|
50
|
+
(id) => serverEntryFileSet.add(id)
|
|
51
|
+
)
|
|
52
|
+
],
|
|
53
|
+
ssr: {
|
|
54
|
+
// We can ignore everything that starts with `node:` because it's not
|
|
55
|
+
// going to be RSCs
|
|
56
|
+
// As of vite 5.2 `true` here means "all except node built-ins"
|
|
57
|
+
noExternal: true,
|
|
58
|
+
// Anything we know won't have "use client" or "use server" in it can
|
|
59
|
+
// safely be external. The more we can externalize the better, because
|
|
60
|
+
// it means we can skip analyzing them, which means faster build times.
|
|
61
|
+
external: [
|
|
62
|
+
"@prisma/client",
|
|
63
|
+
"@prisma/fetch-engine",
|
|
64
|
+
"@prisma/internals",
|
|
65
|
+
"@cedarjs/auth-dbauth-api",
|
|
66
|
+
"@cedarjs/cookie-jar",
|
|
67
|
+
"@cedarjs/server-store",
|
|
68
|
+
"@simplewebauthn/server",
|
|
69
|
+
"graphql-scalars",
|
|
70
|
+
"minimatch",
|
|
71
|
+
"playwright",
|
|
72
|
+
"react"
|
|
73
|
+
],
|
|
74
|
+
resolve: {
|
|
75
|
+
externalConditions: ["react-server"]
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
build: {
|
|
79
|
+
// TODO (RSC): Remove `minify: false` when we don't need to debug as often
|
|
80
|
+
minify: false,
|
|
81
|
+
manifest: "rsc-build-manifest.json",
|
|
82
|
+
write: false,
|
|
83
|
+
// We generate the entries from the simple `getEntries` function that analyses
|
|
84
|
+
// the various pages plus the ServerEntry file. This may need revisiting when we
|
|
85
|
+
// spend time on improving dev support or expand the scope of the components
|
|
86
|
+
// that are looked up via the entries mappings.
|
|
87
|
+
ssr: true,
|
|
88
|
+
rollupOptions: {
|
|
89
|
+
onwarn: import_onWarn.onWarn,
|
|
90
|
+
input: (0, import_entries.getEntries)()
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
const clientEntryFiles = Object.fromEntries(
|
|
95
|
+
Array.from(clientEntryFileSet).map((filename, i) => {
|
|
96
|
+
const rscName = `rsc-${filename.split(/[\/\\]/).at(-1)}-${i}`;
|
|
97
|
+
return [rscName, filename];
|
|
98
|
+
})
|
|
99
|
+
);
|
|
100
|
+
const serverEntryFiles = Object.fromEntries(
|
|
101
|
+
Array.from(serverEntryFileSet).map((filename, i) => {
|
|
102
|
+
const rsaName = `rsa-${filename.split(/[\/\\]/).at(-1)}-${i}`;
|
|
103
|
+
return [rsaName, filename];
|
|
104
|
+
})
|
|
105
|
+
);
|
|
106
|
+
console.log("clientEntryFiles", clientEntryFiles);
|
|
107
|
+
console.log("serverEntryFiles", serverEntryFiles);
|
|
108
|
+
return {
|
|
109
|
+
clientEntryFiles,
|
|
110
|
+
serverEntryFiles
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
114
|
+
0 && (module.exports = {
|
|
115
|
+
rscBuildAnalyze
|
|
116
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var rscBuildClient_exports = {};
|
|
20
|
+
__export(rscBuildClient_exports, {
|
|
21
|
+
rscBuildClient: () => rscBuildClient
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(rscBuildClient_exports);
|
|
24
|
+
var import_vite = require("vite");
|
|
25
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
26
|
+
var import_onWarn = require("../lib/onWarn.js");
|
|
27
|
+
var import_vite_plugin_rsc_routes_auto_loader = require("../plugins/vite-plugin-rsc-routes-auto-loader.js");
|
|
28
|
+
var import_utils = require("../utils.js");
|
|
29
|
+
async function rscBuildClient(clientEntryFiles) {
|
|
30
|
+
console.log("\n");
|
|
31
|
+
console.log("2. rscBuildClient");
|
|
32
|
+
console.log("=================\n");
|
|
33
|
+
const rwPaths = (0, import_project_config.getPaths)();
|
|
34
|
+
(0, import_utils.ensureProcessDirWeb)();
|
|
35
|
+
if (!rwPaths.web.entryClient) {
|
|
36
|
+
throw new Error("Missing web/src/entry.client");
|
|
37
|
+
}
|
|
38
|
+
const clientBuildOutput = await (0, import_vite.build)({
|
|
39
|
+
envFile: false,
|
|
40
|
+
define: {
|
|
41
|
+
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV)
|
|
42
|
+
},
|
|
43
|
+
build: {
|
|
44
|
+
// TODO (RSC): Remove `minify: false` when we don't need to debug as often
|
|
45
|
+
minify: false,
|
|
46
|
+
outDir: rwPaths.web.distBrowser,
|
|
47
|
+
emptyOutDir: true,
|
|
48
|
+
// Needed because `outDir` is not inside `root`
|
|
49
|
+
rollupOptions: {
|
|
50
|
+
onwarn: import_onWarn.onWarn,
|
|
51
|
+
input: {
|
|
52
|
+
// @MARK: temporary hack to find the entry client so we can get the
|
|
53
|
+
// index.css bundle but we don't actually want this on an rsc page!
|
|
54
|
+
__rwjs__client_entry: rwPaths.web.entryClient,
|
|
55
|
+
// we need this, so that the output contains rsc-specific bundles
|
|
56
|
+
// for the client-only components. They get loaded once the page is
|
|
57
|
+
// rendered
|
|
58
|
+
...clientEntryFiles
|
|
59
|
+
},
|
|
60
|
+
preserveEntrySignatures: "exports-only",
|
|
61
|
+
output: {
|
|
62
|
+
// This is not ideal. See
|
|
63
|
+
// https://rollupjs.org/faqs/#why-do-additional-imports-turn-up-in-my-entry-chunks-when-code-splitting
|
|
64
|
+
// But we need it to prevent `import 'client-only'` from being
|
|
65
|
+
// hoisted into App.tsx
|
|
66
|
+
// TODO (RSC): Fix when https://github.com/rollup/rollup/issues/5235
|
|
67
|
+
// is resolved
|
|
68
|
+
hoistTransitiveImports: false,
|
|
69
|
+
entryFileNames: () => {
|
|
70
|
+
return "assets/[name]-[hash].mjs";
|
|
71
|
+
},
|
|
72
|
+
chunkFileNames: `assets/[name]-[hash].mjs`
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
manifest: "client-build-manifest.json"
|
|
76
|
+
},
|
|
77
|
+
esbuild: {
|
|
78
|
+
logLevel: "debug"
|
|
79
|
+
},
|
|
80
|
+
logLevel: "info",
|
|
81
|
+
plugins: [(0, import_vite_plugin_rsc_routes_auto_loader.rscRoutesAutoLoader)()]
|
|
82
|
+
});
|
|
83
|
+
if (!("output" in clientBuildOutput)) {
|
|
84
|
+
throw new Error("Unexpected vite client build output");
|
|
85
|
+
}
|
|
86
|
+
return clientBuildOutput.output;
|
|
87
|
+
}
|
|
88
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
+
0 && (module.exports = {
|
|
90
|
+
rscBuildClient
|
|
91
|
+
});
|