react-server-dom-webpack 19.1.0-canary-6aa8254b-20250312 → 19.1.0-canary-5398b711-20250314

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.
@@ -12,6 +12,16 @@
12
12
  "production" !== process.env.NODE_ENV &&
13
13
  (function () {
14
14
  function _defineProperty(obj, key, value) {
15
+ a: if ("object" == typeof key && key) {
16
+ var e = key[Symbol.toPrimitive];
17
+ if (void 0 !== e) {
18
+ key = e.call(key, "string");
19
+ if ("object" != typeof key) break a;
20
+ throw new TypeError("@@toPrimitive must return a primitive value.");
21
+ }
22
+ key = String(key);
23
+ }
24
+ key = "symbol" == typeof key ? key : key + "";
15
25
  key in obj
16
26
  ? Object.defineProperty(obj, key, {
17
27
  value: value,
@@ -2680,10 +2690,10 @@
2680
2690
  return hook.checkDCE ? !0 : !1;
2681
2691
  })({
2682
2692
  bundleType: 1,
2683
- version: "19.1.0-canary-6aa8254b-20250312",
2693
+ version: "19.1.0-canary-5398b711-20250314",
2684
2694
  rendererPackageName: "react-server-dom-webpack",
2685
2695
  currentDispatcherRef: ReactSharedInternals,
2686
- reconcilerVersion: "19.1.0-canary-6aa8254b-20250312",
2696
+ reconcilerVersion: "19.1.0-canary-5398b711-20250314",
2687
2697
  getCurrentComponentInfo: function () {
2688
2698
  return currentOwnerInDEV;
2689
2699
  }
@@ -12,6 +12,16 @@
12
12
  "production" !== process.env.NODE_ENV &&
13
13
  (function () {
14
14
  function _defineProperty(obj, key, value) {
15
+ a: if ("object" == typeof key && key) {
16
+ var e = key[Symbol.toPrimitive];
17
+ if (void 0 !== e) {
18
+ key = e.call(key, "string");
19
+ if ("object" != typeof key) break a;
20
+ throw new TypeError("@@toPrimitive must return a primitive value.");
21
+ }
22
+ key = String(key);
23
+ }
24
+ key = "symbol" == typeof key ? key : key + "";
15
25
  key in obj
16
26
  ? Object.defineProperty(obj, key, {
17
27
  value: value,
@@ -12,6 +12,16 @@
12
12
  "production" !== process.env.NODE_ENV &&
13
13
  (function () {
14
14
  function _defineProperty(obj, key, value) {
15
+ a: if ("object" == typeof key && key) {
16
+ var e = key[Symbol.toPrimitive];
17
+ if (void 0 !== e) {
18
+ key = e.call(key, "string");
19
+ if ("object" != typeof key) break a;
20
+ throw new TypeError("@@toPrimitive must return a primitive value.");
21
+ }
22
+ key = String(key);
23
+ }
24
+ key = "symbol" == typeof key ? key : key + "";
15
25
  key in obj
16
26
  ? Object.defineProperty(obj, key, {
17
27
  value: value,
@@ -12,6 +12,16 @@
12
12
  "production" !== process.env.NODE_ENV &&
13
13
  (function () {
14
14
  function _defineProperty(obj, key, value) {
15
+ a: if ("object" == typeof key && key) {
16
+ var e = key[Symbol.toPrimitive];
17
+ if (void 0 !== e) {
18
+ key = e.call(key, "string");
19
+ if ("object" != typeof key) break a;
20
+ throw new TypeError("@@toPrimitive must return a primitive value.");
21
+ }
22
+ key = String(key);
23
+ }
24
+ key = "symbol" == typeof key ? key : key + "";
15
25
  key in obj
16
26
  ? Object.defineProperty(obj, key, {
17
27
  value: value,
@@ -33,8 +33,9 @@ function _arrayLikeToArray(arr, len) {
33
33
  return arr2;
34
34
  }
35
35
  function _createForOfIteratorHelper(o, allowArrayLike) {
36
- var it;
37
- if ("undefined" === typeof Symbol || null == o[Symbol.iterator]) {
36
+ var it =
37
+ ("undefined" !== typeof Symbol && o[Symbol.iterator]) || o["@@iterator"];
38
+ if (!it) {
38
39
  if (
39
40
  Array.isArray(o) ||
40
41
  (it = _unsupportedIterableToArray(o)) ||
@@ -63,7 +64,7 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
63
64
  err;
64
65
  return {
65
66
  s: function () {
66
- it = o[Symbol.iterator]();
67
+ it = it.call(o);
67
68
  },
68
69
  n: function () {
69
70
  var step = it.next();
@@ -13,6 +13,16 @@
13
13
  (function () {
14
14
  function voidHandler() {}
15
15
  function _defineProperty(obj, key, value) {
16
+ a: if ("object" == typeof key && key) {
17
+ var e = key[Symbol.toPrimitive];
18
+ if (void 0 !== e) {
19
+ key = e.call(key, "string");
20
+ if ("object" != typeof key) break a;
21
+ throw new TypeError("@@toPrimitive must return a primitive value.");
22
+ }
23
+ key = String(key);
24
+ }
25
+ key = "symbol" == typeof key ? key : key + "";
16
26
  key in obj
17
27
  ? Object.defineProperty(obj, key, {
18
28
  value: value,
@@ -21,6 +21,16 @@
21
21
  return "function" === typeof maybeIterable ? maybeIterable : null;
22
22
  }
23
23
  function _defineProperty(obj, key, value) {
24
+ a: if ("object" == typeof key && key) {
25
+ var e = key[Symbol.toPrimitive];
26
+ if (void 0 !== e) {
27
+ key = e.call(key, "string");
28
+ if ("object" != typeof key) break a;
29
+ throw new TypeError("@@toPrimitive must return a primitive value.");
30
+ }
31
+ key = String(key);
32
+ }
33
+ key = "symbol" == typeof key ? key : key + "";
24
34
  key in obj
25
35
  ? Object.defineProperty(obj, key, {
26
36
  value: value,
@@ -13,6 +13,16 @@
13
13
  (function () {
14
14
  function voidHandler() {}
15
15
  function _defineProperty(obj, key, value) {
16
+ a: if ("object" == typeof key && key) {
17
+ var e = key[Symbol.toPrimitive];
18
+ if (void 0 !== e) {
19
+ key = e.call(key, "string");
20
+ if ("object" != typeof key) break a;
21
+ throw new TypeError("@@toPrimitive must return a primitive value.");
22
+ }
23
+ key = String(key);
24
+ }
25
+ key = "symbol" == typeof key ? key : key + "";
16
26
  key in obj
17
27
  ? Object.defineProperty(obj, key, {
18
28
  value: value,
@@ -3977,12 +3987,12 @@
3977
3987
  "React doesn't accept base64 encoded file uploads because we don't expect form data passed from a browser to ever encode data that way. If that's the wrong assumption, we can easily fix it."
3978
3988
  );
3979
3989
  pendingFiles++;
3980
- var JSCompiler_object_inline_chunks_150 = [];
3990
+ var JSCompiler_object_inline_chunks_153 = [];
3981
3991
  value.on("data", function (chunk) {
3982
- JSCompiler_object_inline_chunks_150.push(chunk);
3992
+ JSCompiler_object_inline_chunks_153.push(chunk);
3983
3993
  });
3984
3994
  value.on("end", function () {
3985
- var blob = new Blob(JSCompiler_object_inline_chunks_150, {
3995
+ var blob = new Blob(JSCompiler_object_inline_chunks_153, {
3986
3996
  type: mimeType
3987
3997
  });
3988
3998
  response._formData.append(name, blob, filename);
@@ -13,6 +13,16 @@
13
13
  (function () {
14
14
  function voidHandler() {}
15
15
  function _defineProperty(obj, key, value) {
16
+ a: if ("object" == typeof key && key) {
17
+ var e = key[Symbol.toPrimitive];
18
+ if (void 0 !== e) {
19
+ key = e.call(key, "string");
20
+ if ("object" != typeof key) break a;
21
+ throw new TypeError("@@toPrimitive must return a primitive value.");
22
+ }
23
+ key = String(key);
24
+ }
25
+ key = "symbol" == typeof key ? key : key + "";
16
26
  key in obj
17
27
  ? Object.defineProperty(obj, key, {
18
28
  value: value,
@@ -3940,12 +3950,12 @@
3940
3950
  "React doesn't accept base64 encoded file uploads because we don't expect form data passed from a browser to ever encode data that way. If that's the wrong assumption, we can easily fix it."
3941
3951
  );
3942
3952
  pendingFiles++;
3943
- var JSCompiler_object_inline_chunks_150 = [];
3953
+ var JSCompiler_object_inline_chunks_153 = [];
3944
3954
  value.on("data", function (chunk) {
3945
- JSCompiler_object_inline_chunks_150.push(chunk);
3955
+ JSCompiler_object_inline_chunks_153.push(chunk);
3946
3956
  });
3947
3957
  value.on("end", function () {
3948
- var blob = new Blob(JSCompiler_object_inline_chunks_150, {
3958
+ var blob = new Blob(JSCompiler_object_inline_chunks_153, {
3949
3959
  type: mimeType
3950
3960
  });
3951
3961
  response._formData.append(name, blob, filename);
@@ -20,19 +20,16 @@ let stashedResolve = null;
20
20
  async function resolve(specifier, context, defaultResolve) {
21
21
  // We stash this in case we end up needing to resolve export * statements later.
22
22
  stashedResolve = defaultResolve;
23
-
24
23
  if (!context.conditions.includes('react-server')) {
25
24
  context = assign({}, context, {
26
25
  conditions: [].concat(context.conditions, ['react-server'])
27
26
  });
28
-
29
27
  if (!warnedAboutConditionsFlag) {
30
- warnedAboutConditionsFlag = true; // eslint-disable-next-line react-internal/no-production-logging
31
-
28
+ warnedAboutConditionsFlag = true;
29
+ // eslint-disable-next-line react-internal/no-production-logging
32
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.');
33
31
  }
34
32
  }
35
-
36
33
  return await defaultResolve(specifier, context, defaultResolve);
37
34
  }
38
35
  async function getSource(url, context, defaultGetSource) {
@@ -40,13 +37,11 @@ async function getSource(url, context, defaultGetSource) {
40
37
  stashedGetSource = defaultGetSource;
41
38
  return defaultGetSource(url, context, defaultGetSource);
42
39
  }
43
-
44
40
  function addExportedEntry(exportedEntries, localNames, localName, exportedName, type, loc) {
45
41
  if (localNames.has(localName)) {
46
42
  // If the same local name is exported more than once, we only need one of the names.
47
43
  return;
48
44
  }
49
-
50
45
  exportedEntries.push({
51
46
  localName,
52
47
  exportedName,
@@ -58,59 +53,47 @@ function addExportedEntry(exportedEntries, localNames, localName, exportedName,
58
53
  nameIndex: -1
59
54
  });
60
55
  }
61
-
62
56
  function addLocalExportedNames(exportedEntries, localNames, node) {
63
57
  switch (node.type) {
64
58
  case 'Identifier':
65
59
  addExportedEntry(exportedEntries, localNames, node.name, node.name, null, node.loc);
66
60
  return;
67
-
68
61
  case 'ObjectPattern':
69
62
  for (let i = 0; i < node.properties.length; i++) addLocalExportedNames(exportedEntries, localNames, node.properties[i]);
70
-
71
63
  return;
72
-
73
64
  case 'ArrayPattern':
74
65
  for (let i = 0; i < node.elements.length; i++) {
75
66
  const element = node.elements[i];
76
67
  if (element) addLocalExportedNames(exportedEntries, localNames, element);
77
68
  }
78
-
79
69
  return;
80
-
81
70
  case 'Property':
82
71
  addLocalExportedNames(exportedEntries, localNames, node.value);
83
72
  return;
84
-
85
73
  case 'AssignmentPattern':
86
74
  addLocalExportedNames(exportedEntries, localNames, node.left);
87
75
  return;
88
-
89
76
  case 'RestElement':
90
77
  addLocalExportedNames(exportedEntries, localNames, node.argument);
91
78
  return;
92
-
93
79
  case 'ParenthesizedExpression':
94
80
  addLocalExportedNames(exportedEntries, localNames, node.expression);
95
81
  return;
96
82
  }
97
83
  }
98
-
99
84
  function transformServerModule(source, program, url, sourceMap, loader) {
100
- const body = program.body; // This entry list needs to be in source location order.
101
-
102
- const exportedEntries = []; // Dedupe set.
85
+ const body = program.body;
103
86
 
87
+ // This entry list needs to be in source location order.
88
+ const exportedEntries = [];
89
+ // Dedupe set.
104
90
  const localNames = new Set();
105
-
106
91
  for (let i = 0; i < body.length; i++) {
107
92
  const node = body[i];
108
-
109
93
  switch (node.type) {
110
94
  case 'ExportAllDeclaration':
111
95
  // If export * is used, the other file needs to explicitly opt into "use server" too.
112
96
  break;
113
-
114
97
  case 'ExportDefaultDeclaration':
115
98
  if (node.declaration.type === 'Identifier') {
116
99
  addExportedEntry(exportedEntries, localNames, node.declaration.name, 'default', null, node.declaration.loc);
@@ -119,14 +102,11 @@ function transformServerModule(source, program, url, sourceMap, loader) {
119
102
  addExportedEntry(exportedEntries, localNames, node.declaration.id.name, 'default', 'function', node.declaration.id.loc);
120
103
  }
121
104
  }
122
-
123
105
  continue;
124
-
125
106
  case 'ExportNamedDeclaration':
126
107
  if (node.declaration) {
127
108
  if (node.declaration.type === 'VariableDeclaration') {
128
109
  const declarations = node.declaration.declarations;
129
-
130
110
  for (let j = 0; j < declarations.length; j++) {
131
111
  addLocalExportedNames(exportedEntries, localNames, declarations[j].id);
132
112
  }
@@ -135,23 +115,18 @@ function transformServerModule(source, program, url, sourceMap, loader) {
135
115
  addExportedEntry(exportedEntries, localNames, name, name, node.declaration.type === 'FunctionDeclaration' ? 'function' : null, node.declaration.id.loc);
136
116
  }
137
117
  }
138
-
139
118
  if (node.specifiers) {
140
119
  const specifiers = node.specifiers;
141
-
142
120
  for (let j = 0; j < specifiers.length; j++) {
143
121
  const specifier = specifiers[j];
144
122
  addExportedEntry(exportedEntries, localNames, specifier.local.name, specifier.exported.name, null, specifier.local.loc);
145
123
  }
146
124
  }
147
-
148
125
  continue;
149
126
  }
150
127
  }
151
-
152
128
  let mappings = sourceMap && typeof sourceMap.mappings === 'string' ? sourceMap.mappings : '';
153
129
  let newSrc = source;
154
-
155
130
  if (exportedEntries.length > 0) {
156
131
  let lastSourceIndex = 0;
157
132
  let lastOriginalLine = 0;
@@ -159,7 +134,6 @@ function transformServerModule(source, program, url, sourceMap, loader) {
159
134
  let lastNameIndex = 0;
160
135
  let sourceLineCount = 0;
161
136
  let lastMappedLine = 0;
162
-
163
137
  if (sourceMap) {
164
138
  // We iterate source mapping entries and our matched exports in parallel to source map
165
139
  // them to their original location.
@@ -176,9 +150,7 @@ function transformServerModule(source, program, url, sourceMap, loader) {
176
150
  exportedEntries[nextEntryIdx].originalSource = lastSourceIndex;
177
151
  exportedEntries[nextEntryIdx].nameIndex = lastNameIndex;
178
152
  }
179
-
180
153
  nextEntryIdx++;
181
-
182
154
  if (nextEntryIdx < exportedEntries.length) {
183
155
  nextEntryLine = exportedEntries[nextEntryIdx].loc.start.line;
184
156
  nextEntryColumn = exportedEntries[nextEntryIdx].loc.start.column;
@@ -187,26 +159,20 @@ function transformServerModule(source, program, url, sourceMap, loader) {
187
159
  nextEntryColumn = -1;
188
160
  }
189
161
  }
190
-
191
162
  lastMappedLine = generatedLine;
192
-
193
163
  if (sourceIndex > -1) {
194
164
  lastSourceIndex = sourceIndex;
195
165
  }
196
-
197
166
  if (originalLine > -1) {
198
167
  lastOriginalLine = originalLine;
199
168
  }
200
-
201
169
  if (originalColumn > -1) {
202
170
  lastOriginalColumn = originalColumn;
203
171
  }
204
-
205
172
  if (nameIndex > -1) {
206
173
  lastNameIndex = nameIndex;
207
174
  }
208
175
  });
209
-
210
176
  if (nextEntryIdx < exportedEntries.length) {
211
177
  if (lastMappedLine === nextEntryLine) {
212
178
  // Match
@@ -216,21 +182,17 @@ function transformServerModule(source, program, url, sourceMap, loader) {
216
182
  exportedEntries[nextEntryIdx].nameIndex = lastNameIndex;
217
183
  }
218
184
  }
219
-
220
185
  for (let lastIdx = mappings.length - 1; lastIdx >= 0 && mappings[lastIdx] === ';'; lastIdx--) {
221
186
  // If the last mapped lines don't contain any segments, we don't get a callback from readMappings
222
187
  // so we need to pad the number of mapped lines, with one for each empty line.
223
188
  lastMappedLine++;
224
189
  }
225
-
226
190
  sourceLineCount = program.loc.end.line;
227
-
228
191
  if (sourceLineCount < lastMappedLine) {
229
192
  throw new Error('The source map has more mappings than there are lines.');
230
- } // If the original source string had more lines than there are mappings in the source map.
193
+ }
194
+ // If the original source string had more lines than there are mappings in the source map.
231
195
  // Add some extra padding of unmapped lines so that any lines that we add line up.
232
-
233
-
234
196
  for (let extraLines = sourceLineCount - lastMappedLine; extraLines > 0; extraLines--) {
235
197
  mappings += ';';
236
198
  }
@@ -239,11 +201,9 @@ function transformServerModule(source, program, url, sourceMap, loader) {
239
201
  // contains the original content and segments pointing to the original lines.
240
202
  sourceLineCount = 1;
241
203
  let idx = -1;
242
-
243
204
  while ((idx = source.indexOf('\n', idx + 1)) !== -1) {
244
205
  sourceLineCount++;
245
206
  }
246
-
247
207
  mappings = 'AAAA' + ';AACA'.repeat(sourceLineCount - 1);
248
208
  sourceMap = {
249
209
  version: 3,
@@ -257,91 +217,73 @@ function transformServerModule(source, program, url, sourceMap, loader) {
257
217
  lastOriginalColumn = 0;
258
218
  lastNameIndex = -1;
259
219
  lastMappedLine = sourceLineCount;
260
-
261
220
  for (let i = 0; i < exportedEntries.length; i++) {
262
221
  // Point each entry to original location.
263
222
  const entry = exportedEntries[i];
264
223
  entry.originalSource = 0;
265
- entry.originalLine = entry.loc.start.line; // We use column zero since we do the short-hand line-only source maps above.
266
-
224
+ entry.originalLine = entry.loc.start.line;
225
+ // We use column zero since we do the short-hand line-only source maps above.
267
226
  entry.originalColumn = 0; // entry.loc.start.column;
268
227
  }
269
228
  }
270
-
271
229
  newSrc += '\n\n;';
272
230
  newSrc += 'import {registerServerReference} from "react-server-dom-webpack/server";\n';
273
-
274
231
  if (mappings) {
275
232
  mappings += ';;';
276
233
  }
234
+ const createMapping = createMappingsSerializer();
277
235
 
278
- const createMapping = createMappingsSerializer(); // Create an empty mapping pointing to where we last left off to reset the counters.
279
-
236
+ // Create an empty mapping pointing to where we last left off to reset the counters.
280
237
  let generatedLine = 1;
281
238
  createMapping(generatedLine, 0, lastSourceIndex, lastOriginalLine, lastOriginalColumn, lastNameIndex);
282
-
283
239
  for (let i = 0; i < exportedEntries.length; i++) {
284
240
  const entry = exportedEntries[i];
285
241
  generatedLine++;
286
-
287
242
  if (entry.type !== 'function') {
288
243
  // We first check if the export is a function and if so annotate it.
289
244
  newSrc += 'if (typeof ' + entry.localName + ' === "function") ';
290
245
  }
291
-
292
246
  newSrc += 'registerServerReference(' + entry.localName + ',';
293
247
  newSrc += JSON.stringify(url) + ',';
294
248
  newSrc += JSON.stringify(entry.exportedName) + ');\n';
295
249
  mappings += createMapping(generatedLine, 0, entry.originalSource, entry.originalLine, entry.originalColumn, entry.nameIndex);
296
250
  }
297
251
  }
298
-
299
252
  if (sourceMap) {
300
253
  // Override with an new mappings and serialize an inline source map.
301
254
  sourceMap.mappings = mappings;
302
255
  newSrc += '//# sourceMappingURL=data:application/json;charset=utf-8;base64,' + Buffer.from(JSON.stringify(sourceMap)).toString('base64');
303
256
  }
304
-
305
257
  return newSrc;
306
258
  }
307
-
308
259
  function addExportNames(names, node) {
309
260
  switch (node.type) {
310
261
  case 'Identifier':
311
262
  names.push(node.name);
312
263
  return;
313
-
314
264
  case 'ObjectPattern':
315
265
  for (let i = 0; i < node.properties.length; i++) addExportNames(names, node.properties[i]);
316
-
317
266
  return;
318
-
319
267
  case 'ArrayPattern':
320
268
  for (let i = 0; i < node.elements.length; i++) {
321
269
  const element = node.elements[i];
322
270
  if (element) addExportNames(names, element);
323
271
  }
324
-
325
272
  return;
326
-
327
273
  case 'Property':
328
274
  addExportNames(names, node.value);
329
275
  return;
330
-
331
276
  case 'AssignmentPattern':
332
277
  addExportNames(names, node.left);
333
278
  return;
334
-
335
279
  case 'RestElement':
336
280
  addExportNames(names, node.argument);
337
281
  return;
338
-
339
282
  case 'ParenthesizedExpression':
340
283
  addExportNames(names, node.expression);
341
284
  return;
342
285
  }
343
286
  }
344
-
345
287
  function resolveClientImport(specifier, parentURL) {
346
288
  // Resolve an import specifier as if it was loaded by the client. This doesn't use
347
289
  // the overrides that this loader does but instead reverts to the default.
@@ -349,21 +291,17 @@ function resolveClientImport(specifier, parentURL) {
349
291
  // as the actual client loader. It should mostly work and if it doesn't you can
350
292
  // always convert to explicit exported names instead.
351
293
  const conditions = ['node', 'import'];
352
-
353
294
  if (stashedResolve === null) {
354
295
  throw new Error('Expected resolve to have been called before transformSource');
355
296
  }
356
-
357
297
  return stashedResolve(specifier, {
358
298
  conditions,
359
299
  parentURL
360
300
  }, stashedResolve);
361
301
  }
362
-
363
302
  async function parseExportNamesInto(body, names, parentURL, loader) {
364
303
  for (let i = 0; i < body.length; i++) {
365
304
  const node = body[i];
366
-
367
305
  switch (node.type) {
368
306
  case 'ExportAllDeclaration':
369
307
  if (node.exported) {
@@ -371,21 +309,17 @@ async function parseExportNamesInto(body, names, parentURL, loader) {
371
309
  continue;
372
310
  } else {
373
311
  const _await$resolveClientI = await resolveClientImport(node.source.value, parentURL),
374
- url = _await$resolveClientI.url;
375
-
312
+ url = _await$resolveClientI.url;
376
313
  const _await$loader = await loader(url, {
377
- format: 'module',
378
- conditions: [],
379
- importAssertions: {}
380
- }, loader),
381
- source = _await$loader.source;
382
-
314
+ format: 'module',
315
+ conditions: [],
316
+ importAssertions: {}
317
+ }, loader),
318
+ source = _await$loader.source;
383
319
  if (typeof source !== 'string') {
384
320
  throw new Error('Expected the transformed source to be a string.');
385
321
  }
386
-
387
322
  let childBody;
388
-
389
323
  try {
390
324
  childBody = acorn.parse(source, {
391
325
  ecmaVersion: '2024',
@@ -396,20 +330,16 @@ async function parseExportNamesInto(body, names, parentURL, loader) {
396
330
  console.error('Error parsing %s %s', url, x.message);
397
331
  continue;
398
332
  }
399
-
400
333
  await parseExportNamesInto(childBody, names, url, loader);
401
334
  continue;
402
335
  }
403
-
404
336
  case 'ExportDefaultDeclaration':
405
337
  names.push('default');
406
338
  continue;
407
-
408
339
  case 'ExportNamedDeclaration':
409
340
  if (node.declaration) {
410
341
  if (node.declaration.type === 'VariableDeclaration') {
411
342
  const declarations = node.declaration.declarations;
412
-
413
343
  for (let j = 0; j < declarations.length; j++) {
414
344
  addExportNames(names, declarations[j].id);
415
345
  }
@@ -417,34 +347,26 @@ async function parseExportNamesInto(body, names, parentURL, loader) {
417
347
  addExportNames(names, node.declaration.id);
418
348
  }
419
349
  }
420
-
421
350
  if (node.specifiers) {
422
351
  const specifiers = node.specifiers;
423
-
424
352
  for (let j = 0; j < specifiers.length; j++) {
425
353
  addExportNames(names, specifiers[j].exported);
426
354
  }
427
355
  }
428
-
429
356
  continue;
430
357
  }
431
358
  }
432
359
  }
433
-
434
360
  async function transformClientModule(program, url, sourceMap, loader) {
435
361
  const body = program.body;
436
362
  const names = [];
437
363
  await parseExportNamesInto(body, names, url, loader);
438
-
439
364
  if (names.length === 0) {
440
365
  return '';
441
366
  }
442
-
443
367
  let newSrc = 'import {registerClientReference} from "react-server-dom-webpack/server";\n';
444
-
445
368
  for (let i = 0; i < names.length; i++) {
446
369
  const name = names[i];
447
-
448
370
  if (name === 'default') {
449
371
  newSrc += 'export default ';
450
372
  newSrc += 'registerClientReference(function() {';
@@ -454,28 +376,24 @@ async function transformClientModule(program, url, sourceMap, loader) {
454
376
  newSrc += 'registerClientReference(function() {';
455
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.") + ');';
456
378
  }
457
-
458
379
  newSrc += '},';
459
380
  newSrc += JSON.stringify(url) + ',';
460
381
  newSrc += JSON.stringify(name) + ');\n';
461
- } // TODO: Generate source maps for Client Reference functions so they can point to their
462
- // original locations.
463
-
382
+ }
464
383
 
384
+ // TODO: Generate source maps for Client Reference functions so they can point to their
385
+ // original locations.
465
386
  return newSrc;
466
387
  }
467
-
468
388
  async function loadClientImport(url, defaultTransformSource) {
469
389
  if (stashedGetSource === null) {
470
390
  throw new Error('Expected getSource to have been called before transformSource');
471
- } // TODO: Validate that this is another module by calling getFormat.
472
-
473
-
391
+ }
392
+ // TODO: Validate that this is another module by calling getFormat.
474
393
  const _await$stashedGetSour = await stashedGetSource(url, {
475
- format: 'module'
476
- }, stashedGetSource),
477
- source = _await$stashedGetSour.source;
478
-
394
+ format: 'module'
395
+ }, stashedGetSource),
396
+ source = _await$stashedGetSour.source;
479
397
  const result = await defaultTransformSource(source, {
480
398
  format: 'module',
481
399
  url
@@ -485,26 +403,22 @@ async function loadClientImport(url, defaultTransformSource) {
485
403
  source: result.source
486
404
  };
487
405
  }
488
-
489
406
  async function transformModuleIfNeeded(source, url, loader) {
490
407
  // Do a quick check for the exact string. If it doesn't exist, don't
491
408
  // bother parsing.
492
409
  if (source.indexOf('use client') === -1 && source.indexOf('use server') === -1) {
493
410
  return source;
494
411
  }
495
-
496
412
  let sourceMappingURL = null;
497
413
  let sourceMappingStart = 0;
498
414
  let sourceMappingEnd = 0;
499
415
  let sourceMappingLines = 0;
500
416
  let program;
501
-
502
417
  try {
503
418
  program = acorn.parse(source, {
504
419
  ecmaVersion: '2024',
505
420
  sourceType: 'module',
506
421
  locations: true,
507
-
508
422
  onComment(block, text, start, end, startLoc, endLoc) {
509
423
  if (text.startsWith('# sourceMappingURL=') || text.startsWith('@ sourceMappingURL=')) {
510
424
  sourceMappingURL = text.slice(19);
@@ -513,46 +427,37 @@ async function transformModuleIfNeeded(source, url, loader) {
513
427
  sourceMappingLines = endLoc.line - startLoc.line;
514
428
  }
515
429
  }
516
-
517
430
  });
518
431
  } catch (x) {
519
432
  // eslint-disable-next-line react-internal/no-production-logging
520
433
  console.error('Error parsing %s %s', url, x.message);
521
434
  return source;
522
435
  }
523
-
524
436
  let useClient = false;
525
437
  let useServer = false;
526
438
  const body = program.body;
527
-
528
439
  for (let i = 0; i < body.length; i++) {
529
440
  const node = body[i];
530
-
531
441
  if (node.type !== 'ExpressionStatement' || !node.directive) {
532
442
  break;
533
443
  }
534
-
535
444
  if (node.directive === 'use client') {
536
445
  useClient = true;
537
446
  }
538
-
539
447
  if (node.directive === 'use server') {
540
448
  useServer = true;
541
449
  }
542
450
  }
543
-
544
451
  if (!useClient && !useServer) {
545
452
  return source;
546
453
  }
547
-
548
454
  if (useClient && useServer) {
549
455
  throw new Error('Cannot have both "use client" and "use server" directives in the same file.');
550
456
  }
551
-
552
457
  let sourceMap = null;
553
-
554
458
  if (sourceMappingURL) {
555
- const sourceMapResult = await loader(sourceMappingURL, // $FlowFixMe
459
+ const sourceMapResult = await loader(sourceMappingURL,
460
+ // $FlowFixMe
556
461
  {
557
462
  format: 'json',
558
463
  conditions: [],
@@ -563,30 +468,26 @@ async function transformModuleIfNeeded(source, url, loader) {
563
468
  type: 'json'
564
469
  }
565
470
  }, loader);
566
- const sourceMapString = typeof sourceMapResult.source === 'string' ? sourceMapResult.source : // $FlowFixMe
471
+ const sourceMapString = typeof sourceMapResult.source === 'string' ? sourceMapResult.source :
472
+ // $FlowFixMe
567
473
  sourceMapResult.source.toString('utf8');
568
- sourceMap = JSON.parse(sourceMapString); // Strip the source mapping comment. We'll re-add it below if needed.
474
+ sourceMap = JSON.parse(sourceMapString);
569
475
 
476
+ // Strip the source mapping comment. We'll re-add it below if needed.
570
477
  source = source.slice(0, sourceMappingStart) + '\n'.repeat(sourceMappingLines) + source.slice(sourceMappingEnd);
571
478
  }
572
-
573
479
  if (useClient) {
574
480
  return transformClientModule(program, url, sourceMap, loader);
575
481
  }
576
-
577
482
  return transformServerModule(source, program, url, sourceMap);
578
483
  }
579
-
580
484
  async function transformSource(source, context, defaultTransformSource) {
581
485
  const transformed = await defaultTransformSource(source, context, defaultTransformSource);
582
-
583
486
  if (context.format === 'module') {
584
487
  const transformedSource = transformed.source;
585
-
586
488
  if (typeof transformedSource !== 'string') {
587
489
  throw new Error('Expected source to have been transformed to a string.');
588
490
  }
589
-
590
491
  const newSrc = await transformModuleIfNeeded(transformedSource, context.url, (url, ctx, defaultLoad) => {
591
492
  return loadClientImport(url, defaultTransformSource);
592
493
  });
@@ -594,24 +495,20 @@ async function transformSource(source, context, defaultTransformSource) {
594
495
  source: newSrc
595
496
  };
596
497
  }
597
-
598
498
  return transformed;
599
499
  }
600
500
  async function load(url, context, defaultLoad) {
601
501
  const result = await defaultLoad(url, context, defaultLoad);
602
-
603
502
  if (result.format === 'module') {
604
503
  if (typeof result.source !== 'string') {
605
504
  throw new Error('Expected source to have been loaded into a string.');
606
505
  }
607
-
608
506
  const newSrc = await transformModuleIfNeeded(result.source, url, defaultLoad);
609
507
  return {
610
508
  format: 'module',
611
509
  source: newSrc
612
510
  };
613
511
  }
614
-
615
512
  return result;
616
513
  }
617
514
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-server-dom-webpack",
3
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.1.0-canary-6aa8254b-20250312",
4
+ "version": "19.1.0-canary-5398b711-20250314",
5
5
  "keywords": [
6
6
  "react"
7
7
  ],
@@ -99,8 +99,8 @@
99
99
  "node": ">=0.10.0"
100
100
  },
101
101
  "peerDependencies": {
102
- "react": "19.1.0-canary-6aa8254b-20250312",
103
- "react-dom": "19.1.0-canary-6aa8254b-20250312",
102
+ "react": "19.1.0-canary-5398b711-20250314",
103
+ "react-dom": "19.1.0-canary-5398b711-20250314",
104
104
  "webpack": "^5.59.0"
105
105
  },
106
106
  "dependencies": {