File tree Expand file tree Collapse file tree 3 files changed +17
-8
lines changed Expand file tree Collapse file tree 3 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -227,21 +227,27 @@ export const composeAutoExternalConfig = (options: {
227
227
return { } ;
228
228
}
229
229
230
+ // User externals configuration has higher priority than autoExternal
231
+ // eg: autoExternal: ['react'], user: output: { externals: { react: 'react-1' } }
232
+ // Only handle the case where the externals type is object, string / string[] does not need to be processed, other types are too complex.
233
+ const userExternalKeys =
234
+ userExternals && isObject ( userExternals ) ? Object . keys ( userExternals ) : [ ] ;
235
+
230
236
const externalOptions = {
231
237
dependencies : true ,
238
+ optionalDependencies : true ,
232
239
peerDependencies : true ,
233
240
devDependencies : false ,
234
241
...( autoExternal === true ? { } : autoExternal ) ,
235
242
} ;
236
243
237
- // User externals configuration has higher priority than autoExternal
238
- // eg: autoExternal: ['react'], user: output: { externals: { react: 'react-1' } }
239
- // Only handle the case where the externals type is object, string / string[] does not need to be processed, other types are too complex.
240
- const userExternalKeys =
241
- userExternals && isObject ( userExternals ) ? Object . keys ( userExternals ) : [ ] ;
242
-
243
244
const externals = (
244
- [ 'dependencies' , 'peerDependencies' , 'devDependencies' ] as const
245
+ [
246
+ 'dependencies' ,
247
+ 'peerDependencies' ,
248
+ 'devDependencies' ,
249
+ 'optionalDependencies' ,
250
+ ] as const
245
251
)
246
252
. reduce < string [ ] > ( ( prev , type ) => {
247
253
if ( externalOptions [ type ] ) {
Original file line number Diff line number Diff line change 1
1
export type PkgJson = {
2
+ type ?: 'module' | 'commonjs' ;
2
3
dependencies ?: Record < string , string > ;
3
4
peerDependencies ?: Record < string , string > ;
4
5
devDependencies ?: Record < string , string > ;
5
- [ key : string ] : unknown ;
6
+ optionalDependencies ?: Record < string , string > ;
6
7
} ;
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ export const calcBundledPackages = (options: {
26
26
dependencies ?: Record < string , string > ;
27
27
peerDependencies ?: Record < string , string > ;
28
28
devDependencies ?: Record < string , string > ;
29
+ optionalDependencies ?: Record < string , string > ;
29
30
} ;
30
31
31
32
try {
@@ -42,6 +43,7 @@ export const calcBundledPackages = (options: {
42
43
? {
43
44
dependencies : true ,
44
45
peerDependencies : true ,
46
+ optionalDependencies : true ,
45
47
devDependencies : false ,
46
48
...( autoExternal === true ? { } : autoExternal ) ,
47
49
}
You can’t perform that action at this time.
0 commit comments