gulp - ContextReplacementPlugin fails within webpack-stream: cannot read property 'forEach' of undefined -


i have webpack configuration works when used through classic webpack command:

// ~/gulp-test/webpack.config.js  module.exports = {     entry: path.resolve(__dirname, 'src/js/entry.js'),     output: {         filename: 'entry.js',         path: path.resolve(__dirname, 'dist'),     },     plugins: [         new webpack.contextreplacementplugin(/moment[\/\\]locale$/, /en|fr/)     ] }; 

(the entry.js file contains simple call moment.)

however, when try run same configuration using webpack-stream within gulp:

// ~/gulp-test/gulpfile.js  const webpack = require('webpack');  // v3.4.1 const webpackstream = require('webpack-stream');  // v3.2.0  gulp.task('build-js', function(cb) {     const webpackoptions = {         entry: './src/js/entry.js',         output: {             filename: 'entry.js'         },         plugins: [             new webpack.contextreplacementplugin(/moment[\/\\]locale$/, /en|fr/)         ]     };      pump([         gulp.src('src/js/entry.js'),         webpackstream(webpackoptions),         gulp.dest('www')     ], cb);  }); 

i following error:

$ gulp build-js [13:46:31] using gulpfile ~/projects/gulp-test/gulpfile.js [13:46:31] starting 'build-js'... ~/gulp-test/node_modules/webpack/lib/contextreplacementplugin.js:87                          result.dependencies.foreach((d) => {                                             ^  typeerror: cannot read property 'foreach' of undefined     @ contextmodulefactory.cmf.plugin (~/gulp-test/node_modules/webpack/lib/contextreplacementplugin.js:87:26)     @ contextmodulefactory.applypluginsasyncwaterfall (~/gulp-test/node_modules/webpack-stream/node_modules/tapable/lib/tapable.js:86:13)     @ contextmodulefactory.<anonymous> (~/gulp-test/node_modules/webpack-stream/node_modules/webpack/lib/contextmodulefactory.js:60:9)     @ ~/gulp-test/node_modules/async/lib/async.js:726:13     @ ~/gulp-test/node_modules/async/lib/async.js:52:16     @ done (~/gulp-test/node_modules/async/lib/async.js:246:17)     @ ~/gulp-test/node_modules/async/lib/async.js:44:16     @ ~/gulp-test/node_modules/async/lib/async.js:723:17     @ ~/gulp-test/node_modules/async/lib/async.js:167:37     @ ~/gulp-test/node_modules/webpack-stream/node_modules/enhanced-resolve/lib/unsafecacheplugin.js:29:4 

i feel related dependencies not being "named" same way within stream rather when webpack handles files itself, couldn't work around it.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -