knip 5.83.0 → 5.84.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/dist/ConfigurationChief.d.ts +24 -0
- package/dist/IssueCollector.d.ts +15 -2
- package/dist/IssueCollector.js +59 -9
- package/dist/ProjectPrincipal.d.ts +2 -1
- package/dist/ProjectPrincipal.js +2 -1
- package/dist/WorkspaceWorker.d.ts +4 -1
- package/dist/WorkspaceWorker.js +69 -13
- package/dist/binaries/bash-parser.d.ts +0 -1
- package/dist/binaries/bash-parser.js +2 -3
- package/dist/binaries/fallback.js +1 -1
- package/dist/binaries/package-manager/npm.js +1 -1
- package/dist/binaries/package-manager/pnpm.js +3 -2
- package/dist/binaries/package-manager/yarn.js +1 -1
- package/dist/binaries/plugins.js +1 -0
- package/dist/compilers/compilers.d.ts +3 -3
- package/dist/compilers/index.d.ts +45 -4
- package/dist/compilers/index.js +6 -20
- package/dist/compilers/scss.d.ts +2 -2
- package/dist/compilers/types.d.ts +6 -5
- package/dist/constants.js +1 -0
- package/dist/graph/analyze.js +11 -0
- package/dist/graph/build.js +29 -15
- package/dist/plugins/astro/compiler-mdx.d.ts +2 -0
- package/dist/{compilers/astro-mdx.js → plugins/astro/compiler-mdx.js} +2 -4
- package/dist/plugins/astro/compiler.d.ts +2 -0
- package/dist/{compilers/astro.js → plugins/astro/compiler.js} +2 -3
- package/dist/plugins/astro/index.js +10 -0
- package/dist/plugins/bun/index.js +14 -5
- package/dist/plugins/bun/types.d.ts +5 -0
- package/dist/plugins/bun/types.js +1 -0
- package/dist/plugins/c8/index.js +1 -1
- package/dist/plugins/convex/index.js +1 -1
- package/dist/plugins/dotenv/index.js +8 -1
- package/dist/plugins/execa/index.d.ts +3 -0
- package/dist/plugins/execa/index.js +15 -0
- package/dist/{typescript/visitors/scripts → plugins/execa/visitors}/execa.js +3 -3
- package/dist/plugins/index.d.ts +4 -0
- package/dist/plugins/index.js +8 -0
- package/dist/plugins/jest/index.js +2 -2
- package/dist/plugins/metro/index.js +8 -2
- package/dist/plugins/nx/index.js +1 -1
- package/dist/plugins/pm2/index.d.ts +3 -0
- package/dist/plugins/pm2/index.js +34 -0
- package/dist/plugins/pm2/types.d.ts +9 -0
- package/dist/plugins/pm2/types.js +1 -0
- package/dist/plugins/prettier/index.js +2 -0
- package/dist/plugins/prisma/compiler.d.ts +2 -0
- package/dist/{compilers/prisma.js → plugins/prisma/compiler.js} +1 -2
- package/dist/plugins/prisma/index.js +6 -0
- package/dist/plugins/react-native/index.d.ts +3 -0
- package/dist/plugins/react-native/index.js +38 -0
- package/dist/plugins/react-native/types.d.ts +7 -0
- package/dist/plugins/react-native/types.js +1 -0
- package/dist/plugins/svelte/compiler.d.ts +2 -0
- package/dist/plugins/svelte/compiler.js +3 -0
- package/dist/plugins/svelte/index.js +6 -0
- package/dist/plugins/tailwind/compiler.d.ts +2 -0
- package/dist/{compilers/tailwind.js → plugins/tailwind/compiler.js} +2 -3
- package/dist/plugins/tailwind/index.js +6 -0
- package/dist/plugins/typescript/index.js +2 -2
- package/dist/plugins/vite/helpers.d.ts +2 -0
- package/dist/plugins/vite/helpers.js +23 -0
- package/dist/plugins/vite/index.js +10 -1
- package/dist/plugins/vite/visitors/importMetaGlob.d.ts +2 -0
- package/dist/plugins/vite/visitors/importMetaGlob.js +32 -0
- package/dist/plugins/vitest/index.js +24 -9
- package/dist/plugins/vue/compiler.d.ts +2 -0
- package/dist/plugins/vue/compiler.js +3 -0
- package/dist/plugins/vue/index.js +6 -0
- package/dist/plugins/webpack/index.js +15 -6
- package/dist/plugins/webpack/visitors/requireContext.d.ts +2 -0
- package/dist/plugins/webpack/visitors/requireContext.js +29 -0
- package/dist/plugins/yarn/index.js +18 -0
- package/dist/plugins/zx/index.d.ts +3 -0
- package/dist/plugins/zx/index.js +15 -0
- package/dist/{typescript/visitors/scripts → plugins/zx/visitors}/zx.js +2 -2
- package/dist/reporters/util/configuration-hints.js +3 -0
- package/dist/reporters/util/util.js +2 -2
- package/dist/run.d.ts +1 -1
- package/dist/schema/configuration.d.ts +60 -0
- package/dist/schema/plugins.d.ts +20 -0
- package/dist/schema/plugins.js +4 -0
- package/dist/session/session.d.ts +1 -1
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +4 -0
- package/dist/types/config.d.ts +26 -4
- package/dist/types/issues.d.ts +1 -1
- package/dist/typescript/ast-helpers.d.ts +2 -0
- package/dist/typescript/ast-helpers.js +55 -6
- package/dist/typescript/get-imports-and-exports.d.ts +2 -2
- package/dist/typescript/get-imports-and-exports.js +5 -5
- package/dist/typescript/visitors/dynamic-imports/index.d.ts +2 -1
- package/dist/typescript/visitors/dynamic-imports/index.js +3 -2
- package/dist/typescript/visitors/dynamic-imports/moduleRegister.d.ts +3 -0
- package/dist/typescript/visitors/dynamic-imports/moduleRegister.js +25 -0
- package/dist/typescript/visitors/index.d.ts +2 -0
- package/dist/typescript/visitors/scripts/index.d.ts +2 -1
- package/dist/typescript/visitors/scripts/index.js +2 -4
- package/dist/util/cli-arguments.d.ts +1 -1
- package/dist/util/cli-arguments.js +5 -3
- package/dist/util/create-input-handler.js +8 -4
- package/dist/util/create-options.d.ts +40 -0
- package/dist/util/jiti.d.ts +1 -5
- package/dist/util/jiti.js +2 -7
- package/dist/util/loader.js +1 -1
- package/dist/util/modules.d.ts +1 -0
- package/dist/util/modules.js +1 -0
- package/dist/util/watch.d.ts +1 -1
- package/dist/util/watch.js +9 -2
- package/dist/util/workspace-selectors.d.ts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/schema.json +19 -0
- package/dist/compilers/astro-mdx.d.ts +0 -6
- package/dist/compilers/astro.d.ts +0 -6
- package/dist/compilers/prisma.d.ts +0 -6
- package/dist/compilers/svelte.d.ts +0 -6
- package/dist/compilers/svelte.js +0 -4
- package/dist/compilers/tailwind.d.ts +0 -6
- package/dist/compilers/vue.d.ts +0 -6
- package/dist/compilers/vue.js +0 -4
- /package/dist/{typescript/visitors/scripts → plugins/execa/visitors}/execa.d.ts +0 -0
- /package/dist/{typescript/visitors/scripts → plugins/zx/visitors}/zx.d.ts +0 -0
package/dist/compilers/index.js
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import Astro from './astro.js';
|
|
2
|
-
import AstroMDX from './astro-mdx.js';
|
|
3
1
|
import MDX from './mdx.js';
|
|
4
|
-
import Prisma from './prisma.js';
|
|
5
2
|
import SCSS from './scss.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import Vue from './vue.js';
|
|
9
|
-
const isAsync = (fn) => (fn ? fn.constructor.name === 'AsyncFunction' : false);
|
|
10
|
-
const normalizeExt = (ext) => ext.replace(/^\.*/, '.');
|
|
3
|
+
const isAsyncCompiler = (fn) => (fn ? fn.constructor.name === 'AsyncFunction' : false);
|
|
4
|
+
export const normalizeCompilerExtension = (ext) => ext.replace(/^\.*/, '.');
|
|
11
5
|
export const partitionCompilers = (rawLocalConfig) => {
|
|
12
6
|
const syncCompilers = {};
|
|
13
7
|
const asyncCompilers = {};
|
|
14
8
|
for (const extension in rawLocalConfig.compilers) {
|
|
15
|
-
const ext =
|
|
9
|
+
const ext = normalizeCompilerExtension(extension);
|
|
16
10
|
const compilerFn = rawLocalConfig.compilers[extension];
|
|
17
11
|
if (typeof compilerFn === 'function') {
|
|
18
|
-
if (!rawLocalConfig.asyncCompilers?.[ext] &&
|
|
12
|
+
if (!rawLocalConfig.asyncCompilers?.[ext] && isAsyncCompiler(compilerFn)) {
|
|
19
13
|
asyncCompilers[ext] = compilerFn;
|
|
20
14
|
}
|
|
21
15
|
else {
|
|
@@ -27,28 +21,20 @@ export const partitionCompilers = (rawLocalConfig) => {
|
|
|
27
21
|
}
|
|
28
22
|
}
|
|
29
23
|
for (const extension in rawLocalConfig.asyncCompilers) {
|
|
30
|
-
const ext =
|
|
24
|
+
const ext = normalizeCompilerExtension(extension);
|
|
31
25
|
asyncCompilers[ext] = rawLocalConfig.asyncCompilers[extension];
|
|
32
26
|
}
|
|
33
27
|
return { ...rawLocalConfig, syncCompilers, asyncCompilers };
|
|
34
28
|
};
|
|
35
29
|
const compilers = new Map([
|
|
36
|
-
['.astro', Astro],
|
|
37
|
-
['.css', CSS],
|
|
38
30
|
['.mdx', MDX],
|
|
39
|
-
['.prisma', Prisma],
|
|
40
31
|
['.sass', SCSS],
|
|
41
32
|
['.scss', SCSS],
|
|
42
|
-
['.svelte', Svelte],
|
|
43
|
-
['.vue', Vue],
|
|
44
33
|
]);
|
|
45
34
|
export const getIncludedCompilers = (syncCompilers, asyncCompilers, dependencies) => {
|
|
46
35
|
const hasDependency = (packageName) => dependencies.has(packageName);
|
|
47
36
|
for (const [extension, { condition, compiler }] of compilers) {
|
|
48
|
-
if (extension
|
|
49
|
-
syncCompilers.set(extension, AstroMDX.compiler);
|
|
50
|
-
}
|
|
51
|
-
else if ((!syncCompilers.has(extension) && condition(hasDependency)) || syncCompilers.get(extension) === true) {
|
|
37
|
+
if ((!syncCompilers.has(extension) && condition(hasDependency)) || syncCompilers.get(extension) === true) {
|
|
52
38
|
syncCompilers.set(extension, compiler);
|
|
53
39
|
}
|
|
54
40
|
}
|
package/dist/compilers/scss.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CompilerSync, HasDependency } from './types.js';
|
|
2
2
|
declare const _default: {
|
|
3
3
|
condition: (hasDependency: HasDependency) => boolean;
|
|
4
|
-
compiler:
|
|
4
|
+
compiler: CompilerSync;
|
|
5
5
|
};
|
|
6
6
|
export default _default;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
type FileExtension = string;
|
|
2
|
-
export type
|
|
3
|
-
export type
|
|
4
|
-
export type RawSyncCompilers = Map<FileExtension,
|
|
5
|
-
export type SyncCompilers = Map<FileExtension,
|
|
6
|
-
export type AsyncCompilers = Map<FileExtension,
|
|
2
|
+
export type CompilerSync = (source: string, path: string) => string;
|
|
3
|
+
export type CompilerAsync = (source: string, path: string) => Promise<string>;
|
|
4
|
+
export type RawSyncCompilers = Map<FileExtension, CompilerSync | true>;
|
|
5
|
+
export type SyncCompilers = Map<FileExtension, CompilerSync>;
|
|
6
|
+
export type AsyncCompilers = Map<FileExtension, CompilerAsync>;
|
|
7
|
+
export type Compilers = [SyncCompilers, AsyncCompilers];
|
|
7
8
|
export type HasDependency = (pkgName: string) => boolean;
|
|
8
9
|
export {};
|
package/dist/constants.js
CHANGED
package/dist/graph/analyze.js
CHANGED
|
@@ -11,9 +11,17 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
11
11
|
const isReferencedInUsedExport = (exportedItem, filePath, includeEntryExports) => {
|
|
12
12
|
if (!exportedItem.referencedIn)
|
|
13
13
|
return false;
|
|
14
|
+
const file = graph.get(filePath);
|
|
15
|
+
if (!file)
|
|
16
|
+
return false;
|
|
14
17
|
for (const containingExport of exportedItem.referencedIn) {
|
|
15
18
|
if (explorer.isReferenced(filePath, containingExport, { includeEntryExports })[0])
|
|
16
19
|
return true;
|
|
20
|
+
const inExport = file.exports.get(containingExport);
|
|
21
|
+
if (!inExport)
|
|
22
|
+
return false;
|
|
23
|
+
if (inExport.hasRefsInFile && (inExport.type === 'type' || inExport.type === 'interface'))
|
|
24
|
+
return true;
|
|
17
25
|
}
|
|
18
26
|
return false;
|
|
19
27
|
};
|
|
@@ -230,6 +238,9 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
230
238
|
for (const identifier of unusedIgnoredWorkspaces) {
|
|
231
239
|
collector.addConfigurationHint({ type: 'ignoreWorkspaces', identifier });
|
|
232
240
|
}
|
|
241
|
+
for (const hint of collector.getUnusedIgnorePatternHints(options)) {
|
|
242
|
+
collector.addConfigurationHint(hint);
|
|
243
|
+
}
|
|
233
244
|
for (const hint of chief.getConfigurationHints())
|
|
234
245
|
collector.addConfigurationHint(hint);
|
|
235
246
|
};
|
package/dist/graph/build.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { _getInputsFromScripts } from '../binaries/index.js';
|
|
2
|
-
import { getCompilerExtensions, getIncludedCompilers } from '../compilers/index.js';
|
|
2
|
+
import { getCompilerExtensions, getIncludedCompilers, normalizeCompilerExtension } from '../compilers/index.js';
|
|
3
3
|
import { DEFAULT_EXTENSIONS, FOREIGN_FILE_EXTENSIONS, IS_DTS } from '../constants.js';
|
|
4
4
|
import { partition } from '../util/array.js';
|
|
5
5
|
import { createInputHandler } from '../util/create-input-handler.js';
|
|
6
6
|
import { debugLog, debugLogArray } from '../util/debug.js';
|
|
7
|
-
import { _glob, _syncGlob, negate, prependDirToPattern } from '../util/glob.js';
|
|
7
|
+
import { _glob, _syncGlob, negate, prependDirToPattern as prependDir } from '../util/glob.js';
|
|
8
8
|
import { isAlias, isConfig, isDeferResolveEntry, isDeferResolveProductionEntry, isEntry, isIgnore, isProductionEntry, isProject, toProductionEntry, } from '../util/input.js';
|
|
9
9
|
import { loadTSConfig } from '../util/load-tsconfig.js';
|
|
10
10
|
import { createFileNode, updateImportMap } from '../util/module-graph.js';
|
|
@@ -39,8 +39,8 @@ export async function build({ chief, collector, counselor, deputy, factory, isGi
|
|
|
39
39
|
});
|
|
40
40
|
counselor.addWorkspace(manifest);
|
|
41
41
|
}
|
|
42
|
-
collector.addIgnorePatterns(chief.config.ignore.map(
|
|
43
|
-
collector.addIgnoreFilesPatterns(chief.config.ignoreFiles.map(
|
|
42
|
+
collector.addIgnorePatterns(chief.config.ignore.map(id => ({ pattern: prependDir(options.cwd, id), id })));
|
|
43
|
+
collector.addIgnoreFilesPatterns(chief.config.ignoreFiles.map(id => ({ pattern: prependDir(options.cwd, id), id })));
|
|
44
44
|
for (const workspace of workspaces) {
|
|
45
45
|
const { name, dir, ancestors, pkgName, manifestPath: filePath } = workspace;
|
|
46
46
|
streamer.cast('Analyzing workspace', name);
|
|
@@ -48,10 +48,7 @@ export async function build({ chief, collector, counselor, deputy, factory, isGi
|
|
|
48
48
|
if (!manifest)
|
|
49
49
|
continue;
|
|
50
50
|
const dependencies = deputy.getDependencies(name);
|
|
51
|
-
const
|
|
52
|
-
const extensions = getCompilerExtensions(compilers);
|
|
53
|
-
const extensionGlobStr = `.{${[...DEFAULT_EXTENSIONS, ...extensions].map(ext => ext.slice(1)).join(',')}}`;
|
|
54
|
-
const config = chief.getConfigForWorkspace(name, extensions);
|
|
51
|
+
const baseConfig = chief.getConfigForWorkspace(name);
|
|
55
52
|
const tsConfigFilePath = join(dir, options.tsConfigFile ?? 'tsconfig.json');
|
|
56
53
|
const { isFile, compilerOptions, fileNames } = await loadTSConfig(tsConfigFilePath);
|
|
57
54
|
const [definitionPaths, tscSourcePaths] = partition(fileNames, filePath => IS_DTS.test(filePath));
|
|
@@ -60,7 +57,7 @@ export async function build({ chief, collector, counselor, deputy, factory, isGi
|
|
|
60
57
|
const worker = new WorkspaceWorker({
|
|
61
58
|
name,
|
|
62
59
|
dir,
|
|
63
|
-
config,
|
|
60
|
+
config: baseConfig,
|
|
64
61
|
manifest,
|
|
65
62
|
dependencies,
|
|
66
63
|
rootManifest,
|
|
@@ -74,6 +71,18 @@ export async function build({ chief, collector, counselor, deputy, factory, isGi
|
|
|
74
71
|
options,
|
|
75
72
|
});
|
|
76
73
|
await worker.init();
|
|
74
|
+
const compilers = getIncludedCompilers(chief.config.syncCompilers, chief.config.asyncCompilers, dependencies);
|
|
75
|
+
const registerCompiler = async ({ extension, compiler }) => {
|
|
76
|
+
const ext = normalizeCompilerExtension(extension);
|
|
77
|
+
if (compilers[0].has(ext))
|
|
78
|
+
return;
|
|
79
|
+
compilers[0].set(ext, compiler);
|
|
80
|
+
};
|
|
81
|
+
await worker.registerCompilers(registerCompiler);
|
|
82
|
+
const extensions = getCompilerExtensions(compilers);
|
|
83
|
+
const extensionGlobStr = `.{${[...DEFAULT_EXTENSIONS, ...extensions].map(ext => ext.slice(1)).join(',')}}`;
|
|
84
|
+
const config = chief.getConfigForWorkspace(name, extensions);
|
|
85
|
+
worker.config = config;
|
|
77
86
|
const inputs = new Set();
|
|
78
87
|
if (definitionPaths.length > 0) {
|
|
79
88
|
debugLogArray(name, 'Definition paths', definitionPaths);
|
|
@@ -81,8 +90,9 @@ export async function build({ chief, collector, counselor, deputy, factory, isGi
|
|
|
81
90
|
inputs.add(toProductionEntry(id, { containingFilePath: tsConfigFilePath }));
|
|
82
91
|
}
|
|
83
92
|
const sharedGlobOptions = { cwd: options.cwd, dir, gitignore: options.gitignore };
|
|
84
|
-
|
|
85
|
-
collector.
|
|
93
|
+
const fn = (id) => ({ pattern: prependDir(options.cwd, prependDir(name, id)), id, workspaceName: name });
|
|
94
|
+
collector.addIgnorePatterns(config.ignore.map(fn));
|
|
95
|
+
collector.addIgnoreFilesPatterns(config.ignoreFiles.map(fn));
|
|
86
96
|
const entrySpecifiersFromManifest = getEntrySpecifiersFromManifest(manifest);
|
|
87
97
|
const label = 'entry paths from package.json';
|
|
88
98
|
for (const filePath of await toSourceFilePaths(entrySpecifiersFromManifest, dir, extensionGlobStr, label)) {
|
|
@@ -111,6 +121,12 @@ export async function build({ chief, collector, counselor, deputy, factory, isGi
|
|
|
111
121
|
for (const id of inputsFromPlugins)
|
|
112
122
|
inputs.add(Object.assign(id, { skipExportsAnalysis: !id.allowIncludeExports }));
|
|
113
123
|
enabledPluginsStore.set(name, worker.enabledPlugins);
|
|
124
|
+
worker.registerVisitors(visitors => {
|
|
125
|
+
if (visitors.dynamicImport)
|
|
126
|
+
principal.visitors.dynamicImport.push(...visitors.dynamicImport);
|
|
127
|
+
if (visitors.script)
|
|
128
|
+
principal.visitors.script.push(...visitors.script);
|
|
129
|
+
});
|
|
114
130
|
const DEFAULT_GROUP = 'default';
|
|
115
131
|
const createPatternMap = () => new Map([[DEFAULT_GROUP, new Set()]]);
|
|
116
132
|
const groups = new Set([DEFAULT_GROUP]);
|
|
@@ -284,11 +300,9 @@ export async function build({ chief, collector, counselor, deputy, factory, isGi
|
|
|
284
300
|
file.imports.external.add({ ...unresolvedImport, specifier: sanitizedSpecifier });
|
|
285
301
|
}
|
|
286
302
|
else {
|
|
287
|
-
|
|
288
|
-
if (!isIgnored) {
|
|
303
|
+
if (!isGitIgnored(join(dirname(filePath), sanitizedSpecifier))) {
|
|
289
304
|
const ext = extname(sanitizedSpecifier);
|
|
290
|
-
|
|
291
|
-
if (!ext || (ext !== '.json' && !hasIgnoredExtension))
|
|
305
|
+
if (!ext || (ext !== '.json' && !FOREIGN_FILE_EXTENSIONS.has(ext)))
|
|
292
306
|
unresolvedImports.add(unresolvedImport);
|
|
293
307
|
}
|
|
294
308
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { fencedCodeBlockMatcher, importMatcher, importsWithinFrontmatter, inlineCodeMatcher } from '
|
|
2
|
-
const astroMDXDependencies = ['@astrojs/mdx', '@astrojs/starlight'];
|
|
1
|
+
import { fencedCodeBlockMatcher, importMatcher, importsWithinFrontmatter, inlineCodeMatcher, } from '../../compilers/compilers.js';
|
|
3
2
|
const frontmatterImportFields = ['layout'];
|
|
4
|
-
const condition = (hasDependency) => astroMDXDependencies.some(hasDependency);
|
|
5
3
|
const compiler = (text) => {
|
|
6
4
|
const imports = text.replace(fencedCodeBlockMatcher, '').replace(inlineCodeMatcher, '').matchAll(importMatcher);
|
|
7
5
|
const frontmatterImports = importsWithinFrontmatter(text, frontmatterImportFields);
|
|
8
6
|
return [...imports, frontmatterImports].join('\n');
|
|
9
7
|
};
|
|
10
|
-
export default
|
|
8
|
+
export default compiler;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { frontmatterMatcher, scriptBodies } from '
|
|
2
|
-
const condition = (hasDependency) => hasDependency('astro');
|
|
1
|
+
import { frontmatterMatcher, scriptBodies } from '../../compilers/compilers.js';
|
|
3
2
|
const compiler = (text, path) => {
|
|
4
3
|
const scripts = [];
|
|
5
4
|
const frontmatter = text.match(frontmatterMatcher);
|
|
@@ -10,4 +9,4 @@ const compiler = (text, path) => {
|
|
|
10
9
|
scripts.push(scriptContent);
|
|
11
10
|
return scripts.join('\n');
|
|
12
11
|
};
|
|
13
|
-
export default
|
|
12
|
+
export default compiler;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { toDependency, toEntry, toProductionEntry } from '../../util/input.js';
|
|
2
2
|
import { hasDependency } from '../../util/plugin.js';
|
|
3
|
+
import compiler from './compiler.js';
|
|
4
|
+
import mdxCompiler from './compiler-mdx.js';
|
|
3
5
|
import { getSrcDir } from './resolveFromAST.js';
|
|
4
6
|
const title = 'Astro';
|
|
5
7
|
const enablers = ['astro'];
|
|
@@ -22,6 +24,13 @@ const resolveFromAST = sourceFile => {
|
|
|
22
24
|
...production.map(setSrcDir).map(path => toProductionEntry(path)),
|
|
23
25
|
];
|
|
24
26
|
};
|
|
27
|
+
const registerCompilers = ({ registerCompiler, hasDependency }) => {
|
|
28
|
+
if (hasDependency('astro'))
|
|
29
|
+
registerCompiler({ extension: '.astro', compiler });
|
|
30
|
+
if (hasDependency('@astrojs/mdx') || hasDependency('@astrojs/starlight')) {
|
|
31
|
+
registerCompiler({ extension: '.mdx', compiler: mdxCompiler });
|
|
32
|
+
}
|
|
33
|
+
};
|
|
25
34
|
const resolve = options => {
|
|
26
35
|
const { manifest, isProduction } = options;
|
|
27
36
|
const inputs = [];
|
|
@@ -39,6 +48,7 @@ const plugin = {
|
|
|
39
48
|
config,
|
|
40
49
|
entry,
|
|
41
50
|
production,
|
|
51
|
+
registerCompilers,
|
|
42
52
|
resolveFromAST,
|
|
43
53
|
resolve,
|
|
44
54
|
};
|
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import parseArgs from 'minimist';
|
|
2
|
-
import { toEntry } from '../../util/input.js';
|
|
2
|
+
import { toDeferResolve, toEntry } from '../../util/input.js';
|
|
3
3
|
const title = 'Bun';
|
|
4
4
|
const enablers = ['bun'];
|
|
5
5
|
const hasBunTest = (scripts) => scripts && Object.values(scripts).some(script => /(?<=^|\s)bun test/.test(script));
|
|
6
6
|
const isEnabled = ({ manifest }) => !!hasBunTest(manifest.scripts);
|
|
7
|
+
const config = ['bunfig.toml'];
|
|
7
8
|
const patterns = ['**/*.{test,spec}.{js,jsx,ts,tsx}', '**/*_{test,spec}.{js,jsx,ts,tsx}'];
|
|
9
|
+
const resolveConfig = localConfig => {
|
|
10
|
+
const preload = localConfig.test?.preload ?? [];
|
|
11
|
+
return preload.map(specifier => toDeferResolve(specifier));
|
|
12
|
+
};
|
|
8
13
|
const resolve = options => {
|
|
9
14
|
const scripts = { ...options.rootManifest?.scripts, ...options.manifest.scripts };
|
|
10
15
|
for (const script of Object.values(scripts)) {
|
|
11
16
|
if (/(?<=^|\s)bun test/.test(script)) {
|
|
12
|
-
const parsed = parseArgs(script.split(' '));
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
const parsed = parseArgs(script.split(' '), { string: ['timeout', 'rerun-each', 'preload'] });
|
|
18
|
+
const args = parsed._.filter(id => id !== 'bun' && id !== 'test');
|
|
19
|
+
const inputs = (args.length === 0 ? patterns : args).map(toEntry);
|
|
20
|
+
for (const specifier of [parsed.preload ?? []].flat())
|
|
21
|
+
inputs.push(toDeferResolve(specifier));
|
|
22
|
+
return inputs;
|
|
16
23
|
}
|
|
17
24
|
}
|
|
18
25
|
return [];
|
|
@@ -21,6 +28,8 @@ const plugin = {
|
|
|
21
28
|
title,
|
|
22
29
|
enablers,
|
|
23
30
|
isEnabled,
|
|
31
|
+
config,
|
|
24
32
|
resolve,
|
|
33
|
+
resolveConfig,
|
|
25
34
|
};
|
|
26
35
|
export default plugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/plugins/c8/index.js
CHANGED
|
@@ -3,7 +3,7 @@ const title = 'c8';
|
|
|
3
3
|
const args = {
|
|
4
4
|
args: (args) => args.filter(arg => arg !== 'check-coverage'),
|
|
5
5
|
boolean: ['all', 'check-coverage', 'clean', 'exclude-after-remap', 'per-file', 'skip-full'],
|
|
6
|
-
fromArgs: (parsed, args) => argsFrom(args, parsed._[0]),
|
|
6
|
+
fromArgs: (parsed, args) => (parsed._[0] ? argsFrom(args, parsed._[0]) : (parsed['--'] ?? [])),
|
|
7
7
|
};
|
|
8
8
|
const plugin = {
|
|
9
9
|
title,
|
|
@@ -2,7 +2,7 @@ import { hasDependency } from '../../util/plugin.js';
|
|
|
2
2
|
const title = 'Convex';
|
|
3
3
|
const enablers = ['convex'];
|
|
4
4
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
5
|
-
const entry = ['convex/*.config.@(js|ts)', 'convex
|
|
5
|
+
const entry = ['convex/*.config.@(js|ts)', 'convex/**/_generated/*.@(js|ts)'];
|
|
6
6
|
const plugin = {
|
|
7
7
|
title,
|
|
8
8
|
enablers,
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { argsFrom } from '../../binaries/util.js';
|
|
2
2
|
const title = 'dotenv';
|
|
3
3
|
const args = {
|
|
4
|
-
fromArgs: (parsed, args) =>
|
|
4
|
+
fromArgs: (parsed, args) => {
|
|
5
|
+
if (parsed._[0])
|
|
6
|
+
return argsFrom(args, parsed._[0]);
|
|
7
|
+
if (!parsed['--'] || parsed['--'].length === 0)
|
|
8
|
+
return [];
|
|
9
|
+
const script = parsed['--'].map(arg => (arg.includes(' ') ? `"${arg}"` : arg)).join(' ');
|
|
10
|
+
return [script];
|
|
11
|
+
},
|
|
5
12
|
};
|
|
6
13
|
const plugin = {
|
|
7
14
|
title,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
2
|
+
import execaVisitor from './visitors/execa.js';
|
|
3
|
+
const title = 'execa';
|
|
4
|
+
const enablers = ['execa'];
|
|
5
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
+
const registerVisitors = ({ registerVisitors }) => {
|
|
7
|
+
registerVisitors({ script: [execaVisitor] });
|
|
8
|
+
};
|
|
9
|
+
const plugin = {
|
|
10
|
+
title,
|
|
11
|
+
enablers,
|
|
12
|
+
isEnabled,
|
|
13
|
+
registerVisitors,
|
|
14
|
+
};
|
|
15
|
+
export default plugin;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import { stripQuotes } from '
|
|
3
|
-
import { hasImportSpecifier } from '
|
|
4
|
-
import { scriptVisitor as visit } from '
|
|
2
|
+
import { stripQuotes } from '../../../typescript/ast-helpers.js';
|
|
3
|
+
import { hasImportSpecifier } from '../../../typescript/visitors/helpers.js';
|
|
4
|
+
import { scriptVisitor as visit } from '../../../typescript/visitors/index.js';
|
|
5
5
|
const tags = new Set(['$', '$sync']);
|
|
6
6
|
const methods = new Set(['execa', 'execaSync', 'execaCommand', 'execaCommandSync', '$sync']);
|
|
7
7
|
export default visit(sourceFile => sourceFile.statements.some(node => hasImportSpecifier(node, 'execa')), node => {
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export declare const Plugins: {
|
|
|
27
27
|
drizzle: import("../types/config.js").Plugin;
|
|
28
28
|
eleventy: import("../types/config.js").Plugin;
|
|
29
29
|
eslint: import("../types/config.js").Plugin;
|
|
30
|
+
execa: import("../types/config.js").Plugin;
|
|
30
31
|
expo: import("../types/config.js").Plugin;
|
|
31
32
|
'expressive-code': {
|
|
32
33
|
title: string;
|
|
@@ -79,12 +80,14 @@ export declare const Plugins: {
|
|
|
79
80
|
'playwright-ct': import("../types/config.js").Plugin;
|
|
80
81
|
'playwright-test': import("../types/config.js").Plugin;
|
|
81
82
|
plop: import("../types/config.js").Plugin;
|
|
83
|
+
pm2: import("../types/config.js").Plugin;
|
|
82
84
|
pnpm: import("../types/config.js").Plugin;
|
|
83
85
|
postcss: import("../types/config.js").Plugin;
|
|
84
86
|
preconstruct: import("../types/config.js").Plugin;
|
|
85
87
|
prettier: import("../types/config.js").Plugin;
|
|
86
88
|
prisma: import("../types/config.js").Plugin;
|
|
87
89
|
'react-cosmos': import("../types/config.js").Plugin;
|
|
90
|
+
'react-native': import("../types/config.js").Plugin;
|
|
88
91
|
'react-router': import("../types/config.js").Plugin;
|
|
89
92
|
relay: import("../types/config.js").Plugin;
|
|
90
93
|
'release-it': import("../types/config.js").Plugin;
|
|
@@ -135,4 +138,5 @@ export declare const Plugins: {
|
|
|
135
138
|
xo: import("../types/config.js").Plugin;
|
|
136
139
|
yarn: import("../types/config.js").Plugin;
|
|
137
140
|
yorkie: import("../types/config.js").Plugin;
|
|
141
|
+
zx: import("../types/config.js").Plugin;
|
|
138
142
|
};
|
package/dist/plugins/index.js
CHANGED
|
@@ -26,6 +26,7 @@ import { default as dotenv } from './dotenv/index.js';
|
|
|
26
26
|
import { default as drizzle } from './drizzle/index.js';
|
|
27
27
|
import { default as eleventy } from './eleventy/index.js';
|
|
28
28
|
import { default as eslint } from './eslint/index.js';
|
|
29
|
+
import { default as execa } from './execa/index.js';
|
|
29
30
|
import { default as expo } from './expo/index.js';
|
|
30
31
|
import { default as expressiveCode } from './expressive-code/index.js';
|
|
31
32
|
import { default as gatsby } from './gatsby/index.js';
|
|
@@ -73,12 +74,14 @@ import { default as playwright } from './playwright/index.js';
|
|
|
73
74
|
import { default as playwrightCt } from './playwright-ct/index.js';
|
|
74
75
|
import { default as playwrightTest } from './playwright-test/index.js';
|
|
75
76
|
import { default as plop } from './plop/index.js';
|
|
77
|
+
import { default as pm2 } from './pm2/index.js';
|
|
76
78
|
import { default as pnpm } from './pnpm/index.js';
|
|
77
79
|
import { default as postcss } from './postcss/index.js';
|
|
78
80
|
import { default as preconstruct } from './preconstruct/index.js';
|
|
79
81
|
import { default as prettier } from './prettier/index.js';
|
|
80
82
|
import { default as prisma } from './prisma/index.js';
|
|
81
83
|
import { default as reactCosmos } from './react-cosmos/index.js';
|
|
84
|
+
import { default as reactNative } from './react-native/index.js';
|
|
82
85
|
import { default as reactRouter } from './react-router/index.js';
|
|
83
86
|
import { default as relay } from './relay/index.js';
|
|
84
87
|
import { default as releaseIt } from './release-it/index.js';
|
|
@@ -129,6 +132,7 @@ import { default as wrangler } from './wrangler/index.js';
|
|
|
129
132
|
import { default as xo } from './xo/index.js';
|
|
130
133
|
import { default as yarn } from './yarn/index.js';
|
|
131
134
|
import { default as yorkie } from './yorkie/index.js';
|
|
135
|
+
import { default as zx } from './zx/index.js';
|
|
132
136
|
export const Plugins = {
|
|
133
137
|
angular,
|
|
134
138
|
astro,
|
|
@@ -158,6 +162,7 @@ export const Plugins = {
|
|
|
158
162
|
drizzle,
|
|
159
163
|
eleventy,
|
|
160
164
|
eslint,
|
|
165
|
+
execa,
|
|
161
166
|
expo,
|
|
162
167
|
'expressive-code': expressiveCode,
|
|
163
168
|
gatsby,
|
|
@@ -205,12 +210,14 @@ export const Plugins = {
|
|
|
205
210
|
'playwright-ct': playwrightCt,
|
|
206
211
|
'playwright-test': playwrightTest,
|
|
207
212
|
plop,
|
|
213
|
+
pm2,
|
|
208
214
|
pnpm,
|
|
209
215
|
postcss,
|
|
210
216
|
preconstruct,
|
|
211
217
|
prettier,
|
|
212
218
|
prisma,
|
|
213
219
|
'react-cosmos': reactCosmos,
|
|
220
|
+
'react-native': reactNative,
|
|
214
221
|
'react-router': reactRouter,
|
|
215
222
|
relay,
|
|
216
223
|
'release-it': releaseIt,
|
|
@@ -261,4 +268,5 @@ export const Plugins = {
|
|
|
261
268
|
xo,
|
|
262
269
|
yarn,
|
|
263
270
|
yorkie,
|
|
271
|
+
zx,
|
|
264
272
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { toDeferResolve, toEntry } from '../../util/input.js';
|
|
2
|
-
import { isInternal, join, toAbsolute } from '../../util/path.js';
|
|
2
|
+
import { isInternal, join, normalize, toAbsolute } from '../../util/path.js';
|
|
3
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
4
|
import { getReportersDependencies, resolveExtensibleConfig } from './helpers.js';
|
|
5
5
|
const title = 'Jest';
|
|
@@ -88,7 +88,7 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
88
88
|
if (localConfig.testMatch && !options.config.entry)
|
|
89
89
|
entries.push(...mocks.map(id => toEntry(id)));
|
|
90
90
|
const result = inputs.map(dependency => {
|
|
91
|
-
dependency.specifier = replaceRootDir(dependency.specifier);
|
|
91
|
+
dependency.specifier = normalize(replaceRootDir(dependency.specifier));
|
|
92
92
|
return dependency;
|
|
93
93
|
});
|
|
94
94
|
return entries.concat(result);
|
|
@@ -3,12 +3,14 @@ import { toDeferResolve, toProductionEntry } from '../../util/input.js';
|
|
|
3
3
|
import { join } from '../../util/path.js';
|
|
4
4
|
import { hasDependency } from '../../util/plugin.js';
|
|
5
5
|
const title = 'Metro';
|
|
6
|
-
const enablers = ['metro', 'react-native'];
|
|
6
|
+
const enablers = ['metro', '@react-native/metro-config'];
|
|
7
7
|
const isEnabled = options => hasDependency(options.dependencies, enablers);
|
|
8
8
|
const config = ['metro.config.{js,cjs,json}', 'package.json'];
|
|
9
9
|
const DEFAULT_PLATFORMS = ['ios', 'android', 'windows', 'web'];
|
|
10
10
|
const PLATFORMS = [...DEFAULT_PLATFORMS, 'native', 'default'];
|
|
11
11
|
const DEFAULT_EXTENSIONS = ['js', 'jsx', 'json', 'ts', 'tsx'];
|
|
12
|
+
const DEFAULT_TRANSFORMER_PACKAGE = 'metro-transform-worker';
|
|
13
|
+
const DEFAULT_MINIFIER_PACKAGE = 'metro-minify-terser';
|
|
12
14
|
const production = [`src/**/*.{${PLATFORMS.join(',')}}.{${DEFAULT_EXTENSIONS.join(',')}}`];
|
|
13
15
|
const resolveConfig = async (config) => {
|
|
14
16
|
const { transformerPath, transformer } = config;
|
|
@@ -35,8 +37,11 @@ const resolveConfig = async (config) => {
|
|
|
35
37
|
inputs.push(transformer.minifierPath);
|
|
36
38
|
if (transformer?.babelTransformerPath)
|
|
37
39
|
inputs.push(transformer.babelTransformerPath);
|
|
38
|
-
return Array.from(i).concat([...inputs].map(id => toDeferResolve(id
|
|
40
|
+
return Array.from(i).concat([...inputs].map(id => toDeferResolve(id, {
|
|
41
|
+
optional: id === DEFAULT_TRANSFORMER_PACKAGE || id === DEFAULT_MINIFIER_PACKAGE,
|
|
42
|
+
})));
|
|
39
43
|
};
|
|
44
|
+
const isFilterTransitiveDependencies = true;
|
|
40
45
|
const note = `False positives for platform-specific unused files?
|
|
41
46
|
Override the default \`entry\` patterns to match platforms and extensions.`;
|
|
42
47
|
export const docs = { note };
|
|
@@ -47,5 +52,6 @@ const plugin = {
|
|
|
47
52
|
config,
|
|
48
53
|
production,
|
|
49
54
|
resolveConfig,
|
|
55
|
+
isFilterTransitiveDependencies,
|
|
50
56
|
};
|
|
51
57
|
export default plugin;
|
package/dist/plugins/nx/index.js
CHANGED
|
@@ -71,7 +71,7 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
71
71
|
return compact([...executors, ...inputs, ...configInputs]).map(id => typeof id === 'string' ? toDependency(id) : id);
|
|
72
72
|
};
|
|
73
73
|
const args = {
|
|
74
|
-
fromArgs: (parsed) => (parsed._[0] === 'exec' ? parsed._.slice(1) : []),
|
|
74
|
+
fromArgs: (parsed) => (parsed._[0] === 'exec' ? [...parsed._.slice(1), ...(parsed['--'] ?? [])] : []),
|
|
75
75
|
};
|
|
76
76
|
export const docs = {
|
|
77
77
|
note: `Also see [integrated monorepos](/features/integrated-monorepos) and the note regarding internal workspace dependencies.`,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { toEntry } from '../../util/input.js';
|
|
2
|
+
import { isInternal } from '../../util/path.js';
|
|
3
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
4
|
+
const title = 'pm2';
|
|
5
|
+
const enablers = ['pm2'];
|
|
6
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
7
|
+
const config = ['pm2.config.{json,js,cjs,mjs}', 'ecosystem.config.{json,js,cjs,mjs}'];
|
|
8
|
+
const addApplicationEntry = (application, entries) => {
|
|
9
|
+
if (application.script && isInternal(application.script))
|
|
10
|
+
entries.push(toEntry(application.script));
|
|
11
|
+
};
|
|
12
|
+
const resolveConfig = config => {
|
|
13
|
+
const entries = [];
|
|
14
|
+
if (Array.isArray(config)) {
|
|
15
|
+
for (const application of config)
|
|
16
|
+
addApplicationEntry(application, entries);
|
|
17
|
+
return entries;
|
|
18
|
+
}
|
|
19
|
+
addApplicationEntry(config, entries);
|
|
20
|
+
if (!config.apps)
|
|
21
|
+
return entries;
|
|
22
|
+
const applications = Array.isArray(config.apps) ? config.apps : [config.apps];
|
|
23
|
+
for (const application of applications)
|
|
24
|
+
addApplicationEntry(application, entries);
|
|
25
|
+
return entries;
|
|
26
|
+
};
|
|
27
|
+
const plugin = {
|
|
28
|
+
title,
|
|
29
|
+
enablers,
|
|
30
|
+
isEnabled,
|
|
31
|
+
config,
|
|
32
|
+
resolveConfig,
|
|
33
|
+
};
|
|
34
|
+
export default plugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -16,11 +16,13 @@ const resolveConfig = config => {
|
|
|
16
16
|
? config.plugins.filter((plugin) => typeof plugin === 'string').map(id => toDependency(id))
|
|
17
17
|
: [];
|
|
18
18
|
};
|
|
19
|
+
const isFilterTransitiveDependencies = true;
|
|
19
20
|
const plugin = {
|
|
20
21
|
title,
|
|
21
22
|
enablers,
|
|
22
23
|
isEnabled,
|
|
23
24
|
config,
|
|
24
25
|
resolveConfig,
|
|
26
|
+
isFilterTransitiveDependencies,
|
|
25
27
|
};
|
|
26
28
|
export default plugin;
|