react-server-dom-rspack 0.0.1-alpha.1 → 0.0.1-alpha.2

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.
Files changed (57) hide show
  1. package/dist/client.browser.d.ts +23 -0
  2. package/dist/client.browser.js +41 -0
  3. package/dist/client.d.ts +1 -0
  4. package/dist/client.edge.d.ts +28 -0
  5. package/dist/client.edge.js +27 -0
  6. package/dist/client.js +1 -0
  7. package/dist/client.node.d.ts +11 -0
  8. package/dist/client.node.js +10 -0
  9. package/dist/index.d.ts +0 -0
  10. package/dist/index.js +2 -0
  11. package/dist/server.browser.d.ts +0 -0
  12. package/dist/server.browser.js +2 -0
  13. package/dist/server.d.ts +0 -0
  14. package/dist/server.edge.d.ts +29 -0
  15. package/dist/server.edge.js +44 -0
  16. package/dist/server.js +3 -0
  17. package/dist/server.node.d.ts +30 -0
  18. package/dist/server.node.js +48 -0
  19. package/dist/types.d.ts +41 -0
  20. package/dist/types.js +1 -0
  21. package/package.json +122 -12
  22. package/vendor/react-server-dom-webpack/LICENSE +21 -0
  23. package/vendor/react-server-dom-webpack/README.md +5 -0
  24. package/vendor/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +5006 -0
  25. package/vendor/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.production.js +1947 -0
  26. package/vendor/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +4987 -0
  27. package/vendor/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.js +2128 -0
  28. package/vendor/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +5130 -0
  29. package/vendor/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.production.js +2256 -0
  30. package/vendor/react-server-dom-webpack/cjs/react-server-dom-webpack-node-register.js +69 -0
  31. package/vendor/react-server-dom-webpack/cjs/react-server-dom-webpack-plugin.js +404 -0
  32. package/vendor/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +5515 -0
  33. package/vendor/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.js +3264 -0
  34. package/vendor/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +5617 -0
  35. package/vendor/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.js +3299 -0
  36. package/vendor/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +6403 -0
  37. package/vendor/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.js +3517 -0
  38. package/vendor/react-server-dom-webpack/client.browser.js +7 -0
  39. package/vendor/react-server-dom-webpack/client.edge.js +7 -0
  40. package/vendor/react-server-dom-webpack/client.js +3 -0
  41. package/vendor/react-server-dom-webpack/client.node.js +7 -0
  42. package/vendor/react-server-dom-webpack/esm/package.json +3 -0
  43. package/vendor/react-server-dom-webpack/esm/react-server-dom-webpack-node-loader.production.js +515 -0
  44. package/vendor/react-server-dom-webpack/index.js +12 -0
  45. package/vendor/react-server-dom-webpack/node-register.js +3 -0
  46. package/vendor/react-server-dom-webpack/package.json +96 -0
  47. package/vendor/react-server-dom-webpack/plugin.js +3 -0
  48. package/vendor/react-server-dom-webpack/server.browser.js +17 -0
  49. package/vendor/react-server-dom-webpack/server.edge.js +18 -0
  50. package/vendor/react-server-dom-webpack/server.js +6 -0
  51. package/vendor/react-server-dom-webpack/server.node.js +20 -0
  52. package/vendor/react-server-dom-webpack/static.browser.js +10 -0
  53. package/vendor/react-server-dom-webpack/static.edge.js +10 -0
  54. package/vendor/react-server-dom-webpack/static.js +6 -0
  55. package/vendor/react-server-dom-webpack/static.node.js +11 -0
  56. package/dist/client.mjs +0 -19
  57. package/dist/server.mjs +0 -11
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === 'production') {
4
+ module.exports = require('./cjs/react-server-dom-webpack-client.browser.production.js');
5
+ } else {
6
+ module.exports = require('./cjs/react-server-dom-webpack-client.browser.development.js');
7
+ }
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === 'production') {
4
+ module.exports = require('./cjs/react-server-dom-webpack-client.edge.production.js');
5
+ } else {
6
+ module.exports = require('./cjs/react-server-dom-webpack-client.edge.development.js');
7
+ }
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ module.exports = require('./client.browser');
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === 'production') {
4
+ module.exports = require('./cjs/react-server-dom-webpack-client.node.production.js');
5
+ } else {
6
+ module.exports = require('./cjs/react-server-dom-webpack-client.node.development.js');
7
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,515 @@
1
+ /**
2
+ * @license React
3
+ * react-server-dom-webpack-node-loader.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+
11
+ import * as acorn from 'acorn-loose';
12
+ import readMappings from 'webpack-sources/lib/helpers/readMappings.js';
13
+ import createMappingsSerializer from 'webpack-sources/lib/helpers/createMappingsSerializer.js';
14
+
15
+ const assign = Object.assign;
16
+
17
+ let warnedAboutConditionsFlag = false;
18
+ let stashedGetSource = null;
19
+ let stashedResolve = null;
20
+ async function resolve(specifier, context, defaultResolve) {
21
+ // We stash this in case we end up needing to resolve export * statements later.
22
+ stashedResolve = defaultResolve;
23
+ if (!context.conditions.includes('react-server')) {
24
+ context = assign({}, context, {
25
+ conditions: [].concat(context.conditions, ['react-server'])
26
+ });
27
+ if (!warnedAboutConditionsFlag) {
28
+ warnedAboutConditionsFlag = true;
29
+ // eslint-disable-next-line react-internal/no-production-logging
30
+ console.warn('You did not run Node.js with the `--conditions react-server` flag. ' + 'Any "react-server" override will only work with ESM imports.');
31
+ }
32
+ }
33
+ return await defaultResolve(specifier, context, defaultResolve);
34
+ }
35
+ async function getSource(url, context, defaultGetSource) {
36
+ // We stash this in case we end up needing to resolve export * statements later.
37
+ stashedGetSource = defaultGetSource;
38
+ return defaultGetSource(url, context, defaultGetSource);
39
+ }
40
+ function addExportedEntry(exportedEntries, localNames, localName, exportedName, type, loc) {
41
+ if (localNames.has(localName)) {
42
+ // If the same local name is exported more than once, we only need one of the names.
43
+ return;
44
+ }
45
+ exportedEntries.push({
46
+ localName,
47
+ exportedName,
48
+ type,
49
+ loc,
50
+ originalLine: -1,
51
+ originalColumn: -1,
52
+ originalSource: -1,
53
+ nameIndex: -1
54
+ });
55
+ }
56
+ function addLocalExportedNames(exportedEntries, localNames, node) {
57
+ switch (node.type) {
58
+ case 'Identifier':
59
+ addExportedEntry(exportedEntries, localNames, node.name, node.name, null, node.loc);
60
+ return;
61
+ case 'ObjectPattern':
62
+ for (let i = 0; i < node.properties.length; i++) addLocalExportedNames(exportedEntries, localNames, node.properties[i]);
63
+ return;
64
+ case 'ArrayPattern':
65
+ for (let i = 0; i < node.elements.length; i++) {
66
+ const element = node.elements[i];
67
+ if (element) addLocalExportedNames(exportedEntries, localNames, element);
68
+ }
69
+ return;
70
+ case 'Property':
71
+ addLocalExportedNames(exportedEntries, localNames, node.value);
72
+ return;
73
+ case 'AssignmentPattern':
74
+ addLocalExportedNames(exportedEntries, localNames, node.left);
75
+ return;
76
+ case 'RestElement':
77
+ addLocalExportedNames(exportedEntries, localNames, node.argument);
78
+ return;
79
+ case 'ParenthesizedExpression':
80
+ addLocalExportedNames(exportedEntries, localNames, node.expression);
81
+ return;
82
+ }
83
+ }
84
+ function transformServerModule(source, program, url, sourceMap, loader) {
85
+ const body = program.body;
86
+
87
+ // This entry list needs to be in source location order.
88
+ const exportedEntries = [];
89
+ // Dedupe set.
90
+ const localNames = new Set();
91
+ for (let i = 0; i < body.length; i++) {
92
+ const node = body[i];
93
+ switch (node.type) {
94
+ case 'ExportAllDeclaration':
95
+ // If export * is used, the other file needs to explicitly opt into "use server" too.
96
+ break;
97
+ case 'ExportDefaultDeclaration':
98
+ if (node.declaration.type === 'Identifier') {
99
+ addExportedEntry(exportedEntries, localNames, node.declaration.name, 'default', null, node.declaration.loc);
100
+ } else if (node.declaration.type === 'FunctionDeclaration') {
101
+ if (node.declaration.id) {
102
+ addExportedEntry(exportedEntries, localNames, node.declaration.id.name, 'default', 'function', node.declaration.id.loc);
103
+ }
104
+ }
105
+ continue;
106
+ case 'ExportNamedDeclaration':
107
+ if (node.declaration) {
108
+ if (node.declaration.type === 'VariableDeclaration') {
109
+ const declarations = node.declaration.declarations;
110
+ for (let j = 0; j < declarations.length; j++) {
111
+ addLocalExportedNames(exportedEntries, localNames, declarations[j].id);
112
+ }
113
+ } else {
114
+ const name = node.declaration.id.name;
115
+ addExportedEntry(exportedEntries, localNames, name, name, node.declaration.type === 'FunctionDeclaration' ? 'function' : null, node.declaration.id.loc);
116
+ }
117
+ }
118
+ if (node.specifiers) {
119
+ const specifiers = node.specifiers;
120
+ for (let j = 0; j < specifiers.length; j++) {
121
+ const specifier = specifiers[j];
122
+ addExportedEntry(exportedEntries, localNames, specifier.local.name, specifier.exported.name, null, specifier.local.loc);
123
+ }
124
+ }
125
+ continue;
126
+ }
127
+ }
128
+ let mappings = sourceMap && typeof sourceMap.mappings === 'string' ? sourceMap.mappings : '';
129
+ let newSrc = source;
130
+ if (exportedEntries.length > 0) {
131
+ let lastSourceIndex = 0;
132
+ let lastOriginalLine = 0;
133
+ let lastOriginalColumn = 0;
134
+ let lastNameIndex = 0;
135
+ let sourceLineCount = 0;
136
+ let lastMappedLine = 0;
137
+ if (sourceMap) {
138
+ // We iterate source mapping entries and our matched exports in parallel to source map
139
+ // them to their original location.
140
+ let nextEntryIdx = 0;
141
+ let nextEntryLine = exportedEntries[nextEntryIdx].loc.start.line;
142
+ let nextEntryColumn = exportedEntries[nextEntryIdx].loc.start.column;
143
+ readMappings(mappings, (generatedLine, generatedColumn, sourceIndex, originalLine, originalColumn, nameIndex) => {
144
+ if (generatedLine > nextEntryLine || generatedLine === nextEntryLine && generatedColumn > nextEntryColumn) {
145
+ // We're past the entry which means that the best match we have is the previous entry.
146
+ if (lastMappedLine === nextEntryLine) {
147
+ // Match
148
+ exportedEntries[nextEntryIdx].originalLine = lastOriginalLine;
149
+ exportedEntries[nextEntryIdx].originalColumn = lastOriginalColumn;
150
+ exportedEntries[nextEntryIdx].originalSource = lastSourceIndex;
151
+ exportedEntries[nextEntryIdx].nameIndex = lastNameIndex;
152
+ }
153
+ nextEntryIdx++;
154
+ if (nextEntryIdx < exportedEntries.length) {
155
+ nextEntryLine = exportedEntries[nextEntryIdx].loc.start.line;
156
+ nextEntryColumn = exportedEntries[nextEntryIdx].loc.start.column;
157
+ } else {
158
+ nextEntryLine = -1;
159
+ nextEntryColumn = -1;
160
+ }
161
+ }
162
+ lastMappedLine = generatedLine;
163
+ if (sourceIndex > -1) {
164
+ lastSourceIndex = sourceIndex;
165
+ }
166
+ if (originalLine > -1) {
167
+ lastOriginalLine = originalLine;
168
+ }
169
+ if (originalColumn > -1) {
170
+ lastOriginalColumn = originalColumn;
171
+ }
172
+ if (nameIndex > -1) {
173
+ lastNameIndex = nameIndex;
174
+ }
175
+ });
176
+ if (nextEntryIdx < exportedEntries.length) {
177
+ if (lastMappedLine === nextEntryLine) {
178
+ // Match
179
+ exportedEntries[nextEntryIdx].originalLine = lastOriginalLine;
180
+ exportedEntries[nextEntryIdx].originalColumn = lastOriginalColumn;
181
+ exportedEntries[nextEntryIdx].originalSource = lastSourceIndex;
182
+ exportedEntries[nextEntryIdx].nameIndex = lastNameIndex;
183
+ }
184
+ }
185
+ for (let lastIdx = mappings.length - 1; lastIdx >= 0 && mappings[lastIdx] === ';'; lastIdx--) {
186
+ // If the last mapped lines don't contain any segments, we don't get a callback from readMappings
187
+ // so we need to pad the number of mapped lines, with one for each empty line.
188
+ lastMappedLine++;
189
+ }
190
+ sourceLineCount = program.loc.end.line;
191
+ if (sourceLineCount < lastMappedLine) {
192
+ throw new Error('The source map has more mappings than there are lines.');
193
+ }
194
+ // If the original source string had more lines than there are mappings in the source map.
195
+ // Add some extra padding of unmapped lines so that any lines that we add line up.
196
+ for (let extraLines = sourceLineCount - lastMappedLine; extraLines > 0; extraLines--) {
197
+ mappings += ';';
198
+ }
199
+ } else {
200
+ // If a file doesn't have a source map then we generate a blank source map that just
201
+ // contains the original content and segments pointing to the original lines.
202
+ sourceLineCount = 1;
203
+ let idx = -1;
204
+ while ((idx = source.indexOf('\n', idx + 1)) !== -1) {
205
+ sourceLineCount++;
206
+ }
207
+ mappings = 'AAAA' + ';AACA'.repeat(sourceLineCount - 1);
208
+ sourceMap = {
209
+ version: 3,
210
+ sources: [url],
211
+ sourcesContent: [source],
212
+ mappings: mappings,
213
+ sourceRoot: ''
214
+ };
215
+ lastSourceIndex = 0;
216
+ lastOriginalLine = sourceLineCount;
217
+ lastOriginalColumn = 0;
218
+ lastNameIndex = -1;
219
+ lastMappedLine = sourceLineCount;
220
+ for (let i = 0; i < exportedEntries.length; i++) {
221
+ // Point each entry to original location.
222
+ const entry = exportedEntries[i];
223
+ entry.originalSource = 0;
224
+ entry.originalLine = entry.loc.start.line;
225
+ // We use column zero since we do the short-hand line-only source maps above.
226
+ entry.originalColumn = 0; // entry.loc.start.column;
227
+ }
228
+ }
229
+ newSrc += '\n\n;';
230
+ newSrc += 'import {registerServerReference} from "react-server-dom-webpack/server";\n';
231
+ if (mappings) {
232
+ mappings += ';;';
233
+ }
234
+ const createMapping = createMappingsSerializer();
235
+
236
+ // Create an empty mapping pointing to where we last left off to reset the counters.
237
+ let generatedLine = 1;
238
+ createMapping(generatedLine, 0, lastSourceIndex, lastOriginalLine, lastOriginalColumn, lastNameIndex);
239
+ for (let i = 0; i < exportedEntries.length; i++) {
240
+ const entry = exportedEntries[i];
241
+ generatedLine++;
242
+ if (entry.type !== 'function') {
243
+ // We first check if the export is a function and if so annotate it.
244
+ newSrc += 'if (typeof ' + entry.localName + ' === "function") ';
245
+ }
246
+ newSrc += 'registerServerReference(' + entry.localName + ',';
247
+ newSrc += JSON.stringify(url) + ',';
248
+ newSrc += JSON.stringify(entry.exportedName) + ');\n';
249
+ mappings += createMapping(generatedLine, 0, entry.originalSource, entry.originalLine, entry.originalColumn, entry.nameIndex);
250
+ }
251
+ }
252
+ if (sourceMap) {
253
+ // Override with an new mappings and serialize an inline source map.
254
+ sourceMap.mappings = mappings;
255
+ newSrc += '//# sourceMappingURL=data:application/json;charset=utf-8;base64,' + Buffer.from(JSON.stringify(sourceMap)).toString('base64');
256
+ }
257
+ return newSrc;
258
+ }
259
+ function addExportNames(names, node) {
260
+ switch (node.type) {
261
+ case 'Identifier':
262
+ names.push(node.name);
263
+ return;
264
+ case 'ObjectPattern':
265
+ for (let i = 0; i < node.properties.length; i++) addExportNames(names, node.properties[i]);
266
+ return;
267
+ case 'ArrayPattern':
268
+ for (let i = 0; i < node.elements.length; i++) {
269
+ const element = node.elements[i];
270
+ if (element) addExportNames(names, element);
271
+ }
272
+ return;
273
+ case 'Property':
274
+ addExportNames(names, node.value);
275
+ return;
276
+ case 'AssignmentPattern':
277
+ addExportNames(names, node.left);
278
+ return;
279
+ case 'RestElement':
280
+ addExportNames(names, node.argument);
281
+ return;
282
+ case 'ParenthesizedExpression':
283
+ addExportNames(names, node.expression);
284
+ return;
285
+ }
286
+ }
287
+ function resolveClientImport(specifier, parentURL) {
288
+ // Resolve an import specifier as if it was loaded by the client. This doesn't use
289
+ // the overrides that this loader does but instead reverts to the default.
290
+ // This resolution algorithm will not necessarily have the same configuration
291
+ // as the actual client loader. It should mostly work and if it doesn't you can
292
+ // always convert to explicit exported names instead.
293
+ const conditions = ['node', 'import'];
294
+ if (stashedResolve === null) {
295
+ throw new Error('Expected resolve to have been called before transformSource');
296
+ }
297
+ return stashedResolve(specifier, {
298
+ conditions,
299
+ parentURL
300
+ }, stashedResolve);
301
+ }
302
+ async function parseExportNamesInto(body, names, parentURL, loader) {
303
+ for (let i = 0; i < body.length; i++) {
304
+ const node = body[i];
305
+ switch (node.type) {
306
+ case 'ExportAllDeclaration':
307
+ if (node.exported) {
308
+ addExportNames(names, node.exported);
309
+ continue;
310
+ } else {
311
+ const _await$resolveClientI = await resolveClientImport(node.source.value, parentURL),
312
+ url = _await$resolveClientI.url;
313
+ const _await$loader = await loader(url, {
314
+ format: 'module',
315
+ conditions: [],
316
+ importAssertions: {}
317
+ }, loader),
318
+ source = _await$loader.source;
319
+ if (typeof source !== 'string') {
320
+ throw new Error('Expected the transformed source to be a string.');
321
+ }
322
+ let childBody;
323
+ try {
324
+ childBody = acorn.parse(source, {
325
+ ecmaVersion: '2024',
326
+ sourceType: 'module'
327
+ }).body;
328
+ } catch (x) {
329
+ // eslint-disable-next-line react-internal/no-production-logging
330
+ console.error('Error parsing %s %s', url, x.message);
331
+ continue;
332
+ }
333
+ await parseExportNamesInto(childBody, names, url, loader);
334
+ continue;
335
+ }
336
+ case 'ExportDefaultDeclaration':
337
+ names.push('default');
338
+ continue;
339
+ case 'ExportNamedDeclaration':
340
+ if (node.declaration) {
341
+ if (node.declaration.type === 'VariableDeclaration') {
342
+ const declarations = node.declaration.declarations;
343
+ for (let j = 0; j < declarations.length; j++) {
344
+ addExportNames(names, declarations[j].id);
345
+ }
346
+ } else {
347
+ addExportNames(names, node.declaration.id);
348
+ }
349
+ }
350
+ if (node.specifiers) {
351
+ const specifiers = node.specifiers;
352
+ for (let j = 0; j < specifiers.length; j++) {
353
+ addExportNames(names, specifiers[j].exported);
354
+ }
355
+ }
356
+ continue;
357
+ }
358
+ }
359
+ }
360
+ async function transformClientModule(program, url, sourceMap, loader) {
361
+ const body = program.body;
362
+ const names = [];
363
+ await parseExportNamesInto(body, names, url, loader);
364
+ if (names.length === 0) {
365
+ return '';
366
+ }
367
+ let newSrc = 'import {registerClientReference} from "react-server-dom-webpack/server";\n';
368
+ for (let i = 0; i < names.length; i++) {
369
+ const name = names[i];
370
+ if (name === 'default') {
371
+ newSrc += 'export default ';
372
+ newSrc += 'registerClientReference(function() {';
373
+ newSrc += 'throw new Error(' + JSON.stringify("Attempted to call the default export of " + url + " from the server " + "but it's on the client. It's not possible to invoke a client function from " + "the server, it can only be rendered as a Component or passed to props of a " + "Client Component.") + ');';
374
+ } else {
375
+ newSrc += 'export const ' + name + ' = ';
376
+ newSrc += 'registerClientReference(function() {';
377
+ newSrc += 'throw new Error(' + JSON.stringify("Attempted to call " + name + "() from the server but " + name + " is on the client. " + "It's not possible to invoke a client function from the server, it can " + "only be rendered as a Component or passed to props of a Client Component.") + ');';
378
+ }
379
+ newSrc += '},';
380
+ newSrc += JSON.stringify(url) + ',';
381
+ newSrc += JSON.stringify(name) + ');\n';
382
+ }
383
+
384
+ // TODO: Generate source maps for Client Reference functions so they can point to their
385
+ // original locations.
386
+ return newSrc;
387
+ }
388
+ async function loadClientImport(url, defaultTransformSource) {
389
+ if (stashedGetSource === null) {
390
+ throw new Error('Expected getSource to have been called before transformSource');
391
+ }
392
+ // TODO: Validate that this is another module by calling getFormat.
393
+ const _await$stashedGetSour = await stashedGetSource(url, {
394
+ format: 'module'
395
+ }, stashedGetSource),
396
+ source = _await$stashedGetSour.source;
397
+ const result = await defaultTransformSource(source, {
398
+ format: 'module',
399
+ url
400
+ }, defaultTransformSource);
401
+ return {
402
+ format: 'module',
403
+ source: result.source
404
+ };
405
+ }
406
+ async function transformModuleIfNeeded(source, url, loader) {
407
+ // Do a quick check for the exact string. If it doesn't exist, don't
408
+ // bother parsing.
409
+ if (source.indexOf('use client') === -1 && source.indexOf('use server') === -1) {
410
+ return source;
411
+ }
412
+ let sourceMappingURL = null;
413
+ let sourceMappingStart = 0;
414
+ let sourceMappingEnd = 0;
415
+ let sourceMappingLines = 0;
416
+ let program;
417
+ try {
418
+ program = acorn.parse(source, {
419
+ ecmaVersion: '2024',
420
+ sourceType: 'module',
421
+ locations: true,
422
+ onComment(block, text, start, end, startLoc, endLoc) {
423
+ if (text.startsWith('# sourceMappingURL=') || text.startsWith('@ sourceMappingURL=')) {
424
+ sourceMappingURL = text.slice(19);
425
+ sourceMappingStart = start;
426
+ sourceMappingEnd = end;
427
+ sourceMappingLines = endLoc.line - startLoc.line;
428
+ }
429
+ }
430
+ });
431
+ } catch (x) {
432
+ // eslint-disable-next-line react-internal/no-production-logging
433
+ console.error('Error parsing %s %s', url, x.message);
434
+ return source;
435
+ }
436
+ let useClient = false;
437
+ let useServer = false;
438
+ const body = program.body;
439
+ for (let i = 0; i < body.length; i++) {
440
+ const node = body[i];
441
+ if (node.type !== 'ExpressionStatement' || !node.directive) {
442
+ break;
443
+ }
444
+ if (node.directive === 'use client') {
445
+ useClient = true;
446
+ }
447
+ if (node.directive === 'use server') {
448
+ useServer = true;
449
+ }
450
+ }
451
+ if (!useClient && !useServer) {
452
+ return source;
453
+ }
454
+ if (useClient && useServer) {
455
+ throw new Error('Cannot have both "use client" and "use server" directives in the same file.');
456
+ }
457
+ let sourceMap = null;
458
+ if (sourceMappingURL) {
459
+ const sourceMapResult = await loader(sourceMappingURL,
460
+ // $FlowFixMe
461
+ {
462
+ format: 'json',
463
+ conditions: [],
464
+ importAssertions: {
465
+ type: 'json'
466
+ },
467
+ importAttributes: {
468
+ type: 'json'
469
+ }
470
+ }, loader);
471
+ const sourceMapString = typeof sourceMapResult.source === 'string' ? sourceMapResult.source :
472
+ // $FlowFixMe
473
+ sourceMapResult.source.toString('utf8');
474
+ sourceMap = JSON.parse(sourceMapString);
475
+
476
+ // Strip the source mapping comment. We'll re-add it below if needed.
477
+ source = source.slice(0, sourceMappingStart) + '\n'.repeat(sourceMappingLines) + source.slice(sourceMappingEnd);
478
+ }
479
+ if (useClient) {
480
+ return transformClientModule(program, url, sourceMap, loader);
481
+ }
482
+ return transformServerModule(source, program, url, sourceMap);
483
+ }
484
+ async function transformSource(source, context, defaultTransformSource) {
485
+ const transformed = await defaultTransformSource(source, context, defaultTransformSource);
486
+ if (context.format === 'module') {
487
+ const transformedSource = transformed.source;
488
+ if (typeof transformedSource !== 'string') {
489
+ throw new Error('Expected source to have been transformed to a string.');
490
+ }
491
+ const newSrc = await transformModuleIfNeeded(transformedSource, context.url, (url, ctx, defaultLoad) => {
492
+ return loadClientImport(url, defaultTransformSource);
493
+ });
494
+ return {
495
+ source: newSrc
496
+ };
497
+ }
498
+ return transformed;
499
+ }
500
+ async function load(url, context, defaultLoad) {
501
+ const result = await defaultLoad(url, context, defaultLoad);
502
+ if (result.format === 'module') {
503
+ if (typeof result.source !== 'string') {
504
+ throw new Error('Expected source to have been loaded into a string.');
505
+ }
506
+ const newSrc = await transformModuleIfNeeded(result.source, url, defaultLoad);
507
+ return {
508
+ format: 'module',
509
+ source: newSrc
510
+ };
511
+ }
512
+ return result;
513
+ }
514
+
515
+ export { getSource, load, resolve, transformSource };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow
8
+ */
9
+
10
+ 'use strict';
11
+
12
+ throw new Error('Use react-server-dom-webpack/client instead.');
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ module.exports = require('./cjs/react-server-dom-webpack-node-register.js');
@@ -0,0 +1,96 @@
1
+ {
2
+ "name": "react-server-dom-webpack",
3
+ "description": "React Server Components bindings for DOM using Webpack. This is intended to be integrated into meta-frameworks. It is not intended to be imported directly.",
4
+ "version": "19.2.3",
5
+ "keywords": [
6
+ "react"
7
+ ],
8
+ "homepage": "https://react.dev/",
9
+ "bugs": "https://github.com/facebook/react/issues",
10
+ "license": "MIT",
11
+ "files": [
12
+ "LICENSE",
13
+ "README.md",
14
+ "index.js",
15
+ "plugin.js",
16
+ "client.js",
17
+ "client.browser.js",
18
+ "client.edge.js",
19
+ "client.node.js",
20
+ "server.js",
21
+ "server.browser.js",
22
+ "server.edge.js",
23
+ "server.node.js",
24
+ "static.js",
25
+ "static.browser.js",
26
+ "static.edge.js",
27
+ "static.node.js",
28
+ "node-register.js",
29
+ "cjs/",
30
+ "esm/"
31
+ ],
32
+ "exports": {
33
+ ".": "./index.js",
34
+ "./plugin": "./plugin.js",
35
+ "./client": {
36
+ "workerd": "./client.edge.js",
37
+ "deno": "./client.edge.js",
38
+ "worker": "./client.edge.js",
39
+ "node": "./client.node.js",
40
+ "edge-light": "./client.edge.js",
41
+ "browser": "./client.browser.js",
42
+ "default": "./client.browser.js"
43
+ },
44
+ "./client.browser": "./client.browser.js",
45
+ "./client.edge": "./client.edge.js",
46
+ "./client.node": "./client.node.js",
47
+ "./server": {
48
+ "react-server": {
49
+ "workerd": "./server.edge.js",
50
+ "deno": "./server.browser.js",
51
+ "node": "./server.node.js",
52
+ "edge-light": "./server.edge.js",
53
+ "browser": "./server.browser.js"
54
+ },
55
+ "default": "./server.js"
56
+ },
57
+ "./server.browser": "./server.browser.js",
58
+ "./server.edge": "./server.edge.js",
59
+ "./server.node": "./server.node.js",
60
+ "./static": {
61
+ "react-server": {
62
+ "workerd": "./static.edge.js",
63
+ "deno": "./static.browser.js",
64
+ "node": "./static.node.js",
65
+ "edge-light": "./static.edge.js",
66
+ "browser": "./static.browser.js"
67
+ },
68
+ "default": "./static.js"
69
+ },
70
+ "./static.browser": "./static.browser.js",
71
+ "./static.edge": "./static.edge.js",
72
+ "./static.node": "./static.node.js",
73
+ "./node-loader": "./esm/react-server-dom-webpack-node-loader.production.js",
74
+ "./node-register": "./node-register.js",
75
+ "./package.json": "./package.json"
76
+ },
77
+ "main": "index.js",
78
+ "repository": {
79
+ "type": "git",
80
+ "url": "https://github.com/facebook/react.git",
81
+ "directory": "packages/react-server-dom-webpack"
82
+ },
83
+ "engines": {
84
+ "node": ">=0.10.0"
85
+ },
86
+ "peerDependencies": {
87
+ "react": "^19.2.3",
88
+ "react-dom": "^19.2.3",
89
+ "webpack": "^5.59.0"
90
+ },
91
+ "dependencies": {
92
+ "acorn-loose": "^8.3.0",
93
+ "neo-async": "^2.6.1",
94
+ "webpack-sources": "^3.2.0"
95
+ }
96
+ }
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ module.exports = require('./cjs/react-server-dom-webpack-plugin.js');
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ var s;
4
+ if (process.env.NODE_ENV === 'production') {
5
+ s = require('./cjs/react-server-dom-webpack-server.browser.production.js');
6
+ } else {
7
+ s = require('./cjs/react-server-dom-webpack-server.browser.development.js');
8
+ }
9
+
10
+ exports.renderToReadableStream = s.renderToReadableStream;
11
+ exports.decodeReply = s.decodeReply;
12
+ exports.decodeAction = s.decodeAction;
13
+ exports.decodeFormState = s.decodeFormState;
14
+ exports.registerServerReference = s.registerServerReference;
15
+ exports.registerClientReference = s.registerClientReference;
16
+ exports.createClientModuleProxy = s.createClientModuleProxy;
17
+ exports.createTemporaryReferenceSet = s.createTemporaryReferenceSet;