-
Notifications
You must be signed in to change notification settings - Fork 78
[WIP] [Toolchain] Replace TS+Babel6 pipeline with just Babel 7 #991
Conversation
Babel 7’s TS plugin does not support it, but out linter also doesn’t so good riddance altogether.
Only Flow or TS Babel plugin can be enabled, so need to preprocess the dependency sources to not have Flow types.
"prestorybook": "rnstl", | ||
"prepare": "patch-package" | ||
"postinstall": "yarn -s patch", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Need to figure out the exact order of these scripts, because when trying to run the patch
script from prepare
the patch:packages
step would fail to apply unless the patch:remove-flow-from-packages
script was removed from the patch
script.
Oof, gonna remove the Danger comment for now, as it’s not helpful at this very moment. |
Hey @alloy, a couple thoughts:
import 'InitializeCore'; Hopefully this helps to get you a little closer. Let me know how it goes. |
Related to Blob, I also had a similar problem with making POSTs using XMLHttpRequests |
@orta Did you record details about the |
I was seeing exactly the issue that was linked below it ( jhen0409/react-native-debugger#38 ) so considered that enough documentation |
@jamesreggio Thanks for taking the time! I’ll respond inline:
I’ll report back once I’ve had the time to work on this again. |
Thanks for trying those out, @alloy. Too bad none of it worked 😕 Good luck, and please keep me posted! |
Re the Blob issue with a debugger connected: jhen0409/react-native-debugger#209 To elaborate a bit, this is caused by doing this: global.XMLHttpRequest = global.originalXMLHttpRequest |
Ah, gotcha. So it's just down to the |
@jamesreggio Looks like it! I’d love to spend some time on getting network debugging to work again as well, of course, but at least it doesn’t appear to be due to the changes in this PR. |
Could we make babel plugin that uses flow only in files for |
Our jest automated tests are busted in our React-Native (ReactXP) project because of this type of issue. I'd love to hear if anybody figures out how to resolve it! |
I updated us to React Native 0.56rc which moves RN to use babel 7 - #1117 |
This also could handle some of the tricky integration issues around flow + TS - https://babeljs.io/blog/2018/06/26/on-consuming-and-publishing-es2015+-packages#how-babel-v7-helps |
deprecated by #1210 |
#1210 will probably get merge in a few weeks now, so I'm closing this. |
Supersedes #780.
Decided to have another go at it and go through @jamesreggio’s excellent blog post on the topic.
Our setup is a little different, because we use TypeScript. These are the things that I had to do differently:
@babel/preset-flow
with@babel/preset-typescript
namespace
by moving to new file and re-exporting, because@babel/preset-typescript
does not supportnamespace
.node_modules/react-native-scrollable-tab-view/SceneComponent.js
node_modules
from Flow typings, because only one of the Flow or TS Babel plugin can be used at a time. For this to work I had to patch the following files to add the@flow
comment so it would properly be detected and stripped:node_modules/react-native/Libraries/Experimental/SwipeableRow/SwipeableListViewDataSource.js
node_modules/react-native/Libraries/Interaction/PanResponder.js
node_modules/react-native-sentry/lib/NativeClient.js
node_modules/react-native-scrollable-tab-view/StaticContainer.js
Status
Well, there’s good news and there’s bad news; shall we start with the good news?
Does work
For a view that does not use Relay (i.e. only the ‘consignment flow’), this now works! 🎉
Does not work
While I don’t know yet if and how it’s related to Relay, there’s definitely a correlation. I guess it’s related to some polyfilling not being right because there’s a difference between running on JSCore vs Chrome debugger and multiple versions of the same class existing (Blob).
Without JS debugger
Fails with a an exception about a
require
implementation missing:With JS debugger
(i.e. JS is evaluated in Chrome)
Fails with an exception about the response of the (Relay) network request not being a ‘blob’. It definitely is, but it appears we’ve got ourselves a classic ‘multiple versions of the same class’ problem, because the instance has a different prototype than the one that is being tested against: