react/packages/react-server-dom-webpack
Timothy Yung 13f35433bc
Mock modules in tests using Module (#28678)
## Summary

Fixes a type validation error introduced in newer versions of Node.js
when calling `Module.prototype._compile` in our unit tests. (I tried but
have yet to pinpoint the precise change in Node.js that introduced this
vaildation.)

The specific error that currently occurs when running unit tests with
Node.js v18.16.1:

```
TypeError: The "mod" argument must be an instance of Module. Received an instance of Object

      80 |
      81 |     if (useServer) {
    > 82 |       originalCompile.apply(this, arguments);
         |                       ^
      83 |
      84 |       const moduleId: string = (url.pathToFileURL(filename).href: any);
      85 |
```

This fixes the type validation error by mocking modules using `new
Module()` instead of plain objects.

## How did you test this change?

Ran the unit tests successfully:

```
$ node --version
v18.16.1

$ yarn test
```
2024-03-29 13:19:54 -07:00
..
esm Split out Edge and Node implementations of the Flight Client (#26187) 2023-02-21 13:18:24 -05:00
npm Create a bunch of custom webpack vs unbundled node bundles (#26172) 2023-02-16 11:01:52 -05:00
src Mock modules in tests using Module (#28678) 2024-03-29 13:19:54 -07:00
client.browser.js Split out Edge and Node implementations of the Flight Client (#26187) 2023-02-21 13:18:24 -05:00
client.edge.js Split out Edge and Node implementations of the Flight Client (#26187) 2023-02-21 13:18:24 -05:00
client.js Create a bunch of custom webpack vs unbundled node bundles (#26172) 2023-02-16 11:01:52 -05:00
client.node.js Split out Edge and Node implementations of the Flight Client (#26187) 2023-02-21 13:18:24 -05:00
client.node.unbundled.js Split out Edge and Node implementations of the Flight Client (#26187) 2023-02-21 13:18:24 -05:00
index.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
node-register.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
package.json Bump canary versions to v19-canary (#28646) 2024-03-26 15:31:57 -04:00
plugin.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
README.md [Flight] Rename react-transport-... packages to react-server-... (#20403) 2020-12-08 08:08:57 -05:00
server.browser.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
server.edge.js Add Edge Server Builds for workerd / edge-light (#26116) 2023-02-07 15:10:01 -05:00
server.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
server.node.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
server.node.unbundled.js Create a bunch of custom webpack vs unbundled node bundles (#26172) 2023-02-16 11:01:52 -05:00

react-server-dom-webpack

Experimental React Flight bindings for DOM using Webpack.

Use it at your own risk.