@@ -75,6 +75,7 @@ const UseFilePlugin = require("./UseFilePlugin");
75
75
* @property {(string|RegExp)[]= } restrictions A list of resolve restrictions
76
76
* @property {boolean= } useSyncFileSystemCalls Use only the sync constiants of the file system calls
77
77
* @property {boolean= } preferRelative Prefer to resolve module requests as relative requests before falling back to modules
78
+ * @property {boolean= } preferAbsolute Prefer to resolve server-relative urls as absolute paths before falling back to resolve in roots
78
79
*/
79
80
80
81
/**
@@ -104,6 +105,7 @@ const UseFilePlugin = require("./UseFilePlugin");
104
105
* @property {boolean } resolveToContext
105
106
* @property {Set<string|RegExp> } restrictions
106
107
* @property {boolean } preferRelative
108
+ * @property {boolean } preferAbsolute
107
109
*/
108
110
109
111
/**
@@ -113,7 +115,7 @@ const UseFilePlugin = require("./UseFilePlugin");
113
115
function processPnpApiOption ( option ) {
114
116
if (
115
117
option === undefined &&
116
- /** @type {NodeJS.ProcessVersions & {pnp: string} } */ ( versions ) . pnp
118
+ /** @type {NodeJS.ProcessVersions & {pnp: string} } */ versions . pnp
117
119
) {
118
120
// @ts -ignore
119
121
return require ( "pnpapi" ) ; // eslint-disable-line node/no-missing-require
@@ -222,6 +224,7 @@ function createOptions(options) {
222
224
fullySpecified : options . fullySpecified || false ,
223
225
resolveToContext : options . resolveToContext || false ,
224
226
preferRelative : options . preferRelative || false ,
227
+ preferAbsolute : options . preferAbsolute || false ,
225
228
restrictions : new Set ( options . restrictions )
226
229
} ;
227
230
}
@@ -254,6 +257,7 @@ exports.createResolver = function (options) {
254
257
pnpApi,
255
258
resolveToContext,
256
259
preferRelative,
260
+ preferAbsolute,
257
261
symlinks,
258
262
unsafeCache,
259
263
resolver : customResolver ,
@@ -364,10 +368,13 @@ exports.createResolver = function (options) {
364
368
"internal"
365
369
)
366
370
) ;
371
+ if ( preferAbsolute ) {
372
+ plugins . push ( new JoinRequestPlugin ( "after-normal-resolve" , "relative" ) ) ;
373
+ }
367
374
if ( roots . size > 0 ) {
368
375
plugins . push ( new RootsPlugin ( "after-normal-resolve" , roots , "relative" ) ) ;
369
376
}
370
- if ( ! preferRelative ) {
377
+ if ( ! preferRelative && ! preferAbsolute ) {
371
378
plugins . push ( new JoinRequestPlugin ( "after-normal-resolve" , "relative" ) ) ;
372
379
}
373
380
0 commit comments