Skip to content

Commit 97317a7

Browse files
committed
dedupe require argument extraction
1 parent 8863c94 commit 97317a7

1 file changed

Lines changed: 3 additions & 15 deletions

File tree

‎packages/core/build-support/find-create-require.ts‎

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,9 @@ function findRequireCalls(ast: ParseResult, requireVarName: string): RequireCall
103103
return;
104104
}
105105

106-
// Extract the first argument (module specifier)
107-
if (node.arguments.length === 0) {
108-
return;
109-
}
110-
const arg = node.arguments[0];
111-
if (arg.type !== 'Literal') {
112-
return;
113-
}
114-
const value = (arg as { value: unknown; start: number; end: number }).value;
115-
if (typeof value === 'string') {
116-
calls.push({
117-
module: value,
118-
start: arg.start,
119-
end: arg.end,
120-
});
106+
const call = getLiteralRequireArgument(node);
107+
if (call) {
108+
calls.push(call);
121109
}
122110
},
123111
});

0 commit comments

Comments
 (0)