In Node, a common idiom for checking if the current module is the one that was directly invoked is if (require.main === module) { ... }. Here are the docs.
This works as expected when the module is "inlined" in the top-level IIFE of the generated JavaScript code (see my other issue), but when this code is used inside of a defined module this condition fails because require is not the expected object.
This seems to be caused by require being provided by dependency injection, because the injected require object is a function rather than its usual object value.
In Node, a common idiom for checking if the current module is the one that was directly invoked is
if (require.main === module) { ... }. Here are the docs.This works as expected when the module is "inlined" in the top-level IIFE of the generated JavaScript code (see my other issue), but when this code is used inside of a
defined module this condition fails becauserequireis not the expected object.This seems to be caused by
requirebeing provided by dependency injection, because the injectedrequireobject is a function rather than its usual object value.