diff --git a/packages/metro-resolver/package.json b/packages/metro-resolver/package.json index 7f90b1ab35..b1aff73ce3 100644 --- a/packages/metro-resolver/package.json +++ b/packages/metro-resolver/package.json @@ -12,7 +12,6 @@ "cleanup-release": "test ! -e build && mv src build && mv src.real src" }, "dependencies": { - "absolute-path": "^0.0.0", "invariant": "^2.2.4" }, "license": "MIT", diff --git a/packages/metro-resolver/src/resolve.js b/packages/metro-resolver/src/resolve.js index 11333079f7..ce2be4dc62 100644 --- a/packages/metro-resolver/src/resolve.js +++ b/packages/metro-resolver/src/resolve.js @@ -19,7 +19,6 @@ import type { Result, } from './types'; -import isAbsolutePath from 'absolute-path'; import path from 'path'; import FailedToResolveNameError from './errors/FailedToResolveNameError'; import FailedToResolvePathError from './errors/FailedToResolvePathError'; @@ -51,7 +50,7 @@ function resolve( ); } - if (isRelativeImport(moduleName) || isAbsolutePath(moduleName)) { + if (isRelativeImport(moduleName) || path.isAbsolute(moduleName)) { return resolveModulePath(context, moduleName, platform); } @@ -65,7 +64,7 @@ function resolve( const {originModulePath} = context; const isDirectImport = - isRelativeImport(realModuleName) || isAbsolutePath(realModuleName); + isRelativeImport(realModuleName) || path.isAbsolute(realModuleName); if (isDirectImport) { // derive absolute path /.../node_modules/originModuleDir/realModuleName @@ -149,7 +148,7 @@ function resolveModulePath( toModuleName: string, platform: string | null, ): Resolution { - const modulePath = isAbsolutePath(toModuleName) + const modulePath = path.isAbsolute(toModuleName) ? resolveWindowsPath(toModuleName) : path.join(path.dirname(context.originModulePath), toModuleName); const redirectedPath = context.redirectModulePath(modulePath); diff --git a/packages/metro/package.json b/packages/metro/package.json index 255b4c0fb4..51883ab0dc 100644 --- a/packages/metro/package.json +++ b/packages/metro/package.json @@ -20,7 +20,6 @@ "@babel/template": "^7.0.0", "@babel/traverse": "^7.20.0", "@babel/types": "^7.20.0", - "absolute-path": "^0.0.0", "accepts": "^1.3.7", "async": "^3.2.2", "chalk": "^4.0.0", diff --git a/packages/metro/src/node-haste/Module.js b/packages/metro/src/node-haste/Module.js index bf2d29b25b..b0325d14dc 100644 --- a/packages/metro/src/node-haste/Module.js +++ b/packages/metro/src/node-haste/Module.js @@ -14,7 +14,7 @@ import type ModuleCache from './ModuleCache'; import type Package from './Package'; -const isAbsolutePath = require('absolute-path'); +import path from 'path'; class Module { path: string; @@ -23,7 +23,7 @@ class Module { _sourceCode: ?string; constructor(file: string, moduleCache: ModuleCache) { - if (!isAbsolutePath(file)) { + if (!path.isAbsolute(file)) { throw new Error('Expected file to be absolute path but got ' + file); } diff --git a/yarn.lock b/yarn.lock index 000d19505b..e77e411ce0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1373,11 +1373,6 @@ abort-controller@^3.0.0: dependencies: event-target-shim "^5.0.0" -absolute-path@^0.0.0: - version "0.0.0" - resolved "https://registry.yarnpkg.com/absolute-path/-/absolute-path-0.0.0.tgz#a78762fbdadfb5297be99b15d35a785b2f095bf7" - integrity sha1-p4di+9rftSl76ZsV01p4Wy8JW/c= - accepts@^1.3.7: version "1.3.7" resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.7.tgz#531bc726517a3b2b41f850021c6cc15eaab507cd"