From df7be266cf35bcefcc958432951bf829c3c5cf5a Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Tue, 16 Nov 2021 16:53:40 -0500 Subject: [PATCH] Revert normalizeNonRelativeId changes in config/resolveModuleIds.ts. This reverts commit 60e18e95b366c845501fc30f5e607ab5bf9d2035 from PR #8396. --- config/resolveModuleIds.ts | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/config/resolveModuleIds.ts b/config/resolveModuleIds.ts index 24057110a42..a63ed739f3f 100644 --- a/config/resolveModuleIds.ts +++ b/config/resolveModuleIds.ts @@ -83,11 +83,9 @@ class Transformer { } normalizeSourceString(file: string, source?: Node | null) { - if (source && n.StringLiteral.check(source)) { + if (source && n.StringLiteral.check(source) && this.isRelative(source.value)) { try { - source.value = this.isRelative(source.value) - ? this.normalizeId(source.value, file) - : this.normalizeNonRelativeId(source.value, file); + source.value = this.normalizeId(source.value, file); } catch (error) { console.error(`Failed to resolve ${source.value} in ${file} with error ${error}`); process.exit(1); @@ -95,27 +93,6 @@ class Transformer { } } - normalizeNonRelativeId(id: string, file: string) { - const normal = this.normalizeId(id, file); - const normalParts = normal.split("/"); - const sourceParts = id.split("/"); - const nodeModulesIndex = normalParts.lastIndexOf("node_modules"); - if ( - nodeModulesIndex >= 0 && - normalParts[nodeModulesIndex + 1] === sourceParts[0] - ) { - const bareModuleIdentifier = - normalParts.slice(nodeModulesIndex + 1).join("/"); - if (normal === this.normalizeId(bareModuleIdentifier, file)) { - return bareModuleIdentifier; - } - console.error(`Leaving ${id} import in ${file} unchanged because ${ - bareModuleIdentifier - } does not resolve to the same module`); - } - return id; - } - normalizeId(id: string, file: string) { const basedir = path.dirname(file); const absPath = resolve.sync(id, {