所以我有一个模块树,特别是两个表现奇怪的模块。使用Babel 6 + Browserify(babelify)。
模块#1(WindowManager / index.js)导出一个名为reducer
的命名函数,以及一个默认导出。
import WindowManager from './component';
import { combineReducers } from 'redux';
import { connect } from 'react-redux';
import { reducer as search_palette } from './SearchPalette';
const initialState = {
// stuff
};
const window_manager = (state = initialState, action) => {
// stuff
return state;
};
export const reducer = combineReducers({window_manager, search_palette})
const mapStateToProps = (state) => {
return {
// stuff
};
};
export default connect(mapStateToProps)(WindowManager)
模块#2(store.js)导入WindowManager/index.js
的{{1}}函数并尝试使用它。
reducer
由于某种原因,store.js在import { createStore, combineReducers } from 'redux';
import { reducer as WindowManagerReducer } from './WindowManager';
const initialState = {
// stuff
};
const FetchApplicationsReducer = (state = initialState, action) => {
// stuff
return state;
}
export default createStore(
combineReducers({
applications: FetchApplicationsReducer,
ui: WindowManagerReducer,
})
)
之前执行,因此导出不可用。
有人碰到这个吗?
答案 0 :(得分:0)
经过大量调整后,修改import
语句的顺序解决了问题。它是一棵复杂的树,很难以一种不涉及倾销整个项目的方式在这里表达......但我认为最终Babel的ES6模块系统中可能存在一个错误。