虽然我尝试了在google上找到的所有babel预设和插件,但我的webpack无法使用facebook""流式检查器"来解析javascript文件。
我得到的错误:
ERROR in ./~/mapbox-gl/src/geo/transform.js
Module parse failed: /home/project/project-repo/Vee/superset/assets/node_modules/mapbox-gl/src/geo/transform.js Unexpected token (22:12)
You may need an appropriate loader to handle this file type.
| */
| class Transform {
| tileSize: number;
| tileZoom: number;
| lngRange: ?[number, number];
@ ./~/react-map-gl/dist/utils/transform.js 11:17-54
@ ./~/react-map-gl/dist/map.react.js
@ ./~/react-map-gl/dist/index.js
@ ./~/react-map-gl/index.js
@ ./visualizations/mapbox.jsx
@ ./visualizations/main.js
@ ./javascripts/modules/superset.js
@ ./javascripts/dashboard/Dashboard.jsx
@ multi babel-polyfill ./javascripts/dashboard/Dashboard.jsx
我的网络包配置规则:
{
test: /\.js$/,
exclude: APP_DIR + '/node_modules/',
use: [{
loader:'babel-loader',
options:{
presets:[
'airbnb',
'es2015',
"stage-2",
"flow"
],
plugins:[
"transform-flow-strip-types",
"transform-flow-comments"
]
}
}],
},
我的.babelrc文件:
{
"presets" : ["airbnb", "es2015", "react","flow"],
"plugins": ["async-to-promises","transform-flow-strip-types","transform-flow-comments"]
}
答案 0 :(得分:0)
听起来这个模块正在使用超级hacky方法来集成Flowtype。好像你正在使用https://github.com/uber/react-map-gl/issues/179这样的逻辑:https://github.com/uber/react-map-gl/pull/192/files
我建议他们提交一个错误。这不应该是您通过Webpack处理的责任。