OiO.lk Blog javascript Testing a react component library project using vite
javascript

Testing a react component library project using vite


I have a library project using TS, React, and vite for bundler. Folder structure looks like this

- LibraryProject
 - src
  - main
   - TestComponent.tsx
  - hooks
   - hookFile.ts
  - enums
   - enumFile.enum.ts

My current vite config builds a lib properly and I am able to use that in a separate React demo project.

To import my Library project into the react demo project, I am using the default npm install command followed by the ../pathToLibraryProject. Once the project is linked I am able to reference the main file but unable to import enums or hooks.

Current import statement,

import TestComponent, { enumA } from "library-project";

TestComponent as I mentioned is imported correctly but not ENUM_A.

Error,

ERROR in ./src/App.js 46:22-39
export 'enumA' (imported as 'enumA') was not found in 'library-project' (possible exports: default)

Can anyone point out what can possibly fix this?

Thanks.



You need to sign in to view this answers

Exit mobile version