Skip to content

fix: nonce for ReactDOM.preloadModule #33120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hi-ogawa
Copy link

@hi-ogawa hi-ogawa commented May 5, 2025

Summary

nonce option is mentioned in ReactDOM.preloadModule documentation https://react.dev/reference/react-dom/preloadModule, but I found that it has no effect. This looks like an minor oversight and this is a one liner fix PR.

How did you test this change?

Added a new test "ReactDOMFloat > preloadModule > supports nonce" in packages/react-dom/src/__tests__/ReactDOMFloat-test.js, which is a preloadModule equivalent of an existing test "ReactDOMFloat > preload > supports nonce".

@facebook-github-bot
Copy link

Hi @hi-ogawa!

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 cla@meta.com. Thanks!

@eps1lon
Copy link
Collaborator

eps1lon commented May 5, 2025

@hi-ogawa Thanks for filing this. Could you sign the CLA so that we can merge it if the PR is accepted. I pinged @gnoff for review who knows the most about these APIs.

@react-sizebot
Copy link

Comparing: 0ca8420...8db0989

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.js +1.12% 6.68 kB 6.76 kB +0.27% 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 528.27 kB 528.27 kB = 93.14 kB 93.14 kB
oss-experimental/react-dom/cjs/react-dom.production.js +1.12% 6.69 kB 6.76 kB +0.22% 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 633.90 kB 633.90 kB = 111.33 kB 111.33 kB
facebook-www/ReactDOM-prod.classic.js +0.01% 671.68 kB 671.76 kB = 117.77 kB 117.78 kB
facebook-www/ReactDOM-prod.modern.js +0.01% 661.96 kB 662.04 kB = 116.21 kB 116.21 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable-semver/react-dom/cjs/react-dom.react-server.production.js +1.54% 4.88 kB 4.95 kB +0.24% 1.26 kB 1.26 kB
oss-stable/react-dom/cjs/react-dom.react-server.production.js +1.53% 4.90 kB 4.98 kB +0.31% 1.28 kB 1.29 kB
oss-experimental/react-dom/cjs/react-dom.react-server.production.js +1.53% 4.91 kB 4.98 kB +0.31% 1.29 kB 1.29 kB
facebook-react-native/react-dom/cjs/ReactDOM-prod.js +1.16% 6.48 kB 6.55 kB +0.33% 1.81 kB 1.81 kB
facebook-react-native/react-dom/cjs/ReactDOM-profiling.js +1.16% 6.48 kB 6.55 kB +0.33% 1.81 kB 1.81 kB
oss-stable-semver/react-dom/cjs/react-dom.production.js +1.13% 6.66 kB 6.73 kB +0.11% 1.80 kB 1.81 kB
oss-stable/react-dom/cjs/react-dom.production.js +1.12% 6.68 kB 6.76 kB +0.27% 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom.production.js +1.12% 6.69 kB 6.76 kB +0.22% 1.83 kB 1.83 kB
oss-stable-semver/react-dom/cjs/react-dom.react-server.development.js +0.57% 14.21 kB 14.29 kB +0.11% 2.82 kB 2.83 kB
oss-stable/react-dom/cjs/react-dom.react-server.development.js +0.57% 14.24 kB 14.32 kB +0.11% 2.85 kB 2.85 kB
oss-experimental/react-dom/cjs/react-dom.react-server.development.js +0.57% 14.24 kB 14.32 kB +0.11% 2.86 kB 2.86 kB
facebook-react-native/react-dom/cjs/ReactDOM-dev.js +0.48% 16.74 kB 16.82 kB +0.06% 3.60 kB 3.61 kB
oss-stable-semver/react-dom/cjs/react-dom.development.js +0.46% 17.67 kB 17.75 kB +0.10% 3.82 kB 3.82 kB
oss-stable/react-dom/cjs/react-dom.development.js +0.46% 17.70 kB 17.78 kB +0.10% 3.85 kB 3.85 kB
oss-experimental/react-dom/cjs/react-dom.development.js +0.46% 17.70 kB 17.79 kB +0.10% 3.85 kB 3.85 kB

Generated by 🚫 dangerJS against 8db0989

@hi-ogawa
Copy link
Author

hi-ogawa commented May 5, 2025

Thanks for taking a look and assigning reviewers! I'm now checking CLA with my employer and it shouldn't take long. Thanks for the patience 🙏

@brijeshb42
Copy link

Related PR for nonce on style tags - #32461

@hi-ogawa
Copy link
Author

hi-ogawa commented May 10, 2025

Hmm, I realized that using nonce for non-inline script might not make sense in general 🤔 I wasn't really familiar with CSP, but the rational seems to be people use script-src 'self' or domain to whitelist allowed script url and nonce is specifically for inline scripts (or styles).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants