perf: prefilter extension boundary parsing
This commit is contained in:
@@ -47,6 +47,10 @@ function shouldSkipFile(filePath) {
|
||||
return relativeFile.startsWith("packages/plugin-sdk/dist/");
|
||||
}
|
||||
|
||||
function shouldParseSource(source) {
|
||||
return source.includes(BUNDLED_PLUGIN_PATH_PREFIX);
|
||||
}
|
||||
|
||||
function scanImportBoundaryViolations(sourceFile, filePath) {
|
||||
const entries = [];
|
||||
const relativeFile = normalizeRepoPath(repoRoot, filePath);
|
||||
@@ -87,6 +91,7 @@ export async function collectSdkPackageExtensionImportBoundaryInventory() {
|
||||
collectEntries(sourceFile, filePath) {
|
||||
return scanImportBoundaryViolations(sourceFile, filePath);
|
||||
},
|
||||
shouldParseSource,
|
||||
});
|
||||
})();
|
||||
|
||||
|
||||
@@ -52,6 +52,10 @@ function shouldSkipFile(filePath) {
|
||||
);
|
||||
}
|
||||
|
||||
function shouldParseSource(source) {
|
||||
return source.includes(BUNDLED_PLUGIN_PATH_PREFIX);
|
||||
}
|
||||
|
||||
function scanImportBoundaryViolations(sourceFile, filePath) {
|
||||
const entries = [];
|
||||
const relativeFile = normalizeRepoPath(repoRoot, filePath);
|
||||
@@ -92,6 +96,7 @@ export async function collectSrcExtensionImportBoundaryInventory() {
|
||||
collectEntries(sourceFile, filePath) {
|
||||
return scanImportBoundaryViolations(sourceFile, filePath);
|
||||
},
|
||||
shouldParseSource,
|
||||
});
|
||||
})();
|
||||
|
||||
|
||||
@@ -83,6 +83,9 @@ export async function collectTypeScriptInventory(params) {
|
||||
let sourceFile = parsedTypeScriptSourceCache.get(cacheKey);
|
||||
if (!sourceFile) {
|
||||
const source = await fs.readFile(filePath, "utf8");
|
||||
if (params.shouldParseSource && !params.shouldParseSource(source, filePath)) {
|
||||
continue;
|
||||
}
|
||||
sourceFile = params.ts.createSourceFile(
|
||||
filePath,
|
||||
source,
|
||||
|
||||
Reference in New Issue
Block a user