knip 2.40.1 → 2.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/ConfigurationValidator.d.ts +56 -0
- package/dist/ConfigurationValidator.js +1 -0
- package/dist/PrincipalFactory.d.ts +4 -2
- package/dist/PrincipalFactory.js +9 -5
- package/dist/ProjectPrincipal.d.ts +4 -9
- package/dist/ProjectPrincipal.js +2 -3
- package/dist/WorkspaceWorker.d.ts +1 -1
- package/dist/binaries/resolvers/fallback.js +0 -1
- package/dist/binaries/resolvers/index.d.ts +1 -0
- package/dist/binaries/resolvers/index.js +1 -0
- package/dist/binaries/resolvers/node.js +1 -1
- package/dist/binaries/resolvers/tsx.d.ts +2 -0
- package/dist/binaries/resolvers/tsx.js +6 -0
- package/dist/index.js +5 -3
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/node-test-runner/index.js +4 -4
- package/dist/plugins/tsup/index.d.ts +6 -0
- package/dist/plugins/tsup/index.js +23 -0
- package/dist/plugins/tsup/types.d.ts +7 -0
- package/dist/plugins/tsup/types.js +1 -0
- package/dist/plugins/vite/index.js +1 -1
- package/dist/plugins/vitest/index.d.ts +1 -1
- package/dist/plugins/vitest/index.js +10 -8
- package/dist/typescript/ast-helpers.d.ts +0 -6
- package/dist/typescript/ast-helpers.js +5 -7
- package/dist/typescript/getImportsAndExports.js +8 -5
- package/dist/typescript/visitors/exports/moduleExportsAccessExpression.js +29 -21
- package/dist/util/compilers.d.ts +10 -0
- package/dist/util/glob.js +1 -1
- package/dist/util/modules.d.ts +6 -1
- package/dist/util/modules.js +2 -2
- package/dist/util/plugin.d.ts +1 -0
- package/dist/util/plugin.js +1 -0
- package/dist/util/require.js +6 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/schema.json +4 -0
package/README.md
CHANGED
|
@@ -304,6 +304,7 @@ Knip contains a growing list of plugins:
|
|
|
304
304
|
- [Stylelint][plugin-stylelint]
|
|
305
305
|
- [Svelte][plugin-svelte]
|
|
306
306
|
- [Tailwind][plugin-tailwind]
|
|
307
|
+
- [tsup][plugin-tsup]
|
|
307
308
|
- [TypeDoc][plugin-typedoc]
|
|
308
309
|
- [TypeScript][plugin-typescript]
|
|
309
310
|
- [Vite][plugin-vite]
|
|
@@ -956,6 +957,7 @@ Special thanks to the wonderful people who have contributed to this project:
|
|
|
956
957
|
[plugin-stylelint]: ./src/plugins/stylelint
|
|
957
958
|
[plugin-svelte]: ./src/plugins/svelte
|
|
958
959
|
[plugin-tailwind]: ./src/plugins/tailwind
|
|
960
|
+
[plugin-tsup]: ./src/plugins/tsup
|
|
959
961
|
[plugin-typedoc]: ./src/plugins/typedoc
|
|
960
962
|
[plugin-typescript]: ./src/plugins/typescript
|
|
961
963
|
[plugin-vite]: ./src/plugins/vite
|
|
@@ -528,6 +528,19 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
528
528
|
entry?: string | string[] | undefined;
|
|
529
529
|
project?: string | string[] | undefined;
|
|
530
530
|
}>]>>;
|
|
531
|
+
tsup: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
|
|
532
|
+
config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
533
|
+
entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
534
|
+
project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
535
|
+
}, "strip", z.ZodTypeAny, {
|
|
536
|
+
config?: string | string[] | undefined;
|
|
537
|
+
entry?: string | string[] | undefined;
|
|
538
|
+
project?: string | string[] | undefined;
|
|
539
|
+
}, {
|
|
540
|
+
config?: string | string[] | undefined;
|
|
541
|
+
entry?: string | string[] | undefined;
|
|
542
|
+
project?: string | string[] | undefined;
|
|
543
|
+
}>]>>;
|
|
531
544
|
typedoc: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
|
|
532
545
|
config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
533
546
|
entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
@@ -790,6 +803,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
790
803
|
entry?: string | string[] | undefined;
|
|
791
804
|
project?: string | string[] | undefined;
|
|
792
805
|
} | undefined;
|
|
806
|
+
tsup?: string | boolean | string[] | {
|
|
807
|
+
config?: string | string[] | undefined;
|
|
808
|
+
entry?: string | string[] | undefined;
|
|
809
|
+
project?: string | string[] | undefined;
|
|
810
|
+
} | undefined;
|
|
793
811
|
typedoc?: string | boolean | string[] | {
|
|
794
812
|
config?: string | string[] | undefined;
|
|
795
813
|
entry?: string | string[] | undefined;
|
|
@@ -1012,6 +1030,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
1012
1030
|
entry?: string | string[] | undefined;
|
|
1013
1031
|
project?: string | string[] | undefined;
|
|
1014
1032
|
} | undefined;
|
|
1033
|
+
tsup?: string | boolean | string[] | {
|
|
1034
|
+
config?: string | string[] | undefined;
|
|
1035
|
+
entry?: string | string[] | undefined;
|
|
1036
|
+
project?: string | string[] | undefined;
|
|
1037
|
+
} | undefined;
|
|
1015
1038
|
typedoc?: string | boolean | string[] | {
|
|
1016
1039
|
config?: string | string[] | undefined;
|
|
1017
1040
|
entry?: string | string[] | undefined;
|
|
@@ -1532,6 +1555,19 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
1532
1555
|
entry?: string | string[] | undefined;
|
|
1533
1556
|
project?: string | string[] | undefined;
|
|
1534
1557
|
}>]>>;
|
|
1558
|
+
tsup: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
|
|
1559
|
+
config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
1560
|
+
entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
1561
|
+
project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
1562
|
+
}, "strip", z.ZodTypeAny, {
|
|
1563
|
+
config?: string | string[] | undefined;
|
|
1564
|
+
entry?: string | string[] | undefined;
|
|
1565
|
+
project?: string | string[] | undefined;
|
|
1566
|
+
}, {
|
|
1567
|
+
config?: string | string[] | undefined;
|
|
1568
|
+
entry?: string | string[] | undefined;
|
|
1569
|
+
project?: string | string[] | undefined;
|
|
1570
|
+
}>]>>;
|
|
1535
1571
|
typedoc: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
|
|
1536
1572
|
config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
1537
1573
|
entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
@@ -1809,6 +1845,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
1809
1845
|
entry?: string | string[] | undefined;
|
|
1810
1846
|
project?: string | string[] | undefined;
|
|
1811
1847
|
} | undefined;
|
|
1848
|
+
tsup?: string | boolean | string[] | {
|
|
1849
|
+
config?: string | string[] | undefined;
|
|
1850
|
+
entry?: string | string[] | undefined;
|
|
1851
|
+
project?: string | string[] | undefined;
|
|
1852
|
+
} | undefined;
|
|
1812
1853
|
typedoc?: string | boolean | string[] | {
|
|
1813
1854
|
config?: string | string[] | undefined;
|
|
1814
1855
|
entry?: string | string[] | undefined;
|
|
@@ -2025,6 +2066,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
2025
2066
|
entry?: string | string[] | undefined;
|
|
2026
2067
|
project?: string | string[] | undefined;
|
|
2027
2068
|
} | undefined;
|
|
2069
|
+
tsup?: string | boolean | string[] | {
|
|
2070
|
+
config?: string | string[] | undefined;
|
|
2071
|
+
entry?: string | string[] | undefined;
|
|
2072
|
+
project?: string | string[] | undefined;
|
|
2073
|
+
} | undefined;
|
|
2028
2074
|
typedoc?: string | boolean | string[] | {
|
|
2029
2075
|
config?: string | string[] | undefined;
|
|
2030
2076
|
entry?: string | string[] | undefined;
|
|
@@ -2262,6 +2308,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
2262
2308
|
entry?: string | string[] | undefined;
|
|
2263
2309
|
project?: string | string[] | undefined;
|
|
2264
2310
|
} | undefined;
|
|
2311
|
+
tsup?: string | boolean | string[] | {
|
|
2312
|
+
config?: string | string[] | undefined;
|
|
2313
|
+
entry?: string | string[] | undefined;
|
|
2314
|
+
project?: string | string[] | undefined;
|
|
2315
|
+
} | undefined;
|
|
2265
2316
|
typedoc?: string | boolean | string[] | {
|
|
2266
2317
|
config?: string | string[] | undefined;
|
|
2267
2318
|
entry?: string | string[] | undefined;
|
|
@@ -2478,6 +2529,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
2478
2529
|
entry?: string | string[] | undefined;
|
|
2479
2530
|
project?: string | string[] | undefined;
|
|
2480
2531
|
} | undefined;
|
|
2532
|
+
tsup?: string | boolean | string[] | {
|
|
2533
|
+
config?: string | string[] | undefined;
|
|
2534
|
+
entry?: string | string[] | undefined;
|
|
2535
|
+
project?: string | string[] | undefined;
|
|
2536
|
+
} | undefined;
|
|
2481
2537
|
typedoc?: string | boolean | string[] | {
|
|
2482
2538
|
config?: string | string[] | undefined;
|
|
2483
2539
|
entry?: string | string[] | undefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import { ProjectPrincipal } from './ProjectPrincipal.js';
|
|
3
3
|
import type { SyncCompilers, AsyncCompilers } from './types/compilers.js';
|
|
4
|
+
import type { GlobbyFilterFunction } from 'globby';
|
|
4
5
|
type Paths = ts.CompilerOptions['paths'];
|
|
5
6
|
type Principal = {
|
|
6
7
|
principal: ProjectPrincipal;
|
|
@@ -9,16 +10,17 @@ type Principal = {
|
|
|
9
10
|
pkgNames: Set<string>;
|
|
10
11
|
};
|
|
11
12
|
type Principals = Set<Principal>;
|
|
12
|
-
type
|
|
13
|
+
export type PrincipalOptions = {
|
|
13
14
|
cwd: string;
|
|
14
15
|
compilerOptions: ts.CompilerOptions;
|
|
15
16
|
paths: Paths;
|
|
16
17
|
compilers: [SyncCompilers, AsyncCompilers];
|
|
17
18
|
pkgName: string;
|
|
19
|
+
isGitIgnored: GlobbyFilterFunction;
|
|
18
20
|
};
|
|
19
21
|
export declare class PrincipalFactory {
|
|
20
22
|
principals: Principals;
|
|
21
|
-
getPrincipal(options:
|
|
23
|
+
getPrincipal(options: PrincipalOptions): ProjectPrincipal;
|
|
22
24
|
private findReusablePrincipal;
|
|
23
25
|
private linkPrincipal;
|
|
24
26
|
private addNewPrincipal;
|
package/dist/PrincipalFactory.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import { ProjectPrincipal } from './ProjectPrincipal.js';
|
|
3
3
|
import { toAbsolute } from './util/path.js';
|
|
4
|
+
const mapToAbsolutePaths = (paths, cwd) => Object.keys(paths).reduce((result, key) => {
|
|
5
|
+
result[key] = paths[key].map(entry => toAbsolute(entry, cwd));
|
|
6
|
+
return result;
|
|
7
|
+
}, {});
|
|
4
8
|
const mergePaths = (cwd, compilerOptions, paths = {}) => {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
compilerOptions.paths = { ...
|
|
9
|
+
const compilerPaths = !compilerOptions.baseUrl && compilerOptions.paths
|
|
10
|
+
? mapToAbsolutePaths(compilerOptions.paths, cwd)
|
|
11
|
+
: compilerOptions.paths;
|
|
12
|
+
const extraPaths = mapToAbsolutePaths(paths, cwd);
|
|
13
|
+
compilerOptions.paths = { ...compilerPaths, ...extraPaths };
|
|
10
14
|
return compilerOptions;
|
|
11
15
|
};
|
|
12
16
|
export class PrincipalFactory {
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import { isGitIgnoredSync } from 'globby';
|
|
2
1
|
import ts from 'typescript';
|
|
3
2
|
import { createCustomModuleResolver } from './typescript/resolveModuleNames.js';
|
|
4
3
|
import { SourceFileManager } from './typescript/SourceFileManager.js';
|
|
4
|
+
import type { PrincipalOptions } from './PrincipalFactory.js';
|
|
5
5
|
import type { SyncCompilers, AsyncCompilers } from './types/compilers.js';
|
|
6
6
|
import type { ExportItem, ExportItemMember } from './types/exports.js';
|
|
7
|
-
type
|
|
8
|
-
compilerOptions: ts.CompilerOptions;
|
|
9
|
-
cwd: string;
|
|
10
|
-
compilers: [SyncCompilers, AsyncCompilers];
|
|
11
|
-
};
|
|
7
|
+
import type { GlobbyFilterFunction } from 'globby';
|
|
12
8
|
export declare class ProjectPrincipal {
|
|
13
9
|
entryPaths: Set<string>;
|
|
14
10
|
projectPaths: Set<string>;
|
|
15
11
|
skipExportsAnalysis: Set<string>;
|
|
16
|
-
isGitIgnored:
|
|
12
|
+
isGitIgnored: GlobbyFilterFunction;
|
|
17
13
|
cwd: string;
|
|
18
14
|
compilerOptions: ts.CompilerOptions;
|
|
19
15
|
extensions: Set<string>;
|
|
@@ -26,7 +22,7 @@ export declare class ProjectPrincipal {
|
|
|
26
22
|
lsFindReferences: ts.LanguageService['findReferences'];
|
|
27
23
|
program?: ts.Program;
|
|
28
24
|
};
|
|
29
|
-
constructor({ compilerOptions, cwd, compilers }:
|
|
25
|
+
constructor({ compilerOptions, cwd, compilers, isGitIgnored }: PrincipalOptions);
|
|
30
26
|
private createProgram;
|
|
31
27
|
private hasAcceptedExtension;
|
|
32
28
|
addEntryPath(filePath: string, options?: {
|
|
@@ -67,4 +63,3 @@ export declare class ProjectPrincipal {
|
|
|
67
63
|
col: number;
|
|
68
64
|
};
|
|
69
65
|
}
|
|
70
|
-
export {};
|
package/dist/ProjectPrincipal.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isGitIgnoredSync } from 'globby';
|
|
2
1
|
import ts from 'typescript';
|
|
3
2
|
import { DEFAULT_EXTENSIONS } from './constants.js';
|
|
4
3
|
import { IGNORED_FILE_EXTENSIONS } from './constants.js';
|
|
@@ -35,9 +34,9 @@ export class ProjectPrincipal {
|
|
|
35
34
|
syncCompilers;
|
|
36
35
|
asyncCompilers;
|
|
37
36
|
backend;
|
|
38
|
-
constructor({ compilerOptions, cwd, compilers }) {
|
|
37
|
+
constructor({ compilerOptions, cwd, compilers, isGitIgnored }) {
|
|
39
38
|
this.cwd = cwd;
|
|
40
|
-
this.isGitIgnored =
|
|
39
|
+
this.isGitIgnored = isGitIgnored;
|
|
41
40
|
this.compilerOptions = {
|
|
42
41
|
...compilerOptions,
|
|
43
42
|
...baseCompilerOptions,
|
|
@@ -52,7 +52,7 @@ export declare class WorkspaceWorker {
|
|
|
52
52
|
installedBinaries: InstalledBinaries;
|
|
53
53
|
referencedDependencies: ReferencedDependencies;
|
|
54
54
|
hasTypesIncluded: Set<string>;
|
|
55
|
-
enabledPlugins: ("astro" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cypress" | "eslint" | "gatsby" | "husky" | "jest" | "lefthook" | "markdownlint" | "mocha" | "next" | "nx" | "nyc" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "stylelint" | "tailwind" | "typedoc" | "typescript" | "vite" | "vitest" | "webpack" | "drizzle" | "githubActions" | "graphqlCodegen" | "lintStaged" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "releaseIt" | "semanticRelease" | "svelte")[];
|
|
55
|
+
enabledPlugins: ("astro" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cypress" | "eslint" | "gatsby" | "husky" | "jest" | "lefthook" | "markdownlint" | "mocha" | "next" | "nx" | "nyc" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "stylelint" | "tailwind" | "tsup" | "typedoc" | "typescript" | "vite" | "vitest" | "webpack" | "drizzle" | "githubActions" | "graphqlCodegen" | "lintStaged" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "releaseIt" | "semanticRelease" | "svelte")[];
|
|
56
56
|
entryFilePatterns: string[];
|
|
57
57
|
productionEntryFilePatterns: string[];
|
|
58
58
|
}>;
|
|
@@ -4,7 +4,7 @@ import { tryResolveFilePath, tryResolveSpecifiers } from '../util.js';
|
|
|
4
4
|
export const resolve = (binary, args, { cwd }) => {
|
|
5
5
|
const parsed = parseArgs(args, {
|
|
6
6
|
string: ['r'],
|
|
7
|
-
alias: { require: ['r', 'loader', 'experimental-loader', 'test-reporter'] },
|
|
7
|
+
alias: { require: ['r', 'loader', 'experimental-loader', 'test-reporter', 'watch'] },
|
|
8
8
|
});
|
|
9
9
|
return compact([tryResolveFilePath(cwd, parsed._[0]), ...tryResolveSpecifiers(cwd, [parsed.require].flat())]);
|
|
10
10
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { toBinary } from '../../util/protocols.js';
|
|
2
|
+
import { resolve as resolveNode } from './node.js';
|
|
3
|
+
export const resolve = (binary, args, options) => {
|
|
4
|
+
args = args.map(a => (a === 'watch' ? '--watch' : a));
|
|
5
|
+
return [toBinary(binary), ...resolveNode(binary, args, options)];
|
|
6
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isGitIgnoredSync } from 'globby';
|
|
1
2
|
import micromatch from 'micromatch';
|
|
2
3
|
import { _getDependenciesFromScripts } from './binaries/index.js';
|
|
3
4
|
import { ConfigurationChief } from './ConfigurationChief.js';
|
|
@@ -21,6 +22,7 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
21
22
|
const deputy = new DependencyDeputy({ isStrict });
|
|
22
23
|
const factory = new PrincipalFactory();
|
|
23
24
|
const streamer = new ConsoleStreamer({ isEnabled: isShowProgress });
|
|
25
|
+
const isGitIgnored = gitignore ? isGitIgnoredSync({ cwd }) : () => false;
|
|
24
26
|
streamer.cast('Reading workspace configuration(s)...');
|
|
25
27
|
await chief.init();
|
|
26
28
|
const compilers = chief.getCompilers();
|
|
@@ -41,7 +43,7 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
41
43
|
if (isInternal(specifier)) {
|
|
42
44
|
const filePath = principal.resolveModule(specifier, containingFilePath)?.resolvedFileName;
|
|
43
45
|
if (filePath) {
|
|
44
|
-
const ignorePatterns = workspace.config.ignore.map(pattern => join(
|
|
46
|
+
const ignorePatterns = workspace.config.ignore.map(pattern => join(workspace.dir, pattern));
|
|
45
47
|
const isIgnored = micromatch.isMatch(filePath, ignorePatterns);
|
|
46
48
|
if (!isIgnored)
|
|
47
49
|
principal.addEntryPath(filePath);
|
|
@@ -85,7 +87,7 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
85
87
|
streamer.cast(`Analyzing workspace ${name}...`);
|
|
86
88
|
deputy.addWorkspace({ name, dir, manifestPath, manifest, ignoreDependencies, ignoreBinaries });
|
|
87
89
|
const { compilerOptions, definitionPaths } = await loadTSConfig(join(dir, tsConfigFile ?? 'tsconfig.json'));
|
|
88
|
-
const principal = factory.getPrincipal({ cwd: dir, paths, compilerOptions, compilers, pkgName });
|
|
90
|
+
const principal = factory.getPrincipal({ cwd: dir, paths, compilerOptions, compilers, pkgName, isGitIgnored });
|
|
89
91
|
const worker = new WorkspaceWorker({
|
|
90
92
|
name,
|
|
91
93
|
dir,
|
|
@@ -102,7 +104,7 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
102
104
|
principal.addEntryPaths(definitionPaths);
|
|
103
105
|
debugLogArray(name, `Definition paths`, definitionPaths);
|
|
104
106
|
const sharedGlobOptions = { cwd, workingDir: dir, gitignore, ignore: worker.getIgnorePatterns() };
|
|
105
|
-
const entryPathsFromManifest = await getEntryPathFromManifest(
|
|
107
|
+
const entryPathsFromManifest = await getEntryPathFromManifest(manifest, sharedGlobOptions);
|
|
106
108
|
debugLogArray(name, 'Entry paths in package.json', entryPathsFromManifest);
|
|
107
109
|
principal.addEntryPaths(entryPathsFromManifest);
|
|
108
110
|
const dependencies = await worker.findAllDependencies();
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export * as stryker from './stryker/index.js';
|
|
|
39
39
|
export * as stylelint from './stylelint/index.js';
|
|
40
40
|
export * as svelte from './svelte/index.js';
|
|
41
41
|
export * as tailwind from './tailwind/index.js';
|
|
42
|
+
export * as tsup from './tsup/index.js';
|
|
42
43
|
export * as typedoc from './typedoc/index.js';
|
|
43
44
|
export * as typescript from './typescript/index.js';
|
|
44
45
|
export * as vite from './vite/index.js';
|
package/dist/plugins/index.js
CHANGED
|
@@ -39,6 +39,7 @@ export * as stryker from './stryker/index.js';
|
|
|
39
39
|
export * as stylelint from './stylelint/index.js';
|
|
40
40
|
export * as svelte from './svelte/index.js';
|
|
41
41
|
export * as tailwind from './tailwind/index.js';
|
|
42
|
+
export * as tsup from './tsup/index.js';
|
|
42
43
|
export * as typedoc from './typedoc/index.js';
|
|
43
44
|
export * as typescript from './typescript/index.js';
|
|
44
45
|
export * as vite from './vite/index.js';
|
|
@@ -8,10 +8,10 @@ export const isEnabled = ({ manifest }) => {
|
|
|
8
8
|
.some(s => manifest.scripts && /node (.*)--test/.test(manifest.scripts[s]));
|
|
9
9
|
};
|
|
10
10
|
export const ENTRY_FILE_PATTERNS = [
|
|
11
|
-
'
|
|
12
|
-
'**/test
|
|
13
|
-
'
|
|
14
|
-
'**/test
|
|
11
|
+
'**/*{.,-,_}test.?(c|m)js',
|
|
12
|
+
'**/test-*.?(c|m)js',
|
|
13
|
+
'**/test.?(c|m)js',
|
|
14
|
+
'**/test/**/*.?(c|m)js',
|
|
15
15
|
];
|
|
16
16
|
const findNodeTestRunnerDependencies = async (configFilePath, options) => {
|
|
17
17
|
return (options.config?.entry ?? ENTRY_FILE_PATTERNS).map(toEntryPattern);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
|
|
2
|
+
export declare const NAME = "tsup";
|
|
3
|
+
export declare const ENABLERS: string[];
|
|
4
|
+
export declare const isEnabled: IsPluginEnabledCallback;
|
|
5
|
+
export declare const CONFIG_FILE_PATTERNS: string[];
|
|
6
|
+
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { timerify } from '../../util/Performance.js';
|
|
2
|
+
import { hasDependency, load } from '../../util/plugin.js';
|
|
3
|
+
import { toEntryPattern } from '../../util/protocols.js';
|
|
4
|
+
export const NAME = 'tsup';
|
|
5
|
+
export const ENABLERS = ['tsup'];
|
|
6
|
+
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
7
|
+
export const CONFIG_FILE_PATTERNS = ['tsup.config.js'];
|
|
8
|
+
const findTsupDependencies = async (configFilePath) => {
|
|
9
|
+
let localConfig = await load(configFilePath);
|
|
10
|
+
if (typeof localConfig === 'function')
|
|
11
|
+
localConfig = await localConfig({});
|
|
12
|
+
if (!localConfig)
|
|
13
|
+
return [];
|
|
14
|
+
const entryPatterns = [localConfig].flat().flatMap(config => {
|
|
15
|
+
if (!config.entry)
|
|
16
|
+
return [];
|
|
17
|
+
if (Array.isArray(config.entry))
|
|
18
|
+
return config.entry.map(toEntryPattern);
|
|
19
|
+
return Object.values(config.entry).map(toEntryPattern);
|
|
20
|
+
});
|
|
21
|
+
return entryPatterns;
|
|
22
|
+
};
|
|
23
|
+
export const findDependencies = timerify(findTsupDependencies);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -9,6 +9,6 @@ const findViteDependencies = async (configFilePath, options) => {
|
|
|
9
9
|
const localConfig = await load(configFilePath);
|
|
10
10
|
if (!localConfig)
|
|
11
11
|
return [];
|
|
12
|
-
return findVitestDependencies(localConfig, options);
|
|
12
|
+
return findVitestDependencies(configFilePath, localConfig, options);
|
|
13
13
|
};
|
|
14
14
|
export const findDependencies = timerify(findViteDependencies);
|
|
@@ -5,5 +5,5 @@ export declare const ENABLERS: string[];
|
|
|
5
5
|
export declare const isEnabled: IsPluginEnabledCallback;
|
|
6
6
|
export declare const CONFIG_FILE_PATTERNS: string[];
|
|
7
7
|
export declare const ENTRY_FILE_PATTERNS: string[];
|
|
8
|
-
export declare const findVitestDependencies: (localConfig: ViteConfigOrFn, options: GenericPluginCallbackOptions) => Promise<any[]>;
|
|
8
|
+
export declare const findVitestDependencies: (configFilePath: string, localConfig: ViteConfigOrFn, options: GenericPluginCallbackOptions) => Promise<any[]>;
|
|
9
9
|
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { compact } from '../../util/array.js';
|
|
2
|
+
import { dirname, join } from '../../util/path.js';
|
|
2
3
|
import { timerify } from '../../util/Performance.js';
|
|
3
|
-
import { hasDependency, load } from '../../util/plugin.js';
|
|
4
|
+
import { hasDependency, load, tryResolve } from '../../util/plugin.js';
|
|
4
5
|
import { toEntryPattern } from '../../util/protocols.js';
|
|
5
6
|
import { getEnvPackageName, getExternalReporters } from './helpers.js';
|
|
6
7
|
export const NAME = 'Vitest';
|
|
@@ -8,7 +9,7 @@ export const ENABLERS = ['vitest'];
|
|
|
8
9
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
9
10
|
export const CONFIG_FILE_PATTERNS = ['vitest.config.ts', 'vitest.{workspace,projects}.{ts,js,json}'];
|
|
10
11
|
export const ENTRY_FILE_PATTERNS = ['**/*.{test,spec}.?(c|m)[jt]s?(x)'];
|
|
11
|
-
const findConfigDependencies = (localConfig, options) => {
|
|
12
|
+
const findConfigDependencies = (configFilePath, localConfig, options) => {
|
|
12
13
|
const { isProduction, config } = options;
|
|
13
14
|
const testConfig = localConfig.test;
|
|
14
15
|
const entryPatterns = (config?.entry ?? testConfig?.include ?? ENTRY_FILE_PATTERNS).map(toEntryPattern);
|
|
@@ -17,11 +18,12 @@ const findConfigDependencies = (localConfig, options) => {
|
|
|
17
18
|
const environments = testConfig.environment ? [getEnvPackageName(testConfig.environment)] : [];
|
|
18
19
|
const reporters = getExternalReporters(testConfig.reporters);
|
|
19
20
|
const coverage = testConfig.coverage ? [`@vitest/coverage-${testConfig.coverage.provider ?? 'v8'}`] : [];
|
|
20
|
-
const
|
|
21
|
-
const
|
|
21
|
+
const toPath = (v) => tryResolve(join(dirname(configFilePath), v), configFilePath) ?? v;
|
|
22
|
+
const setupFiles = (testConfig.setupFiles ? [testConfig.setupFiles].flat() : []).map(toPath);
|
|
23
|
+
const globalSetup = (testConfig.globalSetup ? [testConfig.globalSetup].flat() : []).map(toPath);
|
|
22
24
|
return [...entryPatterns, ...environments, ...reporters, ...coverage, ...setupFiles, ...globalSetup];
|
|
23
25
|
};
|
|
24
|
-
export const findVitestDependencies = async (localConfig, options) => {
|
|
26
|
+
export const findVitestDependencies = async (configFilePath, localConfig, options) => {
|
|
25
27
|
if (!localConfig)
|
|
26
28
|
return [];
|
|
27
29
|
if (typeof localConfig === 'function') {
|
|
@@ -29,21 +31,21 @@ export const findVitestDependencies = async (localConfig, options) => {
|
|
|
29
31
|
for (const command of ['dev', 'serve', 'build']) {
|
|
30
32
|
for (const mode of ['development', 'production']) {
|
|
31
33
|
const config = await localConfig({ command, mode, ssrBuild: undefined });
|
|
32
|
-
findConfigDependencies(config, options).forEach(dependency => dependencies.add(dependency));
|
|
34
|
+
findConfigDependencies(configFilePath, config, options).forEach(dependency => dependencies.add(dependency));
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
return Array.from(dependencies);
|
|
36
38
|
}
|
|
37
39
|
if (!localConfig.test)
|
|
38
40
|
return [];
|
|
39
|
-
return findConfigDependencies(localConfig, options);
|
|
41
|
+
return findConfigDependencies(configFilePath, localConfig, options);
|
|
40
42
|
};
|
|
41
43
|
const findVitestWorkspaceDependencies = async (configFilePath, options) => {
|
|
42
44
|
const localConfig = await load(configFilePath);
|
|
43
45
|
const dependencies = new Set();
|
|
44
46
|
for (const config of [localConfig].flat()) {
|
|
45
47
|
if (config && typeof config !== 'string') {
|
|
46
|
-
(await findVitestDependencies(config, options)).forEach(dependency => dependencies.add(dependency));
|
|
48
|
+
(await findVitestDependencies(configFilePath, config, options)).forEach(dependency => dependencies.add(dependency));
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
51
|
return compact(dependencies);
|
|
@@ -13,12 +13,6 @@ export declare function isImportCall(node: ts.Node): node is ts.ImportCall;
|
|
|
13
13
|
export declare function isRequireCall(callExpression: ts.Node): callExpression is ts.CallExpression;
|
|
14
14
|
export declare function isPropertyAccessCall(node: ts.Node, identifier: string): node is ts.CallExpression;
|
|
15
15
|
export declare function getAccessExpressionName(node: ts.PropertyAccessExpression | ts.ElementAccessExpression): string;
|
|
16
|
-
type LiteralLikeElementAccessExpression = ts.ElementAccessExpression & ts.Declaration & {
|
|
17
|
-
readonly argumentExpression: ts.StringLiteralLike | ts.NumericLiteral;
|
|
18
|
-
};
|
|
19
|
-
export declare function isModuleExportsAccessExpression(node: ts.Node): node is LiteralLikeElementAccessExpression & {
|
|
20
|
-
expression: ts.Identifier;
|
|
21
|
-
};
|
|
22
16
|
export declare function stripQuotes(name: string): string;
|
|
23
17
|
export declare function findAncestor<T>(node: ts.Node | undefined, callback: (element: ts.Node) => boolean | 'STOP'): T | undefined;
|
|
24
18
|
export declare function findDescendants<T>(node: ts.Node | undefined, callback: (element: ts.Node) => boolean | 'STOP'): T[];
|
|
@@ -36,12 +36,6 @@ export function isPropertyAccessCall(node, identifier) {
|
|
|
36
36
|
export function getAccessExpressionName(node) {
|
|
37
37
|
return 'argumentExpression' in node ? stripQuotes(node.argumentExpression.getText()) : node.name.getText();
|
|
38
38
|
}
|
|
39
|
-
export function isModuleExportsAccessExpression(node) {
|
|
40
|
-
return ((ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
|
|
41
|
-
ts.isIdentifier(node.expression) &&
|
|
42
|
-
node.expression.escapedText === 'module' &&
|
|
43
|
-
getAccessExpressionName(node) === 'exports');
|
|
44
|
-
}
|
|
45
39
|
export function stripQuotes(name) {
|
|
46
40
|
const length = name.length;
|
|
47
41
|
if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && isQuoteOrBacktick(name.charCodeAt(0))) {
|
|
@@ -103,7 +97,11 @@ export const isInModuleBlock = (node) => {
|
|
|
103
97
|
};
|
|
104
98
|
export const getJSDocTags = (node) => {
|
|
105
99
|
const tags = new Set();
|
|
106
|
-
|
|
100
|
+
let tagNodes = ts.getJSDocTags(node);
|
|
101
|
+
if (ts.isExportSpecifier(node) || ts.isBindingElement(node)) {
|
|
102
|
+
tagNodes = [...tagNodes, ...ts.getJSDocTags(node.parent.parent)];
|
|
103
|
+
}
|
|
104
|
+
for (const tagNode of tagNodes) {
|
|
107
105
|
const match = tagNode.getText()?.match(/@\S+/);
|
|
108
106
|
if (match)
|
|
109
107
|
tags.add(match[0]);
|
|
@@ -122,11 +122,14 @@ export const getImportsAndExports = (sourceFile, options) => {
|
|
|
122
122
|
[results].flat().forEach(addImport);
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (
|
|
129
|
-
|
|
125
|
+
const isTopLevel = node.parent === sourceFile || node.parent?.parent === sourceFile;
|
|
126
|
+
if (isTopLevel) {
|
|
127
|
+
for (const visitor of visitors.export) {
|
|
128
|
+
if (visitor) {
|
|
129
|
+
const results = visitor(node, options);
|
|
130
|
+
if (results)
|
|
131
|
+
[results].flat().forEach(addExport);
|
|
132
|
+
}
|
|
130
133
|
}
|
|
131
134
|
}
|
|
132
135
|
for (const visitor of visitors.script) {
|
|
@@ -1,30 +1,38 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import { SymbolType } from '../../../types/issues.js';
|
|
3
|
-
import {
|
|
3
|
+
import { stripQuotes } from '../../ast-helpers.js';
|
|
4
4
|
import { isJS } from '../helpers.js';
|
|
5
5
|
import { exportVisitor as visit } from '../index.js';
|
|
6
|
+
const isModuleExportsAccess = (node) => ts.isIdentifier(node.expression) && node.expression.escapedText === 'module' && node.name.escapedText === 'exports';
|
|
6
7
|
export default visit(isJS, node => {
|
|
7
|
-
if (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
8
|
+
if (ts.isExpressionStatement(node)) {
|
|
9
|
+
if (ts.isBinaryExpression(node.expression)) {
|
|
10
|
+
if (ts.isPropertyAccessExpression(node.expression.left)) {
|
|
11
|
+
if (ts.isPropertyAccessExpression(node.expression.left.expression) &&
|
|
12
|
+
isModuleExportsAccess(node.expression.left.expression)) {
|
|
13
|
+
const identifier = node.expression.left.name.getText();
|
|
14
|
+
const pos = node.expression.left.name.pos;
|
|
15
|
+
return { node, identifier, type: SymbolType.UNKNOWN, pos };
|
|
16
|
+
}
|
|
17
|
+
else if (isModuleExportsAccess(node.expression.left)) {
|
|
18
|
+
const expr = node.expression.right;
|
|
19
|
+
if (ts.isObjectLiteralExpression(expr) && expr.properties.every(ts.isShorthandPropertyAssignment)) {
|
|
20
|
+
return expr.properties.map(node => {
|
|
21
|
+
return { node, identifier: node.getText(), type: SymbolType.UNKNOWN, pos: node.pos };
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return { node, identifier: 'default', type: SymbolType.UNKNOWN, pos: expr.pos };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
25
28
|
}
|
|
26
|
-
else
|
|
27
|
-
|
|
29
|
+
else if (ts.isElementAccessExpression(node.expression.left) &&
|
|
30
|
+
ts.isPropertyAccessExpression(node.expression.left.expression) &&
|
|
31
|
+
ts.isIdentifier(node.expression.left.expression.name) &&
|
|
32
|
+
isModuleExportsAccess(node.expression.left.expression)) {
|
|
33
|
+
const identifier = stripQuotes(node.expression.left.argumentExpression.getText());
|
|
34
|
+
const pos = node.expression.left.argumentExpression.pos;
|
|
35
|
+
return { node, identifier, type: SymbolType.UNKNOWN, pos };
|
|
28
36
|
}
|
|
29
37
|
}
|
|
30
38
|
}
|
package/dist/util/compilers.d.ts
CHANGED
|
@@ -212,6 +212,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
212
212
|
entry?: string | string[] | undefined;
|
|
213
213
|
project?: string | string[] | undefined;
|
|
214
214
|
} | undefined;
|
|
215
|
+
tsup?: string | boolean | string[] | {
|
|
216
|
+
config?: string | string[] | undefined;
|
|
217
|
+
entry?: string | string[] | undefined;
|
|
218
|
+
project?: string | string[] | undefined;
|
|
219
|
+
} | undefined;
|
|
215
220
|
typedoc?: string | boolean | string[] | {
|
|
216
221
|
config?: string | string[] | undefined;
|
|
217
222
|
entry?: string | string[] | undefined;
|
|
@@ -428,6 +433,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
428
433
|
entry?: string | string[] | undefined;
|
|
429
434
|
project?: string | string[] | undefined;
|
|
430
435
|
} | undefined;
|
|
436
|
+
tsup?: string | boolean | string[] | {
|
|
437
|
+
config?: string | string[] | undefined;
|
|
438
|
+
entry?: string | string[] | undefined;
|
|
439
|
+
project?: string | string[] | undefined;
|
|
440
|
+
} | undefined;
|
|
431
441
|
typedoc?: string | boolean | string[] | {
|
|
432
442
|
config?: string | string[] | undefined;
|
|
433
443
|
entry?: string | string[] | undefined;
|
package/dist/util/glob.js
CHANGED
|
@@ -24,7 +24,7 @@ const glob = async ({ cwd, workingDir = cwd, patterns, ignore = [], gitignore =
|
|
|
24
24
|
if (globPatterns[0].startsWith('!'))
|
|
25
25
|
return [];
|
|
26
26
|
const ignorePatterns = compact([...ignore, ...GLOBAL_IGNORE_PATTERNS]);
|
|
27
|
-
debugLogObject(relativePath || ROOT_WORKSPACE_NAME, `Glob options`, { cwd, globPatterns, ignorePatterns });
|
|
27
|
+
debugLogObject(relativePath || ROOT_WORKSPACE_NAME, `Glob options`, { cwd, globPatterns, ignorePatterns, gitignore });
|
|
28
28
|
return globby(globPatterns, {
|
|
29
29
|
cwd,
|
|
30
30
|
ignore: ignorePatterns,
|
package/dist/util/modules.d.ts
CHANGED
|
@@ -6,5 +6,10 @@ export declare const isMaybePackageName: (specifier: string) => boolean;
|
|
|
6
6
|
export declare const isDefinitelyTyped: (packageName: string) => boolean;
|
|
7
7
|
export declare const getDefinitelyTypedFor: (packageName: string) => string;
|
|
8
8
|
export declare const getPackageFromDefinitelyTyped: (typedDependency: string) => string;
|
|
9
|
-
export declare const getEntryPathFromManifest: (
|
|
9
|
+
export declare const getEntryPathFromManifest: (manifest: PackageJson, sharedGlobOptions: {
|
|
10
|
+
cwd: string;
|
|
11
|
+
workingDir: string;
|
|
12
|
+
gitignore: boolean;
|
|
13
|
+
ignore: string[];
|
|
14
|
+
}) => Promise<string[]>;
|
|
10
15
|
export declare const sanitizeSpecifier: (specifier: string) => string;
|
package/dist/util/modules.js
CHANGED
|
@@ -35,7 +35,7 @@ export const getPackageFromDefinitelyTyped = (typedDependency) => {
|
|
|
35
35
|
}
|
|
36
36
|
return typedDependency;
|
|
37
37
|
};
|
|
38
|
-
export const getEntryPathFromManifest = (
|
|
38
|
+
export const getEntryPathFromManifest = (manifest, sharedGlobOptions) => {
|
|
39
39
|
const { main, bin, exports } = manifest;
|
|
40
40
|
const entryPaths = new Set();
|
|
41
41
|
if (typeof main === 'string')
|
|
@@ -49,7 +49,7 @@ export const getEntryPathFromManifest = (cwd, dir, manifest) => {
|
|
|
49
49
|
if (exports) {
|
|
50
50
|
getStringValues(exports).forEach(item => entryPaths.add(item));
|
|
51
51
|
}
|
|
52
|
-
return _glob({
|
|
52
|
+
return _glob({ ...sharedGlobOptions, patterns: Array.from(entryPaths) });
|
|
53
53
|
};
|
|
54
54
|
export const sanitizeSpecifier = (specifier) => {
|
|
55
55
|
if (specifier.startsWith('node:'))
|
package/dist/util/plugin.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { _load as load, _loadFile as loadFile } from './loader.js';
|
|
2
|
+
export { _tryResolve as tryResolve } from './require.js';
|
|
2
3
|
import type { RawPluginConfiguration } from '../types/config.js';
|
|
3
4
|
export declare const toCamelCase: (name: string) => string;
|
|
4
5
|
export declare const hasDependency: (dependencies: Set<string>, values: (string | RegExp)[]) => boolean;
|
package/dist/util/plugin.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { _load as load, _loadFile as loadFile } from './loader.js';
|
|
2
|
+
export { _tryResolve as tryResolve } from './require.js';
|
|
2
3
|
import { arrayify } from './array.js';
|
|
3
4
|
export const toCamelCase = (name) => name.toLowerCase().replace(/(-[a-z])/g, group => group.toUpperCase().replace('-', ''));
|
|
4
5
|
export const hasDependency = (dependencies, values) => values.some(value => {
|
package/dist/util/require.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { createRequire as nodeCreateRequire } from 'node:module';
|
|
2
2
|
import { pathToFileURL } from 'node:url';
|
|
3
|
+
import createJITI from 'jiti';
|
|
3
4
|
import { debugLog } from './debug.js';
|
|
4
5
|
import { getPackageNameFromModuleSpecifier } from './modules.js';
|
|
5
6
|
import { cwd, toPosix, join } from './path.js';
|
|
6
7
|
import { timerify } from './Performance.js';
|
|
8
|
+
import { jiti } from './register.js';
|
|
7
9
|
const createRequire = (path) => nodeCreateRequire(pathToFileURL(path ?? cwd));
|
|
8
10
|
const require = createRequire();
|
|
9
|
-
const
|
|
11
|
+
export const _require = timerify(require);
|
|
12
|
+
const resolve = (specifier) => toPosix(jiti.resolve(specifier));
|
|
10
13
|
const tryResolve = (specifier, from) => {
|
|
11
14
|
try {
|
|
12
15
|
return resolve(specifier);
|
|
@@ -17,8 +20,8 @@ const tryResolve = (specifier, from) => {
|
|
|
17
20
|
};
|
|
18
21
|
const resolveSpecifier = (dir, specifier) => {
|
|
19
22
|
try {
|
|
20
|
-
const
|
|
21
|
-
return toPosix(
|
|
23
|
+
const jiti = createJITI(dir);
|
|
24
|
+
return toPosix(jiti.resolve(specifier));
|
|
22
25
|
}
|
|
23
26
|
catch {
|
|
24
27
|
const packageName = getPackageNameFromModuleSpecifier(specifier);
|
|
@@ -28,7 +31,6 @@ const resolveSpecifier = (dir, specifier) => {
|
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
};
|
|
31
|
-
export const _require = timerify(require);
|
|
32
34
|
export const _resolve = timerify(resolve);
|
|
33
35
|
export const _tryResolve = timerify(tryResolve);
|
|
34
36
|
export const _resolveSpecifier = timerify(resolveSpecifier);
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "2.
|
|
1
|
+
export declare const version = "2.41.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.
|
|
1
|
+
export const version = '2.41.0';
|
package/package.json
CHANGED
package/schema.json
CHANGED
|
@@ -384,6 +384,10 @@
|
|
|
384
384
|
"title": "tailwind plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/tailwind/README.md)",
|
|
385
385
|
"$ref": "#/definitions/plugin"
|
|
386
386
|
},
|
|
387
|
+
"tsup": {
|
|
388
|
+
"title": "tsup plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/tsup/README.md)",
|
|
389
|
+
"$ref": "#/definitions/plugin"
|
|
390
|
+
},
|
|
387
391
|
"typedoc": {
|
|
388
392
|
"title": "typedoc plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/typedoc/README.md)",
|
|
389
393
|
"$ref": "#/definitions/plugin"
|