This applies only when Tagify is imported as module (see codesandbox ↑).
What is the expected behavior?
When the script enters code where Tagify.logger is supposed to print some logs, no error should be thrown. For example, tag element doesn't exist in getSetTagData().
What is happening instead?
An error is thrown at the point where Tagify.logger is called.
What error message are you getting?ReferenceError: Tagify is not defined
The problem is that Tagify is not globally available when used as module. You would need to put the logger logic into some extra file from where it gets imported into the other files. Something like:
Prerequisites
💥 Demo Page
https://codesandbox.io/p/sandbox/simple-tagify-setup-logger-error-95nc55
Explanation
This applies only when Tagify is imported as module (see codesandbox ↑).
What is the expected behavior? When the script enters code where
Tagify.logger
is supposed to print some logs, no error should be thrown. For example,tag element doesn't exist
ingetSetTagData()
.What is happening instead? An error is thrown at the point where
Tagify.logger
is called.What error message are you getting?
ReferenceError: Tagify is not defined
The problem is that Tagify is not globally available when used as module. You would need to put the logger logic into some extra file from where it gets imported into the other files. Something like: