存在模块时,将忽略Webpack别名

时间:2018-08-29 14:02:00

标签: javascript react-native webpack react-native-web

我将react-native-web模块的别名为webpackConfig.resolve.alias["react-native$"] = "react-native-web"; ,如下所示:

react-native

如果我没有在node_modules中安装react-native模块,那么一切都很好,但是如果我安装了它(因为我的本机应用需要它),则别名似乎没有工作,它只是尝试导入react-native-web而不是 DCNDemoListener list = new DCNDemoListener(this); dcr.addListener(list); // second step: add objects in the registration: Statement stmt = conn.createStatement(); // associate the statement with the registration: ((OracleStatement)stmt).setDatabaseChangeRegistration(dcr); ResultSet rs = stmt.executeQuery("select * from testtable where ID=1");
这是Webpack的正常行为吗?如果模块存在,则忽略别名。

1 个答案:

答案 0 :(得分:0)

我通过包含react-native来解决此问题,该文件将由babel装入程序进行编译。不确定为什么我必须这样做,但是只要能奏效,我就会感到高兴。