fix webpack to handle node global functions

This commit is contained in:
Sendil Kumar 2018-07-03 18:14:30 +02:00
parent bfffd58683
commit 8f034bc078

View File

@ -48,6 +48,14 @@ fn project() -> Project {
"webpack.config.js".to_string(),
r#"
const path = require('path');
const fs = require('fs');
let nodeModules = {};
fs.readdirSync('node_modules').filter(function(x) {
return ['.bin'].indexOf(x) === -1;
}).forEach(function(mod) {
nodeModules[mod] = 'commonjs ' + mod;
});
module.exports = {
entry: './run.js',
@ -69,7 +77,8 @@ fn project() -> Project {
filename: 'bundle.js',
path: path.resolve(__dirname, '.')
},
target: 'node'
target: 'node',
externals: nodeModules
};
"#.to_string(),
),