vite-plugin-react-server 1.1.13 → 1.1.14
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 +3 -1
- package/dist/plugin/config/defaults.d.ts +2 -2
- package/dist/plugin/config/defaults.d.ts.map +1 -1
- package/dist/plugin/config/defaults.js +2 -2
- 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 +98 -61
- package/dist/plugin/config/resolveOptions.js.map +1 -1
- package/dist/plugin/error/toError.d.ts.map +1 -1
- package/dist/plugin/error/toError.js +0 -1
- package/dist/plugin/error/toError.js.map +1 -1
- package/dist/plugin/helpers/collectManifestCss.d.ts +1 -2
- package/dist/plugin/helpers/collectManifestCss.d.ts.map +1 -1
- package/dist/plugin/helpers/collectManifestCss.js +3 -5
- package/dist/plugin/helpers/collectManifestCss.js.map +1 -1
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts +1 -1
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts.map +1 -1
- package/dist/plugin/helpers/collectViteModuleGraphCss.js +6 -2
- package/dist/plugin/helpers/collectViteModuleGraphCss.js.map +1 -1
- package/dist/plugin/helpers/createCssProps.d.ts +1 -1
- package/dist/plugin/helpers/createCssProps.d.ts.map +1 -1
- package/dist/plugin/helpers/createCssProps.js +11 -32
- package/dist/plugin/helpers/createCssProps.js.map +1 -1
- package/dist/plugin/helpers/createRscStream.d.ts.map +1 -1
- package/dist/plugin/helpers/createRscStream.js +1 -0
- package/dist/plugin/helpers/createRscStream.js.map +1 -1
- package/dist/plugin/loader/createDefaultLoader.d.ts.map +1 -1
- package/dist/plugin/loader/createDefaultLoader.js +68 -4
- package/dist/plugin/loader/css-loader.development.d.ts +2 -15
- package/dist/plugin/loader/css-loader.development.d.ts.map +1 -1
- package/dist/plugin/loader/css-loader.development.js +16 -15
- package/dist/plugin/loader/css-loader.development.js.map +1 -1
- package/dist/plugin/loader/css-loader.production.d.ts +1 -1
- package/dist/plugin/loader/css-loader.production.d.ts.map +1 -1
- package/dist/plugin/loader/css-loader.production.js +1 -1
- package/dist/plugin/loader/css-loader.production.js.map +1 -1
- package/dist/plugin/loader/env-loader.development.d.ts +1 -0
- package/dist/plugin/loader/env-loader.development.d.ts.map +1 -1
- package/dist/plugin/loader/env-loader.development.js +17 -9
- package/dist/plugin/loader/handleExports.d.ts +1 -0
- package/dist/plugin/loader/handleExports.d.ts.map +1 -1
- package/dist/plugin/loader/handleExports.js +27 -8
- package/dist/plugin/loader/handleExports.js.map +1 -1
- package/dist/plugin/loader/react-loader.server.d.ts +2 -2
- package/dist/plugin/loader/react-loader.server.d.ts.map +1 -1
- package/dist/plugin/loader/react-loader.server.js +88 -26
- package/dist/plugin/loader/transformModuleIfNeeded.d.ts.map +1 -1
- package/dist/plugin/loader/transformModuleIfNeeded.js +1 -1
- package/dist/plugin/loader/transformModuleIfNeeded.js.map +1 -1
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.d.ts.map +1 -1
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.js +86 -13
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.js.map +1 -1
- package/dist/plugin/plugin.client.d.ts.map +1 -1
- package/dist/plugin/plugin.client.js +0 -1
- package/dist/plugin/plugin.client.js.map +1 -1
- package/dist/plugin/react-client/configureWorkerRequestHandler.d.ts.map +1 -1
- package/dist/plugin/react-client/configureWorkerRequestHandler.js +85 -6
- package/dist/plugin/react-client/configureWorkerRequestHandler.js.map +1 -1
- package/dist/plugin/react-client/createMessageHandlers.d.ts.map +1 -1
- package/dist/plugin/react-client/createMessageHandlers.js +3 -0
- package/dist/plugin/react-client/createMessageHandlers.js.map +1 -1
- package/dist/plugin/react-client/createWorkerStream.d.ts +2 -2
- package/dist/plugin/react-client/createWorkerStream.d.ts.map +1 -1
- package/dist/plugin/react-client/createWorkerStream.js +13 -2
- package/dist/plugin/react-client/createWorkerStream.js.map +1 -1
- package/dist/plugin/react-client/handleWorkerRscStream.d.ts.map +1 -1
- package/dist/plugin/react-client/handleWorkerRscStream.js +10 -3
- package/dist/plugin/react-client/handleWorkerRscStream.js.map +1 -1
- package/dist/plugin/react-client/restartWorker.d.ts.map +1 -1
- package/dist/plugin/react-client/restartWorker.js +2 -1
- package/dist/plugin/react-client/restartWorker.js.map +1 -1
- package/dist/plugin/react-server/configureReactServer.d.ts.map +1 -1
- package/dist/plugin/react-server/configureReactServer.js +1 -2
- package/dist/plugin/react-server/configureReactServer.js.map +1 -1
- package/dist/plugin/react-server/handleServerAction.d.ts.map +1 -1
- package/dist/plugin/react-server/handleServerAction.js +0 -16
- package/dist/plugin/react-server/handleServerAction.js.map +1 -1
- package/dist/plugin/react-static/createBuildLoader.d.ts.map +1 -0
- package/dist/plugin/react-static/createBuildLoader.js.map +1 -0
- package/dist/plugin/react-static/plugin.d.ts.map +1 -1
- package/dist/plugin/react-static/plugin.js +9 -12
- package/dist/plugin/react-static/plugin.js.map +1 -1
- package/dist/plugin/react-static/temporaryReferences.d.ts.map +1 -0
- package/dist/plugin/react-static/temporaryReferences.js.map +1 -0
- package/dist/plugin/transformer/plugin.server.js +2 -2
- package/dist/plugin/transformer/plugin.server.js.map +1 -1
- package/dist/plugin/types.d.ts +14 -3
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/handleRender.js +1 -0
- package/dist/plugin/worker/rsc/handleRender.js.map +1 -1
- package/dist/plugin/worker/rsc/handlers.d.ts +3 -0
- package/dist/plugin/worker/rsc/handlers.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/handlers.js +223 -0
- package/dist/plugin/worker/rsc/handlers.js.map +1 -0
- package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.js +5 -110
- package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.development.js +13 -16
- package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
- package/dist/plugin/worker/rsc/state.d.ts +1 -2
- package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/state.js +1 -2
- package/dist/plugin/worker/rsc/state.js.map +1 -1
- package/dist/plugin/worker/rsc/userOptions.d.ts +2 -0
- package/dist/plugin/worker/rsc/userOptions.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/userOptions.js +17 -0
- package/dist/plugin/worker/rsc/userOptions.js.map +1 -0
- package/dist/plugin/worker/types.d.ts +2 -1
- package/dist/plugin/worker/types.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -1
- package/plugin/config/defaults.tsx +5 -2
- package/plugin/config/resolveOptions.ts +101 -67
- package/plugin/error/toError.ts +0 -2
- package/plugin/helpers/collectManifestCss.ts +2 -6
- package/plugin/helpers/collectViteModuleGraphCss.ts +6 -0
- package/plugin/helpers/createCssProps.tsx +17 -46
- package/plugin/helpers/createRscStream.tsx +1 -0
- package/plugin/loader/createDefaultLoader.ts +80 -4
- package/plugin/loader/css-loader.development.ts +17 -34
- package/plugin/loader/css-loader.production.ts +2 -4
- package/plugin/loader/env-loader.development.ts +38 -15
- package/plugin/loader/handleExports.ts +36 -13
- package/plugin/loader/react-loader.server.ts +110 -32
- package/plugin/loader/transformModuleIfNeeded.ts +2 -2
- package/plugin/loader/transformModuleWithPreservedFunctions.ts +128 -21
- package/plugin/plugin.client.ts +0 -2
- package/plugin/react-client/configureWorkerRequestHandler.ts +107 -4
- package/plugin/react-client/createMessageHandlers.ts +3 -0
- package/plugin/react-client/createWorkerStream.ts +15 -1
- package/plugin/react-client/handleWorkerRscStream.ts +12 -3
- package/plugin/react-client/restartWorker.ts +1 -0
- package/plugin/react-server/configureReactServer.ts +1 -2
- package/plugin/react-server/handleServerAction.ts +1 -19
- package/plugin/react-static/plugin.ts +9 -12
- package/plugin/transformer/plugin.server.ts +2 -2
- package/plugin/types.ts +25 -2
- package/plugin/worker/rsc/handleRender.ts +1 -0
- package/plugin/worker/rsc/handlers.ts +243 -0
- package/plugin/worker/rsc/messageHandler.tsx +4 -118
- package/plugin/worker/rsc/rsc-worker.development.ts +17 -20
- package/plugin/worker/rsc/state.ts +2 -6
- package/plugin/worker/rsc/userOptions.ts +8 -0
- package/plugin/worker/types.ts +2 -0
- package/dist/plugin/loader/createBuildLoader.d.ts.map +0 -1
- package/dist/plugin/loader/createBuildLoader.js.map +0 -1
- package/dist/plugin/loader/plugin.d.ts +0 -22
- package/dist/plugin/loader/plugin.d.ts.map +0 -1
- package/dist/plugin/loader/plugin.js +0 -27
- package/dist/plugin/loader/temporaryReferences.d.ts.map +0 -1
- package/dist/plugin/loader/temporaryReferences.js.map +0 -1
- package/plugin/loader/plugin.ts +0 -33
- /package/dist/plugin/{loader → react-static}/createBuildLoader.d.ts +0 -0
- /package/dist/plugin/{loader → react-static}/createBuildLoader.js +0 -0
- /package/dist/plugin/{loader → react-static}/temporaryReferences.d.ts +0 -0
- /package/dist/plugin/{loader → react-static}/temporaryReferences.js +0 -0
- /package/plugin/{loader → react-static}/createBuildLoader.ts +0 -0
- /package/plugin/{loader → react-static}/temporaryReferences.ts +0 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { sendRscWorkerMessage } from "../sendMessage.js";
|
|
2
|
+
import type { StreamHandlers } from "../types.js";
|
|
3
|
+
import { toError } from "../../error/toError.js";
|
|
4
|
+
import { userOptions } from "./userOptions.js";
|
|
5
|
+
import { addCssFileContent, addModuleId } from "./state.js";
|
|
6
|
+
import { join } from "path";
|
|
7
|
+
import { ReactDOMServer } from "../../vendor/vendor.server.js";
|
|
8
|
+
import { PassThrough } from "node:stream";
|
|
9
|
+
|
|
10
|
+
export const handlers: Required<StreamHandlers> = {
|
|
11
|
+
onError: (id, error, errorInfo) => {
|
|
12
|
+
sendRscWorkerMessage({
|
|
13
|
+
type: "ERROR",
|
|
14
|
+
id: id,
|
|
15
|
+
errorInfo,
|
|
16
|
+
error: toError(error),
|
|
17
|
+
});
|
|
18
|
+
sendRscWorkerMessage({
|
|
19
|
+
type: "RSC_END",
|
|
20
|
+
id: id,
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
onData: (id, data: any) => {
|
|
24
|
+
sendRscWorkerMessage({
|
|
25
|
+
type: "RSC_CHUNK",
|
|
26
|
+
id: id,
|
|
27
|
+
chunk: data,
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
onEnd: (id: string) => {
|
|
31
|
+
sendRscWorkerMessage({
|
|
32
|
+
type: "RSC_END",
|
|
33
|
+
id: id,
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
onMetrics: (id: string, metrics: any) => {
|
|
37
|
+
sendRscWorkerMessage ({
|
|
38
|
+
type: "RSC_METRICS",
|
|
39
|
+
id: id,
|
|
40
|
+
metrics,
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
onHmrAccept: (id, routes) => {
|
|
44
|
+
sendRscWorkerMessage({
|
|
45
|
+
type: "HMR_ACCEPT",
|
|
46
|
+
id: id,
|
|
47
|
+
routes: routes,
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
onHmrUpdate: (id, routes) => {
|
|
51
|
+
sendRscWorkerMessage({
|
|
52
|
+
type: "HMR_UPDATE",
|
|
53
|
+
id: id,
|
|
54
|
+
routes: routes,
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
onServerModule: (id, url, source) => {
|
|
58
|
+
addModuleId(id, url);
|
|
59
|
+
sendRscWorkerMessage({
|
|
60
|
+
type: "SERVER_MODULE",
|
|
61
|
+
id,
|
|
62
|
+
url,
|
|
63
|
+
source,
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
onServerActionResponse: (id, result) => {
|
|
67
|
+
const stream = ReactDOMServer.renderToPipeableStream(
|
|
68
|
+
{
|
|
69
|
+
type: "server-action-response",
|
|
70
|
+
returnValue: result
|
|
71
|
+
},
|
|
72
|
+
userOptions.moduleBasePath,
|
|
73
|
+
{
|
|
74
|
+
onError(error: Error) {
|
|
75
|
+
sendRscWorkerMessage({
|
|
76
|
+
type: "ERROR",
|
|
77
|
+
id,
|
|
78
|
+
error: toError(error)
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const passThrough = new PassThrough();
|
|
85
|
+
stream.pipe(passThrough);
|
|
86
|
+
|
|
87
|
+
passThrough.on("data", (chunk) => {
|
|
88
|
+
sendRscWorkerMessage({
|
|
89
|
+
type: "RSC_CHUNK",
|
|
90
|
+
id,
|
|
91
|
+
chunk
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
passThrough.on("end", () => {
|
|
96
|
+
sendRscWorkerMessage({
|
|
97
|
+
type: "RSC_END",
|
|
98
|
+
id
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
passThrough.on("error", (error) => {
|
|
103
|
+
sendRscWorkerMessage({
|
|
104
|
+
type: "ERROR",
|
|
105
|
+
id,
|
|
106
|
+
error: toError(error)
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
onServerAction: async (id, args) => {
|
|
111
|
+
try {
|
|
112
|
+
// Parse the server action ID to get the file path and export name
|
|
113
|
+
const [filePath, exportName] = id.split("#");
|
|
114
|
+
if (!filePath || !exportName) {
|
|
115
|
+
throw new Error(`Invalid server action ID format: ${id}. Expected format: "path/to/file.ts#exportName"`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Convert the server action ID to a file path
|
|
119
|
+
const actionPath = filePath.startsWith("/") ? filePath.slice(1) : filePath;
|
|
120
|
+
const fullPath = join(userOptions.projectRoot, actionPath);
|
|
121
|
+
|
|
122
|
+
// Load the server action module
|
|
123
|
+
const module = await import(fullPath);
|
|
124
|
+
const action = module[exportName];
|
|
125
|
+
|
|
126
|
+
if (typeof action !== "function") {
|
|
127
|
+
throw new Error(`Server action not found: ${id}`);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Execute the server action
|
|
131
|
+
const result = await action(...args);
|
|
132
|
+
|
|
133
|
+
// Send success response using RSC stream
|
|
134
|
+
const stream = ReactDOMServer.renderToPipeableStream(
|
|
135
|
+
{
|
|
136
|
+
type: "server-action-response",
|
|
137
|
+
returnValue: result
|
|
138
|
+
},
|
|
139
|
+
userOptions.moduleBasePath,
|
|
140
|
+
{
|
|
141
|
+
onError(error: Error) {
|
|
142
|
+
sendRscWorkerMessage({
|
|
143
|
+
type: "ERROR",
|
|
144
|
+
id,
|
|
145
|
+
error: toError(error)
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
const passThrough = new PassThrough();
|
|
152
|
+
stream.pipe(passThrough);
|
|
153
|
+
|
|
154
|
+
passThrough.on("data", (chunk) => {
|
|
155
|
+
sendRscWorkerMessage({
|
|
156
|
+
type: "RSC_CHUNK",
|
|
157
|
+
id,
|
|
158
|
+
chunk
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
passThrough.on("end", () => {
|
|
163
|
+
sendRscWorkerMessage({
|
|
164
|
+
type: "RSC_END",
|
|
165
|
+
id
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
passThrough.on("error", (error) => {
|
|
170
|
+
sendRscWorkerMessage({
|
|
171
|
+
type: "ERROR",
|
|
172
|
+
id,
|
|
173
|
+
error: toError(error)
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
} catch (error: unknown) {
|
|
177
|
+
const errorMessage = toError(error).message;
|
|
178
|
+
// Send error response using RSC stream
|
|
179
|
+
const stream = ReactDOMServer.renderToPipeableStream(
|
|
180
|
+
{
|
|
181
|
+
type: "server-action-response",
|
|
182
|
+
returnValue: { success: false, error: errorMessage }
|
|
183
|
+
},
|
|
184
|
+
userOptions.moduleBasePath,
|
|
185
|
+
{
|
|
186
|
+
onError(error: Error) {
|
|
187
|
+
sendRscWorkerMessage({
|
|
188
|
+
type: "ERROR",
|
|
189
|
+
id,
|
|
190
|
+
error: toError(error)
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
const passThrough = new PassThrough();
|
|
197
|
+
stream.pipe(passThrough);
|
|
198
|
+
|
|
199
|
+
passThrough.on("data", (chunk) => {
|
|
200
|
+
sendRscWorkerMessage({
|
|
201
|
+
type: "RSC_CHUNK",
|
|
202
|
+
id,
|
|
203
|
+
chunk
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
passThrough.on("end", () => {
|
|
208
|
+
sendRscWorkerMessage({
|
|
209
|
+
type: "RSC_END",
|
|
210
|
+
id
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
passThrough.on("error", (error) => {
|
|
215
|
+
sendRscWorkerMessage({
|
|
216
|
+
type: "ERROR",
|
|
217
|
+
id,
|
|
218
|
+
error: toError(error)
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
onShutdown: (id: string) => {
|
|
224
|
+
// Send SHUTDOWN_COMPLETE message to signal that shutdown is complete
|
|
225
|
+
sendRscWorkerMessage({
|
|
226
|
+
type: "SHUTDOWN_COMPLETE",
|
|
227
|
+
id: id,
|
|
228
|
+
});
|
|
229
|
+
},
|
|
230
|
+
onCssFile: (id, code) => {
|
|
231
|
+
if (id) {
|
|
232
|
+
// Add to CSS registry
|
|
233
|
+
addCssFileContent(id, code, userOptions);
|
|
234
|
+
|
|
235
|
+
// Send CSS file message
|
|
236
|
+
sendRscWorkerMessage({
|
|
237
|
+
type: "CSS_FILE",
|
|
238
|
+
id,
|
|
239
|
+
content: code
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
};
|
|
@@ -1,117 +1,19 @@
|
|
|
1
|
-
import { parentPort
|
|
1
|
+
import { parentPort } from "node:worker_threads";
|
|
2
2
|
import {
|
|
3
3
|
activeStreams,
|
|
4
|
-
addCssFileContent,
|
|
5
4
|
hmrState,
|
|
6
|
-
addModuleId,
|
|
7
5
|
} from "./state.js";
|
|
8
6
|
import { handleRender } from "./handleRender.js";
|
|
9
7
|
import type {
|
|
10
8
|
RscWorkerInputMessage,
|
|
11
|
-
StreamHandlers,
|
|
12
9
|
} from "../types.js";
|
|
13
|
-
import { sendRscWorkerMessage } from "../sendMessage.js";
|
|
14
10
|
import { toError } from "../../error/toError.js";
|
|
11
|
+
import { handlers } from "./handlers.js";
|
|
15
12
|
|
|
16
13
|
// In test mode, we want errors to propagate up immediately
|
|
17
14
|
const isTestEnv = process.env["VITEST"] || process.env["NODE_ENV"] === "test";
|
|
18
15
|
const isDevEnv = process.env["NODE_ENV"] !== "production";
|
|
19
16
|
|
|
20
|
-
const handlers: Required<StreamHandlers> = {
|
|
21
|
-
onError: (id, error, errorInfo) => {
|
|
22
|
-
sendRscWorkerMessage({
|
|
23
|
-
type: "ERROR",
|
|
24
|
-
id: id,
|
|
25
|
-
errorInfo,
|
|
26
|
-
error: toError(error),
|
|
27
|
-
});
|
|
28
|
-
sendRscWorkerMessage({
|
|
29
|
-
type: "RSC_END",
|
|
30
|
-
id: id,
|
|
31
|
-
});
|
|
32
|
-
},
|
|
33
|
-
onData: (id, data: any) => {
|
|
34
|
-
sendRscWorkerMessage({
|
|
35
|
-
type: "RSC_CHUNK",
|
|
36
|
-
id: id,
|
|
37
|
-
chunk: data,
|
|
38
|
-
});
|
|
39
|
-
},
|
|
40
|
-
onEnd: (id: string) => {
|
|
41
|
-
sendRscWorkerMessage({
|
|
42
|
-
type: "RSC_END",
|
|
43
|
-
id: id,
|
|
44
|
-
});
|
|
45
|
-
},
|
|
46
|
-
onMetrics: (id: string, metrics: any) => {
|
|
47
|
-
sendRscWorkerMessage({
|
|
48
|
-
type: "RSC_METRICS",
|
|
49
|
-
id: id,
|
|
50
|
-
metrics,
|
|
51
|
-
});
|
|
52
|
-
},
|
|
53
|
-
onHmrAccept: (id, routes) => {
|
|
54
|
-
sendRscWorkerMessage({
|
|
55
|
-
type: "HMR_ACCEPT",
|
|
56
|
-
id: id,
|
|
57
|
-
routes: routes,
|
|
58
|
-
});
|
|
59
|
-
},
|
|
60
|
-
onHmrUpdate: (id, routes) => {
|
|
61
|
-
sendRscWorkerMessage({
|
|
62
|
-
type: "HMR_UPDATE",
|
|
63
|
-
id: id,
|
|
64
|
-
routes: routes,
|
|
65
|
-
});
|
|
66
|
-
},
|
|
67
|
-
onServerModule: (id, url, source) => {
|
|
68
|
-
sendRscWorkerMessage({
|
|
69
|
-
type: "SERVER_MODULE",
|
|
70
|
-
id,
|
|
71
|
-
url,
|
|
72
|
-
source,
|
|
73
|
-
});
|
|
74
|
-
},
|
|
75
|
-
onServerActionResponse: (id, result, error) => {
|
|
76
|
-
sendRscWorkerMessage({
|
|
77
|
-
type: "SERVER_ACTION_RESPONSE",
|
|
78
|
-
id,
|
|
79
|
-
result,
|
|
80
|
-
error,
|
|
81
|
-
});
|
|
82
|
-
},
|
|
83
|
-
onServerAction: async (id, args) => {
|
|
84
|
-
try {
|
|
85
|
-
// Get the server action function from the worker data
|
|
86
|
-
const serverAction = workerData.serverActions?.[id];
|
|
87
|
-
if (!serverAction) {
|
|
88
|
-
throw new Error(`Server action ${id} not found`);
|
|
89
|
-
}
|
|
90
|
-
// Execute the server action
|
|
91
|
-
const result = await serverAction(...args);
|
|
92
|
-
// Send the result back
|
|
93
|
-
sendRscWorkerMessage({
|
|
94
|
-
type: "SERVER_ACTION_RESPONSE",
|
|
95
|
-
id,
|
|
96
|
-
result,
|
|
97
|
-
});
|
|
98
|
-
} catch (error) {
|
|
99
|
-
// Send error back
|
|
100
|
-
sendRscWorkerMessage({
|
|
101
|
-
type: "SERVER_ACTION_RESPONSE",
|
|
102
|
-
id,
|
|
103
|
-
error: error instanceof Error ? error.message : String(error),
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
onShutdown: (id: string) => {
|
|
108
|
-
// Send SHUTDOWN_COMPLETE message to signal that shutdown is complete
|
|
109
|
-
sendRscWorkerMessage({
|
|
110
|
-
type: "SHUTDOWN_COMPLETE",
|
|
111
|
-
id: id,
|
|
112
|
-
});
|
|
113
|
-
},
|
|
114
|
-
};
|
|
115
17
|
|
|
116
18
|
export async function messageHandler(
|
|
117
19
|
msg: RscWorkerInputMessage,
|
|
@@ -127,10 +29,9 @@ export async function messageHandler(
|
|
|
127
29
|
case "SERVER_ACTION":
|
|
128
30
|
return handlers.onServerAction(msg.id, msg.args);
|
|
129
31
|
case "INITIALIZED_REACT_LOADER":
|
|
130
|
-
return;
|
|
131
32
|
case "INITIALIZED_CSS_LOADER":
|
|
132
|
-
return;
|
|
133
33
|
case "INITIALIZED_ENV_LOADER":
|
|
34
|
+
console.log("Initialized ", msg.id);
|
|
134
35
|
return;
|
|
135
36
|
case "HMR_UPDATE":
|
|
136
37
|
// Mark the module as invalidated
|
|
@@ -149,24 +50,9 @@ export async function messageHandler(
|
|
|
149
50
|
handlers.onHmrAccept(msg.id, msg.routes || []);
|
|
150
51
|
return;
|
|
151
52
|
case "CSS_FILE":
|
|
152
|
-
|
|
153
|
-
const cssOptions = workerData.userOptions.css || {
|
|
154
|
-
inlineThreshold: 1000,
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
addCssFileContent(msg.id, msg.content, {
|
|
158
|
-
projectRoot: workerData.userOptions.projectRoot || process.cwd(),
|
|
159
|
-
moduleBaseURL: workerData.userOptions.moduleBaseURL || "/",
|
|
160
|
-
moduleBasePath: workerData.userOptions.moduleBasePath || "/",
|
|
161
|
-
moduleRootPath: workerData.userOptions.moduleRootPath,
|
|
162
|
-
css: cssOptions,
|
|
163
|
-
});
|
|
164
|
-
}
|
|
53
|
+
handlers.onCssFile(msg.id, msg.content);
|
|
165
54
|
return;
|
|
166
55
|
case "SERVER_MODULE":
|
|
167
|
-
if (msg.id && msg.url) {
|
|
168
|
-
addModuleId(msg.id, msg.url);
|
|
169
|
-
}
|
|
170
56
|
handlers.onServerModule(msg.id, msg.url, msg.source);
|
|
171
57
|
return;
|
|
172
58
|
case "SHUTDOWN": {
|
|
@@ -4,13 +4,13 @@ import { register } from "node:module";
|
|
|
4
4
|
import { register as registerTsx } from "tsx/esm/api";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { pluginRoot } from "../../root.js";
|
|
7
|
-
import { deserializeRegExp } from "../../helpers/serializeUserOptions.js";
|
|
8
7
|
import type {
|
|
9
8
|
HmrAcceptMessage,
|
|
10
9
|
HmrUpdateMessage,
|
|
11
10
|
ReadyMessage,
|
|
12
11
|
} from "../types.js";
|
|
13
12
|
import { toError } from "../../error/toError.js";
|
|
13
|
+
|
|
14
14
|
// Initialize worker
|
|
15
15
|
if (!parentPort) {
|
|
16
16
|
throw new Error("This module must be run as a worker");
|
|
@@ -55,20 +55,15 @@ const developmentReactLoaderMessageHandler = (msg: any) => {
|
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
try {
|
|
58
|
-
// Deserialize workerData to restore RegExp objects
|
|
59
|
-
if (workerData) {
|
|
60
|
-
workerData.userOptions = deserializeRegExp(workerData.userOptions);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
58
|
// Create channels for each loader
|
|
64
59
|
const reactLoaderChannel = new MessageChannel();
|
|
65
60
|
const cssLoaderChannel = new MessageChannel();
|
|
66
61
|
const envLoaderChannel = new MessageChannel();
|
|
67
62
|
|
|
68
63
|
// Set up message handlers before transferring ports
|
|
69
|
-
reactLoaderChannel.
|
|
70
|
-
cssLoaderChannel.
|
|
71
|
-
envLoaderChannel.
|
|
64
|
+
reactLoaderChannel.port2.on("message", developmentReactLoaderMessageHandler);
|
|
65
|
+
cssLoaderChannel.port2.on("message", developmentCssLoaderMessageHandler);
|
|
66
|
+
envLoaderChannel.port2.on("message", developmentEnvLoaderMessageHandler);
|
|
72
67
|
|
|
73
68
|
const reactLoaderPath =
|
|
74
69
|
"file://" + join(pluginRoot, "loader/react-loader.server.js");
|
|
@@ -77,29 +72,31 @@ try {
|
|
|
77
72
|
const envLoaderPath =
|
|
78
73
|
"file://" + join(pluginRoot, "loader/env-loader.development.js");
|
|
79
74
|
|
|
80
|
-
// Register loaders with their ports
|
|
81
|
-
register(reactLoaderPath, {
|
|
82
|
-
parentURL: pluginRoot,
|
|
83
|
-
data: {
|
|
84
|
-
id: "react-loader",
|
|
85
|
-
port: reactLoaderChannel.port1,
|
|
86
|
-
userOptions: workerData.userOptions,
|
|
87
|
-
},
|
|
88
|
-
transferList: [reactLoaderChannel.port1],
|
|
89
|
-
});
|
|
90
75
|
register(cssLoaderPath, {
|
|
91
76
|
parentURL: pluginRoot,
|
|
92
77
|
data: {
|
|
93
78
|
id: "css-loader",
|
|
94
79
|
port: cssLoaderChannel.port1,
|
|
80
|
+
userOptions: workerData.userOptions,
|
|
95
81
|
resolvedConfig: workerData.resolvedConfig,
|
|
96
82
|
},
|
|
97
83
|
transferList: [cssLoaderChannel.port1],
|
|
98
84
|
});
|
|
99
85
|
|
|
100
|
-
// Register
|
|
86
|
+
// Register tsx
|
|
101
87
|
registerTsx();
|
|
102
88
|
|
|
89
|
+
// Register loaders with their ports
|
|
90
|
+
register(reactLoaderPath, {
|
|
91
|
+
parentURL: pluginRoot,
|
|
92
|
+
data: {
|
|
93
|
+
id: "react-loader",
|
|
94
|
+
port: reactLoaderChannel.port1,
|
|
95
|
+
userOptions: workerData.userOptions,
|
|
96
|
+
},
|
|
97
|
+
transferList: [reactLoaderChannel.port1],
|
|
98
|
+
});
|
|
99
|
+
|
|
103
100
|
// Register env-loader (ensure this the last)
|
|
104
101
|
register(envLoaderPath, {
|
|
105
102
|
parentURL: pluginRoot,
|
|
@@ -59,17 +59,13 @@ export function clearServerActionFiles() {
|
|
|
59
59
|
serverActionFiles.clear();
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
export function addCssFile(id: string, cssFile: CssContent) {
|
|
63
|
-
cssFiles.set(id, cssFile);
|
|
64
|
-
}
|
|
65
62
|
|
|
66
63
|
|
|
67
|
-
export function addCssFileContent(id: string, code: string, userOptions: Pick<ResolvedUserOptions, "projectRoot" | "moduleBaseURL" | "moduleBasePath" | "moduleRootPath" | "css">) {
|
|
64
|
+
export function addCssFileContent(id: string, code: string, userOptions: Pick<ResolvedUserOptions, "projectRoot" | "moduleBaseURL" | "moduleBasePath" | "moduleRootPath" | "css" | "normalizer" | "moduleID">) {
|
|
68
65
|
if(typeof code !== "string"){
|
|
69
66
|
throw new Error(`Expected css to be loaded as a string, but got ${typeof code}`);
|
|
70
67
|
}
|
|
71
|
-
|
|
72
|
-
cssFiles.set(normalizeId, createCssProps({
|
|
68
|
+
cssFiles.set(id, createCssProps({
|
|
73
69
|
id,
|
|
74
70
|
code,
|
|
75
71
|
userOptions
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { resolveOptions } from "../../config/index.js";
|
|
2
|
+
import { hydrateUserOptions } from "../../helpers/index.js";
|
|
3
|
+
import { workerData } from "node:worker_threads";
|
|
4
|
+
const userOptionsResult = resolveOptions(hydrateUserOptions(workerData.userOptions));
|
|
5
|
+
if(userOptionsResult.type === "error") {
|
|
6
|
+
throw userOptionsResult.error;
|
|
7
|
+
}
|
|
8
|
+
export const userOptions = userOptionsResult.userOptions;
|
package/plugin/worker/types.ts
CHANGED
|
@@ -86,6 +86,7 @@ export type StreamHandlers = {
|
|
|
86
86
|
onServerActionResponse?: (id: string, result?: unknown, error?: string) => void;
|
|
87
87
|
onServerModule?: (id: string, url: string, source: string) => void;
|
|
88
88
|
onShutdown?: (id: string) => void;
|
|
89
|
+
onCssFile?: (id: string, code: string) => void;
|
|
89
90
|
};
|
|
90
91
|
|
|
91
92
|
// RSC Messages
|
|
@@ -288,6 +289,7 @@ export type RscWorkerInputMessage =
|
|
|
288
289
|
| HmrCleanupMessage
|
|
289
290
|
| CleanupCompleteMessage
|
|
290
291
|
| ServerActionMessage
|
|
292
|
+
| ServerActionResponseMessage
|
|
291
293
|
| ServerModuleMessage;
|
|
292
294
|
|
|
293
295
|
export interface CssFileRequestMessage extends WorkerMessage {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createBuildLoader.d.ts","sourceRoot":"","sources":["../../../plugin/loader/createBuildLoader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAErC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAI3C,MAAM,WAAW,kBAAkB,CACjC,CAAC,SAAS,WAAW,GAAG,WAAW,EACnC,SAAS,SAAS,YAAY,GAAG,YAAY;IAE7C,UAAU,EAAE,kBAAkB,CAAC;IAC/B,WAAW,EAAE,mBAAmB,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IAC/C,cAAc,EAAE,QAAQ,CAAC;IACzB,cAAc,EAAE,QAAQ,CAAC;IACzB,cAAc,EAAE,QAAQ,CAAC;CAC1B;AAED;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,CAAC,SAAS,WAAW,GAAG,WAAW,EACnC,SAAS,SAAS,YAAY,GAAG,YAAY,EAE7C,EACE,WAAW,EACX,cAAc,EACd,cAAc,EACd,cAAc,GACf,EAAE,kBAAkB,CAAC,CAAC,EAAE,SAAS,CAAC,EACnC,MAAM,EAAE,YAAY,gBAOkB,MAAM,mBAgJ7C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createBuildLoader.js","sources":["../../../plugin/loader/createBuildLoader.ts"],"sourcesContent":["import { join } from \"node:path\";\nimport type {\n InlineCssOpt,\n PagePropOpt,\n ResolvedUserConfig,\n ResolvedUserOptions,\n} from \"../../server.js\";\nimport type { Manifest } from \"vite\";\nimport { getModuleRef } from \"../helpers/moduleRefs.js\";\nimport type { OutputBundle } from \"rollup\";\nimport { temporaryReferences } from \"./temporaryReferences.js\";\nimport { toError } from \"../error/toError.js\";\n\nexport interface BuildLoaderOptions<\n T extends PagePropOpt = PagePropOpt,\n InlineCSS extends InlineCssOpt = InlineCssOpt\n> {\n userConfig: ResolvedUserConfig;\n userOptions: ResolvedUserOptions<T, InlineCSS>;\n serverManifest: Manifest;\n clientManifest: Manifest;\n staticManifest: Manifest;\n}\n\n/**\n * Creates a loader function for handling module resolution during build.\n *\n * The loader handles the following strategy:\n * - For client components: Use client manifest and client.browser.js\n * - For server components: Use server manifest and server.js\n * - For static assets: Use static manifest\n */\nexport async function createBuildLoader<\n T extends PagePropOpt = PagePropOpt,\n InlineCSS extends InlineCssOpt = InlineCssOpt\n>(\n {\n userOptions,\n serverManifest,\n clientManifest,\n staticManifest,\n }: BuildLoaderOptions<T, InlineCSS>,\n bundle: OutputBundle\n) {\n const manifestKeys = Object.keys(serverManifest);\n if (!manifestKeys.length) {\n throw new Error(\"Server manifest is empty\");\n }\n\n return async function buildLoader(id: string) {\n const [withoutQuery, query] = id.split(\"?\", 2);\n const [normalizedKey, normalizedValue] =\n userOptions.normalizer(withoutQuery);\n const moduleRef = getModuleRef(id);\n\n // Check if we have a temporary reference (cached module)\n if (temporaryReferences?.has(moduleRef)) {\n const mod = temporaryReferences.get(moduleRef);\n if (typeof mod === \"object\" && mod !== null && \"error\" in mod) {\n // ignore it\n } else {\n return mod;\n }\n }\n\n try {\n // For inline modules, handle them directly\n if (query === \"inline\") {\n const startsWithMarker = normalizedKey.split(\"-\")[0];\n const serverChunk =\n bundle[serverManifest[normalizedValue]?.file] ??\n bundle[staticManifest[normalizedValue]?.file] ??\n bundle[clientManifest[normalizedValue]?.file] ??\n bundle[withoutQuery] ??\n bundle[normalizedValue] ??\n Object.entries(bundle).find(\n ([, value]) => value.name === normalizedValue\n )?.[1] ??\n Object.entries(bundle).find(([_key]) =>\n _key.startsWith(startsWithMarker)\n )?.[1];\n\n if (serverChunk) {\n if (serverChunk.type === \"asset\") {\n // For CSS files, ensure we're in the React Server environment\n if (userOptions.autoDiscover.jsonPattern(normalizedValue)) {\n const jsonContent = serverChunk.source;\n if (typeof jsonContent === \"string\") {\n return { default: JSON.parse(jsonContent) };\n }\n } else if (userOptions.autoDiscover.cssPattern(normalizedValue)) {\n const cssContent = serverChunk.source;\n if (typeof cssContent === \"string\") {\n return { default: cssContent };\n }\n }\n return { default: serverChunk.source };\n } else if (\"code\" in serverChunk) {\n return { default: serverChunk.code };\n }\n }\n console.warn(\"Could not find inline module for: \" + normalizedValue);\n return null;\n }\n\n // Determine if this is a client component\n const isClientComponent =\n userOptions.autoDiscover.clientComponents(normalizedValue);\n const isServerAction =\n userOptions.autoDiscover.serverFunctions(normalizedValue);\n const isPage = userOptions.autoDiscover.pagePattern(normalizedValue);\n const isProps = userOptions.autoDiscover.propsPattern(normalizedValue);\n\n // For client components, use client manifest\n if (isClientComponent) {\n const clientEntry = clientManifest[normalizedValue];\n if (clientEntry) {\n try {\n const module = await import(\n join(\n userOptions.projectRoot,\n userOptions.build.outDir,\n userOptions.build.client,\n clientEntry.file\n )\n );\n temporaryReferences?.set(moduleRef, module);\n return module;\n } catch (error) {\n const err = toError(error);\n console.warn(\"Error loading client module:\", err);\n temporaryReferences?.delete(moduleRef);\n throw err;\n }\n }\n }\n\n // For server components and actions, use server manifest\n if (isServerAction || isPage || isProps) {\n const serverEntry = serverManifest[normalizedValue];\n if (serverEntry) {\n try {\n const module = await import(\n join(\n userOptions.projectRoot,\n userOptions.build.outDir,\n userOptions.build.server,\n serverEntry.file\n )\n );\n temporaryReferences?.set(moduleRef, module);\n return module;\n } catch (error) {\n const err = toError(error);\n console.warn(\"Error loading server module:\", err);\n temporaryReferences?.delete(moduleRef);\n throw err;\n }\n }\n }\n\n // For static assets, use static manifest\n const staticEntry = staticManifest[normalizedValue];\n if (staticEntry) {\n try {\n const module = await import(\n join(\n userOptions.projectRoot,\n userOptions.build.outDir,\n userOptions.build.static,\n staticEntry.file\n )\n );\n temporaryReferences?.set(moduleRef, module);\n return module;\n } catch (error) {\n const err = toError(error);\n console.warn(\"Error loading static module:\", err);\n temporaryReferences?.delete(moduleRef);\n throw err;\n }\n }\n\n throw new Error(`Module ${normalizedValue} not found during build`);\n } catch (error) {\n const emptyExports = {\n error: error instanceof Error ? error : new Error(String(error)),\n id: id,\n };\n temporaryReferences?.delete(moduleRef);\n return emptyExports;\n }\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;AAgCA,eAAsB,iBAIpB,CAAA;AAAA,EACE,WAAA;AAAA,EACA,cAAA;AAAA,EACA,cAAA;AAAA,EACA;AACF,CAAA,EACA,MACA,EAAA;AACA,EAAM,MAAA,YAAA,GAAe,MAAO,CAAA,IAAA,CAAK,cAAc,CAAA;AAC/C,EAAI,IAAA,CAAC,aAAa,MAAQ,EAAA;AACxB,IAAM,MAAA,IAAI,MAAM,0BAA0B,CAAA;AAAA;AAG5C,EAAO,OAAA,eAAe,YAAY,EAAY,EAAA;AAC5C,IAAA,MAAM,CAAC,YAAc,EAAA,KAAK,IAAI,EAAG,CAAA,KAAA,CAAM,KAAK,CAAC,CAAA;AAC7C,IAAA,MAAM,CAAC,aAAe,EAAA,eAAe,CACnC,GAAA,WAAA,CAAY,WAAW,YAAY,CAAA;AACrC,IAAM,MAAA,SAAA,GAAY,aAAa,EAAE,CAAA;AAGjC,IAAI,IAAA,mBAAA,EAAqB,GAAI,CAAA,SAAS,CAAG,EAAA;AACvC,MAAM,MAAA,GAAA,GAAM,mBAAoB,CAAA,GAAA,CAAI,SAAS,CAAA;AAC7C,MAAA,IAAI,OAAO,GAAQ,KAAA,QAAA,IAAY,GAAQ,KAAA,IAAA,IAAQ,WAAW,GAAK,EAAA,CAExD,MAAA;AACL,QAAO,OAAA,GAAA;AAAA;AACT;AAGF,IAAI,IAAA;AA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CAAA;AAAA,aAC3D,KAAO,EAAA;AACd,MAAA,MAAM,YAAe,GAAA;AAAA,QACnB,KAAA,EAAO,iBAAiB,KAAQ,GAAA,KAAA,GAAQ,IAAI,KAAM,CAAA,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,QAC/D;AAAA,OACF;AACA,MAAA,mBAAA,EAAqB,OAAO,SAAS,CAAA;AACrC,MAAO,OAAA,YAAA;AAAA;AACT,GACF;AACF;;;;"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { StreamPluginOptions } from "../types.js";
|
|
2
|
-
import type { Plugin } from "vite";
|
|
3
|
-
/**
|
|
4
|
-
* Plugin for loading various front-end react files like css-loader, react-loader, etc.
|
|
5
|
-
*
|
|
6
|
-
* Core responsibilities:
|
|
7
|
-
* 1. Use the load hook to use the appropriate loader for the file type
|
|
8
|
-
* 2. When used, we can assume that such files work the same as when used as node loader
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* export default defineConfig({
|
|
13
|
-
* plugins: [
|
|
14
|
-
* reactLoaderPlugin({
|
|
15
|
-
* projectRoot: process.cwd(),
|
|
16
|
-
* })
|
|
17
|
-
* ]
|
|
18
|
-
* });
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export declare function reactLoaderPlugin(options: StreamPluginOptions): Plugin;
|
|
22
|
-
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../plugin/loader/plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EACpB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC;;;;;;;;;;;;;;;;;GAiBG;AAEH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAOtE"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { resolveOptions } from "../config/resolveOptions.js";
|
|
2
|
-
/**
|
|
3
|
-
* Plugin for loading various front-end react files like css-loader, react-loader, etc.
|
|
4
|
-
*
|
|
5
|
-
* Core responsibilities:
|
|
6
|
-
* 1. Use the load hook to use the appropriate loader for the file type
|
|
7
|
-
* 2. When used, we can assume that such files work the same as when used as node loader
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```ts
|
|
11
|
-
* export default defineConfig({
|
|
12
|
-
* plugins: [
|
|
13
|
-
* reactLoaderPlugin({
|
|
14
|
-
* projectRoot: process.cwd(),
|
|
15
|
-
* })
|
|
16
|
-
* ]
|
|
17
|
-
* });
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export function reactLoaderPlugin(options) {
|
|
21
|
-
const resolvedOptionsResult = resolveOptions(options);
|
|
22
|
-
if (resolvedOptionsResult.type === "error")
|
|
23
|
-
throw resolvedOptionsResult.error;
|
|
24
|
-
return {
|
|
25
|
-
name: "vite:react-loader",
|
|
26
|
-
};
|
|
27
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"temporaryReferences.d.ts","sourceRoot":"","sources":["../../../plugin/loader/temporaryReferences.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,KAAgC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"temporaryReferences.js","sources":["../../../plugin/loader/temporaryReferences.ts"],"sourcesContent":["import { createTemporaryReferenceSet } from \"react-server-dom-esm/server.node\";\n\nexport const temporaryReferences = createTemporaryReferenceSet();\n"],"names":[],"mappings":";;;;;;;AAEO,MAAM,sBAAsB,2BAA4B;;;;"}
|
package/plugin/loader/plugin.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { resolveOptions } from "../config/resolveOptions.js";
|
|
2
|
-
import type {
|
|
3
|
-
StreamPluginOptions,
|
|
4
|
-
} from "../types.js";
|
|
5
|
-
import type { Plugin } from "vite";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Plugin for loading various front-end react files like css-loader, react-loader, etc.
|
|
9
|
-
*
|
|
10
|
-
* Core responsibilities:
|
|
11
|
-
* 1. Use the load hook to use the appropriate loader for the file type
|
|
12
|
-
* 2. When used, we can assume that such files work the same as when used as node loader
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* export default defineConfig({
|
|
17
|
-
* plugins: [
|
|
18
|
-
* reactLoaderPlugin({
|
|
19
|
-
* projectRoot: process.cwd(),
|
|
20
|
-
* })
|
|
21
|
-
* ]
|
|
22
|
-
* });
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
export function reactLoaderPlugin(options: StreamPluginOptions): Plugin {
|
|
27
|
-
const resolvedOptionsResult = resolveOptions(options);
|
|
28
|
-
if (resolvedOptionsResult.type === "error") throw resolvedOptionsResult.error;
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
name: "vite:react-loader",
|
|
32
|
-
};
|
|
33
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|