From 9dff8897f13ef5117103c53f5f51095bff6aac8d Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Sat, 26 Oct 2024 15:44:06 +0800 Subject: [PATCH] Fix(compiler): Fix multi-level dependency path compilation error BUG --- src/renderer/src/components/Playground/compiler.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/components/Playground/compiler.ts b/src/renderer/src/components/Playground/compiler.ts index 2334aa1..d16ad94 100644 --- a/src/renderer/src/components/Playground/compiler.ts +++ b/src/renderer/src/components/Playground/compiler.ts @@ -136,7 +136,12 @@ class Compiler { } } - const path = importMap.imports[args.path] + let path = importMap.imports[args.path] + let tempPath = args.path + while (!path && tempPath.includes('/')) { + tempPath = tempPath.substring(0, tempPath.lastIndexOf('/')) + path = args.path.replace(tempPath, importMap.imports[tempPath]) + } if (!path) { throw Error(`Import '${args.path}' not found in Import Map`)