couetilc / react-social-icons

svg social icons in react

Home Page:https://react-social-icons.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tree-shaking with TypeScript

cwerner87 opened this issue · comments

I'm having some issues using react-social-icons with tree-shaking using TypeScript. It may be me doing something very stupid but I'm at a loss.

A minimal reproducible example:

npx create-react-app test-social --template typescript
cd test-social
yarn add react-social-icons --save

In App.tsx, add:

import { SocialIcon } from 'react-social-icons/component';

Then yarn build yields:

TS2307: Cannot find module 'react-social-icons/component' or its corresponding type declarations.
    3 | import './App.css';
    4 |
    5 | import { SocialIcon } from 'react-social-icons/component';
      |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    6 |
    7 | function App() {
    8 |   return (

Any ideas on what I'm doing wrong here?

@cwerner87 Thank for providing a reproducible issue. In the short term, change "moduleResolution" in your tsconfig.json to "bundler". That should fix the error. I'll dig into why "moduleResolution": "node" does not work over the next few days.