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

Move gatsby-link into gatsby #3864

Merged
merged 5 commits into from
Feb 7, 2018
Merged

Move gatsby-link into gatsby #3864

merged 5 commits into from
Feb 7, 2018

Conversation

tsriram
Copy link
Contributor

@tsriram tsriram commented Feb 5, 2018

This is for #3714.

Just copied over files from gatsby-link to gatsby, added required dependencies and changed the main file to dist/index.js in gatsby's package.json. Testing importing Link from gatsby in a local project and it seems to be working fine.

Wonder if I should delete gatsby-link package already?

This change is mostly copying the files from `gatsby-link` package to `gatsby` package. Have added a missing dependency (prop-types) and changed the `main` file to `dist/index.js` in gatsby's package.json.
Just copying over index.d.ts from `gatsby-link` package to `gatsby` and removing default export as we don't export `Link` component as the default one.
@ghost ghost assigned tsriram Feb 5, 2018
@ghost ghost added the review label Feb 5, 2018
}
]
]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

this is correct, you shouldn't need the babelrc here, the existing setup will handle it correctly when it's imported in the browser code.

@@ -0,0 +1,3 @@
import Link, { withPrefix, navigateTo } from './components/link'

export { Link, withPrefix, navigateTo }
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this is the best way to handle the imports here...I think we want an explicit browser entry file, so that all the server side code isn't accidently (in the future) imported.

I would make a browser.js or maybe client.js (w/d/t @KyleAMathews) and point to that file in package.json browser: main field (more info)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cool, never realized that browser field existed in package.json 😄 Thanks for pointing out. WIll probably wait for @KyleAMathews' comment and make browser.js or client.js.

@@ -0,0 +1,189 @@
/*global __PREFIX_PATHS__, __PATH_PREFIX__ */
import React from "react"
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather then moving the source code here it might make sense to leave the external pacakge and have gatsby depend on it directly and re-export

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm...quite not sure about this. If there are plans to have more components in gatsby package, I think it's better to have the code here as we may not want other components to be in their own packages. If that's not something we're looking at now, yeah, it makes sense to just leave the package as is and re-export the component.

Copy link
Contributor

Choose a reason for hiding this comment

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

it might be the case taht new components live here, but I do think there is probably less friction to re-export. The other benefit tho is that someone can update/bug fix gatsby-link without requiring a gatsby release. That said I defer to what @KyleAMathews thinks

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @jquense. It's a much smaller change to leave it where it is and just export it. Also it keeps our packaging setup simpler as with gatsby-link we know it's browser code and we can build and publish it accordingly.

Copy link
Contributor Author

@tsriram tsriram Feb 6, 2018

Choose a reason for hiding this comment

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

The other benefit tho is that someone can update/bug fix gatsby-link without requiring a gatsby release.

@jquense, might be a silly question, but I don't quite understand this - do you mean we'll keep publishing new changes to gatsby-link on to npm as a separate package without publishing gatsby? If we want Link to be imported from gatsby, we've to discontinue publishing a separate package no?

Copy link
Contributor

Choose a reason for hiding this comment

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

@tsriram no we'd still publish gatsby-link as a separate package — it'd just now be a dependency of gatsby and we'd instruct people to use the re-exported version there.

@jquense lerna would actually still publish gatsby on every new gatsby-link change — excess of caution perhaps but whatever. We already release gatsby a few times a day or so so no big deal :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@KyleAMathews Cool. gatsby-link already seems to be a dependency of gatsby:

"gatsby-link": "^1.6.36",

So only re-exporting needs to be done here I guess.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also updating example sites and www and any docs referencing gatsby-link :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah 😄

@KyleAMathews
Copy link
Contributor

Looks great! Merging this now. Would love help as well updating example sites + docs :-)

@KyleAMathews KyleAMathews merged commit 4763bbd into gatsbyjs:v2 Feb 7, 2018
@ghost ghost removed the review label Feb 7, 2018
@tsriram
Copy link
Contributor Author

tsriram commented Feb 8, 2018

Sure, I was about to comment that this was WIP and to be merged after I update example sites and docs but it was too late last night. Will send a new PR for that :)

@KyleAMathews
Copy link
Contributor

I got an itchy merge finger :-)

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.

3 participants