This outputs types to a lib subfolder in dist. So you need to update your package.json to point to the correct type entry: "./dist/lib/main.d.ts" (or you could use rollupTypes: true)
I just found out that the issue with ajv was because I (unintentionally) had legacy-peer-deps=true in my global npm config on my other computer. I have updated the FAQs of this article with more details.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I created a new
tsconfig.build.jsonfile and extended tsconfig.app.json, seems to work fine:{"extends": "./tsconfig.app.json",
"include": ["lib"]
}
Also, with the new vite version with tsconfig.app.json, for building type definitions I had to add tsconfigPath:
dts({ include: ['lib'], rollupTypes: true, tsconfigPath: 'tsconfig.app.json' }),I would suggest this:
Do not include the
libfolder intsconfig.app.json, instead create atsconfig.lib.jsonlike so:Then add
tsconfig.lib.jsonto thereferencesarray in yourtsconfig.json.And set the build script to:
I made a branch with the latest vite version (5.4.4 at the time of writing): github.com/receter/my-component-li...
Here is a summary of what I had to change for the building the types:
update to vite-plugin-dts@4
add tsconfig path to dts config
This outputs types to a
libsubfolder in dist. So you need to update your package.json to point to the correct type entry: "./dist/lib/main.d.ts" (or you could use rollupTypes: true)Also I manually had to install
ajvbecause of an issue: stackoverflow.com/questions/787352...In this branch I also use the new package.json
exportsfeature and "self reference" the library in App.tsx.I will try to find time to update my article accordingly, but for now this branch might help you.
I just found out that the issue with
ajvwas because I (unintentionally) hadlegacy-peer-deps=truein my global npm config on my other computer. I have updated the FAQs of this article with more details.