babel-loader cache should be platform specific
grahamlyus opened this issue · 0 comments
grahamlyus commented
Environment
node v.12.11.0
yarn v1.19.1
dependencies
"dependencies": {
"react": "16.9.0",
"react-native": "0.61.4"
},
"devDependencies": {
"@babel/core": "^7.6.2",
"@babel/runtime": "^7.6.2",
"@haul-bundler/babel-preset-react-native": "^0.14.2",
"@haul-bundler/cli": "^0.14.2",
"@haul-bundler/preset-0.60": "^0.14.2",
"@react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.9.0",
"eslint": "^6.5.1",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.56.0",
"react-test-renderer": "16.9.0"
},
Description
When running yarn haul
it seems that the babel-loader
cache is shared between platforms. This can cause errors, specifically when using Platform.select
as an optimization is made even in development.
Reproducible Demo
App.js
import React from 'react';
import {Platform, SafeAreaView, Text} from 'react-native';
const App = () => {
const str = Platform.select({
ios: 'IOS',
android: 'ANDROID',
});
return (
<>
<SafeAreaView>
<Text>{str}</Text>
</SafeAreaView>
</>
);
};
export default App;
yarn haul
wget http://localhost:8081/index.ios.bundle
(scroll to App.js
module)
const App = () => {
const str = 'IOS';
return react_default.a.createElement(react_default.a.Fragment, null, react_default.a.createElement(react_native_implementation["SafeAreaView"], {
__source: {
fileName: _jsxFileName,
lineNumber: 12
}
}, react_default.a.createElement(react_native_implementation["Text"], {
__source: {
fileName: _jsxFileName,
lineNumber: 13
}
}, str)));
};
str is IOS ✅
wget http://localhost:8081/index.android.bundle
(scroll to App.js
module)
const App = () => {
const str = 'IOS';
return react_default.a.createElement(react_default.a.Fragment, null, react_default.a.createElement(react_native_implementation["SafeAreaView"], {
__source: {
fileName: _jsxFileName,
lineNumber: 12
}
}, react_default.a.createElement(react_native_implementation["Text"], {
__source: {
fileName: _jsxFileName,
lineNumber: 13
}
}, str)));
};
str is still IOS ❌
rm -rf caches/babel-loader
wget http://localhost:8081/index.android.bundle
Now str is ANDROID ✅