From 4e3d8c1d5d278e3c49c32dca67bbc60aa4a4a0d8 Mon Sep 17 00:00:00 2001 From: Amjad Masad Date: Thu, 30 Apr 2020 23:51:13 +0000 Subject: [PATCH] Ignore script loaders and absolute paths --- internal/backends/nodejs/grab.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/internal/backends/nodejs/grab.go b/internal/backends/nodejs/grab.go index 973b972d..f4e8544e 100644 --- a/internal/backends/nodejs/grab.go +++ b/internal/backends/nodejs/grab.go @@ -164,9 +164,27 @@ func guessBareImports() map[api.PkgName]bool { continue } + // Skip empty imports + if mod == "" { + continue + } + + // Skip absolute imports + if mod[0] == '/' { + continue + } + + // Skip relative imports if mod[0] == '.' { continue } + + // Skip script loaders + if strings.Contains(mod, "!") { + continue + } + + // Handle scoped modules if mod[0] == '@' { parts := strings.Split(mod, "/") if len(parts) < 2 {