mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-06-06 20:03:47 +00:00
[fix] babel-plugin require call for compiled modules
require('module') => require('module').default
Fix #786
This commit is contained in:
+11
-11
@@ -74,13 +74,13 @@ const { StyleSheet, TouchableOpacity } = require('react-native');
|
|||||||
|
|
||||||
↓ ↓ ↓ ↓ ↓ ↓
|
↓ ↓ ↓ ↓ ↓ ↓
|
||||||
|
|
||||||
const ReactNative = require('react-native-web/dist/index');
|
const ReactNative = require('react-native-web/dist/index').default;
|
||||||
|
|
||||||
const View = require('react-native-web/dist/exports/View');
|
const View = require('react-native-web/dist/exports/View').default;
|
||||||
|
|
||||||
const StyleSheet = require('react-native-web/dist/exports/StyleSheet');
|
const StyleSheet = require('react-native-web/dist/exports/StyleSheet').default;
|
||||||
|
|
||||||
const TouchableOpacity = require('react-native-web/dist/exports/TouchableOpacity');
|
const TouchableOpacity = require('react-native-web/dist/exports/TouchableOpacity').default;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -92,18 +92,18 @@ const { ColorPropType, StyleSheet, View, TouchableOpacity, processColor } = requ
|
|||||||
|
|
||||||
↓ ↓ ↓ ↓ ↓ ↓
|
↓ ↓ ↓ ↓ ↓ ↓
|
||||||
|
|
||||||
const ReactNative = require('react-native-web/dist/index');
|
const ReactNative = require('react-native-web/dist/index').default;
|
||||||
|
|
||||||
const createElement = require('react-native-web/dist/exports/createElement');
|
const createElement = require('react-native-web/dist/exports/createElement').default;
|
||||||
|
|
||||||
const ColorPropType = require('react-native-web/dist/exports/ColorPropType');
|
const ColorPropType = require('react-native-web/dist/exports/ColorPropType').default;
|
||||||
|
|
||||||
const StyleSheet = require('react-native-web/dist/exports/StyleSheet');
|
const StyleSheet = require('react-native-web/dist/exports/StyleSheet').default;
|
||||||
|
|
||||||
const View = require('react-native-web/dist/exports/View');
|
const View = require('react-native-web/dist/exports/View').default;
|
||||||
|
|
||||||
const TouchableOpacity = require('react-native-web/dist/exports/TouchableOpacity');
|
const TouchableOpacity = require('react-native-web/dist/exports/TouchableOpacity').default;
|
||||||
|
|
||||||
const processColor = require('react-native-web/dist/exports/processColor');
|
const processColor = require('react-native-web/dist/exports/processColor').default;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -92,7 +92,10 @@ module.exports = function({ types: t }) {
|
|||||||
return t.variableDeclaration(path.node.kind, [
|
return t.variableDeclaration(path.node.kind, [
|
||||||
t.variableDeclarator(
|
t.variableDeclarator(
|
||||||
t.identifier(identifier.value.name),
|
t.identifier(identifier.value.name),
|
||||||
t.callExpression(t.identifier('require'), [t.stringLiteral(distLocation)])
|
t.memberExpression(
|
||||||
|
t.callExpression(t.identifier('require'), [t.stringLiteral(distLocation)]),
|
||||||
|
t.identifier('default')
|
||||||
|
)
|
||||||
)
|
)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -105,9 +108,12 @@ module.exports = function({ types: t }) {
|
|||||||
const importIndex = t.variableDeclaration(path.node.kind, [
|
const importIndex = t.variableDeclaration(path.node.kind, [
|
||||||
t.variableDeclarator(
|
t.variableDeclarator(
|
||||||
t.identifier(name),
|
t.identifier(name),
|
||||||
t.callExpression(t.identifier('require'), [
|
t.memberExpression(
|
||||||
t.stringLiteral('react-native-web/dist/index')
|
t.callExpression(t.identifier('require'), [
|
||||||
])
|
t.stringLiteral('react-native-web/dist/index')
|
||||||
|
]),
|
||||||
|
t.identifier('default')
|
||||||
|
)
|
||||||
)
|
)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user