I am trying to upgrade my version of a node application from node6 to node8.6, which supports the distribution operator initially, everything works fine until I try to compile my node script using webpack.
I created a test script (testing my own async / await support also about this):
const fs = require('fs') const {promisify} = require('util') const app = async () => { try { const todosString = await promisify(fs.readFile)('todos.txt', { encoding: 'utf8', }) return todosString .split('\n') .filter(Boolean) .reduce((acc, val) => ({...acc, [val]: true}), {}) } catch (e) { console.error('wooot', e) } } app().then(console.log)
Here is the web package configuration:
const path = require('path') const nodeExternals = require('webpack-node-externals') module.exports = { entry: './index.js', output: {filename: '[name].js'}, target: 'node', externals: [nodeExternals()], node: { __dirname: true, __filename: true, }, module: { rules: [ { test: /\.js$/, loader: 'babel-loader', options: { presets: [ [ 'env', { targets: { node: 'current', modules: false, }, }, ], ], }, }, ], }, }
And here is my output of the webpack assembly: 
Distributing the object gives an error, and async / await is forwarded by default, even in the webpack setting target: 'node' ...
UPDATE is package.json: 