While trying to fix the issue (PR: https://github.com/sindresorhus/import-fresh/pull/27), it seems that import-fresh is not actively maintained. lilconfig is a zero-dependency alternative to cosmiconfig with the same API and more lightweight, and just released a new version 3.1.2 with the same fix.
I am proposing to use lilconfig instead in this PR to fix the config loading issue and hopefully avoid some issues caused by legacy components in the future.
Partially fix https://github.com/sainsburys-tech/next-logger/issues/29
Description
Webpack will try to bundle modules during compile time and replace the original
require
, so usingrequire
directly in the Webpack context to load configs could result in MODULE_NOT_FOUND error. next-logger uses the sync API ofcosmiconfig
to load its config, which internally usesimport-fresh
to handle the config loading, andimport-fresh
underneath uses the plainrequire
. This has been causing the issues mentioned in https://github.com/sainsburys-tech/next-logger/issues/13#issuecomment-2113625702 and https://github.com/sainsburys-tech/next-logger/issues/29While trying to fix the issue (PR: https://github.com/sindresorhus/import-fresh/pull/27), it seems that
import-fresh
is not actively maintained.lilconfig
is a zero-dependency alternative tocosmiconfig
with the same API and more lightweight, and just released a new version 3.1.2 with the same fix.I am proposing to use
lilconfig
instead in this PR to fix the config loading issue and hopefully avoid some issues caused by legacy components in the future.Testing
npm run test
npm run lint