Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug when loglevel is used with some ESM translation (e.g. ts-node)
Although loglevel itself is not published using ESM, it seems that some runtime environments will treat its import as such. Because of this, when it's imported with syntax like "import * as log ...", all fields of loglevel are treated as ESM exports, meaning they're frozen and read-only. This is problematic, because loglevel rewrites those fields to change levels, which now fails. This happened in v1.9.0 because we switched from replacing log methods on 'self' to 'this'. 'self' always referred to the logger object within our environment, but 'this' in these runtime environments seems to point to the ESM-imported wrapper which is unmodifiable. Using the internal self reference to our internal state seems to work correctly instead, with no downsides, so we're reverting to that.
- Loading branch information