[Issue][build] Could not resolve ./types
meditation-error opened this issue · 4 comments
Describe the bug
I get the following error using vite to build my project:
error during build:
Could not resolve "./types" from "node_modules/maz-ui/components/index.mjs"
To Reproduce
Steps to reproduce the behavior:
Running vite build
Expected behavior
No build errors
Desktop (please complete the following information)
- OS: Windows
Additional context
The final line of index.mjs is:
export * from './types'
In de git repository there is a file named types.ts, but in the packacge installed with npm this file is called types.d.ts
renaming the file to types.ts fixes the error, but I cannot change this file in an autodeploy environment.
Is there a way I am missing to build this package using vite ?
Hmm, that's strange because the file types.d.ts
is present in the build.
Can you share your code and how you import the component(s)
Normally, you should not use the components
file: https://maz-ui.com/guide/getting-started#not-recommended-fully-components-installation
I import it in my components at the top of the file like this:
import { MazBtn } from 'maz-ui/components'
types.d.ts is indeed present in the build, but types.ts is not.
For some reason my (default) vite / typescript setup does not recognize the types.d.ts file when importing './types'
when I rename the file to types.ts instead of types.d.ts, all works fine.
ah, so if I understand you correctly, I should use: import MazBtn from maz-ui/components/MazBtn
instead. I will try that
This fixed my issue.
Although I did read that import * as components from 'maz-ui/components'
wasn't recommended, I didn't realize that doing import { MazBtn } from 'maz-ui/components'
was practically the same.
So thanks for the clarification!