Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

rangoo94
Copy link
Contributor

It may be pretty common to asynchronously generate file, so I prepared a code (with backwards compatibility) to allow also async functions (with promises)

@rmarscher rmarscher merged commit bd34586 into rmarscher:master Jun 12, 2017
@rmarscher
Copy link
Owner

@rangoo94 I like your approach here. An attempt at this was made in #11 but we couldn't seem to get webpack to wait for the async resolution. I confirmed that your code had the same problem by adding a 1 second delay. Webpack tries to resolve the module before before it is populated. It doesn't seem to use the callback function in the resolve plugin to delay execution. I haven't been able to figure out how to deal with this. It would require a deeper dive into the webpack internals to figure out if it's possible. Feel free to give it another try based on the current master here.

I did merge your changes and added a few additional changes of my own. I published this to NPM as v0.2.1.

Webpack supports exporting a Promise for the webpack.config.js. I documented an approach for async file contents in the README.md that involves resolving the contents first and then returning the webpack config. I updated your contents-async integration test to use this approach. I left your version commented out and also have commented out code for delaying the content resolve by 1 second.

Thanks a lot for the pull.

/cc @papandreou

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants