reach / router

https://reach.tech/router
MIT License
6.9k stars 326 forks source link

having 'BaseContext' is not exported from '@gatsbyjs/reach-router' in gatsby with typescript #509

Open bambeusz opened 2 years ago

bambeusz commented 2 years ago

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @gatsbyjs/reach-router@1.3.7 for the project I'm working on.

I had a problem with starting my gatsby page saying:

warn ./.cache/root.js
Attempted import error: 'BaseContext' is not exported from '@gatsbyjs/reach-router' (imported as 'BaseContext').

and the website would load with the following error:

screenshot

I tried multiple plugin/loader related suggestions, but none of them worked as expected, so I created a patch for my project.

Here is the diff that solved my problem:

diff --git a/node_modules/@gatsbyjs/reach-router/es/index.js b/node_modules/@gatsbyjs/reach-router/es/index.js
index 335b455..4fbe187 100644
--- a/node_modules/@gatsbyjs/reach-router/es/index.js
+++ b/node_modules/@gatsbyjs/reach-router/es/index.js
@@ -722,4 +722,4 @@ var shouldNavigate = function shouldNavigate(event) {
 };

 ////////////////////////////////////////////////////////////////////////
-export { Link, Location, LocationProvider, Match, Redirect, Router, ServerLocation, createHistory, createMemorySource, isRedirect, navigate, redirectTo, globalHistory, match as matchPath, useLocation, useNavigate, useParams, useMatch };
\ No newline at end of file
+export { Link, Location, LocationProvider, Match, Redirect, Router, ServerLocation, createHistory, createMemorySource, isRedirect, navigate, redirectTo, globalHistory, match as matchPath, useLocation, useNavigate, useParams, useMatch, BaseContext };
diff --git a/node_modules/@gatsbyjs/reach-router/index.js b/node_modules/@gatsbyjs/reach-router/index.js
index 0b1dcb9..066f7f0 100644
--- a/node_modules/@gatsbyjs/reach-router/index.js
+++ b/node_modules/@gatsbyjs/reach-router/index.js
@@ -758,3 +758,4 @@ exports.useLocation = useLocation;
 exports.useNavigate = useNavigate;
 exports.useParams = useParams;
 exports.useMatch = useMatch;
+exports.BaseContext = BaseContext;
\ No newline at end of file

This issue body was partially generated by patch-package.