knip 5.46.2 → 5.46.3

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.
@@ -22,14 +22,16 @@ export class PrincipalFactory {
22
22
  options.compilerOptions = mergePaths(cwd, compilerOptions, paths);
23
23
  if (isFile && compilerOptions.module !== ts.ModuleKind.CommonJS)
24
24
  compilerOptions.moduleResolution ??= ts.ModuleResolutionKind.Bundler;
25
- const principal = this.findReusablePrincipal(compilerOptions);
25
+ const principal = this.findReusablePrincipal(cwd, compilerOptions);
26
26
  if (!isIsolateWorkspaces && principal) {
27
27
  this.linkPrincipal(principal, cwd, compilerOptions, pkgName, compilers);
28
28
  return principal.principal;
29
29
  }
30
30
  return this.addNewPrincipal(options);
31
31
  }
32
- findReusablePrincipal(compilerOptions) {
32
+ findReusablePrincipal(cwd, compilerOptions) {
33
+ if (compilerOptions.rootDir && cwd !== compilerOptions.rootDir)
34
+ return;
33
35
  const workspacePaths = compilerOptions?.paths ? Object.keys(compilerOptions.paths) : [];
34
36
  const principal = Array.from(this.principals).find(principal => {
35
37
  if (compilerOptions.pathsBasePath && principal.principal.compilerOptions.pathsBasePath)
@@ -5,6 +5,7 @@ const commands = [
5
5
  'add',
6
6
  'audit',
7
7
  'bin',
8
+ 'cache',
8
9
  'config',
9
10
  'dedupe',
10
11
  'deploy',
@@ -60,6 +60,17 @@ export const findWebpackDependenciesFromConfig = async ({ config, cwd }) => {
60
60
  for (const loader of options.module?.rules?.flatMap(resolveRuleSetDependencies) ?? []) {
61
61
  inputs.add(toDeferResolve(loader.replace(/\?.*/, '')));
62
62
  }
63
+ for (const plugin of options?.plugins ?? []) {
64
+ if (plugin && plugin.constructor.name === 'ProvidePlugin') {
65
+ const providePluginInstance = plugin;
66
+ if (providePluginInstance.definitions) {
67
+ for (const values of Object.values(providePluginInstance.definitions)) {
68
+ const specifier = typeof values === 'string' ? values : values[0];
69
+ inputs.add(toDeferResolve(specifier));
70
+ }
71
+ }
72
+ }
73
+ }
63
74
  if (typeof options.entry === 'string')
64
75
  entries.push(options.entry);
65
76
  else if (Array.isArray(options.entry))
@@ -1,4 +1,4 @@
1
- import type { Configuration } from 'webpack';
1
+ import type { Configuration, ProvidePlugin } from 'webpack';
2
2
  type Mode = 'none' | 'development' | 'production';
3
3
  export type Env = {
4
4
  production: boolean;
@@ -7,6 +7,6 @@ export type Env = {
7
7
  export type Argv = {
8
8
  mode: Mode;
9
9
  };
10
+ export type { ProvidePlugin };
10
11
  type Configurations = Configuration | Configuration[];
11
12
  export type WebpackConfig = Configurations | ((env: Env, argv: Argv) => Configurations) | (() => Promise<Configuration>);
12
- export {};
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.46.2";
1
+ export declare const version = "5.46.3";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.46.2';
1
+ export const version = '5.46.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.46.2",
3
+ "version": "5.46.3",
4
4
  "description": "Find and fix unused files, dependencies and exports in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://knip.dev",
6
6
  "repository": {