Support new `load`/`resolve` API for Node ESM loaders
Summary
As explained here, the current node loader in react-server-dom-webpack only supports the older ESM loader API and not the new API. This PR adds support for the newer API by implementing the load function to replace getSource / transformSource
How did you test this change?
I am actually not sure how to test this within the react repo, I've only managed to test it within the context of my own project and it does seem to work. Ideas?
Hi @mattvague!
Thank you for your pull request and welcome to our community.
Action Required
In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.
Process
In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.
Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.
If you have received this in error or have any questions, please contact us at [email protected]. Thanks!
Comparing: b2748907c3cffb226447417957f2608a7c60c27d...34ef3cf2dbc4aec395e3a7965c23a81d719aa439
Critical size changes
Includes critical production bundles, as well as any change greater than 2%:
| Name | +/- | Base | Current | +/- gzip | Base gzip | Current gzip |
|---|---|---|---|---|---|---|
| oss-stable/react-dom/cjs/react-dom.production.min.js | = | 135.04 kB | 135.04 kB | = | 43.33 kB | 43.33 kB |
| oss-experimental/react-dom/cjs/react-dom.production.min.js | = | 142.50 kB | 142.50 kB | = | 45.51 kB | 45.51 kB |
| facebook-www/ReactDOM-prod.classic.js | = | 489.88 kB | 489.88 kB | = | 87.21 kB | 87.21 kB |
| facebook-www/ReactDOM-prod.modern.js | = | 475.17 kB | 475.17 kB | = | 85.01 kB | 85.01 kB |
| facebook-www/ReactDOMForked-prod.classic.js | = | 489.88 kB | 489.88 kB | = | 87.21 kB | 87.21 kB |
| oss-experimental/react-server-dom-webpack/esm/react-server-dom-webpack-node-loader.js | +12.73% | 8.52 kB | 9.61 kB | +3.56% | 2.84 kB | 2.94 kB |
| oss-stable-semver/react-server-dom-webpack/esm/react-server-dom-webpack-node-loader.js | +12.73% | 8.52 kB | 9.61 kB | +3.56% | 2.84 kB | 2.94 kB |
| oss-stable/react-server-dom-webpack/esm/react-server-dom-webpack-node-loader.js | +12.73% | 8.52 kB | 9.61 kB | +3.56% | 2.84 kB | 2.94 kB |
Significant size changes
Includes any change greater than 0.2%:
Expand to show
| Name | +/- | Base | Current | +/- gzip | Base gzip | Current gzip |
|---|---|---|---|---|---|---|
| oss-experimental/react-server-dom-webpack/esm/react-server-dom-webpack-node-loader.js | +12.73% | 8.52 kB | 9.61 kB | +3.56% | 2.84 kB | 2.94 kB |
| oss-stable-semver/react-server-dom-webpack/esm/react-server-dom-webpack-node-loader.js | +12.73% | 8.52 kB | 9.61 kB | +3.56% | 2.84 kB | 2.94 kB |
| oss-stable/react-server-dom-webpack/esm/react-server-dom-webpack-node-loader.js | +12.73% | 8.52 kB | 9.61 kB | +3.56% | 2.84 kB | 2.94 kB |
Generated by :no_entry_sign: dangerJS against 34ef3cf2dbc4aec395e3a7965c23a81d719aa439
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!
Also: I know the flow types are broken, I'll fix them once I hear from someone that this is the right direction
Neat. I had just started a branch to do the same. Yea this is the right direction.
@sebmarkbage Great! Two questions then:
- What would you recommend doing about the flow type for the
defaultTransformSourcearg for theparseExportNamesIntofunction given that it's now used by bothloadandtransformSourcewhich have different signatures? I'm familiar with TS but new to Flow. - How can I test this change / are there existing tests somewhere for this loader?
@sebmarkbage Also, while we're here: is there any chance of modifying react-server-dom-webpack so that it supports extensions other than .server.js / .client.js? In my project I'd like to be able to, for example, treat all .mdx files as server components as well as be able to support .client.ts and .server.ts files. Right now I've accomplished this with patch-package but it'd probably be nice to make it configureable. Would be happy to open a separate issue for this and/or submit a PR, but wanted to run the idea by you first
This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.
Closing this pull request after a prolonged period of inactivity. If this issue is still present in the latest release, please ask for this pull request to be reopened. Thank you!