jsconfig.json allows for absolute imports in React but breaks Styleguidist imports

I use jsconfig.json for absolute imports throughout my Create-React-App. Is there a way to get Styleguidist to properly honor absolute imports as defined by the jsconfig.json file? It works great in my React app but when the Styleguidist parser tries to read a .js file and encounters one of these absolute imports, it cannot properly locate it.

jsconfig.json

{
  "compilerOptions": {
    "baseUrl": "src"
  }
}

/src/components/Foo.js

import { Bar } from 'components'

Styleguidist terminal:

Module not found: Cant resolve 'components'
/.
+-- styleguide.config.js
+-- src
|   +-- /components
|   |   +-- Foo.js
|   |   +-- Bar.js
|   |   +-- index.js

Please know that I have tried moving the styleguide.config.js into the /src directory to establish a common root between that config and the jsconfig.json. It did not resolve the issue.

Source: Ask Javascript Questions

LEAVE A COMMENT