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

refactor(gatsby): remove parsePath from gatsby core, and move to gatsby-link #9957

Merged
merged 9 commits into from Feb 19, 2019

Conversation

DSchau
Copy link
Contributor

@DSchau DSchau commented Nov 15, 2018

Moving a utility function (that was not used!) in gatsby core into where it belongs, gatsby-link. This was discovered via a community member (@travi), as he was attempting to use storybook to test a Link component (outside of Gatsby), e.g. import Link from 'gatsby-link', which was then requiring gatsby core.

This also generally solves some weirdness that the cyclical require was kinda weird, e.g. gatsby -> gatsby-link -> gatsby

I do not believe this is a breaking change, since the version required of gatsby-link will just be bumped by gatsby, and the export is still exported from the top level gatsby module

Moving a utility function (that was not used!) in gatsby core into where
it belongs, gatsby-link. This was discovered via a community member
(@travi), as he was attempting to use storybook to test a Link component
(outside of Gatsby), e.g. `import Link from 'gatsby-link'`, which was
then requiring `gatsby` core.

This also generally solves some weirdness that the cyclical require was
kinda weird, e.g. gatsby -> gatsby-link -> gatsby

I do not believe this is a breaking change, since the version required
of gatsby-link will just be bumped by gatsby, and the export is still
exported from the top level gatsby module
@DSchau DSchau requested a review from a team as a code owner November 15, 2018 20:24
@pieh
Copy link
Contributor

pieh commented Nov 16, 2018

Moving a utility function (that was not used!) in gatsby core

It is used in https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/cache-dir/navigation.js (but we could import it from gatsby-link there). What is interesting is this change should break e2e tests I think as parsePath should be undefined in navigation.js code and navigation should be broken - am I missing something?

@travi
Copy link
Contributor

travi commented Dec 13, 2018

i've been heads down on a few things, so i've lost track of whats happening with this one. is this still planned to move forward somehow? anything i should try to help out with to help it move forward?

@DSchau
Copy link
Contributor Author

DSchau commented Feb 7, 2019

These tests are failing (I believe!) because parsePath isn't currently an exported API from gatsby-link. I'll validate that though.

Fixed!

I do think this change is probably worth merging in, because it's more correct and resolves some issues for folks. I think it also resolves a circular dependency which is a nice little side benefit, e.g.

gatsby -> gatsby-link -> gatsby

becomes

gatsby -> gatsby-link

@sidharthachatterjee sidharthachatterjee self-assigned this Feb 19, 2019
Copy link
Contributor

@sidharthachatterjee sidharthachatterjee left a comment

Choose a reason for hiding this comment

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

LGTM, thank you @DSchau 👍

@sidharthachatterjee sidharthachatterjee merged commit 3d77520 into gatsbyjs:master Feb 19, 2019
@sidharthachatterjee
Copy link
Contributor

Released in

  • gatsby-link@2.0.11
  • gatsby@2.1.6

@travi
Copy link
Contributor

travi commented Feb 20, 2019

thank you for pushing this through. it does appear to have resolved my issue.

one thing that i noticed that seems like it may have been unintentional is that the display-name changed from GatsbyLink to ForwardRef. Not a big deal on my end, but seems a little less descriptive, so thought I'd pass along in case there were any concerns about it.

@DSchau
Copy link
Contributor Author

DSchau commented Feb 20, 2019

@travi

one thing that i noticed that seems like it may have been unintentional is that the display-name changed from GatsbyLink to ForwardRef

I don't think this was introduced in this PR. We added React.forwardRef a few releases ago, so it's possible you're just getting that now?

Also for context, is this in the React Devtools? I think that's perhaps sort of of a known issue a la https://spectrum.chat/styled-components/help/styled-components-v4-react-devtools-bloat~a5856708-0786-499d-ab32-3626b45a1094

@DSchau DSchau deleted the gatsby-link/parse-path branch February 20, 2019 04:30
@travi
Copy link
Contributor

travi commented Feb 20, 2019

I don't think this was introduced in this PR. We added React.forwardRef a few releases ago, so it's possible you're just getting that now?

very possible. i've been distracted with other projects lately, so i havent given this a lot of attention lately.

is this in the React Devtools?

in my case (at least for now), it wasn't. my tests were using enzyme to select the link for inspection in the test assertions using the display-name approach for that selection. i changed the tests to select using the variable approach instead, so the change isn't very impactful for me.

however, it was the use of devtools that came to mind with mentioning it being less descriptive since i do also inspect the react tree sometimes in that way. just seemed like it would be less obvious in that case that it was a component even related to gatsby-link.

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.

None yet

4 participants