knip 6.46.0 → 6.46.1

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.
@@ -4,7 +4,7 @@ const title = 'astro-og-canvas';
4
4
  const enablers = ['astro-og-canvas'];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
6
  const resolve = async () => {
7
- return [toDependency('canvaskit-wasm', { optional: true })];
7
+ return [toDependency('canvaskit-wasm', { production: true, optional: true })];
8
8
  };
9
9
  const plugin = {
10
10
  title,
@@ -37,7 +37,7 @@ const resolveConfig = async (config, { configFileDir, cwd, manifest }) => {
37
37
  }
38
38
  }
39
39
  }
40
- return [...plugins, ...platforms.map(platform => `@capacitor/${platform}`)].map(id => toDependency(id));
40
+ return [...plugins, ...platforms.map(platform => `@capacitor/${platform}`)].map(id => toDependency(id, { production: true }));
41
41
  };
42
42
  const plugin = {
43
43
  title,
@@ -64,7 +64,7 @@ const resolveArrayConfig = ([name, config], type, cwd) => {
64
64
  const sidebar = sidebarPath ? [toEntryPath(sidebarPath, { production: true, dir: cwd })] : [];
65
65
  if (isLocalPath(name))
66
66
  return [toEntryPath(toAbsolute(name, cwd), { production: true }), ...sidebar];
67
- return [toDependency(resolveModuleName(name, type)), ...sidebar];
67
+ return [toDependency(resolveModuleName(name, type), { production: type !== 'plugin' }), ...sidebar];
68
68
  };
69
69
  export const resolveConfigItems = async (items, type, options) => {
70
70
  const inputs = new Set();
@@ -77,7 +77,7 @@ export const resolveConfigItems = async (items, type, options) => {
77
77
  if (isLocalPath(item))
78
78
  inputs.add(toEntryPath(toAbsolute(item, options.cwd), { production: true }));
79
79
  else
80
- inputs.add(toDependency(resolveModuleName(item, type)));
80
+ inputs.add(toDependency(resolveModuleName(item, type), { production: type !== 'plugin' }));
81
81
  }
82
82
  else if (Array.isArray(item)) {
83
83
  for (const input of resolveArrayConfig(item, type, options.cwd))
@@ -22,7 +22,7 @@ const resolveConfig = async (localConfig) => {
22
22
  .map(id => toEntry(id, { production: true }))
23
23
  .concat([
24
24
  ...(localConfig?.plugins?.map(plugin => plugin.package) ?? []).map(toPluginInput),
25
- ...extractFunctionsConfigProperty(localConfig.functions || {}, 'external_node_modules').map(id => toDependency(id)),
25
+ ...extractFunctionsConfigProperty(localConfig.functions || {}, 'external_node_modules').map(id => toDependency(id, { production: true })),
26
26
  ]);
27
27
  };
28
28
  const plugin = {
@@ -9,7 +9,9 @@ const resolveConfig = async (config) => {
9
9
  if (!config)
10
10
  return [];
11
11
  const inputs = production.map(id => toEntry(id, { production: true }));
12
- for (const id of [...(config.plugins ?? []), ...(config.devPlugins ?? [])])
12
+ for (const id of config.plugins ?? [])
13
+ inputs.push(toDependency(id, { production: true }));
14
+ for (const id of config.devPlugins ?? [])
13
15
  inputs.push(toDependency(id));
14
16
  return inputs;
15
17
  };
@@ -53,14 +53,14 @@ export const resolveFromAST = (program, options) => {
53
53
  if (!id)
54
54
  continue;
55
55
  if (id.startsWith('~'))
56
- inputs.push(toDependency(id.slice(1)));
56
+ inputs.push(toDependency(id.slice(1), { production: true }));
57
57
  else
58
58
  inputs.push(toEntryPath(join(configFileDir, 'src/boot', id), { production: true }));
59
59
  }
60
60
  }
61
61
  for (const id of getStringValues(findProperty(config, 'css'))) {
62
62
  if (id.startsWith('~'))
63
- inputs.push(toDependency(id.slice(1)));
63
+ inputs.push(toDependency(id.slice(1), { production: true }));
64
64
  else
65
65
  inputs.push(toEntryPath(join(configFileDir, 'src/css', id), { production: true }));
66
66
  }
@@ -19,7 +19,7 @@ const resolveConfig = async (config) => {
19
19
  if (config.platforms) {
20
20
  for (const platform of Object.values(config.platforms)) {
21
21
  if (platform.npmPackageName)
22
- inputs.push(toDependency(platform.npmPackageName));
22
+ inputs.push(toDependency(platform.npmPackageName, { production: true }));
23
23
  }
24
24
  }
25
25
  return inputs;
@@ -7,14 +7,17 @@ const enablers = ['@swc/core'];
7
7
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
8
8
  const config = ['.swcrc'];
9
9
  const resolveConfig = async (config, options) => {
10
- const dependencies = [];
10
+ const plugins = [];
11
+ const inputs = [];
11
12
  for (const item of [config].flat()) {
12
13
  for (const [id] of item?.jsc?.experimental?.plugins ?? [])
13
- dependencies.push(id);
14
+ plugins.push(id);
14
15
  if (item?.jsc?.externalHelpers)
15
- dependencies.push('@swc/helpers');
16
+ inputs.push(toDependency('@swc/helpers', { production: true }));
16
17
  }
17
- return compact(dependencies).map(id => (isInternal(id) ? toModule(id, { dir: options.cwd }) : toDependency(id)));
18
+ for (const id of compact(plugins))
19
+ inputs.push(isInternal(id) ? toModule(id, { dir: options.cwd }) : toDependency(id));
20
+ return inputs;
18
21
  };
19
22
  const plugin = {
20
23
  title,
@@ -41,8 +41,7 @@ const resolveRuleSetDependencies = (rule) => {
41
41
  if (typeof useItem === 'function')
42
42
  useItem = useItem(info);
43
43
  if (typeof useItem === 'string' && hasBabelOptions(rule)) {
44
- const d = getDependenciesFromConfig(rule.options).map(d => d.specifier);
45
- return [useItem, ...d];
44
+ return [useItem, ...getDependenciesFromConfig(rule.options)];
46
45
  }
47
46
  if (typeof useItem === 'string' && useItem && rule.options && rule.use == null)
48
47
  useItem = { loader: useItem, options: rule.options };
@@ -50,8 +49,7 @@ const resolveRuleSetDependencies = (rule) => {
50
49
  if (!item)
51
50
  return [];
52
51
  if (hasBabelOptions(item)) {
53
- const d = getDependenciesFromConfig(item.options).map(d => d.specifier);
54
- return [...resolveUseItem(item), ...d];
52
+ return [...resolveUseItem(item), ...getDependenciesFromConfig(item.options)];
55
53
  }
56
54
  if (typeof item !== 'string' && 'oneOf' in item)
57
55
  return item.oneOf?.flatMap(resolveRuleSetDependencies) ?? [];
@@ -97,7 +95,7 @@ export const findWebpackDependenciesFromConfig = async (config, options) => {
97
95
  for (const opts of [resolvedConfig].flat()) {
98
96
  const entries = [];
99
97
  for (const loader of opts.module?.rules?.flatMap(resolveRuleSetDependencies) ?? []) {
100
- inputs.add(toModule(loader.replace(/\?.*/, '')));
98
+ inputs.add(typeof loader === 'string' ? toModule(loader.replace(/\?.*/, '')) : loader);
101
99
  }
102
100
  for (const plugin of opts?.plugins ?? []) {
103
101
  if (plugin && plugin.constructor.name === 'ProvidePlugin') {
@@ -105,7 +103,7 @@ export const findWebpackDependenciesFromConfig = async (config, options) => {
105
103
  if (providePluginInstance.definitions) {
106
104
  for (const values of Object.values(providePluginInstance.definitions)) {
107
105
  const specifier = typeof values === 'string' ? values : values[0];
108
- inputs.add(toModule(specifier));
106
+ inputs.add(toModule(specifier, { production: isProduction }));
109
107
  }
110
108
  }
111
109
  }
@@ -135,7 +133,7 @@ export const findWebpackDependenciesFromConfig = async (config, options) => {
135
133
  inputs.add(toEntryPath(entry, { production: isProduction, dir }));
136
134
  }
137
135
  else {
138
- inputs.add(toModule(entry));
136
+ inputs.add(toModule(entry, { production: isProduction }));
139
137
  }
140
138
  }
141
139
  const processAlias = (aliases) => {
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "6.46.0";
1
+ export declare const version = "6.46.1";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '6.46.0';
1
+ export const version = '6.46.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "6.46.0",
3
+ "version": "6.46.1",
4
4
  "description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
5
5
  "keywords": [
6
6
  "analysis",