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

Fix running-as-script check#7

Open
svicalifornia wants to merge 1 commit intodominictarr:masterfrom
appjudo:master
Open

Fix running-as-script check#7
svicalifornia wants to merge 1 commit intodominictarr:masterfrom
appjudo:master

Conversation

@svicalifornia
Copy link
Copy Markdown

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
Copy Markdown

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