From 3897a7265bc55ec50ad755d8c062b82b69cee069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Sun, 3 Mar 2024 21:21:15 +0800 Subject: [PATCH] perf: move check to `transformInclude` --- src/index.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 4831c8d..542cbda 100644 --- a/src/index.ts +++ b/src/index.ts @@ -34,19 +34,17 @@ export default createUnplugin((rawOptions = {}) => { buildStart() { if (![true, false].includes(preventAssignment)) { console.warn({ - message: - "unplugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.", + message: `${name}: 'preventAssignment' currently defaults to false. It is recommended to set this option to \`true\`, as the next major version will default this option to \`true\`.`, }) } }, transformInclude(id) { + if (keys.length === 0) return false return filter(id) }, transform(code, id) { - if (keys.length === 0) return null - if (!filter(id)) return null return executeReplacement(code, id) },