From ae70da9cbbfad4c4c80d604fb5f4b436f9ef7595 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20My=C5=9Bliwiec?= Date: Wed, 30 Jun 2021 11:18:28 +0200 Subject: [PATCH] fix(plugin): transform absolute paths #1411 --- lib/plugin/utils/plugin-utils.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/plugin/utils/plugin-utils.ts b/lib/plugin/utils/plugin-utils.ts index 21350bab2..7fd7e66bf 100644 --- a/lib/plugin/utils/plugin-utils.ts +++ b/lib/plugin/utils/plugin-utils.ts @@ -1,5 +1,5 @@ import { head } from 'lodash'; -import { posix } from 'path'; +import { isAbsolute, posix } from 'path'; import * as ts from 'typescript'; import { getDecoratorName, @@ -123,7 +123,10 @@ export function replaceImportPath(typeReference: string, fileName: string) { importPath = importPath.slice(2, importPath.length - 1); try { - require.resolve(importPath) + if (isAbsolute(importPath)) { + throw {}; + } + require.resolve(importPath); return typeReference.replace('import', 'require'); } catch (_error) { let relativePath = posix.relative(posix.dirname(fileName), importPath);