From a89637bc2e735db713410689fc15abe95057ab8c Mon Sep 17 00:00:00 2001 From: ryoppippi <1560508+ryoppippi@users.noreply.github.com> Date: Wed, 24 Jul 2024 16:27:36 +0100 Subject: [PATCH 1/2] fix: `resolve` id (fix #237) --- packages/unplugin-typia/src/core/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/unplugin-typia/src/core/index.ts b/packages/unplugin-typia/src/core/index.ts index 19b778cb..e8174eb5 100644 --- a/packages/unplugin-typia/src/core/index.ts +++ b/packages/unplugin-typia/src/core/index.ts @@ -2,6 +2,7 @@ import type { UnpluginFactory, UnpluginInstance } from 'unplugin'; import { createUnplugin } from 'unplugin'; import { createFilter as rollupCreateFilter } from '@rollup/pluginutils'; import MagicString from 'magic-string'; +import { resolve } from 'pathe'; import type { ResolvedOptions } from './options.ts'; import type { Options } from './options.js'; @@ -123,7 +124,7 @@ const unpluginFactory: UnpluginFactory< async transform(_source, _id) { const source = wrap(_source); - const id = wrap(_id); + const id = wrap(resolve(_id)); /** skip if source does not include typia */ if (!source.includes('typia')) { From d739f74038a5dc75280a79b4b115359f27559ed3 Mon Sep 17 00:00:00 2001 From: ryoppippi <1560508+ryoppippi@users.noreply.github.com> Date: Wed, 24 Jul 2024 16:28:47 +0100 Subject: [PATCH 2/2] fix: remove resolve(id) because resolve is already moved to index.ts --- packages/unplugin-typia/src/core/typia.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/unplugin-typia/src/core/typia.ts b/packages/unplugin-typia/src/core/typia.ts index 1f86fcb7..d2881c45 100644 --- a/packages/unplugin-typia/src/core/typia.ts +++ b/packages/unplugin-typia/src/core/typia.ts @@ -179,8 +179,7 @@ function transform( }, ); - const resolvedId = resolve(id); - const file = transformationResult.transformed.find(t => resolve(t.fileName) === resolvedId); + const file = transformationResult.transformed.find(t => resolve(t.fileName) === id); if (file == null) { throw new Error('No file found');