@@ -134,10 +134,23 @@ export function determineModuleContext(
134134 packageNameCache . set ( pkgDir , pkgName ) ;
135135 }
136136 // Compute module-relative path
137- const relPath = normalizeModulePath ( path . relative ( pkgDir , originalPath ) ) ;
137+ const relPath = path . relative ( pkgDir , originalPath ) ;
138138 return { packageName : pkgName , relativePath : relPath } ;
139139}
140140
141+ /**
142+ * Traverse the filesystem upward to find a name for the package that which contains a file.
143+ * This variant normalizes the module path.
144+ */
145+ export function determineNormalizedModuleContext (
146+ modulePath : string ,
147+ originalPath = modulePath
148+ ) : ModuleContext {
149+ const { packageName, relativePath } = determineModuleContext ( modulePath , originalPath ) ;
150+ const relPath = normalizeModulePath ( relativePath ) ;
151+ return { packageName, relativePath : relPath } ;
152+ }
153+
141154export function normalizeModulePath ( modulePath : string ) {
142155 const dirname = path . normalize ( path . dirname ( modulePath ) ) ;
143156 const basename = path . basename ( modulePath ) ;
@@ -154,7 +167,7 @@ export function escapePath(modulePath: string) {
154167 * Get the name of the library which will be used when the module is linked in.
155168 */
156169export function getLibraryName ( modulePath : string , naming : NamingStrategy ) {
157- const { packageName, relativePath } = determineModuleContext ( modulePath ) ;
170+ const { packageName, relativePath } = determineNormalizedModuleContext ( modulePath ) ;
158171 return naming . stripPathSuffix
159172 ? packageName
160173 : `${ packageName } --${ escapePath ( relativePath ) } ` ;
0 commit comments