Skip to content

Commit

Permalink
chore(js): remove ts implementation of ts processing
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz committed Aug 21, 2023
1 parent d566055 commit ee57928
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 789 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { TypeScriptImportLocator } from './typescript-import-locator';
import { TargetProjectLocator } from './target-project-locator';
import {
DependencyType,
Expand All @@ -20,44 +19,7 @@ export function buildExplicitTypeScriptDependencies(
graph: ProjectGraph,
filesToProcess: ProjectFileMap
): ExplicitDependency[] {
let results: ExplicitDependency[];
if (process.env.NX_NATIVE_TS_DEPS !== 'false') {
results = buildExplicitTypeScriptDependenciesWithSwc(filesToProcess, graph);
} else {
results = buildExplicitTypeScriptDependenciesWithTs(filesToProcess, graph);
}
if (
process.env.NX_NATIVE_TS_DEPS &&
process.env.NX_NATIVE_TS_DEPS === 'debug'
) {
const tsResults = buildExplicitTypeScriptDependenciesWithTs(
filesToProcess,
graph
);

const set = new Set<string>();

for (const dep of results) {
set.add(
`+ ${dep.sourceProjectName} -> ${dep.targetProjectName} (${dep.sourceProjectFile})`
);
}
for (const dep of tsResults) {
set.delete(
`+ ${dep.sourceProjectName} -> ${dep.targetProjectName} (${dep.sourceProjectFile})`
);
set.add(
`- ${dep.sourceProjectName} -> ${dep.targetProjectName} (${dep.sourceProjectFile})`
);
}
for (const dep of results) {
set.delete(
`- ${dep.sourceProjectName} -> ${dep.targetProjectName} (${dep.sourceProjectFile})`
);
}
set.forEach((s) => console.log(s));
}
return results;
return buildExplicitTypeScriptDependenciesWithSwc(filesToProcess, graph);
}

function isRoot(graph: ProjectGraph, projectName: string): boolean {
Expand Down Expand Up @@ -161,55 +123,3 @@ function buildExplicitTypeScriptDependenciesWithSwc(

return res;
}

function buildExplicitTypeScriptDependenciesWithTs(
filesToProcess: ProjectFileMap,
graph: ProjectGraph
): ExplicitDependency[] {
const importLocator = new TypeScriptImportLocator();
const targetProjectLocator = new TargetProjectLocator(
graph.nodes as any,
graph.externalNodes
);
const res: ExplicitDependency[] = [];
Object.keys(filesToProcess).forEach((source) => {
Object.values(filesToProcess[source]).forEach((f) => {
importLocator.fromFile(
f.file,
(
importExpr: string,
filePath: string,
type: DependencyType.static | DependencyType.dynamic
) => {
const target = targetProjectLocator.findProjectWithImport(
importExpr,
f.file
);
let targetProjectName;
if (target) {
if (!isRoot(graph, source) && isRoot(graph, target)) {
// TODO: These edges technically should be allowed but we need to figure out how to separate config files out from root
return;
}

targetProjectName = target;
} else {
// treat all unknowns as npm packages, they can be eiher
// - mistyped local import, which has to be fixed manually
// - node internals, which should still be tracked as a dependency
// - npm packages, which are not yet installed but should be tracked
targetProjectName = `npm:${importExpr}`;
}

res.push({
sourceProjectName: source,
targetProjectName,
sourceProjectFile: f.file,
type,
});
}
);
});
});
return res;
}

This file was deleted.

Loading

0 comments on commit ee57928

Please sign in to comment.