-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Lib mode should export types #3461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@nihalgonsalves both workarounds doesn't work with .vue file. import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import ts2 from 'rollup-plugin-typescript2'
export default defineConfig({
plugins: [
vue(),
vueJsx(),
{
...ts2({
check: true,
tsconfig: path.resolve(__dirname, `tsconfig.json`), // your tsconfig.json path
tsconfigOverride: {
compilerOptions: {
sourceMap: false,
declaration: true,
declarationMap: false
},
}
}),
enforce: 'pre'
}
],
// ... other config
}) |
Its doesn't work bro :(. I tried and ... |
|
We decided that we don't want to support emitting declaration files, due to we would need to rely/depend on But it would not be an out-of-the-box solution. |
A direct dependency isn't required, since we can use resolve to find |
I made a plugin |
I was building a custom React component and wanted to:
Here's how I solved it: package.json {
"type": "module",
"files": [
"dist"
],
"types": "./dist/index.d.ts",
"main": "./dist/index.js",
"scripts": {
"dev": "vite",
"build": "tsup src/index.tsx --dts --legacy-output",
"serve": "vite preview"
},
} And then: npm run build
npm run build -- --watch TADA! 🎉 Few notes:
|
@vvo Did you try using the Vite plugin that @qmhc made?
|
@aleclarson I had a look at the plugin but saw that the options were related to Vue. Since I am writing a React application I stopped there. From the README:
|
@vvo My engilsh is not good, may be some vague in my description. I mean these files can including Now I am thinking about whether I need to make some special for react in the plugin, because I rarely use react in recent, I am uncertain. I would appreciate if you can take a try in your project and give me some feedback. |
I'm currently using it for publishing an npm package and it works flawlessly, kudos to @qmhc ... |
This issue has been locked since it has been closed for more than 14 days. If you have found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Vite version. If you have any other comments you should join the chat at Vite Land or create a new discussion. |
Clear and concise description of the problem
Previous issues: #2049, #2989
To provide a better experience for our users, lib mode should automatically generate TypeScript definitions, and not require additional setup.
Suggested solution
Alternative
Workarounds:
@keelii Lib mode doesn't export types #2989 (comment)
@Sanjade Lib mode doesn't export types #2989 (comment)
Additional context
The text was updated successfully, but these errors were encountered: