react-transform-hmr
핫 모듈 리로더를 실행중인 React 프로젝트가 있습니다. 모카 테스트를 구현할 때까지 모두 정상적으로 실행되고 있습니다. 나는 다음과 같은 오류 얻을 테스트를 실행하면 :이 인터넷 검색, 내가했던 .babelrc
파일에서 그리고 웹팩 설정으로 설치를 다시로드 뜨거운 모듈을 이동 언급 할 몇 가지 정보를 발견React Hot Module Reloader 모카 테스트가 실행되지 않도록합니다.
throw new Error('locals[0] does not appear to be a
module
object with Hot Module ' + 'replacement API enabled. You should disable react-transform-hmr in ' + 'production by usingenv
section in Babel configuration. See the ' + 'example in README: https://github.com/gaearon/react-transform-hmr ');
을, 테스트가 잘 돌아 갔지만 Hot Module Reloading이 작동하지 않습니다.
놀아서 함께 놀지 않으면 되돌아 와서 내가 진정으로 붙어있는 것처럼 도움을 요청할 것이라고 생각했습니다. 내가 할 수있는 어떤 아이디어?
{
"presets": ["react", "es2015", "stage-1"],
"env": {
"development": {
"plugins": [
["transform-object-rest-spread"],
["transform-react-display-name"],
["react-transform", {
"transforms": [{
"transform": "react-transform-hmr",
"imports": ["react"],
"locals": ["module"]
}, {
"transform": "react-transform-catch-errors",
"imports": ["react", "redbox-react"]
}]
}]
]
},
"production": {
"plugins": [
["transform-object-rest-spread"],
["transform-react-display-name"]
]
}
}
}
을 그리고 내 웹팩 설정은 다음과 같다 :
module: {
loaders: [
// js
{
test: /\.js$/,
loaders: ['babel'],
include: path.join(__dirname, 'client')
}
]
}
는 이것을 패키지에 다음과 같은 작업을 얻었다
모든 인수를 넣을 수 있습니다 ('--compilers js : babel-core/register --require ./tests/test-helper.js \ "./ tests/**/* @ (. jsx) \ ""')를 파일'test/mocha.opts'에 추가하십시오. – AgentME