Comments (4)
@cdoublev looks like React is behaving differently when bundled with Webpack target 'node' vs running directly in Node -- if you add 'react' to your externals 'keep' array in your Webpack config it fixes it.
Pretty certain it's unrelated to require-from-string
as last time I looked that works exactly the same way as require
but without the restriction of reading from disk...
from webpack-hot-server-middleware.
I've got a hunch it's something to do with multiple instances of React and context -- although I'd have thought marking it as external would ensure there is just a single instance.
from webpack-hot-server-middleware.
Thank you for the feed back. It led me to the right place, I think.
The logic below for Context differs depending on PROD or DEV mode. In DEV mode, we create a separate object for Context.Consumer that acts like a proxy to Context. This proxy object adds unnecessary code in PROD so we use the old behaviour (Context.Consumer references Context) to reduce size and overhead. The separate object references context via a property called "_context", which also gives us the ability to check in DEV mode if this property exists or not and warn if it does not.
I'm still wrapping my head for what it entirely means, but in the meantime, using React directly from NodeJS is a working and totally acceptable solution. Thank you a lot!
Edit: ok, this is what you actually mean by "React is behaving differently when bundled with Webpack target 'node'", ie. the PROD package is used even if we run NODE_ENV=development node server/index.js
.
from webpack-hot-server-middleware.
This was an error on my Webpack config. I had mode: 'production'
set for the server build, which was setting NODE_ENV
to production
. Thank you again! :)
from webpack-hot-server-middleware.
Related Issues (20)
- Side effect from require server render from string
- listen EADDRINUSE: address already in use :::8080 HOT 2
- please remove `yarn` from dependencies HOT 4
- TypeError: serverRenderer is not a function
- Hangs when errors are thrown inside server bundle HOT 1
- filtering websocket webpack-hot-reloading calls from react-hot-server-middleware HOT 1
- serverRenderer is not a function HOT 10
- serverRenderer is not a function HOT 1
- My entry chunk is renamed to an async chunk HOT 2
- is it possible to call the default route from another route in express HOT 5
- serverRender is not a function
- use webpack-hot-server-middleware with typescript HOT 2
- Another "serverRenderer is not a function" question. HOT 4
- cannot find module 'react'
- Why is yarn in runtime dependencies? HOT 1
- Separating Routes? HOT 6
- Error is thrown when the example is run.
- Error when compiling when using Hapijs HOT 1
- bug flow type HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webpack-hot-server-middleware.