@@ -19,6 +19,11 @@ import { getConfigContext } from './configuration-context';
19
19
import { logger } from '../utils/logger' ;
20
20
import { resolveGlobSync } from '../utils/resolve-glob' ;
21
21
22
+ import {
23
+ KeyValuePair ,
24
+ resolveWildcardKeys ,
25
+ } from '../utils/resolve-wildcard-keys' ;
26
+
22
27
let inferVersion = false ;
23
28
24
29
export const DEFAULT_SECONARIES_SKIP_LIST = [
@@ -195,6 +200,10 @@ function readConfiguredSecondaries(
195
200
}
196
201
197
202
const packageJson = JSON . parse ( fs . readFileSync ( libPackageJson , 'utf-8' ) ) ;
203
+
204
+ const version = packageJson [ 'version' ] as string ;
205
+ const esm = packageJson [ 'type' ] === 'module' ;
206
+
198
207
const exports = packageJson [ 'exports' ] as Record <
199
208
string ,
200
209
Record < string , string >
@@ -242,12 +251,29 @@ function readConfiguredSecondaries(
242
251
continue ;
243
252
}
244
253
245
- const items = resolveSecondaries ( key , libPath , parent , secondaryName ) ;
254
+ const items = resolveSecondaries (
255
+ key ,
256
+ libPath ,
257
+ parent ,
258
+ secondaryName ,
259
+ entry
260
+ ) ;
246
261
247
262
for ( const item of items ) {
248
- result [ item ] = {
249
- ...shareObject ,
250
- } ;
263
+ if ( typeof item === 'object' ) {
264
+ result [ item . key ] = {
265
+ ...shareObject ,
266
+ packageInfo : {
267
+ entryPoint : item . value ,
268
+ version : shareObject . version ?? version ,
269
+ esm
270
+ } ,
271
+ } ;
272
+ } else {
273
+ result [ item ] = {
274
+ ...shareObject ,
275
+ } ;
276
+ }
251
277
}
252
278
}
253
279
@@ -258,13 +284,16 @@ function resolveSecondaries(
258
284
key : string ,
259
285
libPath : string ,
260
286
parent : string ,
261
- secondaryName : string
262
- ) {
263
- let items = [ ] ;
287
+ secondaryName : string ,
288
+ entry : string
289
+ ) : Array < string | KeyValuePair > {
290
+ let items : Array < string | KeyValuePair > = [ ] ;
264
291
if ( key . includes ( '*' ) ) {
265
- items = resolveGlobSync ( key , libPath ) . map ( ( e ) =>
266
- path . join ( parent , e . substring ( libPath . length ) )
267
- ) ;
292
+ const expanded = resolveWildcardKeys ( key , entry , libPath ) ;
293
+ items = expanded . map ( ( e ) => ( {
294
+ key : path . join ( parent , e . key ) ,
295
+ value : path . join ( libPath , e . value ) ,
296
+ } ) ) ;
268
297
} else {
269
298
items = [ secondaryName ] ;
270
299
}
0 commit comments