@@ -2,7 +2,7 @@ import path from 'path';
22import resolve from 'resolve' ;
33import glob from 'glob' ;
44import mapToRelative from './mapToRelative' ;
5- import { toLocalPath } from './utils' ;
5+ import { toLocalPath , toPosixPath } from './utils' ;
66
77function createAliasFileMap ( pluginOpts ) {
88 const alias = pluginOpts . alias || { } ;
@@ -32,12 +32,12 @@ export function mapModule(source, file, pluginOpts) {
3232 try {
3333 // check if the file exists (will throw if not)
3434 const extensions = pluginOpts . extensions || defaultBabelExtensions ;
35- const fileAbsPath = resolve . sync ( `./${ source } ` , { basedir : path . resolve ( rootDirs [ i ] ) , extensions } ) ;
36- const realFileExt = path . extname ( fileAbsPath ) ;
37- const sourceFileExt = path . extname ( source ) ;
35+ const resolvedSourceFile = resolve . sync ( `./${ source } ` , { basedir : path . resolve ( rootDirs [ i ] ) , extensions } ) ;
36+ const realSourceFileExtension = path . extname ( resolvedSourceFile ) ;
37+ const sourceFileExtension = path . extname ( source ) ;
3838 // map the source and keep its extension if the import/require had one
39- const ext = realFileExt === sourceFileExt ? realFileExt : '' ;
40- return toLocalPath ( replaceExt ( mapToRelative ( file , fileAbsPath ) , ext ) ) ;
39+ const ext = realSourceFileExtension === sourceFileExtension ? realSourceFileExtension : '' ;
40+ return toLocalPath ( toPosixPath ( replaceExt ( mapToRelative ( file , resolvedSourceFile ) , ext ) ) ) ;
4141 } catch ( e ) {
4242 // empty...
4343 }
@@ -71,7 +71,7 @@ export function mapModule(source, file, pluginOpts) {
7171 return newPath ;
7272 }
7373 // relative alias
74- return toLocalPath ( mapToRelative ( file , newPath ) ) ;
74+ return toLocalPath ( toPosixPath ( mapToRelative ( file , newPath ) ) ) ;
7575}
7676
7777
0 commit comments