我正在尝试为react-native创建一个库,现在我使用的是typescript和react-native-webview,但现在却使用webpack捆绑了。这是我的webpack配置
module.exports = {
mode: 'production',
entry: './src/index.ts',
externals: {
'react-native': true,
},
module: {
rules: [
{
test: /\.(ts|tsx)?$/,
include: path.resolve(__dirname, 'src'),
use: [
{
loader: 'babel-loader',
},
]
},
],
},
resolve: {
extensions: [ '.tsx', '.ts', '.js' ],
},
output: {
filename: 'index.js',
path: path.resolve(__dirname, 'dist'),
libraryTarget: 'umd',
library: '',
},
};
.babelrc
{
"presets": [
"@babel/preset-env",
"module:metro-react-native-babel-preset"
]
}
运行webpack build
ERROR in ./node_modules/react-native-webview/lib/WebView.js 7:36
Module parse failed: Unexpected token (7:36)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| // implementation which is produced by Expo SDK 37.0.0.1 implementation, with
| // similar interface than the native ones have.
> var WebView = function () { return (<View style={{
| alignSelf: 'flex-start',
| borderColor: 'rgb(255, 0, 0)',
我哪里错了?请帮助我