Repository navigation
|
Can tsdown just copy This approch usually used in Vue UI components package, make This was done by a bundler( I tried the Unbundle Mode, but it only promised the source module structure, still compiled/bundled the vue files into js files. |
Replies: 4 comments 1 reply
|
For source-distributed SFCs, copy them separately instead of making them transformed entries: export default defineConfig({
entry: ['src/index.ts'],
dts: { vue: true },
copy: {
from: 'src/**/*.vue',
to: 'dist',
flatten: false,
},
})
|
|
Right— import { defineConfig } from 'tsdown'
import Vue from 'unplugin-vue/rolldown'
export default defineConfig({
entry: ['src/index.ts', 'src/**/*.vue'],
platform: 'neutral',
plugins: [Vue({ isProduction: true })],
dts: { vue: true },
copy: [{ from: 'src/**/*.vue', to: 'dist', flatten: false }],
})pnpm add -D unplugin-vue vue-tsc
|
|
Yes, but not with import { defineConfig } from 'tsdown'
export default defineConfig([
{
// JS + .d.ts for the TS files; `.vue` imports stay as they are
entry: ['src/**/*.ts'],
unbundle: true,
platform: 'neutral',
deps: { neverBundle: [/\.vue$/] },
dts: { vue: true },
copy: [{ from: 'src/**/*.vue', to: 'dist', flatten: false }],
},
{
// declarations only, one X.vue.d.ts per SFC
entry: { '*.vue': 'src/**/*.vue' },
platform: 'neutral',
dts: { vue: true, emitDtsOnly: true },
},
])My test source had Why each piece is there:
About the config in the previous reply: it compiles the SFCs to Who needs the
So the declarations matter for consumers who type-check with plain "./components/*.vue": {
"types": "./dist/components/*.vue.d.ts",
"default": "./dist/components/*.vue"
}Tested with tsdown 0.23.0, rolldown 1.2.8, rolldown-plugin-dts 0.28.5, vue 3.5.42, vue-tsc 3.3.11, TypeScript 5.9.3 and Node 24.13.0 on Windows 11. unplugin-vue 7.2.0 was only used in the variants that failed. I did not test watch mode, TypeScript 7 or tsgo, or older tsdown versions. I also did not bundle the shipped |
|
You're right, and thanks for testing the complete package-consumer path. My previous The two-config approach is the correct one here: copy the raw SFCs in the TS/unbundle build, then use the keyed I withdraw the earlier configuration; your answer addresses the original requirement more accurately. |
Yes, but not with
unplugin-vue. Use two configs: one builds the TS files and leaves the.vueimports alone, and the other only emits declarations for each SFC.My test source had
s…