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

fix for "external" PageRenderer not working in production #5986

Merged
merged 2 commits into from
Jun 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions packages/gatsby/src/cache-dir/gatsby-browser-entry.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
import React from "react"
import PropTypes from "prop-types"
import Link, { withPrefix, push, replace, navigateTo } from "gatsby-link"
import pages from "./pages.json"
import loader from "./loader"
import JSONStore from "./json-store"

const PageRenderer = ({ location }) => {
const pageResources = loader.getResourcesForPathname(location.pathname)
return React.createElement(JSONStore, {
pages,
location,
pageResources,
})
}

PageRenderer.propTypes = {
location: PropTypes.shape({
pathname: PropTypes.string.isRequired,
}).isRequired,
}
import PageRenderer from "./public-page-renderer"

const StaticQueryContext = React.createContext({})

Expand Down
23 changes: 23 additions & 0 deletions packages/gatsby/src/cache-dir/public-page-renderer-dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from "react"
import PropTypes from "prop-types"

import pages from "./pages.json"
import loader from "./loader"
import JSONStore from "./json-store"

const DevPageRenderer = ({ location }) => {
const pageResources = loader.getResourcesForPathname(location.pathname)
return React.createElement(JSONStore, {
pages,
location,
pageResources,
})
}

DevPageRenderer.propTypes = {
location: PropTypes.shape({
pathname: PropTypes.string.isRequired,
}).isRequired,
}

export default DevPageRenderer
21 changes: 21 additions & 0 deletions packages/gatsby/src/cache-dir/public-page-renderer-prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from "react"
import PropTypes from "prop-types"

import InternalPageRenderer from "./page-renderer"
import loader from "./loader"

const ProdPageRenderer = ({ location }) => {
const pageResources = loader.getResourcesForPathname(location.pathname)
return React.createElement(InternalPageRenderer, {
location,
pageResources,
})
}

ProdPageRenderer.propTypes = {
location: PropTypes.shape({
pathname: PropTypes.string.isRequired,
}).isRequired,
}

export default ProdPageRenderer
7 changes: 7 additions & 0 deletions packages/gatsby/src/cache-dir/public-page-renderer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const preferDefault = m => (m && m.default) || m

if (process.env.NODE_ENV === `production`) {
module.exports = preferDefault(require(`./public-page-renderer-prod`))
} else {
module.exports = preferDefault(require(`./public-page-renderer-dev`))
}