Skip to content

Commit c42fcda

Browse files
authoredJan 6, 2024
fix: strictly check dependencies import judgment using regular expressions (#1146)
1 parent 67bf84f commit c42fcda

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed
 

‎packages/core/src/generators/imports.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,12 @@ export const addDependency = ({
181181
hasSchemaDir: boolean;
182182
isAllowSyntheticDefaultImports: boolean;
183183
}) => {
184-
const toAdds = exports.filter((e) =>
185-
implementation.includes(e.alias || e.name),
186-
);
184+
const toAdds = exports.filter((e) => {
185+
const searchWords = [e.alias, e.name].filter((p) => p?.length).join('|');
186+
const pattern = new RegExp(`\\b(${searchWords})\\b`, 'g');
187+
188+
return implementation.match(pattern);
189+
});
187190

188191
if (!toAdds.length) {
189192
return undefined;

0 commit comments

Comments
 (0)
Please sign in to comment.