foresthouse 1.0.1-dev.5 → 1.0.1-dev.7
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/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as printReactUsageTree, c as printPackageDependencyTree, f as analyzeReactUsage, g as analyzePackageDependencies, h as analyzePackageDependencyDiff, i as graphToSerializablePackageTree, m as isSourceCodeFile, n as graphToSerializableTree, o as printDependencyTree, p as analyzeDependencies, r as diffGraphToSerializablePackageTree, s as printPackageDependencyDiffTree, t as graphToSerializableReactTree } from "./react-
|
|
2
|
+
import { a as printReactUsageTree, c as printPackageDependencyTree, f as analyzeReactUsage, g as analyzePackageDependencies, h as analyzePackageDependencyDiff, i as graphToSerializablePackageTree, m as isSourceCodeFile, n as graphToSerializableTree, o as printDependencyTree, p as analyzeDependencies, r as diffGraphToSerializablePackageTree, s as printPackageDependencyDiffTree, t as graphToSerializableReactTree } from "./react-GTkYqQLE.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as printReactUsageTree, c as printPackageDependencyTree, d as getReactUsageRoots, f as analyzeReactUsage, g as analyzePackageDependencies, h as analyzePackageDependencyDiff, i as graphToSerializablePackageTree, l as getFilteredUsages, n as graphToSerializableTree, o as printDependencyTree, p as analyzeDependencies, r as diffGraphToSerializablePackageTree, s as printPackageDependencyDiffTree, t as graphToSerializableReactTree, u as getReactUsageEntries } from "./react-
|
|
1
|
+
import { a as printReactUsageTree, c as printPackageDependencyTree, d as getReactUsageRoots, f as analyzeReactUsage, g as analyzePackageDependencies, h as analyzePackageDependencyDiff, i as graphToSerializablePackageTree, l as getFilteredUsages, n as graphToSerializableTree, o as printDependencyTree, p as analyzeDependencies, r as diffGraphToSerializablePackageTree, s as printPackageDependencyDiffTree, t as graphToSerializableReactTree, u as getReactUsageEntries } from "./react-GTkYqQLE.mjs";
|
|
2
2
|
export { analyzeDependencies, analyzePackageDependencies, analyzePackageDependencyDiff, analyzeReactUsage, diffGraphToSerializablePackageTree, getFilteredUsages, getReactUsageEntries, getReactUsageRoots, graphToSerializablePackageTree, graphToSerializableReactTree, graphToSerializableTree, printDependencyTree, printPackageDependencyDiffTree, printPackageDependencyTree, printReactUsageTree };
|
|
@@ -797,11 +797,16 @@ function getScriptKind(filePath) {
|
|
|
797
797
|
}
|
|
798
798
|
//#endregion
|
|
799
799
|
//#region src/typescript/config.ts
|
|
800
|
+
const nearestConfigCache = /* @__PURE__ */ new Map();
|
|
801
|
+
const loadedConfigCache = /* @__PURE__ */ new Map();
|
|
800
802
|
const workspaceRootCache = /* @__PURE__ */ new Map();
|
|
801
803
|
const workspacePackageCache = /* @__PURE__ */ new Map();
|
|
802
804
|
function loadCompilerOptions(searchFrom, explicitConfigPath) {
|
|
803
|
-
const
|
|
805
|
+
const resolvedSearchFrom = path.resolve(searchFrom);
|
|
806
|
+
const configPath = explicitConfigPath === void 0 ? findNearestConfig(resolvedSearchFrom) : path.resolve(resolvedSearchFrom, explicitConfigPath);
|
|
804
807
|
if (configPath === void 0) return { compilerOptions: defaultCompilerOptions() };
|
|
808
|
+
const cached = loadedConfigCache.get(configPath);
|
|
809
|
+
if (cached !== void 0) return cached;
|
|
805
810
|
let fatalDiagnostic;
|
|
806
811
|
const parsed = ts.getParsedCommandLineOfConfigFile(configPath, defaultCompilerOptions(), createParseConfigHost(configPath, (diagnostic) => {
|
|
807
812
|
fatalDiagnostic = diagnostic;
|
|
@@ -816,22 +821,48 @@ function loadCompilerOptions(searchFrom, explicitConfigPath) {
|
|
|
816
821
|
if (firstError === void 0) throw new Error(`Failed to parse TypeScript config at ${configPath}.`);
|
|
817
822
|
throw new Error(`Failed to parse TypeScript config at ${configPath}: ${formatDiagnostic(firstError)}`);
|
|
818
823
|
}
|
|
819
|
-
|
|
824
|
+
const loadedConfig = {
|
|
820
825
|
path: configPath,
|
|
821
826
|
compilerOptions: parsed.options
|
|
822
827
|
};
|
|
828
|
+
loadedConfigCache.set(configPath, loadedConfig);
|
|
829
|
+
return loadedConfig;
|
|
823
830
|
}
|
|
824
831
|
function findNearestConfig(searchFrom) {
|
|
825
832
|
let currentDirectory = path.resolve(searchFrom);
|
|
833
|
+
const traversedDirectories = [];
|
|
826
834
|
while (true) {
|
|
835
|
+
const cached = nearestConfigCache.get(currentDirectory);
|
|
836
|
+
if (cached !== void 0 || nearestConfigCache.has(currentDirectory)) {
|
|
837
|
+
traversedDirectories.forEach((directory) => {
|
|
838
|
+
nearestConfigCache.set(directory, cached);
|
|
839
|
+
});
|
|
840
|
+
return cached;
|
|
841
|
+
}
|
|
842
|
+
traversedDirectories.push(currentDirectory);
|
|
827
843
|
if (!isInsideNodeModules$1(currentDirectory)) {
|
|
828
844
|
const tsconfigPath = path.join(currentDirectory, "tsconfig.json");
|
|
829
|
-
if (ts.sys.fileExists(tsconfigPath))
|
|
845
|
+
if (ts.sys.fileExists(tsconfigPath)) {
|
|
846
|
+
traversedDirectories.forEach((directory) => {
|
|
847
|
+
nearestConfigCache.set(directory, tsconfigPath);
|
|
848
|
+
});
|
|
849
|
+
return tsconfigPath;
|
|
850
|
+
}
|
|
830
851
|
const jsconfigPath = path.join(currentDirectory, "jsconfig.json");
|
|
831
|
-
if (ts.sys.fileExists(jsconfigPath))
|
|
852
|
+
if (ts.sys.fileExists(jsconfigPath)) {
|
|
853
|
+
traversedDirectories.forEach((directory) => {
|
|
854
|
+
nearestConfigCache.set(directory, jsconfigPath);
|
|
855
|
+
});
|
|
856
|
+
return jsconfigPath;
|
|
857
|
+
}
|
|
832
858
|
}
|
|
833
859
|
const parentDirectory = path.dirname(currentDirectory);
|
|
834
|
-
if (parentDirectory === currentDirectory)
|
|
860
|
+
if (parentDirectory === currentDirectory) {
|
|
861
|
+
traversedDirectories.forEach((directory) => {
|
|
862
|
+
nearestConfigCache.set(directory, void 0);
|
|
863
|
+
});
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
835
866
|
currentDirectory = parentDirectory;
|
|
836
867
|
}
|
|
837
868
|
}
|
|
@@ -1345,15 +1376,18 @@ var DependencyGraphBuilder = class {
|
|
|
1345
1376
|
const normalizedPath = normalizeFilePath(filePath);
|
|
1346
1377
|
if (this.nodes.has(normalizedPath)) return;
|
|
1347
1378
|
const config = this.getConfigForFile(normalizedPath);
|
|
1348
|
-
const program = this.getProgramForFile(normalizedPath, config);
|
|
1349
1379
|
const checker = this.options.trackUnusedImports ? this.getCheckerForFile(normalizedPath, config) : void 0;
|
|
1350
|
-
const dependencies = collectModuleReferences(
|
|
1380
|
+
const dependencies = collectModuleReferences(this.getSourceFileForFile(normalizedPath, config), checker).map((reference) => this.resolveDependencyWithCache(reference, normalizedPath, config, entryConfigPath));
|
|
1351
1381
|
this.nodes.set(normalizedPath, {
|
|
1352
1382
|
id: normalizedPath,
|
|
1353
1383
|
dependencies
|
|
1354
1384
|
});
|
|
1355
1385
|
for (const dependency of dependencies) if (dependency.kind === "source") this.visitFile(dependency.target, entryConfigPath);
|
|
1356
1386
|
}
|
|
1387
|
+
getSourceFileForFile(filePath, config) {
|
|
1388
|
+
if (!this.options.trackUnusedImports) return createSourceFile(filePath);
|
|
1389
|
+
return this.getProgramForFile(filePath, config).getSourceFile(filePath) ?? createSourceFile(filePath);
|
|
1390
|
+
}
|
|
1357
1391
|
getConfigForFile(filePath) {
|
|
1358
1392
|
const directory = path.dirname(filePath);
|
|
1359
1393
|
const cached = this.configCache.get(directory);
|
|
@@ -2858,4 +2892,4 @@ function formatReactNodeFilePath(filePath, kind, cwd) {
|
|
|
2858
2892
|
//#endregion
|
|
2859
2893
|
export { printReactUsageTree as a, printPackageDependencyTree as c, getReactUsageRoots as d, analyzeReactUsage as f, analyzePackageDependencies as g, analyzePackageDependencyDiff as h, graphToSerializablePackageTree as i, getFilteredUsages as l, isSourceCodeFile as m, graphToSerializableTree as n, printDependencyTree as o, analyzeDependencies as p, diffGraphToSerializablePackageTree as r, printPackageDependencyDiffTree as s, graphToSerializableReactTree as t, getReactUsageEntries as u };
|
|
2860
2894
|
|
|
2861
|
-
//# sourceMappingURL=react-
|
|
2895
|
+
//# sourceMappingURL=react-GTkYqQLE.mjs.map
|