From 8e25c4cb1f3d1dc3537592b74980a2c3e4c1e872 Mon Sep 17 00:00:00 2001 From: yeliex Date: Mon, 5 Feb 2024 11:25:43 +0800 Subject: [PATCH] fix: convert fileUrl to path before compile this commit convert fileUrl to path before compile in esm, this may cause path alias resolve issue close https://github.com/swc-project/swc-node/issues/753 --- packages/register/esm.mts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/register/esm.mts b/packages/register/esm.mts index 0c0970ae0..f96cb10b4 100644 --- a/packages/register/esm.mts +++ b/packages/register/esm.mts @@ -94,7 +94,7 @@ export const load: LoadFn = async (url, context, nextLoad) => { if (context.format === 'ts') { const { source } = await nextLoad(url, context) const code = typeof source === 'string' ? source : Buffer.from(source).toString() - const compiled = await compile(code, url, tsconfig, true) + const compiled = await compile(code, fileURLToPath(url), tsconfig, true) return { format: 'module', source: compiled,