Even before the refactor, getImport fallbacks to return all namespace imports if it doesn't find any "named" or "direct" imports. When I refactored the getImport function and introduced getAllImports I kept that behaviour but now that makes me wonder is this the correct intended behaviour?
|
const namespaceImport = imports.find((m) => { |
|
return m.getMatch("NAMESPACE_ALIAS"); |
|
}); |
|
if (namespaceImport) { |
|
return { |
|
alias: namespaceImport.getMatch("NAMESPACE_ALIAS")?.text() ?? "", |
|
isNamespace: true, |
|
moduleType: "esm" as const, // Namespace imports are always ESM |
|
node: namespaceImport.getMatch("NAMESPACE_ALIAS")! as unknown as SgNode<T, "identifier">, |
|
}; |
|
} |
For reference the piece of code before the refactor ^
Changing anything related to this would be considered a breaking change for the end-users.
Even before the refactor, getImport fallbacks to return all namespace imports if it doesn't find any "named" or "direct" imports. When I refactored the
getImportfunction and introducedgetAllImportsI kept that behaviour but now that makes me wonder is this the correct intended behaviour?codemod/packages/jssg-utils/src/javascript/exports/imports.ts
Lines 532 to 542 in 32c9b39
For reference the piece of code before the refactor ^
Changing anything related to this would be considered a breaking change for the end-users.