question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v5: The sync loader for "*.config.js" returned a Promise

See original GitHub issue

Enjoying 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:closed
  • Created 5 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
olsonpmcommented, May 7, 2018

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.

0reactions
shellscapecommented, May 7, 2018

Thanks very much all 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Loader Interface - webpack
A loader is a JavaScript module that exports a function. ... A single result can be returned in sync mode. ... For the...
Read more >
Cosmiconfig - GitHub
Returns a Promise that resolves with a result or with null , if no configuration file is found. You can do the same...
Read more >
Module not found: Can't resolve 'fs' in Next.js application
js APIs that fail to build client-side. In this case, you just need: /** next.config.js - with Webpack v5.x */ module.
Read more >
node_modules/cosmiconfig · Week2 · ehnoh2 / cs242-sp19 ...
If no configuration object is found, the search() Promise resolves with null (or, with searchSync() , null is returned). If a configuration object...
Read more >
ECMAScript modules | Node.js v19.3.0 Documentation
addTwo.mjs function addTwo(num) { return num + 2; } export { addTwo }; ... Authors can tell Node.js to use the ECMAScript modules...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found