Skip to content

Commit

Permalink
fix: strictly check dependencies import judgment using regular expres…
Browse files Browse the repository at this point in the history
…sions (#1146)
  • Loading branch information
soartec-lab authored Jan 6, 2024
1 parent 67bf84f commit c42fcda
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/core/src/generators/imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,12 @@ export const addDependency = ({
hasSchemaDir: boolean;
isAllowSyntheticDefaultImports: boolean;
}) => {
const toAdds = exports.filter((e) =>
implementation.includes(e.alias || e.name),
);
const toAdds = exports.filter((e) => {
const searchWords = [e.alias, e.name].filter((p) => p?.length).join('|');
const pattern = new RegExp(`\\b(${searchWords})\\b`, 'g');

return implementation.match(pattern);
});

if (!toAdds.length) {
return undefined;
Expand Down

0 comments on commit c42fcda

Please sign in to comment.