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
Provide option to disable initial compilation when watching #4991
Comments
Are you seeing bottlenecks at this point of the compilation process? |
Hi @TheLarkInn, only in the sense that it may take upwards of 30-60 seconds (and scaling with each entry) every time I go to start watching. Often times I'll turn it on, flip back to the code, make a couple tweaks, save, switch to the browser, refresh, and then realize that it just finished the first compilation so the changes I just made weren't included. So then I go save again, and I'm good to go. It's just was feels like an unnecessary hickup in the workflow. |
Sounds like a bug. I should actually work this way. It compares timestamp to build start timestamp when starting watching, so this should detect changes between start of compilation and start of watching. |
This is very much needed. Babel CLI has --skip-initial-build option for example. My use case is a Lerna monorepo with libraries (Babelized and Webpacked) and demos, I need to build all libs as phase 1 and then run demos + watch on phase 2, so the more libs you have the more inefficient it becomes. Currently the watch procedure looks like this: {
"scripts": {
"build": "lerna run build --scope=@xxx/lib-* --concurrency=1 --stream",
"start": "npm run build && lerna run start --parallel"
}
} Since Lerna's --parallel completely disregards topology this phased approach is a must, demos are independent of each other while libs have dependencies on each other and demos depend on libs. |
I have a use case where I want, inside a Makefile, to build once, then run a bash script, then start watching. Right now the watch will kick off an unnecessary build. |
I have created this PR which adds: module.exports = {
// ...
watchOptions: {
skipInitialEmit: false
}
} |
@alshdavid duplicate #9730 ? |
@evilebottnawi, any chance you've had a chance to review the PR? |
#9730 is a duplicate dated Sep 24. This one here seems to be the original issue from 2017. |
So it's been over 3 years now since the first report. Any update on this? |
The persistent cache in webpack 5 is basically that. Instead of compiling all modules it restores them from the cache, only builds changes and watches the files. |
How would this impact developers running several webpack instances, where the output of one is required as an input for the other? |
@alshdavid It is side of your code, you need run first compilation, then run second, you can run them in the same time |
My personal reason why I would love to have this feature is that in my current project I run the hosting and the building of the code parallel and cannot make the hosting wait for the first build to happen. So currently the hosting script will start running the old code, then do a live reload after a few seconds when webpack is done with the initial build. I would love to change this to only start the building first, then start the hosting and watching for changes later. I've looked at solutions, which try to leach onto webpack's build events, but either the repos are no longer maintained (you get errors in the console because of that) or you have to add this logic into webpack config. With this addition it could all be done within the scripts of package.json. |
Is the best solution |
I have been using {
"name": "@org/project-root",
"private": true,
"workspace": [
"./packages"
],
"scripts": {
"start": "npm run clean && npx concurrently \"npm run watch:a\" \"npm run wait:a && npm run watch:b\" \"npm run wait:b && npm run serve:b\"",
"clean": "npm run clean:a && npm run clean:b",
"clean:a": "rm -r -f ./packages/a/dist",
"clean:b": "rm -r -f ./packages/b/dist",
"wait:a": "npx wait-on packages/a/dist/index.js",
"wait:b": "npx wait-on packages/b/dist/index.js",
"watch:a": "cd packages/a && npx webpack --watch",
"watch:b": "cd packages/b && npx webpack --watch",
"serve:b": "cd packages/b/dist && npx http-server ."
},
"devDependencies": {
"concurrently": "*",
"webpack": "*",
"http-server": "*",
"wait-on": "*"
}
} |
My current setup is similar, though I use
As I see |
It is good solutions 👍 I don't think it is our side how you will run compilations, because we don't know about it nothing |
This issue had no activity for at least three months. It's subject to automatic issue closing if there is no activity in the next 15 days. |
okay, then: bump Did anyone find any solutions or even alternatives for this? |
Answer here #9730 (comment), we can't skip otherwise we can't track your deps, but if you want to improve initial start you can use https://webpack.js.org/configuration/other-options/#cachetype with the
We done it for webpack v5 (https://github.com/webpack/webpack/blob/master/lib/Compiler.js#L709) |
Do you want to request a feature or report a bug?
Feature Request
What is the current behavior?
When
webpack --watch
is first run, the first thing it does it compile all of the entries.If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
For webpack to simply start watching the files and not immediately compile. But given that this doesn't apply as much to single-entry instances, at least have an option for it.
If this is a feature request, what is motivation or use case for changing the behavior?
Given the number of entries (and if sourcemaps are enabled) this can can take a significant amount of time. With this feature one would be able to enable watching and immediately get to work without having to worry about whether it's finishing compiling and is actually watching, yet.
Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
Node: 4.5.0
Webpack: 2.6.1
OS: Windows 10
The text was updated successfully, but these errors were encountered: