react icon indicating copy to clipboard operation
react copied to clipboard

Support new `load`/`resolve` API for Node ESM loaders

Open mattvague opened this issue 3 years ago • 7 comments

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?

mattvague avatar Sep 21 '22 00:09 mattvague

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!

facebook-github-bot avatar Sep 21 '22 00:09 facebook-github-bot

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

sizebot avatar Sep 21 '22 00:09 sizebot

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

facebook-github-bot avatar Sep 21 '22 01:09 facebook-github-bot

Also: I know the flow types are broken, I'll fix them once I hear from someone that this is the right direction

mattvague avatar Sep 21 '22 01:09 mattvague

Neat. I had just started a branch to do the same. Yea this is the right direction.

sebmarkbage avatar Sep 21 '22 18:09 sebmarkbage

@sebmarkbage Great! Two questions then:

  1. What would you recommend doing about the flow type for the defaultTransformSource arg for the parseExportNamesInto function given that it's now used by both load and transformSource which have different signatures? I'm familiar with TS but new to Flow.
  2. How can I test this change / are there existing tests somewhere for this loader?

mattvague avatar Sep 21 '22 20:09 mattvague

@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

mattvague avatar Sep 21 '22 21:09 mattvague

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.

github-actions[bot] avatar Apr 10 '24 00:04 github-actions[bot]

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!

github-actions[bot] avatar Apr 17 '24 11:04 github-actions[bot]