Skip to content

[DEP_WEBPACK_WATCH_WITHOUT_CALLBACK] error when using --watch flag #1918

Closed

Description

@sanex3339

Describe the bug

PR with the configuration
javascript-obfuscator/javascript-obfuscator#776

After upgrade from webpack@4 to webpack@5 and webpack-cli@3 to [email protected] I got the following error:

[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.

This error happens only when using --watch flag:

webpack --config ./webpack/webpack.node.config.js --mode development --watch

Full error trace:

(node:62890) [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 (/Users/sanex/WebstormProjects/javascript-obfuscator/node_modules/webpack/lib/webpack.js:145:5)
    at f (/Users/sanex/WebstormProjects/javascript-obfuscator/node_modules/webpack/lib/index.js:35:15)
    at Compiler.createCompiler (/Users/sanex/WebstormProjects/javascript-obfuscator/node_modules/webpack-cli/lib/utils/Compiler.js:129:35)
    at WebpackCLI.run (/Users/sanex/WebstormProjects/javascript-obfuscator/node_modules/webpack-cli/lib/webpack-cli.js:220:32)
    at async runCLI (/Users/sanex/WebstormProjects/javascript-obfuscator/node_modules/webpack-cli/lib/bootstrap.js:74:24)

Expected behavior

No error.

Activity

  1. alexander-akait commented on Oct 11, 2020

    @alexander-akait
    Member

    @webpack/cli-team high priority

  2. photonstorm commented on Oct 12, 2020

    @photonstorm

    I get the same error, but I think it's worth mentioning that the watch mode does actually work. Yes, it throws that warning at the start, but it still bundles and still watches for changes correctly.

  3. raduchiriac commented on Oct 12, 2020

    @raduchiriac

    Indeed, webpack v5 does not watch anymore if I remove --watch and do webpack --config webpack.config.js

    I use this config:

    {
      mode: "development",
      watch: true,
      devtool: "inline-cheap-source-map",
      watchOptions: {
        ignored: ["node_modules/**"],
      },
      entry: {
        main: ["core-js/stable", "./src/js/index.js"],
        theme: "./src/scss/th.scss",
      },
    }

    Solution: With my config above the only way to go is adding --watch which I'd prefer not to

  4. snitin315 commented on Oct 12, 2020

    @snitin315
    Contributor

    I will fix it 👍

  5. alexander-akait commented on Oct 12, 2020

    @alexander-akait
    Member

    We have two problems here:

    • watch without callback
    • we don't respect the watch option from config
  6. snitin315 commented on Oct 13, 2020

    @snitin315
    Contributor

    @evilebottnawi fixed with #1931 ?

  7. alexander-akait commented on Oct 13, 2020

    @alexander-akait
    Member

    @snitin315 No, will be fixed in the near future, the next PR

  8. alexander-akait commented on Oct 16, 2020

    @alexander-akait
    Member

    Some problems on webpack side with new API, we are working on it, so I will do release with other fixes, but it will be fixed tomorrow with patch release

  9. gimmi commented on Oct 18, 2020

    @gimmi

    Same problem for me when trying to upgrade to [email protected] and [email protected]

  10. alexander-akait commented on Oct 19, 2020

    @alexander-akait
    Member

    @gimmi why need to spam it? I've always tried to figure it out, but I can't, can you explain it to me?

  11. alexander-akait commented on Oct 19, 2020

    @alexander-akait
    Member

    Just note, this is unnecessary using --watch and watch: true together, just remove watch: true from the config

  12. jakebailey commented on Oct 21, 2020

    @jakebailey

    I hit this with the latest versions of everything and I don't have watch: true set, so I don't think this config option being duplicated is the whole story.

  13. alexander-akait commented on Oct 21, 2020

    @alexander-akait
    Member

    @jakebailey Can you provide link on example of problem, removing watch: true should help

  14. 16 remaining items

  15. thisVioletHydra commented on Oct 27, 2020

    @thisVioletHydra
    √ Webpack
      Compiled successfully in 1.55s
    
    [webpack-cli] Compilationdevelopment starting...
    (node:10048) [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.
    (Use `node --trace-deprecation ...` to show where the warning was created)
    
  16. nestorvanz commented on Oct 31, 2020

    @nestorvanz

    I did update to "webpack": "^5.3.2" and the error still appears

    [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.
    
  17. jdelStrother commented on Nov 4, 2020

    @jdelStrother

    I think we're still waiting on a new release ( > 4.1.0 ) for this. If I test against the master branch it seems to work fine.

    (You can use the master branch with yarn add --dev https://gitpkg.now.sh/webpack/webpack-cli/packages/webpack-cli)

    EDIT: which is weird because allegedly 4.1.0 was the one that fixed watch mode. I'm still trying to narrow down exactly what fixed it... The deprecation warning was fixed in 2cb0c0e

  18. alexander-akait commented on Nov 4, 2020

    @alexander-akait
    Member

    Release will be today

  19. alexander-akait commented on Nov 4, 2020

    @alexander-akait
    Member

    Fixed in [email protected], if somebody faced with the problem again, please open a new issue with reproducible test repo, because we tests most of cases 😄

  20. xccjk commented on Dec 16, 2020

    @xccjk

    Fixed in [email protected], if somebody faced with the problem again, please open a new issue with reproducible test repo, because we tests most of cases 😄

    I still have this problem!

    "webpack": "^5.10.3",
    "webpack-cli": "^4.2.0",
    "webpack-dev-server": "^3.11.0"

    node: v14.15.0
    npm: 6.14.8
    mac: 10.14.6

    github

  21. pedro-w commented on Dec 16, 2020

    @pedro-w

    @xccjk I did a fresh checkout of your https://github.com/xccjk/webpack-demo1 and didn't see this problem.

    I did see a "DEP_WEBPACK_COMPILATION_ASSETS" but this comes from html-webpack-plugin

    • node v14.15.1
    • npm 6.14.8
    • Windows 10 x64
  22. xccjk commented on Dec 16, 2020

    @xccjk

    @xccjk I did a fresh checkout of your https://github.com/xccjk/webpack-demo1 and didn't see this problem.

    I did see a "DEP_WEBPACK_COMPILATION_ASSETS" but this comes from html-webpack-plugin

    • node v14.15.1
    • npm 6.14.8
    • Windows 10 x64

    Thank you very much for your reply, but after removing html-webpack-plugin, I still have the same problem. I updated the github address after removing redundant packages

    • node v14.15.0
    • npm 6.14.8
    • mac 10.14.6
  23. lebadapetru commented on Feb 17, 2021

    @lebadapetru

    "webpack": "^5.12", and this still occurs

  24. alexander-akait commented on Feb 17, 2021

    @alexander-akait
    Member

    You need update webpack-cli to the latest stable version

  25. lebadapetru commented on Feb 17, 2021

    @lebadapetru

    i'm not actually using pure webpack but webpack encore which uses webpack-cli 4, i see that 4.5 is the latest version but i guess i'll have to wait for webpack encore to upgrade it

  26. chadleong commented on Feb 17, 2021

    @chadleong

    Running latest webpack 5.22 and webpack-cli 4.5 - No errors !

  27. PeterBowater commented on May 25, 2021

    @PeterBowater

    Once I had updated webpack-cli it was all good :)

  28. xeroxstar commented on Dec 10, 2021

    @xeroxstar

    "webpack": "^5.61.0" getting same warning when I set the watch property value to true in the config file and running this code:

    let entries = [{
        watch : true
    }];
    let compiler = webpack(entries);
    compiler.watch({
        aggregateTimeout: 1000,
        poll: undefined
    },(err, stats) => {})
    

    if I set to false the watch property value in config so the warning is gone. Anyway, this warning I guess is harmless so it's not big deal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions