geist-org / geist-ui

A design system for building modern websites and applications.
https://geist-ui.dev
MIT License
4.33k stars 334 forks source link

Tree shaking error when using use input hook #594

Closed Andrew-Colman closed 3 years ago

Andrew-Colman commented 3 years ago

Bug report 🐞

Tree shaking error when using use input hook

easily reproducible with Tree shaking with Next.js example

any component using :

import { useInput } from "@geist-ui/react"; const { state, reset, bindings } = useInput();

will break the full project

Version & Environment

Expected Behaviour

Should compile without errors

Actual results (or Errors)

I got an error:

Failed to compile:

Module not found: Can't resolve '@geist-ui/react/esm/use-input'
Andrew-Colman commented 3 years ago

I made a copy of node_modules/@geist-ui/react/esm/input/use-input.js

to: node_modules/@geist-ui/react/esm/use-input.js (and remapped '../utils/use-current-state'; to './utils/use-current-state'; )

and it removed the compilation error on my project (hope this can help track the source of the issue )

unix commented 3 years ago

This is a module path error, which has been fixed in the canary version.(yarn add @geist-ui/react@canary)

Andrew-Colman commented 3 years ago

which has been fixed in the canary version

still getting this error with canary: (2.2.0-rc.8)

small example: https://github.com/Andrew-Colman/geist-ui-react/tree/tree-shaking-use-input-test

git clone https://github.com/Andrew-Colman/geist-ui-react.git 
&& cd geist-ui-react
&& git checkout tree-shaking-use-input-test
&& cd tree-shaking-nextjs-canary && yarn && yarn dev

image

others may face this problem for now.

unix commented 3 years ago

fixed in v2.2.0. If a similar issue occurs again, please reopen.