From 53a3f7fcbf995c507da23c3802f810ae3b71b8b8 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 16 Jun 2022 15:08:19 +1000 Subject: [PATCH] Apply import update logic for external modules --- build-scripts/fix-imports.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/build-scripts/fix-imports.js b/build-scripts/fix-imports.js index dd36bc1246..8eaee14d6c 100644 --- a/build-scripts/fix-imports.js +++ b/build-scripts/fix-imports.js @@ -36,8 +36,16 @@ function fixImportsAtFile(filePath) { } const [_, importPath] = l.split(`"`); - const fullPath = path.join(filePath, "..", importPath); - const exists = fs.existsSync(fullPath); + let exists = true; + let fullPath; + if (importPath.startsWith(".")) { + fullPath = path.join(filePath, "..", importPath); + exists = fs.existsSync(fullPath); + } else { + fullPath = path.join(process.cwd(), "node_modules", importPath); + exists = fs.existsSync(fullPath); + } + if (exists === false) { console.log("Update ", l); return l.replace(IMPORT_REGEXP, JUST_ADD_AN_EXTENSION);