Commit e4f147e 1 parent e018681 commit e4f147e Copy full SHA for e4f147e
File tree 2 files changed +15
-7
lines changed
2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -67,22 +67,29 @@ class DependencyExtractionWebpackPlugin {
67
67
if ( typeof this . options . requestToExternalModule === 'function' ) {
68
68
externalRequest =
69
69
this . options . requestToExternalModule ( request ) ;
70
+
71
+ // requestToExternalModule allows a boolean shorthand
72
+ if ( externalRequest === false ) {
73
+ externalRequest = undefined ;
74
+ }
75
+ if ( externalRequest === true ) {
76
+ externalRequest = request ;
77
+ }
70
78
}
71
79
} else if ( typeof this . options . requestToExternal === 'function' ) {
72
80
externalRequest = this . options . requestToExternal ( request ) ;
73
81
}
74
82
75
83
// Cascade to default if unhandled and enabled.
76
- if ( ! externalRequest && this . options . useDefaults ) {
84
+ if (
85
+ typeof externalRequest === 'undefined' &&
86
+ this . options . useDefaults
87
+ ) {
77
88
externalRequest = this . useModules
78
89
? defaultRequestToExternalModule ( request )
79
90
: defaultRequestToExternal ( request ) ;
80
91
}
81
92
82
- if ( this . useModules && externalRequest === true ) {
83
- externalRequest = request ;
84
- }
85
-
86
93
if ( externalRequest instanceof Error ) {
87
94
return callback ( externalRequest ) ;
88
95
}
Original file line number Diff line number Diff line change @@ -61,10 +61,11 @@ function defaultRequestToExternal( request ) {
61
61
*
62
62
* Currently only @wordpress/interactivity
63
63
*
64
+ * Do not use the boolean shorthand here, it's only handled for the `requestToExternalModule` option.
65
+ *
64
66
* @param {string } request Module request (the module name in `import from`) to be transformed
65
- * @return {string|boolean| Error|undefined } The resulting external definition.
67
+ * @return {string|Error|undefined } The resulting external definition.
66
68
* - Return `undefined` to ignore the request (do not externalize).
67
- * - Return `true` to externalize the request with the same Module ID
68
69
* - Return `string` to map the request to an external.
69
70
* - Return `Error` to emit an error.
70
71
*/
You can’t perform that action at this time.
0 commit comments