Skip to content

Router: fix history import warnings

Administrator requested to merge og/router-fix-history-warnings into main

Created by: oleggromov

Issue

Because we're now in a transition state from router v5 to v6, which changes the way history is imported and used internally (primarily because of the react-router-dom-v5-compat package), we've got warnings like this at the build time:

WARNING in ../../node_modules/react-router-dom-v5-compat/index.js 431:15-25
export 'Action' (imported as 'Action') was not found in 'history' (possible exports: __esModule, createBrowserHistory, createHashHistory, createLocation, createMemoryHistory, createPath, locationsAreEqual, parsePath)

WARNING in ../../node_modules/react-router-dom-v5-compat/node_modules/react-router/index.js 12:0-74
export 'Action' (reexported as 'NavigationType') was not found in 'history' (possible exports: __esModule, createBrowserHistory, createHashHistory, createLocation, createMemoryHistory, createPath, locationsAreEqual, parsePath)

WARNING in ../../node_modules/react-router-dom-v5-compat/node_modules/react-router/index.js 849:21-31
export 'Action' (imported as 'Action') was not found in 'history' (possible exports: __esModule, createBrowserHistory, createHashHistory, createLocation, createMemoryHistory, createPath, locationsAreEqual, parsePath)

This can be reproduced by running yarn build-web on the current main.

Fix

In order to fix it, we remove the resolution of history to a particular version (why did we even need it?) and install @types/history. The latter won't be needed once we complete the migration, but since it's just a devDependency used at the build time only, there's no downside.

Test plan

  1. Run yarn build-web on main and see the errors
  2. Check out this branch, run yarn and then yarn build-web again
  3. Make sure there're no warning anymore

App preview:

Check out the client app preview documentation to learn more.

Merge request reports

Loading