knip 6.20.0 → 6.21.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/plugins/next/index.js +16 -4
- package/dist/plugins/vitest/index.js +13 -0
- package/dist/plugins/vitest/types.d.ts +4 -0
- package/dist/plugins.js +1 -1
- package/dist/util/modules.js +2 -1
- package/dist/util/package-json.js +2 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { toProductionEntry } from '../../util/input.js';
|
|
1
|
+
import { toConfig, toProductionEntry } from '../../util/input.js';
|
|
2
|
+
import { join } from '../../util/path.js';
|
|
2
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
3
4
|
import { getPageExtensions } from './resolveFromAST.js';
|
|
4
5
|
const title = 'Next.js';
|
|
@@ -23,11 +24,21 @@ const getEntryFilePatterns = (pageExtensions = defaultPageExtensions) => {
|
|
|
23
24
|
].flatMap(pattern => [pattern, `src/${pattern}`]);
|
|
24
25
|
};
|
|
25
26
|
const production = getEntryFilePatterns();
|
|
26
|
-
const resolveFromAST = program => {
|
|
27
|
+
const resolveFromAST = (program, { configFileDir }) => {
|
|
27
28
|
const pageExtensions = getPageExtensions(program);
|
|
28
29
|
const extensions = pageExtensions.length > 0 ? pageExtensions : defaultPageExtensions;
|
|
29
|
-
const patterns = getEntryFilePatterns(extensions);
|
|
30
|
-
return patterns.map(id => toProductionEntry(id));
|
|
30
|
+
const patterns = [...getEntryFilePatterns(extensions), 'next-env.d.ts'];
|
|
31
|
+
return patterns.map(id => toProductionEntry(join(configFileDir, id)));
|
|
32
|
+
};
|
|
33
|
+
const commands = new Set(['dev', 'build', 'start']);
|
|
34
|
+
const args = {
|
|
35
|
+
boolean: ['turbo', 'turbopack'],
|
|
36
|
+
resolveInputs: parsed => {
|
|
37
|
+
const dir = commands.has(parsed._[0]) ? parsed._[1] : undefined;
|
|
38
|
+
if (!dir)
|
|
39
|
+
return [];
|
|
40
|
+
return [toConfig('next', join(dir, 'next.config'))];
|
|
41
|
+
},
|
|
31
42
|
};
|
|
32
43
|
const plugin = {
|
|
33
44
|
title,
|
|
@@ -36,5 +47,6 @@ const plugin = {
|
|
|
36
47
|
config,
|
|
37
48
|
production,
|
|
38
49
|
resolveFromAST,
|
|
50
|
+
args,
|
|
39
51
|
};
|
|
40
52
|
export default plugin;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DEFAULT_EXTENSIONS } from '../../constants.js';
|
|
2
2
|
import { _glob } from '../../util/glob.js';
|
|
3
3
|
import { toConfig, toDeferResolve, toDependency, toEntry } from '../../util/input.js';
|
|
4
|
+
import { getPackageNameFromModuleSpecifier } from '../../util/modules.js';
|
|
4
5
|
import { isAbsolute, isInternal, join, toAbsolute } from '../../util/path.js';
|
|
5
6
|
import { hasDependency } from '../../util/plugin.js';
|
|
6
7
|
import { getIndexHtmlEntries } from '../vite/helpers.js';
|
|
@@ -53,6 +54,11 @@ const findConfigDependencies = (localConfig, options, vitestRoot) => {
|
|
|
53
54
|
...projectsDependencies,
|
|
54
55
|
];
|
|
55
56
|
};
|
|
57
|
+
const getOptimizeDepsIncludePackageName = (specifier) => {
|
|
58
|
+
const separatorIndex = specifier.indexOf('>');
|
|
59
|
+
const id = (separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex)).trim();
|
|
60
|
+
return getPackageNameFromModuleSpecifier(id);
|
|
61
|
+
};
|
|
56
62
|
const getConfigs = async (localConfig) => {
|
|
57
63
|
const configs = [];
|
|
58
64
|
for (const config of [localConfig].flat()) {
|
|
@@ -136,6 +142,13 @@ export const resolveConfig = async (localConfig, options) => {
|
|
|
136
142
|
}
|
|
137
143
|
if (cfg.resolve?.alias)
|
|
138
144
|
addAliases(cfg.resolve.alias);
|
|
145
|
+
for (const dependency of cfg.resolve?.dedupe ?? [])
|
|
146
|
+
inputs.add(toDependency(dependency));
|
|
147
|
+
for (const dependency of cfg.optimizeDeps?.include ?? []) {
|
|
148
|
+
const packageName = getOptimizeDepsIncludePackageName(dependency);
|
|
149
|
+
if (packageName)
|
|
150
|
+
inputs.add(toDependency(packageName));
|
|
151
|
+
}
|
|
139
152
|
if (cfg.resolve?.extensions) {
|
|
140
153
|
const customExtensions = cfg.resolve.extensions.filter(ext => ext.startsWith('.') && !DEFAULT_EXTENSIONS.has(ext));
|
|
141
154
|
for (const ext of customExtensions) {
|
package/dist/plugins.js
CHANGED
|
@@ -4,7 +4,7 @@ import { timerify } from './util/Performance.js';
|
|
|
4
4
|
const PMap = Plugins;
|
|
5
5
|
const { values } = parseArgs({ strict: false, options: { performance: { type: 'boolean' } } });
|
|
6
6
|
const isEnabled = !!values.performance;
|
|
7
|
-
const timerifyMethods = ['resolve', 'resolveConfig', '
|
|
7
|
+
const timerifyMethods = ['resolve', 'resolveConfig', 'resolveFromAST'];
|
|
8
8
|
const PluginEntries = Object.entries(PMap);
|
|
9
9
|
if (isEnabled) {
|
|
10
10
|
for (const [, plugin] of PluginEntries) {
|
package/dist/util/modules.js
CHANGED
|
@@ -68,6 +68,7 @@ export const sanitizeSpecifier = (specifier) => {
|
|
|
68
68
|
specifier.startsWith(PROTOCOL_VIRTUAL)) {
|
|
69
69
|
return specifier;
|
|
70
70
|
}
|
|
71
|
+
const isSubpathImport = specifier.charCodeAt(0) === CHAR_HASH;
|
|
71
72
|
const len = specifier.length;
|
|
72
73
|
let start = 0;
|
|
73
74
|
let end = len;
|
|
@@ -82,7 +83,7 @@ export const sanitizeSpecifier = (specifier) => {
|
|
|
82
83
|
if (ch === CHAR_SLASH && colon === -1) {
|
|
83
84
|
hasSlash = true;
|
|
84
85
|
}
|
|
85
|
-
if (colon === -1 && ch === CHAR_COLON && !hasSlash) {
|
|
86
|
+
if (colon === -1 && ch === CHAR_COLON && !hasSlash && !isSubpathImport) {
|
|
86
87
|
colon = i;
|
|
87
88
|
}
|
|
88
89
|
if (ch === CHAR_EXCLAMATION || ch === CHAR_QUESTION || (ch === CHAR_HASH && i > start)) {
|
|
@@ -26,7 +26,8 @@ const getEntriesFromExports = (obj) => {
|
|
|
26
26
|
values.push(obj[prop]);
|
|
27
27
|
}
|
|
28
28
|
else if (obj[prop] === null) {
|
|
29
|
-
|
|
29
|
+
if (prop !== '.')
|
|
30
|
+
values.push(`!${prop}`);
|
|
30
31
|
}
|
|
31
32
|
else if (typeof obj[prop] === 'object') {
|
|
32
33
|
values = values.concat(getEntriesFromExports(obj[prop]));
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.
|
|
1
|
+
export declare const version = "6.21.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '6.
|
|
1
|
+
export const version = '6.21.0';
|