Skip to content
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

Something strange with default in import useRelay from 'react-router-relay'; #192

Closed
nodkz opened this issue Aug 29, 2016 · 11 comments
Closed

Comments

@nodkz
Copy link
Contributor

nodkz commented Aug 29, 2016

I'm started develop relay-northwind-app example app about 10 days ago.

All works perfectly before I make it public and got responses that it does not work. Crashed with the following error:
screen shot 2016-08-29 at 11 19 39

@taion
Copy link
Member

taion commented Aug 29, 2016

It's because of https://github.com/nodkz/relay-northwind-app/blob/dd59c2e55d899dd8cdfb2d36571b5c4f4f5418d5/.babelrc#L28

react-router-relay exposes an ES2015 module build. If you're using webpack 2, but have module transpilation turned on in Babel, you're going to get the above error.

I added that invariant in React Router exactly to catch this case.

@taion taion closed this as completed Aug 29, 2016
@nodkz
Copy link
Contributor Author

nodkz commented Aug 29, 2016

After reinstall node_modules from scratch I got same error. react-router, react-router-relay did not change. So I think that was changed some internal babel dependency (now will use shrinkwrap).

So problem soved by

applyRouterMiddleware(useRelay.default ? useRelay.default : useRelay)

... got answer! @taion thanks!

@nodkz
Copy link
Contributor Author

nodkz commented Aug 29, 2016

@taion definitely needs an ability to setup env via babel-loader options: babel/babel-loader#283

@taion
Copy link
Member

taion commented Aug 29, 2016

Personally, I just don't transpile modules for my Node scripts in projects where I use webpack 2. Actually I don't really use Babel there at all in many cases given the broad ES2015 support in Node 6.

@nodkz
Copy link
Contributor Author

nodkz commented Aug 29, 2016

Did you somehow alive import/export for Node 6?

How I know V8 does not support it yet. And Chakra is not my way.

PS. I'm using HMR on client/server, so for proper work of babelRelayPlugin on my code under webpack, I should use babel for it. Otherwise, needs to rewrite all app from import to require (but this is crazy).

@taion
Copy link
Member

taion commented Aug 29, 2016

Oh, in that case consider using a server webpack bundle perhaps.

@nodkz
Copy link
Contributor Author

nodkz commented Aug 29, 2016

Already use it.
Anyway, all works now. Will wait for V8 with imports, for removing applyRouterMiddleware(useRelay.default) hack with my build routine.

Thanks!

@taion
Copy link
Member

taion commented Aug 29, 2016

You could also drop module from mainFields in your webpack config. As-is, everything that actually has an ES module build under module will break in the same way if you try to use default imports.

@grahamb
Copy link

grahamb commented Sep 8, 2016

@taion I'm seeing this as well with Webpack 2. I have module compilation disabled in my babel-loader config: https://github.com/sfu/student-dashboard/blob/router/webpack.config.js#L53

Any ideas?

@taion
Copy link
Member

taion commented Sep 8, 2016

You need to disable the use of .babelrc in your Babel loader.

@grahamb
Copy link

grahamb commented Sep 8, 2016

Well, that was easy. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants