Tuesday, 14 March 2017

Webpack compiler instance promisification?

I'm using the Webpack 2 Node API and I would like to promisify the run() method using bluebird.

import Promise from 'bluebird'
import webpack from 'webpack'

const compiler = webpack(config)
const runAsync = Promise.promisify(compiler.run)

runAsync().then(stats => {
  console.log('stats:', stats)
}).catch(err => {
  console.log('err:', err)
})

The error I'm getting is:

[TypeError: self.applyPluginsAsync is not a function]

So I'm guessing that the webpack code isn't written in a way that's compatible with bluebird promisification.

If there any other way to promisify webpack's run() method..?

All these callbacks and if statements are bugging me.



via Stephen Last

No comments:

Post a Comment