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: {
227227 return { } ;
228228 }
229229
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+
230236 const externalOptions = {
231237 dependencies : true ,
238+ optionalDependencies : true ,
232239 peerDependencies : true ,
233240 devDependencies : false ,
234241 ...( autoExternal === true ? { } : autoExternal ) ,
235242 } ;
236243
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-
243244 const externals = (
244- [ 'dependencies' , 'peerDependencies' , 'devDependencies' ] as const
245+ [
246+ 'dependencies' ,
247+ 'peerDependencies' ,
248+ 'devDependencies' ,
249+ 'optionalDependencies' ,
250+ ] as const
245251 )
246252 . reduce < string [ ] > ( ( prev , type ) => {
247253 if ( externalOptions [ type ] ) {
Original file line number Diff line number Diff line change 11export type PkgJson = {
2+ type ?: 'module' | 'commonjs' ;
23 dependencies ?: Record < string , string > ;
34 peerDependencies ?: Record < string , string > ;
45 devDependencies ?: Record < string , string > ;
5- [ key : string ] : unknown ;
6+ optionalDependencies ?: Record < string , string > ;
67} ;
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ export const calcBundledPackages = (options: {
2626 dependencies ?: Record < string , string > ;
2727 peerDependencies ?: Record < string , string > ;
2828 devDependencies ?: Record < string , string > ;
29+ optionalDependencies ?: Record < string , string > ;
2930 } ;
3031
3132 try {
@@ -42,6 +43,7 @@ export const calcBundledPackages = (options: {
4243 ? {
4344 dependencies : true ,
4445 peerDependencies : true ,
46+ optionalDependencies : true ,
4547 devDependencies : false ,
4648 ...( autoExternal === true ? { } : autoExternal ) ,
4749 }
You can’t perform that action at this time.
0 commit comments