Skip to content

Port IsSourceFileFromExternalLibrary so that we can implement more paths in sourceFileMayBeEmitted #1234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

maschwenk
Copy link
Contributor

@@ -970,6 +970,7 @@ func (p *Project) GetFileNames(excludeFilesFromExternalLibraries bool, excludeCo
result := []string{}
sourceFiles := p.program.GetSourceFiles()
for _, sourceFile := range sourceFiles {
// !! This is probably ready to be implemented now?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we have IsSourceFileFromExternalLibrary

Comment on lines +834 to +835
// IsSourceFileFromExternalLibrary returns true if the source file is from an external library.
// This mirrors the TypeScript implementation which tracks files found while searching node_modules.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume some LLM added the comments; I would just remove all of these as they just describe exactly what the code says.

fileName: resolvedFileName,
increaseDepth: resolvedModule.IsExternalLibraryImport,
elideOnDepth: isJsFileFromNodeModules,
isFromExternalLibrary: isFromNodeModulesSearch,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not just resolvedModule.IsExternalLibraryImport?

Comment on lines +317 to +319
increaseDepth: false,
elideOnDepth: false,
isFromExternalLibrary: false, // Triple-slash references are always local files
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all defaulted to false if not present.

Comment on lines +840 to +841
isExternal, exists := p.sourceFilesFoundSearchingNodeModules.Load(file.Path())
return exists && isExternal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should have Load. It's just a map.

@@ -50,6 +50,9 @@ type processedFiles struct {
importHelpersImportSpecifiers map[tspath.Path]*ast.Node
// List of present unsupported extensions
unsupportedExtensions []string
// Track which source files were found while searching node_modules
// Similar to TypeScript's sourceFilesFoundSearchingNodeModules map
sourceFilesFoundSearchingNodeModules map[tspath.Path]bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use collections.Set[tspath.Path] here.

Comment on lines +210 to +214
if p.processedFiles.sourceFilesFoundSearchingNodeModules != nil {
for path, isExternal := range p.processedFiles.sourceFilesFoundSearchingNodeModules {
p.sourceFilesFoundSearchingNodeModules.Store(path, isExternal)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be required, the info should already be on processedFiles and therefore be accessible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants