denvned/isomorphic-relay

Make fixFetch patch optional

moret opened this issue · 3 comments

moret commented

Hi!

I use webpack to build my server, and the fixFetch patch is not needed in if alias is used. In fact, when using them together it throws some warnings for Failed Context Types on the server render.

What do you think of making the fixFetch patch optional? It could be used explicitly before requiring anything else:

require('isomorphic-relay/patchFetch');
import Relay from 'react-relay';
import IsomorphicRelay from 'isomorphic-relay';

or have the default export without the patch and a second one with the patch:

import IsomorphicRelay from 'isomorphic-relay/patchedFetch';
import Relay from 'react-relay';

or the other way around:

import Relay from 'react-relay';
import IsomorphicRelay from 'isomorphic-relay/unpatchedFetch';

Do you like the idea? I could help with a PR if you help pick one of the options 8) . I like the first one.

Hi!

I use webpack to build my server, and the fixFetch patch is not needed in if alias is used. In fact, when using them together it throws some warnings for Failed Context Types on the server render.

But it works for me with webpack without disabling fixFetch. Here is a relevant extract from my webpack.config for the server:

target: 'node',
externals: /^[^.]/,
output: {
  libraryTarget: 'commonjs2',
  ...
},
...

So, I don't see yet why a PR is required. Do I miss something?

moret commented

hmmm, I see. It does work for me too, but with warnings. However I don't build using externals like in your webpack.config, neither with commonjs2. I will try to change my build to match yours, if I keep seeing those warnings I will commit them to an example project and get back here.

Anyway, if you feel like the patch could become optional, let me know and I would gladly help with it.

FYI, fixFetch is not needed since version 0.5 of isomorphic-relay.