salvoravida/redux-first-history

rr6 requires react-router incorrectly

alexburkowskypolysign opened this issue · 3 comments

var react_router_1 = require("react-router");

It should require('react-router-dom')

@salvoravida the issue comes down to webpack node_module resolution. It doesn't know that it's re-exported that way. At least that's the issue I'm running into.

This is the shape of my node_modules, and I expect many other monorepos are similar:
Screen Shot 2022-09-11 at 5 52 38 PM

Since react-router isnt on the top level redux-first-history and webpack wont find it. It should always be able to find react-router-dom though. Consumers do not generally explicitly include the base react-router package in their package.json

@salvoravida Hello, I have the same issue.
I run webpack, and get the following error.

    ERROR in ./node_modules/redux-first-history/rr6/index.js 9:21-44
    Module not found: Error: Can't resolve 'react-router' in '/Users/*****/**MyProject**/node_modules/redux-first-history/rr6'
    resolve 'react-router' in '/Users/*****/**MyProject**/node_modules/redux-first-history/rr6'
      Parsed request is a module
      using description file: /Users/*****/**MyProject**/node_modules/redux-first-history/package.json (relative path: ./rr6)
        Field 'browser' doesn't contain a valid alias configuration
        resolve as module
          /Users/*****/**MyProject**/node_modules/redux-first-history/rr6/node_modules doesn't exist or is not a directory
          /Users/*****/**MyProject**/node_modules/redux-first-history/node_modules doesn't exist or is not a directory
          /Users/*****/**MyProject**/node_modules/node_modules doesn't exist or is not a directory
          looking for modules in /Users/*****/**MyProject**/node_modules
            single file module
              using description file: /Users/*****/**MyProject**/package.json (relative path: ./node_modules/react-router)
                no extension
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/*****/**MyProject**/node_modules/react-router doesn't exist
                .mjs
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/*****/**MyProject**/node_modules/react-router.mjs doesn't exist
                .js
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/*****/**MyProject**/node_modules/react-router.js doesn't exist
                .ts
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/*****/**MyProject**/node_modules/react-router.ts doesn't exist
                .tsx
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/*****/**MyProject**/node_modules/react-router.tsx doesn't exist
            /Users/*****/**MyProject**/node_modules/react-router doesn't exist

My package.json deps has react-router-dom but not react-router.

I maybe think, adding react-router to redux-first-history's deps solves this?