@@ -118,10 +118,23 @@ export function determineModuleContext(
118118 packageNameCache . set ( pkgDir , pkgName ) ;
119119 }
120120 // Compute module-relative path
121- const relPath = normalizeModulePath ( path . relative ( pkgDir , originalPath ) ) ;
121+ const relPath = path . relative ( pkgDir , originalPath ) ;
122122 return { packageName : pkgName , relativePath : relPath } ;
123123}
124124
125+ /**
126+ * Traverse the filesystem upward to find a name for the package that which contains a file.
127+ * This variant normalizes the module path.
128+ */
129+ export function determineNormalizedModuleContext (
130+ modulePath : string ,
131+ originalPath = modulePath
132+ ) : ModuleContext {
133+ const { packageName, relativePath } = determineModuleContext ( modulePath , originalPath ) ;
134+ const relPath = normalizeModulePath ( relativePath ) ;
135+ return { packageName, relativePath : relPath } ;
136+ }
137+
125138export function normalizeModulePath ( modulePath : string ) {
126139 const dirname = path . normalize ( path . dirname ( modulePath ) ) ;
127140 const basename = path . basename ( modulePath ) ;
@@ -137,7 +150,7 @@ export function escapePath(modulePath: string) {
137150 * Get the name of the library which will be used when the module is linked in.
138151 */
139152export function getLibraryName ( modulePath : string , naming : NamingStrategy ) {
140- const { packageName, relativePath } = determineModuleContext ( modulePath ) ;
153+ const { packageName, relativePath } = determineNormalizedModuleContext ( modulePath ) ;
141154 return naming . stripPathSuffix
142155 ? packageName
143156 : `${ packageName } --${ escapePath ( relativePath ) } ` ;
0 commit comments