Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack 5 warns about a deprecation in watch mode #230

Closed
cowwoc opened this issue Nov 19, 2020 · 4 comments · Fixed by #232
Closed

Webpack 5 warns about a deprecation in watch mode #230

cowwoc opened this issue Nov 19, 2020 · 4 comments · Fixed by #232

Comments

@cowwoc
Copy link

cowwoc commented Nov 19, 2020

webpack-stream 6.1.0
webpack 5.4.0

I've successfully used this plugin with a custom Webpack 5 compiler passed in as the second argument. One thing I am unable to get working is "watch mode". If I take a working webpack configuration and add watch = true then Webpack fails with:

(node:28480) [DEP_WEBPACK_WATCH_WITHOUT_CALLBACK] DeprecationWarning: A 'callback' argument need to be provided to the 'webpack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.
    at webpack (C:\Users\cowwoc\Documents\holdmyspot\shopping\client\browser\node_modules\webpack\lib\webpack.js:145:5)
    at f (C:\Users\cowwoc\Documents\holdmyspot\shopping\client\browser\node_modules\webpack\lib\index.js:35:15)
    at Stream.<anonymous> (C:\Users\cowwoc\Documents\holdmyspot\shopping\client\browser\node_modules\webpack-stream\index.js:150:38)
    at _end (C:\Users\cowwoc\Documents\holdmyspot\shopping\client\browser\node_modules\through\index.js:65:9)
    at Stream.stream.end (C:\Users\cowwoc\Documents\holdmyspot\shopping\client\browser\node_modules\through\index.js:74:5)
    at module.exports (C:\Users\cowwoc\Documents\holdmyspot\shopping\client\browser\node_modules\webpack-stream\index.js:225:12)

I get this when invoking:

gulpWebpack(config, compiler, function(err, stats)
		{
			if (err)
				throw err;
			console.log(stats);
		}))

where config includes watch=true.

Oddly, I don't get this warning if I invoke webpack.watch() directly without this plugin.

@cowwoc
Copy link
Author

cowwoc commented Nov 24, 2020

Not a bug. See #109 followed by https://github.com/shama/webpack-stream#usage-with-gulp-watch

@cowwoc cowwoc closed this as completed Nov 24, 2020
@cowwoc
Copy link
Author

cowwoc commented Dec 6, 2020

Reopening. Per #18 (comment) the approach in #109 is 10x slower than webpack.watch().

We need to resolve the deprecation warning mentioned above.

@cowwoc cowwoc reopened this Dec 6, 2020
@cowwoc cowwoc changed the title Cannot launch Webpack 5 in watch mode Webpack 5 warns about a deprecation in watch mode Dec 6, 2020
@cowwoc
Copy link
Author

cowwoc commented Dec 6, 2020

@shama I think I figured it out. If you invoke:

const compiler = webpack(config);
compiler.watch({}, callback);

where config does not contain watch: true then webpack does watch the files because you invoked the watch() method explicitly. If I leave watch: true in config then webpack issues the aforementioned warning.

One way you could fix this bug is to simply strip watch: true from config before passing it on to webpack. Users will still need to pass watch: true to this plugin so it knows to invoke compiler.watch() but you will need to strip it out before passing the config to webpack. Makes sense?

@cowwoc
Copy link
Author

cowwoc commented Dec 6, 2020

@shama I tested #231 locally. It fixes the deprecation warning for me. Please review and merge if you agree.

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