From ed0a15ea3611dc88afa13ce5073a0f0a6c95e276 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Wed, 10 Apr 2024 09:39:57 +0300 Subject: [PATCH] Update index.js --- index.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 8e09f79..3c01192 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,6 @@ const fs = require('fs'); const path = require('path'); const { debuglog } = require('util'); const appModulePath = require('app-module-path'); -const isRelative = require('is-relative-path'); const sassLookup = require('sass-lookup'); const stylusLookup = require('stylus-lookup'); const { createMatchPath } = require('tsconfig-paths'); @@ -479,7 +478,7 @@ function resolveWebpackPath({ dependency, filename, directory, webpackConfig }) // we only wnat the path of the resolved file dependency = stripLoader(dependency); - const lookupPath = isRelative(dependency) ? + const lookupPath = isRelativePath(dependency) ? path.dirname(filename) : directory; @@ -499,3 +498,15 @@ function stripLoader(dependency) { return dependency.slice(exclamationLocation + 1); } + +/** + * @param {String} filename + * @return {Boolean} + */ +function isRelativePath(filename) { + if (typeof filename !== 'string') { + throw new TypeError(`Path must be a string. Received ${filename}`); + } + + return filename[0] === '.'; +};