Skip to content

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

Open
@bambeusz

Description

@bambeusz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions