1
1
import es from 'estree'
2
- import * as path from 'path'
2
+ import * as posixPath from 'path/posix '
3
3
4
4
import { CannotFindModuleError , CircularImportError } from '../errors/localImportErrors'
5
5
import { parse } from '../parser/parser'
@@ -39,11 +39,11 @@ export const getImportedLocalModulePaths = (
39
39
program : es . Program ,
40
40
currentFilePath : string
41
41
) : Set < string > => {
42
- if ( ! path . isAbsolute ( currentFilePath ) ) {
42
+ if ( ! posixPath . isAbsolute ( currentFilePath ) ) {
43
43
throw new Error ( `Current file path '${ currentFilePath } ' is not absolute.` )
44
44
}
45
45
46
- const baseFilePath = path . resolve ( currentFilePath , '..' )
46
+ const baseFilePath = posixPath . resolve ( currentFilePath , '..' )
47
47
const importedLocalModuleNames : Set < string > = new Set ( )
48
48
const importDeclarations = program . body . filter ( isImportDeclaration )
49
49
importDeclarations . forEach ( ( importDeclaration : es . ImportDeclaration ) : void => {
@@ -52,7 +52,7 @@ export const getImportedLocalModulePaths = (
52
52
throw new Error ( 'Module names must be strings.' )
53
53
}
54
54
if ( ! isSourceModule ( modulePath ) ) {
55
- const absoluteModulePath = path . resolve ( baseFilePath , modulePath )
55
+ const absoluteModulePath = posixPath . resolve ( baseFilePath , modulePath )
56
56
importedLocalModuleNames . add ( absoluteModulePath )
57
57
}
58
58
} )
@@ -192,7 +192,7 @@ const preprocessFileImports = (
192
192
// We want to operate on the entrypoint program to get the eventual
193
193
// preprocessed program.
194
194
const entrypointProgram = programs [ entrypointFilePath ]
195
- const entrypointDirPath = path . resolve ( entrypointFilePath , '..' )
195
+ const entrypointDirPath = posixPath . resolve ( entrypointFilePath , '..' )
196
196
197
197
// Create variables to hold the imported statements.
198
198
const entrypointProgramModuleDeclarations = entrypointProgram . body . filter ( isModuleDeclaration )
0 commit comments