Closed mochizin closed 2 weeks ago
@mochizin , hello. Is there any updates on this subject? Should we recreate react and vite app with older version? I want to install older version of vite. Which is doesnt have this problem?
@mochizin , I removed tsconfig.app.json and moved all its content to tsconfig.json. And it started to work properly. I could import UI component to my other project.
@mochizin , I removed tsconfig.app.json and moved all its content to tsconfig.json. And it started to work properly. I could import UI component to my other project.
Yeah, this was my solution as well, but it is how Vite do in previous versions. I was looking for some solution/fix that works with latest Vite
@yestay90, @mochizin, I think this fix must come from this plugin in a future update. Until it happens, this is what I did to fix it on my side:
dts({
tsconfigPath: resolve(__dirname, "tsconfig.app.json"),
rollupTypes: true,
}),
So, I didn't need to change the "Vite way" of organizing the tsconfig files.
@willian, I tried to do that previously as well but when I run npm run build
that contains tsc -b
, it generates a vite.config.js file in my root folder. I'm using vite.config.ts.
So this solution doesn't work for me 😕
@mochizin I got exactly the same your issue Here is the fix
plugins: [
react(),
dts({
rollupTypes: true,
tsconfigPath: "./tsconfig.app.json",
}),
],
@phuongthuan wow amazing how this works, why does it happen?
@phuongthuan can't see the file, can you post the code here?
This also ended up working for me
Me too after 4 days of searching
It has been updated in FAQs.
@yestay90, @mochizin, I think this fix must come from this plugin in a future update. Until it happens, this is what I did to fix it on my side:
dts({ tsconfigPath: resolve(__dirname, "tsconfig.app.json"), rollupTypes: true, }),
So, I didn't need to change the "Vite way" of organizing the tsconfig files.
Thanks for the fix, appreciate it! @willian @phuongthuan
Any updated on this? Some of these suggested config didn't work for me...
error during build:
[vite:dts] Internal Error: getResolvedModule() could not resolve module name "./stories/button/button.component"
/Users/luizfernandodemorais/Desktop/projetos/personal-projects/prolog-component-js/dist/index.d.ts:1:1
I'm using the same build command as mentioned by @mochizin "build": "tsc -b && vite build"
Describe the bug
I'm trying to use DTS with Vite for React 5.3.1 In this version Vite introduced tsconfig.app.json and reference it in tsconfig.json:
For some reason, the tsconfig.app.json is not being recognized by DTS. I get the following error:
Module './App.tsx' was resolved to 'libray-ui/src/App.tsx', but '--jsx' is not set.
The solution that I'm using is addEdit: This solution doesn't work properlytsconfigPath: "./tsconfig.app.json",
Is this a good solution?Reproduction
https://stackblitz.com/edit/vitejs-vite-yxnnz2?file=vite.config.ts
Steps to reproduce
Run:
npm create vite@latest
npm install @types/node
npm install --save-dev vite-plugin-dts
vite.config.ts
export default defineConfig({ plugins: [ react(), dts(), ], build: { lib: { entry: resolve(__dirname, "src/main.ts"), name: "trigger-ui", formats: ["es"], fileName: "trigger-ui", }, rollupOptions: { external: ["react", "react/jsx-runtime"], }, }, });
export const Card = ({ children, ...props }: CardTypes) => { return <button {...props}>{children}; };
type CardTypes = { children: string; } & React.ComponentPropsWithoutRef<"button">;
Validations