File tree Expand file tree Collapse file tree 4 files changed +39
-6
lines changed Expand file tree Collapse file tree 4 files changed +39
-6
lines changed Original file line number Diff line number Diff line change 11import dts from 'rollup-plugin-dts'
22
3+ // Bundle the generated declaration entry into a single dist/index.d.ts.
4+ // Treat workspace deps as external so we don't try to resolve them during
5+ // bundling (the consumer will have their own types for those packages).
36export default [
47 {
8+ // Vite emits declarations under dist/types
59 input : './dist/types/exports.d.ts' ,
6- plugins : [ dts ( ) ] ,
10+ plugins : [
11+ dts ( {
12+ // Leave external type imports in place
13+ respectExternal : true ,
14+ } ) ,
15+ ] ,
16+ external : [
17+ / ^ (?: s t r e a m - m a r k d o w n - p a r s e r ) (?: \/ .* ) ? $ / ,
18+ ] ,
719 output : [
820 {
921 file : 'dist/index.d.ts' ,
Original file line number Diff line number Diff line change @@ -3,3 +3,14 @@ declare module '*.vue' {
33 const component : ReturnType < typeof defineComponent >
44 export default component
55}
6+
7+ // Vite asset imports used in this project
8+ declare module '*.svg?raw' {
9+ const src : string
10+ export default src
11+ }
12+
13+ declare module '*.svg?url' {
14+ const src : string
15+ export default src
16+ }
Original file line number Diff line number Diff line change 55 "lib" : [" DOM" , " ESNext" ],
66 "module" : " ESNext" ,
77 "moduleResolution" : " node" ,
8+ "types" : [" vite/client" ],
89 "resolveJsonModule" : true ,
910 "declaration" : true ,
1011 "emitDeclarationOnly" : true ,
Original file line number Diff line number Diff line change @@ -26,6 +26,10 @@ export default defineConfig(({ mode }) => {
2626 Vue ( ) ,
2727 dts ( {
2828 outDir : 'dist/types' ,
29+ // Use a build-only tsconfig without path aliases to avoid rewriting
30+ // imports like "stream-markdown-parser" into relative workspace paths
31+ // in the emitted .d.ts (which breaks type bundling).
32+ tsconfigPath : './tsconfig.build.json' ,
2933 } ) ,
3034 UnpluginClassExtractor ( {
3135 output : 'dist/tailwind.ts' ,
@@ -111,6 +115,15 @@ export default defineConfig(({ mode }) => {
111115 }
112116 }
113117
118+ // Alias resolution: during dev/test, point workspace dep to source to avoid needing its dist build
119+ const alias : Record < string , string > = {
120+ '@' : '/src' ,
121+ }
122+ if ( mode !== 'npm' ) {
123+ alias [ 'stream-markdown-parser' ] = '/packages/markdown-parser/src/index.ts'
124+ alias [ 'stream-markdown-parser/*' ] = '/packages/markdown-parser/src/*'
125+ }
126+
114127 return {
115128 base,
116129 plugins,
@@ -137,10 +150,6 @@ export default defineConfig(({ mode }) => {
137150 css : {
138151 postcss : './postcss.config.cjs' ,
139152 } ,
140- resolve : {
141- alias : {
142- '@' : '/src' ,
143- } ,
144- } ,
153+ resolve : { alias } ,
145154 }
146155} )
You can’t perform that action at this time.
0 commit comments