-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Expand file tree
/
Copy pathknip.patch
More file actions
31 lines (31 loc) · 2.16 KB
/
knip.patch
File metadata and controls
31 lines (31 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
diff --git a/dist/plugins/babel/index.js b/dist/plugins/babel/index.js
index d451e0ab75c530b794e6925466e18e798b7df960..ca4eeb240ef200fe89964532764513279c45b45c 100644
--- a/dist/plugins/babel/index.js
+++ b/dist/plugins/babel/index.js
@@ -9,11 +9,13 @@ const config = ['babel.config.{json,js,cjs,mjs,cts,ts}', '.babelrc.{json,js,cjs,
const getName = (value) => [Array.isArray(value) ? value[0] : value].filter(name => typeof name === 'string');
export const getDependenciesFromConfig = (config) => {
const presets = config.presets?.flatMap(getName).map(name => resolveName(name, 'preset')) ?? [];
+ const presetIncludes = config.presets?.filter(preset => Array.isArray(preset) && typeof preset[1] === "object").flatMap(preset => preset[1]?.include ?? []).map(name => resolveName(name, 'plugin')) ?? [];
const plugins = config.plugins?.flatMap(getName).map(name => resolveName(name, 'plugin')) ?? [];
const nested = config.env ? Object.values(config.env).flatMap(getDependenciesFromConfig) : [];
const overrides = config.overrides ? [config.overrides].flat().flatMap(getDependenciesFromConfig) : [];
return compact([
...presets.map(id => toDeferResolve(id)),
+ ...presetIncludes.map(id => toDeferResolve(id)),
...plugins.map(id => toDeferResolve(id)),
...(plugins.includes('@babel/plugin-transform-runtime')
? [toDeferResolve('@babel/runtime', { optional: true })]
diff --git a/dist/typescript/pragmas/custom.js b/dist/typescript/pragmas/custom.js
index 6ab98ae60cf8f07047a0ad7132c11a0da780bfbc..7c8818e81cde7e4ee9c11084d55043441e37208e 100644
--- a/dist/typescript/pragmas/custom.js
+++ b/dist/typescript/pragmas/custom.js
@@ -2,7 +2,7 @@ import { IMPORT_FLAGS } from "../../constants.js";
import { getEnvSpecifier } from "../../plugins/vitest/helpers.js";
import { isAbsolute, isInternal } from "../../util/path.js";
import { getLeadingComments, stripQuotes } from "../ast-helpers.js";
-const VITEST_ENV = /@(vitest|jest)-environment\s+(\S+)/g;
+const VITEST_ENV = /@(vitest)-environment\s+(\S+)/g;
export const collectCustomImports = (sourceFile) => {
const comments = getLeadingComments(sourceFile);
if (!comments.length)