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.

Handle returned Promises

See original GitHub issue

Webpack 2 supports returning a Promise from the config function.

https://webpack.js.org/configuration/configuration-types/#exporting-a-promise

This currently isn’t supported by webpack-merge.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
butterybreadcommented, Jul 4, 2019

I have found a solution that does not require webpack-merge to support promises:

This does not work:

module.exports = merge(someConfig, async () => ({
  prop: await someFunc()
}));

This does work:

module.exports = async () => {
  const value = await someFunc();
  return merge(someConfig, { prop: value });
};

I am not sure if this solves every problem out there. But it solved mine.

0reactions
bebrawcommented, Jul 3, 2020

I will throw an error in this case at v5 (#135). It’s likely best to wrap merge within a Promise at the user space as that avoids complexity though I can still accept a PR at a later time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using promises - JavaScript - MDN Web Docs
Essentially, a promise is a returned object to which you attach callbacks, instead of passing callbacks into a function. Imagine a function, ...
Read more >
How to handle returning a promise when one is already ...
The only method I can think of is to return a Promise which wraps a call to setInterval checking the status. Surely there...
Read more >
Error handling with promises - The Modern JavaScript Tutorial
Promise chains are great at error handling. When a promise rejects, the control jumps to the closest rejection handler.
Read more >
Javascript: How to access the return value of a Promise object
In the moment when console.log() function starting to run, a Promise that should be returned from a fetch() request is in a pending...
Read more >
JavaScript Promise Tutorial – How to Resolve or Reject ...
The new Promise() constructor returns a promise object. As the executor function needs to handle async operations, the returned promise ...
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