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

[v2] Migration guide updates #5661

Merged
merged 27 commits into from Jun 5, 2018
Merged
Changes from 4 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ddd19d6
Remove yarn examples for consistency with other docs
m-allanson Jun 1, 2018
8718398
Add rename responsive image queries section
m-allanson Jun 1, 2018
bf0a458
Add postcss plugins section
m-allanson Jun 1, 2018
231184a
Remove checklist (moved to issue 3986)
m-allanson Jun 1, 2018
00d68ee
Add mixed CommonJS/ES6 section
m-allanson Jun 1, 2018
8053835
Link to Gatsby webpack docs
m-allanson Jun 1, 2018
bb64597
Add node id section
m-allanson Jun 1, 2018
7afa9d9
Add section: remove explicit polyfills
m-allanson Jun 1, 2018
f616086
Add section: Change modifyBabelrc to onCreateBabelConfig
m-allanson Jun 1, 2018
163d7ea
Add section: Change `modifyWebpackConfig` to `onCreateWebpackConfig`
m-allanson Jun 1, 2018
e54d5f9
Add section: CSS is inlined automatically
m-allanson Jun 1, 2018
5413b73
Add introduction and small tweaks
m-allanson Jun 1, 2018
d10adad
Correct line numbers
m-allanson Jun 1, 2018
ca6d375
Improve explanation around movement of libs to peerDependencies
KyleAMathews Jun 1, 2018
433833a
chore: minor capitalization tweak
jlengstorf Jun 1, 2018
05b1e85
Add edit link
m-allanson Jun 4, 2018
d0cebc7
Split peer dep updates into two sections
m-allanson Jun 4, 2018
9124ad1
Declarative headings
m-allanson Jun 4, 2018
c5e1c15
Add table of contents
m-allanson Jun 4, 2018
2be2dca
Use neater Fragment syntax
m-allanson Jun 4, 2018
b8c4860
More detail on deprecation note
m-allanson Jun 4, 2018
405073e
Inline comments on code examples
m-allanson Jun 4, 2018
bfc9301
Add Jason's node ID query example
m-allanson Jun 4, 2018
6af965a
merge origin/v2-migration-guide
m-allanson Jun 4, 2018
d5beb1b
Use markdown diff syntax for before / after examples
m-allanson Jun 4, 2018
ad47463
Add 'in-progress' note about babel polyfills
m-allanson Jun 4, 2018
ed23990
Add instructions on how to install Gatsby v2
m-allanson Jun 4, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
103 changes: 77 additions & 26 deletions docs/docs/migrating-from-v1-to-v2.md
Expand Up @@ -9,24 +9,12 @@ In v1, React and ReactDOM were magically resolved. This “feature” has been r
npm i react react-dom
```

or

```bash
yarn add react react-dom
```

Depending on the plugins you use, there may be more dependencies you need to install. For example: if you use typography.js, you now also need to install its dependencies.

```bash
npm i typography react-typography
```

or

```bash
yarn add typography react-typography
```

Search for the plugins that you use in [Gatsby’s plugins page](/plugins) and check their installation instructions.

## Layout component
Expand Down Expand Up @@ -180,17 +168,80 @@ export default props => (
## Rename `pathContext` to `pageContext`
Similar to `boundActionCreators` above, `pathContext` is deprecated in favor of `pageContext`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this a breaking change? If so we should highlight that -- I don't believe boundActionCreators is.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not — we pass both pathContext and pageContext as props


<!--
Taken from: https://github.com/gatsbyjs/gatsby/blob/v2/Breaking%20Changes.md
* [] Remove postcss plugins (cssnext, cssimport) from default css loader config
* [x] boundActionCreators => actions
* [x] pathContext => pageContext
* [] Source & transformer plugins now use UUIDs for ids. If you used glob or regex to query nodes by id then you'll need to query something else.
* [] Mixed commonjs/es6 modules fail
* [] Remove explicit polyfill and use the new builtins: usage support in babel 7.
* [] Changed modifyBabelrc to onCreateBabelConfig
* [] Changed modifyWebpackConfig to onCreateWebpackConfig
* [] Inlining CSS changed — remove it from any custom html.js as done automatically by core now.
* [x] Manually install react and react-dom, along with any dependencies required by your plugins.
* [x] Layouts have been removed. To achieve the same behavior as v1, you have to wrap your pages and page templates with your own Layout component. Since Layout is a non-page component, making query has to be done with StaticQuery.
-->
## Rename responsive image queries

The `sizes` and `resolutions` queries are deprecated in v2. These queries have been renamed to `fluid` and `fixed` to make them easier to understand.

Before:

```jsx
const Example = ({ data }) => {
<div>
<Img sizes={data.foo.childImageSharp.sizes} />
<Img resolutions={data.bar.childImageSharp.resolutions} />
</div>
}

export default Example

export const pageQuery = graphql`
query IndexQuery {
foo: file(relativePath: { regex: "/foo.jpg/" }) {
childImageSharp {
sizes(maxWidth: 700) {
...GatsbyImageSharpSizes_tracedSVG
}
}
}
bar: file(relativePath: { regex: "/bar.jpg/" }) {
childImageSharp {
resolutions(width: 500) {
...GatsbyImageSharpResolutions_withWebp
}
}
}
}
`
```

After:

```jsx{2-3,13-14,20-21}
const Example = ({ data }) => {
<div>
<Img fluid={data.foo.childImageSharp.fluid} />
<Img fixed={data.bar.childImageSharp.fixed} />
</div>
}

export default Example

export const pageQuery = graphql`
query IndexQuery {
foo: file(relativePath: { regex: "/foo.jpg/" }) {
childImageSharp {
fluid(maxWidth: 700) {
...GatsbyImageSharpFluid_tracedSVG
}
}
}
bar: file(relativePath: { regex: "/bar.jpg/" }) {
childImageSharp {
fixed(width: 500) {
...GatsbyImageSharpFixed_withWebp
}
}
}
}
`
```

Further examples can be found in the [Gatsby Image docs](https://github.com/gatsbyjs/gatsby/tree/d0e29272ed7b009dae18d35d41a45e700cdcab0d/packages/gatsby-image).
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a note that this is deprecated, but will continue working (similar to the boundActionCreators note)?


## Manually specify postcss plugins

Gatsby v2 removed `postcss-cssnext` and `postcss-import` from the default postcss setup.

Use `modifyWebpackConfig` to specify your postcss plugins.
Copy link
Contributor

Choose a reason for hiding this comment

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

Link this to the new webpack docs page


Note: there will be a `postcss` plugin that allows you to configure postcss from a standard postcss config file. [Follow this discussion on issue 3284](https://github.com/gatsbyjs/gatsby/issues/3284).