@@ -40,6 +40,7 @@ const { sep, relative, resolve } = require('path');
40
40
const preserveSymlinks = getOptionValue ( '--preserve-symlinks' ) ;
41
41
const preserveSymlinksMain = getOptionValue ( '--preserve-symlinks-main' ) ;
42
42
const typeFlag = getOptionValue ( '--input-type' ) ;
43
+ const pendingDeprecation = getOptionValue ( '--pending-deprecation' ) ;
43
44
const { URL , pathToFileURL, fileURLToPath } = require ( 'internal/url' ) ;
44
45
const {
45
46
ERR_INPUT_TYPE_NOT_ALLOWED ,
@@ -106,6 +107,22 @@ function emitFolderMapDeprecation(match, pjsonUrl, isExports, base) {
106
107
) ;
107
108
}
108
109
110
+ function emitTrailingSlashPatternDeprecation ( match , pjsonUrl , isExports , base ) {
111
+ if ( ! pendingDeprecation ) return ;
112
+ const pjsonPath = fileURLToPath ( pjsonUrl ) ;
113
+ if ( emittedPackageWarnings . has ( pjsonPath + '|' + match ) )
114
+ return ;
115
+ emittedPackageWarnings . add ( pjsonPath + '|' + match ) ;
116
+ process . emitWarning (
117
+ `Use of deprecated trailing slash pattern mapping "${ match } " in the ${
118
+ isExports ? '"exports"' : '"imports"' } field module resolution of the ` +
119
+ `package at ${ pjsonPath } ${ base ? ` imported from ${ fileURLToPath ( base ) } ` :
120
+ '' } . Mapping specifiers ending in "/" is no longer supported.`,
121
+ 'DeprecationWarning' ,
122
+ 'DEP0155'
123
+ ) ;
124
+ }
125
+
109
126
/**
110
127
* @param {URL } url
111
128
* @param {URL } packageJSONUrl
@@ -639,6 +656,9 @@ function packageExportsResolve(
639
656
if ( patternIndex !== - 1 &&
640
657
StringPrototypeStartsWith ( packageSubpath ,
641
658
StringPrototypeSlice ( key , 0 , patternIndex ) ) ) {
659
+ if ( StringPrototypeEndsWith ( packageSubpath , '/' ) )
660
+ emitTrailingSlashPatternDeprecation ( packageSubpath , packageJSONUrl ,
661
+ true , base ) ;
642
662
const patternTrailer = StringPrototypeSlice ( key , patternIndex + 1 ) ;
643
663
if ( packageSubpath . length >= key . length &&
644
664
StringPrototypeEndsWith ( packageSubpath , patternTrailer ) &&
0 commit comments