seek-oss / playroom

Design with JSX, powered by your own component library.
MIT License
4.48k stars 182 forks source link

Unable to resolve aliased imports #168

Closed antsmo closed 4 years ago

antsmo commented 4 years ago

Hey, really excited to try out this tool with our component library but I'm running into a configuration issue.

We're using aliases to clean up our import paths, so we've defined the following in eslintrc.js:

module.exports = {
  ...
  "settings": {
    "import/resolver": {
      "node": {
        "paths": ["lib"]
      }
    }
  },
  ...
}

It doesn't look like this works out of the box with Playroom because I'm getting the following error from one of our components that imports using an alias:

These dependencies were not found:

* utils/toMap in ./lib/components/common/Loader/loaderTypes.ts, ./lib/components/common/Text/textVariants.ts
* utils/type in ./lib/components/common/Loader/loaderTypes.ts, ./lib/components/common/Text/textVariants.ts

To install them, you can run: npm install --save utils/toMap utils/type

I'm not sure how to proceed so would really appreciate any help or direction. Thanks!

mandymichael commented 4 years ago

We have aliases too, I set it up in the playroom.config.js file, in the custom webpack config - i just copied mine from our tsconfig

e.g

webpackConfig: () => ({
...
  resolve: {
            extensions: ['.js', '.ts', '.tsx'],
            alias: {
                'component-library':  path.resolve(__dirname, 'src/component-library/'),
            },
        },
}),
antsmo commented 4 years ago

@mandymichael Thanks very much :)