-
Notifications
You must be signed in to change notification settings - Fork 57
locals[0] does not appear to be a module
object with Hot Module replacement API enabled
#5
Comments
I just discovered the bootstrap you provided https://github.com/gaearon/react-transform-boilerplate and it seems to work. I'll check whats different on my end. |
Seems like my https://github.com/reactjs/express-react-views templates are causing these errors with react-transform-hmr. |
Please provide a project reproducing the problem. |
One thing to look out for is that you shouldn't transform |
I'm having this too. |
Its because of the recent changes in version 1.0.0. And for me it seems like the problem appears since, as @gaearon supposed, I got files in custom modules that are transformed by |
@Gaeron i have same error but completed your recommendations. |
Repo:
Execute app:
Out in console:
|
Don't enable the transform in the Node server build. Most other React Transforms don't expect to be invoked on server either so it's good to fail early. |
@gaearon Why can't one use babel in webpack configuration? |
I'm not sure I understand the question. You can configure Babel plugin either in .babelrc with env option (corresponds to BABEL_ENV or NODE_ENV, whichever is set), or in your build tool setup (for example babel-loader for Webpack lets you pass configuration as an object to "query" field). |
my
Is it good? |
It's the error i get when running the server. |
My solution is as follows:
With this configuration it works, but they've made a mistake by using JSON instead of Javascript in their |
Maybe, but that would be up to Babel. Maybe you can file an issue there (unless one already exists). |
@gaearon Nah, they obviously won't listen to a stranger with no history of commits. The thing is Babel requires Node.js so why not make the configuration non-declarative like they did in Webpack. By the way, I didn't find a way to stop Babel from loading the default .babelrc, so my approach with custom .babelrc.server didn't work. |
If you use Webpack on client, you can put React Transform configuration there. For example see this React Native example using |
@gaearon hmmm, actually, that would be a better solution. I'll use it. |
That's really strange. |
@aulizko yes, that's a new feature of babel so I recommend removing |
You can always make a PR to recommend the right way. 😉 |
@gaearon but there's always the project owner factor where the project owner should say "yes, do it" otherwise noone's gonna merge your PR. |
@gaearon by the way you've got a bunch of cool projects here. not Holowaychuk level of course but still a lot of development efforts. so that you know we appreciate your contribution to the progression of society. |
@gaearon I think you are awesome. Whatever level that is. |
I believe the change itself is for the better so that's why I released it. However configuring Babel is something you know better than me: you have real apps with different requirements and you are a better judge of how to make this change work in your project and what best practices are. That's what I'm trying to say: I can't document the best approach because I don't know it. If you know a better approach than the docs say, submit a PR and let's discuss it. |
okay, I propose some kind of this textual addition to the readme:
That's my idea of updating the Readme but most likely you'll want to change this somehow. |
When testing, set NODE_ENV to `test` to prevent babel from loading the transform plugin server-side See gaearon/react-transform-hmr#5
When testing, set NODE_ENV to `test` to prevent babel from loading the transform plugin server-side See gaearon/react-transform-hmr#5
When testing, set NODE_ENV to `test` to prevent babel from loading the transform plugin server-side See gaearon/react-transform-hmr#5
When testing, set NODE_ENV to `test` to prevent babel from loading the transform plugin server-side See gaearon/react-transform-hmr#5
When testing, set NODE_ENV to `test` to prevent babel from loading the transform plugin server-side See gaearon/react-transform-hmr#5
When testing, set NODE_ENV to `test` to prevent babel from loading the transform plugin server-side See gaearon/react-transform-hmr#5
When testing, set NODE_ENV to `test` to prevent babel from loading the transform plugin server-side See gaearon/react-transform-hmr#5
When testing, set NODE_ENV to `test` to prevent babel from loading the transform plugin server-side See gaearon/react-transform-hmr#5
When testing, set NODE_ENV to `test` to prevent babel from loading the transform plugin server-side See gaearon/react-transform-hmr#5
When testing, set NODE_ENV to `test` to prevent babel from loading the transform plugin server-side See gaearon/react-transform-hmr#5
When testing, set NODE_ENV to `test` to prevent babel from loading the transform plugin server-side See gaearon/react-transform-hmr#5
When testing, set NODE_ENV to `test` to prevent babel from loading the transform plugin server-side See gaearon/react-transform-hmr#5
When testing, set NODE_ENV to `production` to prevent babel from loading the transform plugin server-side See gaearon/react-transform-hmr#5
Things changed with |
What exactly changed? The problem is that you're either enabling the transform in environments other than development, or you are compiling for production with a dev/empty environment. This was the cause of the problem before, and it is the cause of the problem now. How did this change? |
@gaearon wow, I have this problem because I comment However, I found my app wont update even there is log: [WDS] Hot Module Replacement enabled.
[WDS] App updated. Recompiling...
[WDS] App hot update...
[WDS] App updated. Recompiling...
[WDS] App hot update... |
Hi, try this: hot is the key. |
None of this should matter in React Hot Loader 3. |
I had this same problem in react-native, i can't erase the .babelrc because use the "presets": ["react-native"], and his configuration, this only happend when i desactive JS Dev Mode in Dev Settings, i don't want change node_modules carpets, any idea? |
fwiw - I had this issue in react-native project, I disabled |
@guyca where cani find debug prefrernces? |
@yash2code It is at the top of the Dev settings menu when you shake the device. |
Hi,
I've installed 1.0.0, I've copy&pasted .babelrc from the examples and I'm using babel-loader with webpack as adviced, all in my dev environment, but I'm getting said error as soon as I'm running the whole thing. Whereas, the previous version worked.
Is there anything not yet documented I'm missing?
The text was updated successfully, but these errors were encountered: