(fileName string)
| 339 | } |
| 340 | |
| 341 | func (p *fileLoader) loadSourceFileMetaData(fileName string) ast.SourceFileMetaData { |
| 342 | packageJsonScope := p.resolver.GetPackageScopeForPath(tspath.GetDirectoryPath(fileName)) |
| 343 | moduleResolutionKind := p.opts.Config.CompilerOptions().GetModuleResolutionKind() |
| 344 | |
| 345 | var packageJsonType, packageJsonDirectory string |
| 346 | if packageJsonScope.Exists() { |
| 347 | packageJsonDirectory = packageJsonScope.PackageDirectory |
| 348 | if value, ok := packageJsonScope.Contents.Type.GetValue(); ok { |
| 349 | if !tspath.FileExtensionIsOneOf(fileName, []string{tspath.ExtensionMts, tspath.ExtensionCts, tspath.ExtensionMjs, tspath.ExtensionCjs}) && |
| 350 | core.ModuleResolutionKindNode16 <= moduleResolutionKind && moduleResolutionKind <= core.ModuleResolutionKindNodeNext || strings.Contains(fileName, "/node_modules/") { |
| 351 | packageJsonType = value |
| 352 | } |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | impliedNodeFormat := ast.GetImpliedNodeFormatForFile(fileName, packageJsonType) |
| 357 | return ast.SourceFileMetaData{ |
| 358 | PackageJsonType: packageJsonType, |
| 359 | PackageJsonDirectory: packageJsonDirectory, |
| 360 | ImpliedNodeFormat: impliedNodeFormat, |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | func (p *fileLoader) parseSourceFile(t *parseTask) *ast.SourceFile { |
| 365 | if p.opts.Tracing != nil { |
no test coverage detected