You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into a situation where if a configuration file is a cjs file, then cosmiconfig will always return the same configuration files between runs even if it has changed:
consider a quick psuedo example:
constgetConfig=async()=>{constconfigExplorer=cosmiconfig(MODULE_NAME);constconfig=awaitconfigExplorer.search('...');returnconfig}// see the old configconstoldConfig=awaitgetConfig()// change the config somehowchangeConfigSomehow();// should see an updated config hereconstnewConfig=awaitgetConfig()
This works for JSON file types, but CJS file type in and ESM project will fail.
My hunch is that it is because it gets cached in the internal ESM cache which cannot be busted like the old require cache. see nodejs/node#49442
Internally, cosmiconfig uses a package called import-fresh which can only do fresh imports for the CJS cache, in an ESM context, I don't believe it works.
The text was updated successfully, but these errors were encountered:
I ran into a situation where if a configuration file is a cjs file, then cosmiconfig will always return the same configuration files between runs even if it has changed:
consider a quick psuedo example:
This works for JSON file types, but CJS file type in and ESM project will fail.
My hunch is that it is because it gets cached in the internal ESM cache which cannot be busted like the old require cache. see nodejs/node#49442
Internally, cosmiconfig uses a package called
import-fresh
which can only do fresh imports for the CJS cache, in an ESM context, I don't believe it works.The text was updated successfully, but these errors were encountered: