Skip to content
New issue

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

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

Already on GitHub? # to your account

Use globalThis if possible to access fetch in react-fetch browser build #22777

Merged
merged 1 commit into from
Nov 16, 2021

Conversation

huozhi
Copy link
Contributor

@huozhi huozhi commented Nov 16, 2021

Summary

Make the browser build of react-fetch is more flexible to be adopted in web runtime like next.js custom web runtime for streaming.

How did you test this change?

Test with next-rsc-demo by using react-fetch and chaing the dist code of react-fetch@experimental with following changes locally.

@sizebot
Copy link

sizebot commented Nov 16, 2021

Comparing: 4ff5f57...ab64dd8

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 = 129.98 kB 129.98 kB = 41.56 kB 41.56 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 134.74 kB 134.74 kB = 42.96 kB 42.96 kB
facebook-www/ReactDOM-prod.classic.js = 424.31 kB 424.31 kB = 78.20 kB 78.20 kB
facebook-www/ReactDOM-prod.modern.js = 412.87 kB 412.87 kB = 76.47 kB 76.47 kB
facebook-www/ReactDOMForked-prod.classic.js = 424.31 kB 424.31 kB = 78.20 kB 78.20 kB
oss-experimental/react-fetch/cjs/react-fetch.browser.production.min.js +3.04% 1.48 kB 1.53 kB +3.03% 0.69 kB 0.72 kB
oss-stable-semver/react-fetch/cjs/react-fetch.browser.production.min.js +3.04% 1.48 kB 1.53 kB +3.03% 0.69 kB 0.72 kB
oss-stable/react-fetch/cjs/react-fetch.browser.production.min.js +3.04% 1.48 kB 1.53 kB +3.03% 0.69 kB 0.72 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-fetch/cjs/react-fetch.browser.production.min.js +3.04% 1.48 kB 1.53 kB +3.03% 0.69 kB 0.72 kB
oss-stable-semver/react-fetch/cjs/react-fetch.browser.production.min.js +3.04% 1.48 kB 1.53 kB +3.03% 0.69 kB 0.72 kB
oss-stable/react-fetch/cjs/react-fetch.browser.production.min.js +3.04% 1.48 kB 1.53 kB +3.03% 0.69 kB 0.72 kB
oss-experimental/react-fetch/cjs/react-fetch.browser.development.js +1.51% 3.39 kB 3.44 kB +2.02% 1.14 kB 1.16 kB
oss-stable-semver/react-fetch/cjs/react-fetch.browser.development.js +1.51% 3.39 kB 3.44 kB +2.02% 1.14 kB 1.16 kB
oss-stable/react-fetch/cjs/react-fetch.browser.development.js +1.51% 3.39 kB 3.44 kB +2.02% 1.14 kB 1.16 kB

Generated by 🚫 dangerJS against ab64dd8

@gaearon
Copy link
Collaborator

gaearon commented Nov 16, 2021

Looks like you need to teach flow and lint about it.

@huozhi huozhi force-pushed the react-fetch/use-global-this branch from fe01427 to ab64dd8 Compare November 16, 2021 19:50
@huozhi
Copy link
Contributor Author

huozhi commented Nov 16, 2021

Thanks for the tip, fixed!

@gaearon gaearon merged commit 520ffc7 into facebook:main Nov 16, 2021
@huozhi huozhi deleted the react-fetch/use-global-this branch November 16, 2021 21:50
facebook-github-bot pushed a commit to facebook/react-native that referenced this pull request Nov 29, 2021
Summary:
This sync includes the following changes:
- **[c1220ebdd](facebook/react@c1220ebdd )**: treat empty string as null ([#22807](facebook/react#22807)) //<salazarm>//
- **[09d9b1775](facebook/react@09d9b1775 )**: Update deprecated features in ESLint configuration files. ([#22767](facebook/react#22767)) //<Esteban>//
- **[bddbfb86d](facebook/react@bddbfb86d )**: Revert "Fix Node package.json ./ exports deprecation warning ([#22783](facebook/react#22783))" ([#22792](facebook/react#22792)) //<Sebastian Silbermann>//
- **[b831aec48](facebook/react@b831aec48 )**: chore(fast-refresh): double check wasMounted ([#22740](facebook/react#22740)) //<anc95>//
- **[8edeb787b](facebook/react@8edeb787b )**: Fix Node package.json ./ exports deprecation warning ([#22783](facebook/react#22783)) //<Rin Arakaki>//
- **[fdc1d617a](facebook/react@fdc1d617a )**: Flag for client render fallback behavior on hydration mismatch ([#22787](facebook/react#22787)) //<salazarm>//
- **[aa19d569b](facebook/react@aa19d569b )**: Add test selectors to experimental build ([#22760](facebook/react#22760)) //<Brian Vaughn>//
- **[520ffc77a](facebook/react@520ffc77a )**: Use globalThis if possible for native fetch in browser build ([#22777](facebook/react#22777)) //<Jiachi Liu>//
- **[afbc2d08f](facebook/react@afbc2d08f )**: Remove unused react-internal/invariant-args ESLint rule. ([#22778](facebook/react#22778)) //<Esteban>//
- **[ca94e2680](facebook/react@ca94e2680 )**: Remove 'packages/shared/invariant.js' ([#22779](facebook/react#22779)) //<Esteban>//
- **[83564712b](facebook/react@83564712b )**: Move SuspenseList to experimental channel ([#22765](facebook/react#22765)) //<Andrew Clark>//
- **[d4144e6e5](facebook/react@d4144e6e5 )**: fix : grammatical typo for test description ([#22764](facebook/react#22764)) //<Brijesh Prasad>//
- **[0b329511b](facebook/react@0b329511b )**: chore: fix comment typo ([#22657](facebook/react#22657)) //<Han Han>//
- **[e6f60d2ad](facebook/react@e6f60d2ad )**: fix typos ([#22715](facebook/react#22715)) //<180909>//

Changelog:
[General][Changed] - React Native sync for revisions c0c71a8...c1220eb

jest_e2e[run_all_tests]

Reviewed By: yungsters

Differential Revision: D32646433

fbshipit-source-id: c534ee7a17141634700c90fc2c7b34bfbe17887a
nawbc pushed a commit to NawbExplorer/react-native that referenced this pull request Dec 7, 2021
Summary:
This sync includes the following changes:
- **[c1220ebdd](facebook/react@c1220ebdd )**: treat empty string as null ([facebook#22807](facebook/react#22807)) //<salazarm>//
- **[09d9b1775](facebook/react@09d9b1775 )**: Update deprecated features in ESLint configuration files. ([facebook#22767](facebook/react#22767)) //<Esteban>//
- **[bddbfb86d](facebook/react@bddbfb86d )**: Revert "Fix Node package.json ./ exports deprecation warning ([facebook#22783](facebook/react#22783))" ([facebook#22792](facebook/react#22792)) //<Sebastian Silbermann>//
- **[b831aec48](facebook/react@b831aec48 )**: chore(fast-refresh): double check wasMounted ([facebook#22740](facebook/react#22740)) //<anc95>//
- **[8edeb787b](facebook/react@8edeb787b )**: Fix Node package.json ./ exports deprecation warning ([facebook#22783](facebook/react#22783)) //<Rin Arakaki>//
- **[fdc1d617a](facebook/react@fdc1d617a )**: Flag for client render fallback behavior on hydration mismatch ([facebook#22787](facebook/react#22787)) //<salazarm>//
- **[aa19d569b](facebook/react@aa19d569b )**: Add test selectors to experimental build ([facebook#22760](facebook/react#22760)) //<Brian Vaughn>//
- **[520ffc77a](facebook/react@520ffc77a )**: Use globalThis if possible for native fetch in browser build ([facebook#22777](facebook/react#22777)) //<Jiachi Liu>//
- **[afbc2d08f](facebook/react@afbc2d08f )**: Remove unused react-internal/invariant-args ESLint rule. ([facebook#22778](facebook/react#22778)) //<Esteban>//
- **[ca94e2680](facebook/react@ca94e2680 )**: Remove 'packages/shared/invariant.js' ([facebook#22779](facebook/react#22779)) //<Esteban>//
- **[83564712b](facebook/react@83564712b )**: Move SuspenseList to experimental channel ([facebook#22765](facebook/react#22765)) //<Andrew Clark>//
- **[d4144e6e5](facebook/react@d4144e6e5 )**: fix : grammatical typo for test description ([facebook#22764](facebook/react#22764)) //<Brijesh Prasad>//
- **[0b329511b](facebook/react@0b329511b )**: chore: fix comment typo ([facebook#22657](facebook/react#22657)) //<Han Han>//
- **[e6f60d2ad](facebook/react@e6f60d2ad )**: fix typos ([facebook#22715](facebook/react#22715)) //<180909>//

Changelog:
[General][Changed] - React Native sync for revisions c0c71a8...c1220eb

jest_e2e[run_all_tests]

Reviewed By: yungsters

Differential Revision: D32646433

fbshipit-source-id: c534ee7a17141634700c90fc2c7b34bfbe17887a
@gaearon gaearon mentioned this pull request Mar 29, 2022
zhengjitf pushed a commit to zhengjitf/react that referenced this pull request Apr 15, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants