Skip to content

[web] Polyfill emitters#3676

Merged
EvanBacon merged 7 commits intomasterfrom
@evanbacon/expo-web/remove-internal-deps
Mar 8, 2019
Merged

[web] Polyfill emitters#3676
EvanBacon merged 7 commits intomasterfrom
@evanbacon/expo-web/remove-internal-deps

Conversation

@EvanBacon
Copy link
Copy Markdown
Contributor

@EvanBacon EvanBacon commented Mar 8, 2019

Why

Using React Native internals will bundle react-native on web which can be avoided.

How

Test Plan

NCL should run without throwing any error

@EvanBacon EvanBacon added the Platform: web Using Expo in the browser label Mar 8, 2019
@EvanBacon EvanBacon self-assigned this Mar 8, 2019
@EvanBacon EvanBacon requested a review from ide March 8, 2019 00:32
@EvanBacon EvanBacon changed the title @evanbacon/expo web/remove internal deps [web] Polyfill emitters Mar 8, 2019
* Removed comments from emitter
* Updated babel plugin alias
@brentvatne
Copy link
Copy Markdown
Member

Using React Native internals will bundle react-native on web which can be avoided.

so the purpose of this is that when libraries mistakenly import react-native internals, we alias that so that they don't end up bundling all of react-native in their app by accident? if so, this seems pretty reasonable as a way to avoid people shooting themselves in the foot. we need to also make some changes to react-native upstream to warn people when they import from internals to stop libraries from doing this so we can eventually get rid of this code

@EvanBacon
Copy link
Copy Markdown
Contributor Author

@brentvatne yes just for the emitters though. We are going to be removing the safe-guards in favor of errors 🙃

@EvanBacon EvanBacon merged commit 89b5a0a into master Mar 8, 2019
facebook-github-bot pushed a commit to facebook/react-native that referenced this pull request Mar 11, 2019
Summary:
Initially if a `react-native-web` project were to use a library that required internals `expo/webpack-config` would polyfill those internals. This `Platform.web` was used for cases where `react-native` modules needed other internal `react-native` modules, ex: `Animated/src/AnimatedEvent -> Renderer/shims/ReactNative -> Renderer/oss/ReactNativeRenderer-dev -> Core/InitializeCore -> Devtools/setupDevtools -> WebSocket/WebSocket -> Utilities/Platform`

The consensus is that if any `react-native` library references a `react-native` internal (ex: `react-native/*`), it should continue to throw errors. We've removed the use of internals from all of the Unimodules, `react-navigation`, and `react-native-gesture-handler`. This covers a wide enough area for a lot of projects to get web support.

* Add emitters for libs referencing internals necolas/react-native-web#1275
* Remove monkey patch that bundles RN, libs that use internals will crash instead expo/expo-cli#409
* Remove all unsupported internals and polyfills from the Expo suite expo/expo#3676
* Remove internals from react-native-gesture-handler software-mansion/react-native-gesture-handler#406

* Related #23387

[GENERAL] [REMOVED] - Platform.web.js
Pull Request resolved: #23830

Differential Revision: D14406145

Pulled By: hramos

fbshipit-source-id: bdda99a334d33f5543fdb954eb80e2e7186f985a
ronlaureles pushed a commit to ronlaureles/expo that referenced this pull request May 20, 2019
* Removed internal react-native reference

* Use latest RNGH with web polyfill

* Remove internal web polyfills from `expo`

* Updated expo-react-native-adapter to use polyfill for RCTDeviceEventEmitter on web

* Pending necolas/react-native-web#1275
* Updated babel alias to use RNWeb emitters

* Bump `1.1.0`

* Removed flow

* Moved files to vendor

* Removed comments from emitter
* Updated babel plugin alias
@tsapeta tsapeta deleted the @evanbacon/expo-web/remove-internal-deps branch February 13, 2021 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Platform: web Using Expo in the browser

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants