( foldedHelpersById: ReadonlyMap<string, string[]>, imports: Imports, isTransformed: (id: string) => boolean, cwd: string )
| 739 | |
| 740 | // a folded helper's call runs only where the plugin transforms it |
| 741 | export const unfoldedCallProblemOf = ( |
| 742 | foldedHelpersById: ReadonlyMap<string, string[]>, |
| 743 | imports: Imports, |
| 744 | isTransformed: (id: string) => boolean, |
| 745 | cwd: string |
| 746 | ): string | undefined => { |
| 747 | const pathOf = (id: string) => |
| 748 | isAbsolute(id) ? printablePathOf(cwd, fileOf(id)) : id |
| 749 | for (const entry of imports.entries) { |
| 750 | const [helper] = |
| 751 | (entry !== undefined && foldedHelpersById.get(fileOf(entry))) || [] |
| 752 | if (helper) return writeEntryHelperMessage(pathOf(entry!), helper) |
| 753 | } |
| 754 | for (const [importer, target] of imports.edges) { |
| 755 | const [helper] = foldedHelpersById.get(fileOf(target)) ?? [] |
| 756 | if (helper && (importer === undefined || !isTransformed(importer))) { |
| 757 | return writeUntransformedHelperMessage( |
| 758 | importer === undefined ? "a module it can't read" : pathOf(importer), |
| 759 | pathOf(target), |
| 760 | helper |
| 761 | ) |
| 762 | } |
| 763 | } |
| 764 | } |
| 765 | |
| 766 | export const writeUntransformedHelperMessage = ( |
| 767 | importer: string, |
no test coverage detected