0👍
My question is a bit of a misnomer because while the error is emitted from running the scripts Vite build process, it’s vue-tsc that causes it.
My scripts section of package.json looks like this:
"dev": "vite",
"build": "run-p type-check build-only",
"watch": "vite build --watch",
"preview": "vite preview",
"build-only": "vite build --emptyOutDir",
"type-check": "vue-tsc --noEmit",
As part of the build process, vue-tsc (Vue’s ts compiler for SFCs) runs. It picks up everything, even files that are not used in the project. So just using the build-only
command runs the build and skips the type checking.
1👍
You’re looking for Vite’s build as library.
By default, the build includes the specified entries and the contents of public
folder.
Any module imported by the included entries can be excluded from build by declaring as external
1 (the import
is replaced with a require()
in the output). If not, they’ll be included (minified).
1 – a notable exception is when your lib has .jsx
or .tsx
exports, in which case Vite will include automatic JSX runtime. When exporting react components, it can be avoided using jsxRuntime: 'classic'
in react
plugin’s options. I’m guessing it’s the same for vue()
, but I’ve never used jsx in Vue.