diff --git a/src/resolvePath.js b/src/resolvePath.js index 1fde1a1..ed27c7e 100644 --- a/src/resolvePath.js +++ b/src/resolvePath.js @@ -97,7 +97,8 @@ function resolvePathFromAliasConfig(sourcePath, currentFile, opts) { const resolvers = [resolvePathFromAliasConfig, resolvePathFromRootConfig]; export default function resolvePath(sourcePath, currentFile, opts) { - if (isRelativePath(sourcePath)) { + // `.` and `./` are specific paths, we can't transfrom them + if (isRelativePath(sourcePath) || sourcePath === '.' || sourcePath === './') { return sourcePath; } diff --git a/test/index.test.js b/test/index.test.js index fedd977..c210a57 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -25,6 +25,15 @@ describe('module-resolver', () => { expect(result).toBe('./app'); }); + + it('should not change a single dot import', () => { + const opts = { + root: ['./test/testproject/src/components'], + }; + const result = resolvePath('.', './test/testproject/src/components/SideBar/Footer', opts); + + expect(result).toBe('.'); + }); }); });