11'use strict' ;
22
33const getPackages = require ( 'get-monorepo-packages' ) ;
4- const { dirname, relative, sep, resolve , isAbsolute } = require ( 'path' ) ;
4+ const { dirname, join , relative, sep, normalize , isAbsolute } = require ( 'path' ) ;
55
66const isSubPath = ( parent , path ) => {
77 const relativePath = relative ( parent , path ) ;
@@ -23,7 +23,7 @@ const packages = getPackages(process.cwd()).map(
2323const resolvePath = ( parent , path ) => {
2424 if ( path [ 0 ] !== '.' ) return path ;
2525
26- return resolve ( parent , path ) ;
26+ return join ( parent , path ) . replace ( / \\ / g , '/' ) ;
2727} ;
2828
2929const resolveImport = ( context , node , { value, range } , currentPackage ) => {
@@ -35,9 +35,11 @@ const resolveImport = (context, node, { value, range }, currentPackage) => {
3535const pathToImport = path => {
3636 if ( path === '' ) return '.' ;
3737
38- if ( path [ 0 ] !== '.' ) return `./ ${ path } ` ;
38+ const normalized = normalize ( path ) . replace ( / \\ / g , '/' ) ;
3939
40- return path ;
40+ if ( normalized [ 0 ] !== '.' ) return `./${ normalized } ` ;
41+
42+ return normalized ;
4143} ;
4244
4345const findCurrentPackage = context =>
0 commit comments