Skip to content

Conversation

@sheetalkamat
Copy link
Member

Bind the source file as external module only if not already done
Return type of require call is from external module resolution only if it doesn't resolve to local module

Fixes #10931

Note that we cannot fully guarantee that things will work perfectly because by the time we know that require is not a local symbol it is too late since the source file binding has already happened as external module. This is just little better handling in few cases like #10931

Return type of require call is from external module resolution only if
it doesnt resolve to local module
Fixes #10931
if (isInJavaScriptFile(node) &&
isRequireCall(node, /*checkArgumentIsStringLiteral*/true) &&
// Make sure require is not a local function
!resolveName(node.expression, (<Identifier>node.expression).text, SymbolFlags.Value | SymbolFlags.ExportValue, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need the ExportValue is not Value enough?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make sure it behaves similar to resolving identifier though its not really needed, I just like to keep it in sync with it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when would it find an ExportValue that is not an Value?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A require call that isn't the global require will clobber bindings

4 participants