@@ -5,6 +5,7 @@ export interface PackageInfo {
5
5
packageName : string ;
6
6
entryPoint : string ;
7
7
version : string ;
8
+ esm : boolean ;
8
9
}
9
10
10
11
export interface PartialPackageJson {
@@ -33,6 +34,7 @@ export function getPackageInfo(
33
34
const mainPkgJson = readJson ( mainPkgJsonPath ) ;
34
35
35
36
const version = mainPkgJson [ 'version' ] as string ;
37
+ const esm = mainPkgJson [ 'type' ] === 'module' ;
36
38
37
39
if ( ! version ) {
38
40
// TODO: Add logger
@@ -49,12 +51,23 @@ export function getPackageInfo(
49
51
relSecondaryPath = './' + relSecondaryPath . replace ( / \\ / g, '/' ) ;
50
52
}
51
53
52
- let cand = mainPkgJson ?. exports ?. [ relSecondaryPath ] ?. default ;
54
+ let cand = mainPkgJson ?. exports ?. [ relSecondaryPath ] ?. import ;
53
55
if ( cand ) {
54
56
return {
55
57
entryPoint : path . join ( mainPkgPath , cand ) ,
56
58
packageName,
57
59
version,
60
+ esm
61
+ } ;
62
+ }
63
+
64
+ cand = mainPkgJson ?. exports ?. [ relSecondaryPath ] ?. default ;
65
+ if ( cand ) {
66
+ return {
67
+ entryPoint : path . join ( mainPkgPath , cand ) ,
68
+ packageName,
69
+ version,
70
+ esm
58
71
} ;
59
72
}
60
73
@@ -65,6 +78,7 @@ export function getPackageInfo(
65
78
entryPoint : path . join ( mainPkgPath , cand ) ,
66
79
packageName,
67
80
version,
81
+ esm : true
68
82
} ;
69
83
}
70
84
@@ -80,6 +94,7 @@ export function getPackageInfo(
80
94
entryPoint : path . join ( secondaryPgkPath , secondaryPgkJson . module ) ,
81
95
packageName,
82
96
version,
97
+ esm : true
83
98
} ;
84
99
}
85
100
@@ -89,6 +104,7 @@ export function getPackageInfo(
89
104
entryPoint : cand ,
90
105
packageName,
91
106
version,
107
+ esm : true
92
108
} ;
93
109
}
94
110
@@ -97,6 +113,7 @@ export function getPackageInfo(
97
113
entryPoint : path . join ( secondaryPgkPath , secondaryPgkJson . main ) ,
98
114
packageName,
99
115
version,
116
+ esm
100
117
} ;
101
118
}
102
119
@@ -106,11 +123,12 @@ export function getPackageInfo(
106
123
entryPoint : cand ,
107
124
packageName,
108
125
version,
126
+ esm
109
127
} ;
110
128
}
111
129
112
130
// TODO: Add logger
113
- console . warn ( 'No esm-based entry point found for ' + packageName ) ;
131
+ console . warn ( 'No entry point found for ' + packageName ) ;
114
132
console . warn (
115
133
' >> Did you confuse dependencies with depDependencies in your package.json or your federation config?'
116
134
) ;
0 commit comments