Comments (9)
Hi @shaimo. Probably you need to change the server side webpack config: denvned/isomorphic-relay-router#5 (comment)
from isomorphic-relay.
Thanks @denvned. I will try to change it but can you explain why it won't work as is?
from isomorphic-relay.
I tried adding the externals and target field, and also changed the libraryTarget to commonjs2 and now I'm getting a different error:
Encountered error: "TypeError: require is not a function"
If I try adding just the externals field I get:
Encountered error: "ReferenceError: isomorphic is not defined"
from isomorphic-relay.
Do you get these errors in the browser, or on Node?
from isomorphic-relay.
On the server side. The only caveat is that my backend is rails so for server rendering it is using ExecJS. I set it to use Node (rather than the default therubyracer) but it doesn't seem to matter.
Maybe something that can explain the problem - I'm looking at the bundled code generated by webpack and I'm not entirely understanding the order it puts things in. E.g. currently my original few lines of code are:
require('fixFetch'); // copied from isomorphic-relay to try and put it first
var stringify = require('json-stringify-safe');
import IsomorphicFetch from 'isomorphic-fetch';
import IsomorphicRelay from 'isomorphic-relay';
import Relay from 'react-relay';
var React = require('react');
import ReactOnRails from 'react-on-rails';
and what I get is:
/***/ function(module, exports, __webpack_require__) {
'use strict';
var _isomorphicFetch = __webpack_require__(1);
var _isomorphicFetch2 = _interopRequireDefault(_isomorphicFetch);
var _isomorphicRelay = __webpack_require__(3);
var _isomorphicRelay2 = _interopRequireDefault(_isomorphicRelay);
var _reactRelay = __webpack_require__(72);
var _reactRelay2 = _interopRequireDefault(_reactRelay);
var _reactOnRails = __webpack_require__(427);
var _reactOnRails2 = _interopRequireDefault(_reactOnRails);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
__webpack_require__(447); // copied from isomorphic-relay to try and put it first
var stringify = __webpack_require__(448);
var React = __webpack_require__(132);
It seems that for some reason webpack is refusing to put fixFetch (I guess module 447 above) first. Any idea why and what I can do to force it to require it first?
from isomorphic-relay.
Regarding the order, I guess it's putting the "import"s before the regular "require"s. If I change
require('fixFetch');
to
import 'fixFetch';
it then puts it first. But it still doesn't work and I'm getting the same error:
Encountered error: "ReferenceError: self is not defined"
from isomorphic-relay.
Maybe I understand why it's not working. Your hack changes prototype.require to replace the loading of fetch with the isomorphic fetch. But webpack changes all those require calls to webpack_require with module numbers (no more module names).
Maybe this can somehow be hacked instead at the webpack level when preparing the bundle?
from isomorphic-relay.
Maybe this can somehow be hacked instead at the webpack level when preparing the bundle?
Something like this might work:
externals: {
"fbjs/lib/fetch": "global.fetch",
"fbjs/lib/fetchWithRetries": "global.fetch"
}
from isomorphic-relay.
FYI, the hack is not needed since version 0.5 of isomorphic-relay.
from isomorphic-relay.
Related Issues (20)
- Peer Dependencies HOT 3
- Query running on both client and server. HOT 10
- Network Layer making multiple requests in NodeJS
- Authenticating with Isomorphic Relay HOT 4
- injectPreparedData on the server side? HOT 10
- Help needed in applying isomorphic-relay HOT 1
- Question: Parse session in graphql HOT 1
- Uncaught TypeError: Cannot read property 'id' of undefined in getConfigs() HOT 3
- complex type as argument in queries - fetchWithRetries(): Still no successful response after 1 retries, giving up. HOT 3
- passport.js req.user issue on SSR
- Use it only for backend? HOT 1
- support for Relay 0.10.0 ? HOT 2
- Differences between Relay.Renderer and IsomorphicRelay.Renderer HOT 1
- Why is prepareInitialRender async? HOT 2
- Why does Relay sometimes prefix query keys with underscores and random strings? HOT 3
- How to load data for a RootContainer supplied to Router on server side? HOT 6
- Example todo app has 'Invariant Violation: RelayQueryNode: Abstract class cannot be instantiated'
- Passing preloadedRequests to prepareData for queries with aliased parameterized fields
- Upgrade to relay modern HOT 1
- Is it possible to complete reload of component data on the browser ?
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 isomorphic-relay.