v5: The sync loader for "*.config.js" returned a Promise
See original GitHub issueEnjoying the enhanced simplicity of the v5 release. I’ve been able to remove quite a lot of code as a result of upgrading. However, there is one sticking point that is preventing me from moving forward: There are completely valid situations in which a module may return a Promise
while using searchSync
.
I present exhibit A, webpack.config.js
:
module.exports = new Promise((resolve /* reject */) => {
resolve({
entry: 'promise',
mode: 'development',
});
});
That Promise
should be returned to the consumer of cosmiconfig
so that the Promise
can be operated on by the consumer. This pattern has been supported in webpack
for a little over a year now, and it’s a blocker for the project to leverage v5. I’m not sure what the justifications were for requiring that the result from a searchSync
call had to be only an Object
or null
, but that seems on the surface like a needless limitation.
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (7 by maintainers)
Top GitHub Comments
Ha - I was happy to see the
instanceof
check because I’m one of those developers that makes stupid mistakes and thus code defensively to save myself debugging time. The webpack use-case makes perfect sense though. Thanks for bringing that up.Thanks very much all 🎉