-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[v2] compile cache dir #5637
[v2] compile cache dir #5637
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,4 @@ node_modules | |
|
||
decls | ||
dist | ||
cache-dir |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"presets": [ | ||
["../../../../.babel-preset.js", { "browser": true }] | ||
] | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,7 @@ import PageRenderer from "./page-renderer" | |
import { StaticQueryContext } from "gatsby" | ||
import socketIo, { getStaticQueryData, getPageQueryData } from "./socketIo" | ||
|
||
const getPathFromProps = props => | ||
props.pageResources | ||
? props.pageResources.page | ||
? props.pageResources.page.path | ||
: undefined | ||
: undefined | ||
const getPathFromProps = props => props.pageResources?.page?.path | ||
|
||
class JSONStore extends React.Component { | ||
constructor(props) { | ||
|
@@ -47,10 +42,9 @@ class JSONStore extends React.Component { | |
} | ||
} | ||
|
||
componentWillReceiveProps(nextProps) { | ||
componentDidUpdate() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure about that change, I've used recomendation from https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops , but it probably means extra render |
||
const { path } = this.state | ||
const newPath = getPathFromProps(nextProps) | ||
|
||
const newPath = getPathFromProps(this.props) | ||
if (path !== newPath) { | ||
this.unregisterPath(path) | ||
this.registerPath(newPath) | ||
|
@@ -72,7 +66,7 @@ class JSONStore extends React.Component { | |
} | ||
|
||
render() { | ||
const data = this.state.pageQueryData[this.state.path] | ||
const data = this.state.pageQueryData[getPathFromProps(this.props)] | ||
// eslint-disable-next-line | ||
const { pages, ...propsWithoutPages } = this.props | ||
if (!data) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,19 +153,12 @@ export default (pagePath, callback) => { | |
} | ||
|
||
// Create paths to scripts | ||
let runtimeScript | ||
const scriptsAndStyles = flatten( | ||
[`app`, page.componentChunkName].map(s => { | ||
const fetchKey = `assetsByChunkName[${s}]` | ||
|
||
let chunks = get(stats, fetchKey) | ||
|
||
// Remove the runtime as we always inline that instead | ||
// of loading it. | ||
if (s === `app`) { | ||
runtimeScript = chunks[0] | ||
} | ||
|
||
if (!chunks) { | ||
return null | ||
} | ||
|
@@ -195,11 +188,6 @@ export default (pagePath, callback) => { | |
pathPrefix, | ||
}) | ||
|
||
const runtimeRaw = fs.readFileSync( | ||
join(process.cwd(), `public`, runtimeScript), | ||
`utf-8` | ||
) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this isn't currently used anywhere - should it be used? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks ok to delete - the related code was removed in 7983e27#diff-917ba78a52f29b1a1fe42be34d81fc83 |
||
scripts | ||
.slice(0) | ||
.reverse() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
npm run build:rawfiles
is missing here. I'll add a commit.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ops, thanks for catching this!