Skip to content

Upgrade to Gatsby v2 #1104

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

Merged
merged 34 commits into from
Sep 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
add1754
Upgrade to Gatsby v2
Aug 1, 2018
97b520d
Remove unnecessary polyfills since gatsby already provides them
Aug 2, 2018
ee364bd
Move global styles to gatsby-browser
Aug 2, 2018
563305e
Add fb comment and convert to cjs
Aug 2, 2018
832abed
Revert to use pageQuery again
Aug 3, 2018
3c9ccfc
Add back html.js
Aug 3, 2018
a7811bd
Update dependencies
Aug 3, 2018
538efeb
Move TitleAndMetaTags
Aug 3, 2018
d7cdf7b
Replace glamor/reset with normalize.css which fixes style order in prod
Aug 3, 2018
ebe1d08
Prettier formatting
Aug 3, 2018
ee1c636
Remove unused types
Aug 3, 2018
8334d19
Remove old layout
Aug 3, 2018
9bb7341
Fix versions link
Aug 4, 2018
df11ee8
Update deps
Aug 5, 2018
1b409dc
Update deps
Aug 7, 2018
05c5142
Remove hack since it's no longer needed
Aug 7, 2018
8eee020
Update dependencies
Aug 9, 2018
88170d1
Fix build error
Aug 9, 2018
156e6f0
Fix prettier config resolution
Aug 9, 2018
3c0847e
Update gatsby
Aug 9, 2018
ac09f2d
Remove custom onCreatePage logic
Aug 13, 2018
db09d03
Update dependencies
Aug 13, 2018
3c987d6
Fix build
Aug 13, 2018
a25165d
Update dependencies
Aug 13, 2018
a3c83ba
Merge branch 'master' into gatsby-v2
Aug 13, 2018
9e9f02e
Merge branch 'master' into gatsby-v2
Aug 24, 2018
929a407
prettier formatting
Aug 24, 2018
6538649
update dependencies
Aug 24, 2018
10738d9
add custom babel config for flow
Aug 24, 2018
6cdb603
upgrade dependencies
Sep 3, 2018
dc1a76a
Merge branch 'master' into gatsby-v2
Sep 3, 2018
430115d
update dependencies
Sep 15, 2018
d035dc5
Merge branch 'master' into gatsby-v2
Sep 15, 2018
59b6b1b
use stable gatsby release
Sep 18, 2018
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
43 changes: 40 additions & 3 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,41 @@
{
"presets": ['react', 'es2015', 'stage-1'],
"plugins": ['add-module-exports']
}
"presets": [
[
"@babel/preset-env",
{
"loose": true,
"modules": false,
"useBuiltIns": "usage",
"shippedProposals": true,
"targets": {
"browsers": [">0.25%", "not dead"],
}
}
],
[
"@babel/preset-react",
{
"useBuiltIns": true,
"pragma": "React.createElement",
}
],
"@babel/flow"
],
"plugins": [
[
"@babel/plugin-proposal-class-properties",
{
"loose": true
}
],
"@babel/plugin-syntax-dynamic-import",
"babel-plugin-macros",
[
"@babel/plugin-transform-runtime",
{
"helpers": true,
"regenerator": true
}
]
]
}
File renamed without changes.
2 changes: 1 addition & 1 deletion flow-typed/gatsby-link.js → flow-typed/gatsby.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
declare module 'gatsby-link' {
declare module 'gatsby' {
declare module.exports: any;
}
4 changes: 0 additions & 4 deletions flow-typed/glamor.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,3 @@ declare module 'glamor/react' {
propMerge: Function,
};
}

declare module 'glamor/reset' {
declare module.exports: any;
}
1 change: 0 additions & 1 deletion flow-typed/graphql.js

This file was deleted.

11 changes: 0 additions & 11 deletions flow-typed/polyfills.js

This file was deleted.

17 changes: 17 additions & 0 deletions gatsby-browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* @emails react-core
*/

'use strict';

// Import global styles
require('normalize.css');
require('./src/css/reset.css');
require('./src/prism-styles');
require('./src/css/algolia.css');

// A stub function is needed because gatsby won't load this file otherwise
// (https://github.com/gatsbyjs/gatsby/issues/6759)
exports.onClientEntry = () => {};
3 changes: 1 addition & 2 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ module.exports = {
'gatsby-transformer-versions-yaml',
'gatsby-plugin-netlify',
'gatsby-plugin-glamor',
'gatsby-plugin-react-next',
'gatsby-plugin-twitter',
{
resolve: 'gatsby-plugin-nprogress',
Expand Down Expand Up @@ -134,7 +133,7 @@ module.exports = {
{
allMarkdownRemark
(limit: 10,
filter: {id: {regex: "/blog/"}},
filter: {fileAbsolutePath: {regex: "/blog/"}},
sort: {fields: [fields___date],
order: DESC}) {
edges {
Expand Down
2 changes: 1 addition & 1 deletion gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

'use strict';

exports.modifyWebpackConfig = require('./gatsby/modifyWebpackConfig');
exports.onCreateWebpackConfig = require('./gatsby/onCreateWebpackConfig');
exports.createPages = require('./gatsby/createPages');
exports.onCreateNode = require('./gatsby/onCreateNode');
exports.onCreatePage = require('./gatsby/onCreatePage');
9 changes: 5 additions & 4 deletions gatsby/createPages.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

const {resolve} = require('path');

module.exports = async ({graphql, boundActionCreators}) => {
const {createPage, createRedirect} = boundActionCreators;
module.exports = async ({graphql, actions}) => {
const {createPage, createRedirect} = actions;

// Used to detect and prevent duplicate redirects
const redirectToSlugMap = {};
Expand Down Expand Up @@ -129,7 +129,7 @@ module.exports = async ({graphql, boundActionCreators}) => {
{
allMarkdownRemark(
limit: 1
filter: {id: {regex: "/blog/"}}
filter: {fileAbsolutePath: {regex: "/blog/"}}
sort: {fields: [fields___date], order: DESC}
) {
edges {
Expand All @@ -143,6 +143,7 @@ module.exports = async ({graphql, boundActionCreators}) => {
}
`,
);

const newestBlogNode = newestBlogEntry.data.allMarkdownRemark.edges[0].node;

// Blog landing page should always show the most recent blog entry.
Expand All @@ -151,4 +152,4 @@ module.exports = async ({graphql, boundActionCreators}) => {
redirectInBrowser: true,
toPath: newestBlogNode.fields.slug,
});
};
};
23 changes: 0 additions & 23 deletions gatsby/modifyWebpackConfig.js

This file was deleted.

4 changes: 2 additions & 2 deletions gatsby/onCreateNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ function buildRedirectString(permalink, redirect_from) {
}

// Add custom fields to MarkdownRemark nodes.
module.exports = exports.onCreateNode = ({node, boundActionCreators, getNode}) => {
const {createNodeField} = boundActionCreators;
module.exports = exports.onCreateNode = ({node, actions, getNode}) => {
const {createNodeField} = actions;

switch (node.internal.type) {
case 'MarkdownRemark':
Expand Down
8 changes: 2 additions & 6 deletions gatsby/onCreatePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@

'use strict';

module.exports = async ({page, boundActionCreators}) => {
const {createPage} = boundActionCreators;
module.exports = async ({page, actions}) => {
const {createPage} = actions;

return new Promise(resolvePromise => {
// page.matchPath is a special key that's used for matching pages only on the client.
// Explicitly wire up all error code wildcard matches to redirect to the error code page.
if (page.path.includes('docs/error-decoder.html')) {
page.matchPath = 'docs/error-decoder:path?';
page.context.slug = 'docs/error-decoder.html';

createPage(page);
}

resolvePromise();
});
};
23 changes: 23 additions & 0 deletions gatsby/onCreateWebpackConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* @emails react-core
*/

'use strict';

const {resolve} = require('path');
const webpack = require('webpack');

module.exports = ({stage, actions}) => {
actions.setWebpackConfig({
resolve: {
modules: [
resolve(__dirname, '../src'),
resolve(__dirname, '../node_modules'),
],
},
// See https://github.com/FormidableLabs/react-live/issues/5
plugins: [new webpack.IgnorePlugin(/^(xor|props)$/)],
});
};
59 changes: 30 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"url": "https://github.com/reactjs/reactjs.org"
},
"dependencies": {
"array-from": "^2.1.1",
"babel-eslint": "^8.0.1",
"eslint": "^4.8.0",
"eslint-config-fbjs": "^2.0.0",
Expand All @@ -19,40 +18,41 @@
"eslint-plugin-react": "^7.4.0",
"eslint-plugin-relay": "^0.0.19",
"flow-bin": "^0.56.0",
"gatsby": "^1.9.273",
"gatsby-link": "^1.6.9",
"gatsby-plugin-catch-links": "^1.0.9",
"gatsby-plugin-feed": "^1.3.9",
"gatsby-plugin-glamor": "^1.6.4",
"gatsby-plugin-google-analytics": "^1.0.4",
"gatsby-plugin-manifest": "^1.0.4",
"gatsby-plugin-netlify": "^1.0.21",
"gatsby-plugin-nprogress": "^1.0.7",
"gatsby-plugin-react-helmet": "^1.0.3",
"gatsby-plugin-react-next": "^1.0.3",
"gatsby-plugin-sharp": "^1.6.48",
"gatsby-plugin-twitter": "^1.0.10",
"gatsby-remark-autolink-headers": "^1.4.4",
"gatsby-remark-code-repls": "^1.0.2",
"gatsby-remark-copy-linked-files": "^1.5.2",
"gatsby-remark-embed-snippet": "^1.0.22",
"gatsby-remark-images": "^1.5.67",
"gatsby-remark-prismjs": "^1.2.24",
"gatsby-remark-responsive-iframe": "^1.4.3",
"gatsby-remark-smartypants": "^1.4.3",
"gatsby-source-filesystem": "^1.4.4",
"gatsby-transformer-remark": "^1.7.44",
"gatsby-transformer-sharp": "^1.6.27",
"gatsby": "^2.0.0",
"gatsby-plugin-catch-links": "^2.0.0",
"gatsby-plugin-feed": "^2.0.0",
"gatsby-plugin-glamor": "^2.0.0",
"gatsby-plugin-google-analytics": "^2.0.0",
"gatsby-plugin-manifest": "^2.0.0",
"gatsby-plugin-netlify": "^2.0.0",
"gatsby-plugin-nprogress": "^2.0.0",
"gatsby-plugin-react-helmet": "^3.0.0",
"gatsby-plugin-sharp": "^2.0.0",
"gatsby-plugin-twitter": "^2.0.0",
"gatsby-remark-autolink-headers": "^2.0.0",
"gatsby-remark-code-repls": "^2.0.0",
"gatsby-remark-copy-linked-files": "^2.0.0",
"gatsby-remark-embed-snippet": "^3.0.0",
"gatsby-remark-images": "^2.0.0",
"gatsby-remark-prismjs": "^3.0.0",
"gatsby-remark-responsive-iframe": "^2.0.0",
"gatsby-remark-smartypants": "^2.0.0",
"gatsby-source-filesystem": "^2.0.0",
"gatsby-transformer-remark": "^2.0.0",
"gatsby-transformer-sharp": "^2.0.0",
"glamor": "^2.20.40",
"hex2rgba": "^0.0.1",
"normalize.css": "^8.0.0",
"prettier": "^1.7.4",
"prismjs": "^1.15.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-helmet": "^5.2.0",
"react-live": "1.8.0-0",
"remarkable": "^1.7.1",
"request-promise": "^4.2.2",
"rimraf": "^2.6.1",
"slugify": "^1.2.1",
"string.prototype.includes": "^1.0.0",
"string.prototype.repeat": "^0.2.0",
"unist-util-visit": "^1.1.3"
},
"engines": {
Expand All @@ -76,16 +76,17 @@
"dev": "gatsby develop -H 0.0.0.0",
"flow": "flow",
"format:source": "prettier --config .prettierrc --write \"{gatsby-*.js,{flow-typed,plugins,src}/**/*.js}\"",
"format:examples": "prettier --config .prettierrc.examples --write \"examples/**/*.js\"",
"format:examples": "prettier --config examples/.prettierrc --write \"examples/**/*.js\"",
"lint": "eslint .",
"netlify": "yarn --version && rimraf node_modules && yarn install --frozen-lockfile --check-files && yarn build",
"nit:source": "prettier --config .prettierrc --list-different \"{gatsby-*.js,{flow-typed,plugins,src}/**/*.js}\"",
"nit:examples": "prettier --config .prettierrc.examples --list-different \"examples/**/*.js\"",
"nit:examples": "prettier --config examples/.prettierrc --list-different \"examples/**/*.js\"",
"prettier": "yarn format:source && yarn format:examples",
"prettier:diff": "yarn nit:source && yarn nit:examples",
"reset": "rimraf ./.cache"
},
"devDependencies": {
"@babel/preset-flow": "^7.0.0",
"eslint-config-prettier": "^2.6.0",
"lz-string": "^1.4.4",
"npm-run-all": "^4.1.2",
Expand Down
4 changes: 2 additions & 2 deletions plugins/gatsby-source-react-error-codes/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ const request = require('request-promise');
const errorCodesUrl =
'http://raw.githubusercontent.com/facebook/react/master/scripts/error-codes/codes.json';

exports.sourceNodes = async ({boundActionCreators}) => {
const {createNode} = boundActionCreators;
exports.sourceNodes = async ({actions}) => {
const {createNode} = actions;

try {
const jsonString = await request(errorCodesUrl);
Expand Down
4 changes: 2 additions & 2 deletions plugins/gatsby-transformer-authors-yaml/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const safeLoad = require('js-yaml').safeLoad;

// Reads authors.yml data into GraphQL.
// This is auto-linked by gatsby-config.js to blog posts.
exports.sourceNodes = ({graphql, boundActionCreators}) => {
const {createNode} = boundActionCreators;
exports.sourceNodes = ({graphql, actions}) => {
const {createNode} = actions;

const path = resolve(__dirname, '../../content/authors.yml');
const file = readFileSync(path, 'utf8');
Expand Down
4 changes: 2 additions & 2 deletions plugins/gatsby-transformer-home-example-code/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ const {join, resolve} = require('path');

// Store code snippets in GraphQL for the home page examples.
// Snippets will be matched with markdown templates of the same name.
exports.sourceNodes = ({graphql, boundActionCreators}) => {
const {createNode} = boundActionCreators;
exports.sourceNodes = ({graphql, actions}) => {
const {createNode} = actions;

const path = resolve(__dirname, '../../content/home/examples');
const files = readdirSync(path);
Expand Down
2 changes: 1 addition & 1 deletion src/components/ButtonLink/ButtonLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @emails react-core
*/

import Link from 'gatsby-link';
import {Link} from 'gatsby';
import React from 'react';
import {colors, media} from 'theme';

Expand Down
2 changes: 1 addition & 1 deletion src/components/ErrorDecoder/ErrorDecoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function ErrorDecoder(props: {|
let msg = '';

const errorCodes = JSON.parse(props.errorCodesString);
const parseResult = parseQueryString(props.location.search);
const parseResult = parseQueryString(props.location.search || '');
if (parseResult != null) {
code = parseResult.code;
msg = replaceArgs(errorCodes[code], parseResult.args);
Expand Down
Loading