Add support for main.cjs files

This commit is contained in:
Ian VanSchooten 2022-02-16 23:38:05 -05:00
parent 75b841912c
commit d74511418d

View File

@ -18,7 +18,14 @@ const requireMain = (configDir: string) => {
// eslint-disable-next-line global-require,import/no-dynamic-require
main = require(mainFile);
} catch (err) {
logger.warn(`Unable to find main.js: ${mainFile}`);
try {
// Try finding a .cjs version of the main file
const mainFileCjs = path.join(absoluteConfigDir, 'main.cjs');
// eslint-disable-next-line global-require,import/no-dynamic-require
main = require(mainFileCjs);
} catch (cjsErr) {
logger.warn(`Unable to find main.js or main.cjs: ${mainFile}`);
}
}
return main;
};