Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Fix running-as-script check #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

svicalifornia
Copy link

This library checks !module.parent to determine whether it is running as a script. When used in the create-react-app webpack environment, module.parent is not set as expected, either via import or require. The lack of value for module.parent causes spurious logging to the console in these React apps.

Per the official Node module docs, we should be checking require.main === module instead. This pull request does just that. With this change, the spurious console logs disappear.

@mike-weshop
Copy link

Any chance of this PR getting merged? And should the console.log rather use a logger, so it won't output unless a logger is defined for debugging or other usage?

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.

2 participants