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

[1.0] Redux example #1081

Merged
merged 15 commits into from
Jun 7, 2017
Merged

[1.0] Redux example #1081

merged 15 commits into from
Jun 7, 2017

Conversation

scottyeck
Copy link
Contributor

Related: #1079

@gatsbybot
Copy link
Collaborator

gatsbybot commented Jun 1, 2017

Deploy preview ready!

Built with commit b27a1fa

https://deploy-preview-1081--using-drupal.netlify.com

@gatsbybot
Copy link
Collaborator

gatsbybot commented Jun 1, 2017

Deploy preview ready!

Built with commit b27a1fa

https://deploy-preview-1081--gatsbyjs.netlify.com

@gatsbybot
Copy link
Collaborator

gatsbybot commented Jun 1, 2017

Deploy preview ready!

Built with commit b27a1fa

https://deploy-preview-1081--gatsbygram.netlify.com

<meta charSet="utf-8" />
<meta
name="description"
content="Gatsby example site showing use with no plugins"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this and title need updated

@KyleAMathews
Copy link
Contributor

Nice! Perfect little example. Very clear.

@scottyeck scottyeck changed the title Redux example [1.0] Redux example Jun 2, 2017
@mericsson
Copy link
Contributor

mericsson commented Jun 7, 2017

Agree, great example! Thanks @scottyeck!

@KyleAMathews I used this to see I could reproduce the issue I was seeing where webpack was not getting applied to gatsby-ssr.js. I wonder if @scottyeck sees this as well?

I pulled the code out into a separate repo to make it easier to repro.

yarn run build && yarn run serve-build works fine and the webapp renders correctly.

yarn run develop builds fine, but when rendering http://localhost:8000 I get:

/Users/mericsson/dev/gatsby-using-redux/gatsby-ssr.js:1
(function (exports, require, module, __filename, __dirname) { import React from 'react'
                                                              ^^^^^^
SyntaxError: Unexpected token import
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/mericsson/dev/gatsby-using-redux/.cache/api-runner-ssr.js:2:15)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)

@KyleAMathews If it repro's for you too, I can look into a fix if you point me in the right direction.

@KyleAMathews
Copy link
Contributor

ahhh this very specific case is where there's trouble because Gatsby isn't running things through Babel or Webpack. Gatsby does a server render of your html.js/ssr plugins when you load a page in development

const apiRunner = require(`${directory}/.cache/api-runner-ssr`)

To ensure consistency with production, we should really be generating an HTML file there with https://github.com/markdalgleish/static-site-generator-webpack-plugin Right now a gatsby-ssr plugin could import a file or some other webpack-specific thing and development would break.

Would be great if you could tackle that.

@scottyeck on this PR — do you think you'll have a bit of time in the next day or two to push this across the finish line?

@scottyeck
Copy link
Contributor Author

@mericsson Yup - can confirm that we're seeing the same thing. We had to ship something ASAP, so I actually just converted all of our gatsby-ssr dependencies (there weren't many) to support require. Would love if I didn't have to do that extra brainwork.

@KyleAMathews KyleAMathews merged commit 8fdca0b into gatsbyjs:1.0 Jun 7, 2017
@KyleAMathews
Copy link
Contributor

Thanks @scottyeck !

@KyleAMathews
Copy link
Contributor

@KyleAMathews
Copy link
Contributor

Deploy preview failed.

Built with commit b27a1fa

https://app.netlify.com/sites/using-glamor/deploys/593875218ebdd94fe24352d0

@KyleAMathews
Copy link
Contributor

Deploy preview failed.

Built with commit b27a1fa

https://app.netlify.com/sites/using-contentful/deploys/593875218ebdd94fe24352d6

@KyleAMathews
Copy link
Contributor

Not quite sure what those netlify errors are but they don't have anything to do with this PR

jbolda pushed a commit to jbolda/gatsby that referenced this pull request Jun 10, 2017
* Fixes 0-index issue with link preloader as per gatsbyjs#988

* Allowing for disabled sourcemaps

* Fix bad logic

* Adds redux example

* Ignores children in prop type validation

* Rolls back to older canary to alleviate 404 issues

* Example title metadata

* Separate createStore

* First pass at wrapping server render body

* Moves api implementation into gatsby-ssr.js

* Updates metadata
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

Successfully merging this pull request may close these issues.

4 participants