Reputation: 36179
I have a test repo with redux-observable
It works with webpack-dev-server
but breaks with server-side-rendering
giving:
TypeError: action$.ofType(...).delay is not a function
How to reproduce:
yarn dev
works okay (webpack-dev-server).
yarn build && yarn start
- runs node server-side-rendering which is breaking when creating store with redux createStore
method.
It recognizes imported operators from rxjs
within a browser (webpack-dev-server). My guess it might be a problem with webpack serverConfig
, more specifically with:
externals: fs.readdirSync('./node_modules').concat([
'react-dom/server',
]).reduce((ext, mod) => {
ext[mod] = `commonjs ${mod}`;
return ext;
}, {}),
Upvotes: 0
Views: 509
Reputation: 14179
importing the whole rxjs
library will jeopardise your tree shaking.
use pipe
instead.
import { delay } from 'rxjs/operators';
const epic = action$ => action$
.ofType('baz')
.pipe(delay(5000))
.mapTo({ type: 'bar' });
;
Upvotes: 1
Reputation: 36179
It turned out I had to include rxjs
in server.js where express
is like:
import `rxjs`;
But I would swear I tried that solution before I posting a question.
Upvotes: 0