Do you want to request a feature or report a bug?
What is the current behavior?
--watch mode is not specified, Webpack always runs the function in the config file on the inputs, to produce the output.
If the current behavior is a bug, please provide the steps to reproduce.
- Specify a Webpack function that transforms the inputs into an output, in a config file.
- Make a change to one of the input files and save it.
- Invoke webpack with
webpack --config /path/to/config.json, to write the output file as a function of the inputs.
- Immediately run
webpackagain with the same commands.
What is the expected behavior?
The second time
webpack is invoked, I expect it to detect that the mtimes of the inputs are all older than the mtimes of the output file, print that there is no work to be done, and exit with a 0 return code.
If this is a feature request, what is motivation or use case for changing the behavior?
output.js: static/one.js static/two.js
and invoke it with:
Make will check the mtimes of
output.js (which you can check by using the Lstat syscall on the affected files). If the mtime for output.js is newer than its inputs, make outputs the following:
make: Nothing to be done for `output.js'.
And exits with a 0 return code. This means it is faster – make does not do unnecessary work – and more composable. It is always easy to invoke
make output.js as part of another build script, since make will exit early if there is no work to be done.
By contrast, webpack does all of the work every single time. This makes it more difficult to compose as part of a larger build process, since invoking webpack means the work is always performed even if there is no point in doing the work since the inputs haven’t changed since the output file was written.
In addition to doing unnecessary work, webpack has a slower startup time than
make. Here is the amount of time it takes
make to print the version string:
$ time make -v GNU Make 4.2.1 Built for x86_64-apple-darwin16.6.0 Copyright (C) 1988-2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. make -v 0.00s user 0.00s system 32%% cpu 0.026 total
Or 26 milliseconds. It takes
webpack, released 36 years later, about 8 times as long to print the version string:
$ time webpack -v 2.6.1 webpack -v 0.17s user 0.04s system 84%% cpu 0.242 tota
This is a significant performance regression, both in startup time and in the amount of work that is performed. It’s especially confusing given the modest improvements in CPU performance, and the increases in available RAM, in the years between 1976 and 2012.
It would be nice if performance improved along one or both of these axes.