diff --git a/lib/appenders/index.js b/lib/appenders/index.js index 3e26c12..aa81599 100644 --- a/lib/appenders/index.js +++ b/lib/appenders/index.js @@ -22,10 +22,18 @@ coreAppenders.set('tcp', require('./tcp')); const appenders = new Map(); const tryLoading = (modulePath, config) => { - debug('Loading module from ', modulePath); + let resolvedPath; + try { + const modulePathCJS = `${modulePath}.cjs`; + resolvedPath = require.resolve(modulePathCJS); + debug('Loading module from ', modulePathCJS); + } catch (e) { + resolvedPath = modulePath; + debug('Loading module from ', modulePath); + } try { // eslint-disable-next-line global-require, import/no-dynamic-require - return require(modulePath); + return require(resolvedPath); } catch (e) { // if the module was found, and we still got an error, then raise it configuration.throwExceptionIf( diff --git a/test/tap/dummy-appender.js b/test/tap/dummy-appender.cjs similarity index 100% rename from test/tap/dummy-appender.js rename to test/tap/dummy-appender.cjs