From 23b7cdf01e0f771da3fbc65978ea330991f7e669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=8E=E9=B8=A1=E6=B2=A1=E5=90=8D?= Date: Sun, 25 Jun 2023 17:07:33 +0800 Subject: [PATCH] fix: correct esbuild loader --- src/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index c831afb..37c56f9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,7 @@ import fs from 'node:fs' import path from 'node:path' import type { Plugin, ResolvedConfig } from 'vite' +import type { Loader } from 'esbuild' import { parse as parseAst } from 'acorn' import { DEFAULT_EXTENSIONS, @@ -85,7 +86,10 @@ export default function commonjs(options: Options = {}): Plugin { }) if (contents != null) { - return { contents } + return { + contents, + loader: id.slice(id.lastIndexOf('.') + 1) as Loader, + } } }) },