@@ -144,15 +144,18 @@ function emitDemo(
144
144
const { demos } = ret . meta ;
145
145
const shareDepsMap : Record < string , string > = { } ;
146
146
const demoDepsMap : Record < string , Record < string , string > > = { } ;
147
+ const relativeDepsMap : Record < string , Record < string , string > > = { } ;
147
148
148
149
demos ?. forEach ( ( demo ) => {
149
150
if ( 'resolveMap' in demo && 'asset' in demo ) {
150
151
const entryFileName = Object . keys ( demo . asset . dependencies ) [ 0 ] ;
151
152
demoDepsMap [ demo . id ] ??= { } ;
153
+ relativeDepsMap [ demo . id ] ??= { } ;
152
154
Object . keys ( demo . resolveMap ) . forEach ( ( key , index ) => {
153
155
const specifier = `${ demo . id . replace ( / [ ^ \w \d ] / g, '_' ) } _deps_${ index } ` ;
154
156
if ( key !== entryFileName ) {
155
- const normalizedKey = isRelativePath ( key )
157
+ const isRelative = isRelativePath ( key ) ;
158
+ const normalizedKey = isRelative
156
159
? winPath ( demo . resolveMap [ key ] )
157
160
: key ;
158
161
@@ -162,6 +165,12 @@ function emitDemo(
162
165
} else {
163
166
demoDepsMap [ demo . id ] [ normalizedKey ] = shareDepsMap [ normalizedKey ] ;
164
167
}
168
+
169
+ if ( isRelative ) {
170
+ relativeDepsMap [ demo . id ] [ key ] = `{{{${
171
+ shareDepsMap [ normalizedKey ] || specifier
172
+ } }}}`;
173
+ }
165
174
}
166
175
} ) ;
167
176
}
@@ -244,7 +253,7 @@ export const demos = {
244
253
...acc ,
245
254
...{ [ key ] : `{{{${ specifier } }}}` } ,
246
255
} ) ,
247
- { } ,
256
+ relativeDepsMap [ this . id ] ,
248
257
) ;
249
258
return JSON . stringify ( context , null , 2 ) . replace ( / " { { { | } } } " / g, '' ) ;
250
259
} ,
0 commit comments