-
Notifications
You must be signed in to change notification settings - Fork 67
Error - Make sure the relay
property on the React context conforms to the RelayEnvironment
interface.
#189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Oh, I figure out the error. I have to change
to
I wonder why don't we just use |
That shouldn't be necessary. How are you transpiling your import statements? |
|
Thanks for gettting back to me. I used the webpack 2 to transpile the .babelrc
Here is my config for webpack. default.js 'use strict';
const path = require('path');
const ROOT = require('./../../path-helper').ROOT;
const config = require('./../../index');
const webpack = require('webpack');
module.exports = {
context: ROOT,
entry: {
app: [
path.join(ROOT, config.path.app, 'app'),
],
},
output: {
path: path.join(ROOT, config.path.publicAssets),
},
externals: [],
resolve: {
extensions: ['', '.js', '.jsx'],
modules: [
path.resolve('./app'),
'node_modules',
],
},
module: {
loaders: [
{
test: /\.async\.jsx$/,
loader: 'react-proxy-loader!exports-loader?exports.default',
},
{
test: /.(js|jsx)$/,
exclude: /node_modules/,
loaders: ['babel-loader', 'eslint-loader'],
},
{
test: /\.(gif|jpg|jpeg|png|svg|ttf|eot|woff|woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader',
},
],
},
plugins: [
new webpack.optimize.AggressiveMergingPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env.RUNTIME_ENV': "'client'",
}),
],
eslint: {
emitWarning: true,
},
}; development.js 'use strict';
const _ = require('lodash');
const ROOT = require('./../../path-helper').ROOT;
const config = require('./../../index');
const cssnext = require('postcss-cssnext');
const webpack = require('webpack');
const WebpackIsomorphicToolsPlugin = require('webpack-isomorphic-tools/plugin');
const webpackIsomorphicToolsPlugin = new WebpackIsomorphicToolsPlugin(
require('./../../webpack/webpack-isomorphic-tools')
);
const developmentConfig = require('./default');
_.mergeWith(developmentConfig, {
output: {
publicPath: `http://localhost:8080${config.path.build}`,
filename: '[name].js',
chunkFilename: '[id].js',
},
cache: true,
debug: true,
outputPathinfo: true,
devtool: 'source-map',
devServer: {
contentBase: ROOT,
noInfo: true,
hot: true,
inline: true,
},
postcss() {
return [cssnext()];
},
}, (obj1, obj2) =>
_.isArray(obj2) ? obj2.concat(obj1) : undefined
);
developmentConfig.module.loaders.push(
{
test: /\.css$/,
loader: `style!css${config.cssModules}!postcss`,
},
{
test: /\.less$/,
loader: `style!css${config.cssModules}!postcss!less`,
},
{
test: /\.scss$/,
loader: `style!css${config.cssModules}!postcss!sass`,
}
);
developmentConfig.plugins.push(
// new webpack.optimize.CommonsChunkPlugin('common', 'common.bundle.js'), // Code splitting
new webpack.DefinePlugin({
'process.env.NODE_ENV': "'development'",
'process.env.SERVER_RENDERING': process.env.SERVER_RENDERING || false,
}),
webpackIsomorphicToolsPlugin.development(),
new webpack.HotModuleReplacementPlugin(), new webpack.NoErrorsPlugin() // Hot Module Replacement
);
module.exports = developmentConfig; production.js 'use strict';
const _ = require('lodash');
const config = require('./../../index');
const cssnext = require('postcss-cssnext');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const ChunkManifestPlugin = require('chunk-manifest-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const WebpackIsomorphicToolsPlugin = require('webpack-isomorphic-tools/plugin');
const webpackIsomorphicToolsPlugin = new WebpackIsomorphicToolsPlugin(
require('./../../webpack/webpack-isomorphic-tools')
);
const productionConfig = require('./default');
_.mergeWith(productionConfig, {
devtool: false,
output: {
publicPath: config.path.assets,
filename: '[name]-[chunkhash].bundle.js',
chunkFilename: '[id]-[chunkhash].bundle.js',
},
postcss() {
return [cssnext()];
},
}, (obj1, obj2) =>
_.isArray(obj2) ? obj2.concat(obj1) : undefined
);
productionConfig.module.loaders.push(
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
fallbackLoader: 'style',
loader: `css${config.cssModules}!postcss`,
}),
},
{
test: /\.less$/,
loader: ExtractTextPlugin.extract({
fallbackLoader: 'style',
loader: `css${config.cssModules}!postcss!less`,
}),
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract({
fallbackLoader: 'style',
loader: `css${config.cssModules}!postcss!sass`,
}),
}
);
productionConfig.plugins.push(
// new webpack.optimize.CommonsChunkPlugin('common', 'common-[chunkhash].bundle.js'), // Code splitting
new webpack.DefinePlugin({
'process.env.NODE_ENV': "'production'",
'process.env.SERVER_RENDERING': true,
}),
new ExtractTextPlugin({
filename: '[name]-[contenthash].css',
allChunks: true,
}),
new ChunkManifestPlugin({
filename: 'webpack-common-manifest.json',
manfiestVariable: 'webpackManifest',
}),
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false,
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
},
output: {
comments: false,
},
sourceMap: false,
}),
new CompressionPlugin(),
webpackIsomorphicToolsPlugin
);
module.exports = productionConfig; I used separate config files for development and production. The weird thing is that it ran fine in production and threw error in development. So that currently, I have to use a workaround
So far, I looked at the problem, it is may related to the webpack 2 `"module": "es/index.js". But I am not sure why it behaves differently |
Same problem here with |
You need to turn off the CommonJS modules transform in Babel if you're using webpack 2. |
Uhm, @taion. I did try the
|
You should resolve that error, then. Though with recent Babel versions you don't even need es2015-webpack. |
Oh, I don't know this. Thanks @taion |
For who is looking for the answer. |
I get Here's my {
"passPerPreset": true,
"presets": [
{ "plugins": [ "./babelRelayPlugin" ] },
"react",
["es2015", { "modules": false }],
"stage-0"
],
"plugins": [
"transform-runtime",
"transform-decorators-legacy",
"transform-class-properties",
"react-hot-loader/babel"
]
} I'm using the latest babel+webpack beta 20. |
webpack 2 has native support for ES modules. As such, you need to (and should) turn off the CommonJS modules transform, as this package is set up to expose an ES module build to bundlers that support it, which apparently leads to weird things happening if you are using the CommonJS module transform. If you're running your code through Node, you need to enable the CommonJS module transform, as Node does not support CommonJS modules. |
@taion thanks. How does one do that? The suggested solution ( |
See e.g. https://github.com/reactjs/react-router/blob/master/tools/es2015Preset.js, but set up the branches appropriately for the conditions in which you want to use or not use the CommonJS module transform. |
@hung-phan @taion Hi I have my setup as
but still getting original error like |
Hi @bsr203, see this project if that helps. You will see my config for And the better way is that you should show your repo or gist. We cannot help you just by looking at your babel config |
Uh oh!
There was an error while loading. Please reload this page.
Hi, I ran into some problems with the new version (Not very sure about this). Basically, I got the error:
I use
createContainer
from recompose, and I don't know how I got this error. I just got this error recently. By the way, this is my projecthttps://github.com/hung-phan/koa-react-isomorphic/tree/features/relay
The text was updated successfully, but these errors were encountered: