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
Watch mode not working correctly for certain filetypes #347
Comments
in my project php files are not copied. |
@gewisser what do you mean, problem above not related to |
@HoldYourWaffle I can't find loaders (what you mean says |
(Disclaimer: I know close to nothing about how webpack works internally, I'm just applying my limited knowledge from using it here) Let me word it in a different way: copied files I expect to be watched ( Even though my guess at what could cause this was probably wrong, the issue remains the same: certain filetypes aren't watched & recopied when they should. |
@HoldYourWaffle can't install reproducible test repo, no |
Just clarify, all files which have loaders should be ignored (you should setup |
Oh that's weird. I'll push it when I get home. |
@evilebottnawi Done. |
@HoldYourWaffle can't reproduce you problem |
All files copies (modified and new created) |
Looks you provide not full reproducible test repo |
So problem not in |
I re-cloned the repository I made, and I can with 100% certainty say that it does reproduce the issue on my machine. Perhaps it's a platform specific issue? I checked with
I would upload the log, but I don't think you're going to see anything exciting (mainly the lack of messages). @gewisser Are you able to reproduce the issue with the repository I provided? |
@HoldYourWaffle what is your platform? Please provide log, maybe it is help |
@HoldYourWaffle Also can you test this on previous version ( |
I listed my platform in the original comment. Using v4.6.0 of this plugin didn't help. I have added the logs to the repository (
I think I spotted a 'skipping xxx because it was not modified' somewhere that shouldn't have been skipped, but that may very well be a misread from me. |
@HoldYourWaffle please provide information about you platform, it can't reproduced on |
I can reproduce the bug on Windows 10 using HoldYourWaffle's example repository. When I run I'm using almost the same system as HoldYourWaffle:
@evilebottnawi What further information could help? |
Thanks, investigate |
Do you mean changed file doesn't copied to dist directory, right? |
Yes, you are right. The changed files are not copied to |
I did some more experimenting, and I can confirm that the file gets skipped "because content hasn't changed" (even though it definitely has). |
@gewisser thanks for good video, it is really strange, because i was do same on windows 10 using virtual box image and can't reproduce problem, i have only one idea, @HoldYourWaffle working good on Also we have tests on CI for this and all tests passed, also this package uses in many popular boilerplate and if it will be global problem, we have many issues and 👍 here, so i think problem in IDE /cc @HoldYourWaffle @gewisser @pmwmedia you are using |
I tested it in Visual Studio Code & Notepad++. I don't think the problem lies in the files not being written due to some cache because the actual file system trigger does happen (as shown in the log), the log just says the files get skipped because they 'weren't modified'. This makes me think that the issue lies somewhere in this 'has this file changed' logic. Maybe the file system trigger happens before the changed contents are actually written to the file system? That wouldn't explain why it only happens with certain filetypes though... Either way I'm pretty sure that there's something wrong with the 'has this changed' logic, because the files get deliberately skipped and the |
@HoldYourWaffle Can you create video too with reproducible test repo (https://github.com/HoldYourWaffle/webpack-copy-issue)? |
In theory problem can be on webpack side (i.e. https://github.com/webpack/watchpack, webpack uses this module for watching, maybe you can add |
I don't see how my video would be different from gewisser's, but if you really want me to I'll do it when I get home. I wouldn't be surprised if this issue is on the webpack side, it would explain why certain filetypes do get watched correctly (see my loader theory). |
/cc @HoldYourWaffle @gewisser Right now i am try this on |
@evilebottnawi #355. У меня проблема исчезла. / Problem I have is gone. |
As far as I can tell the new branch fixes the issue 😄 |
hm, great, i will try to add more tests on this PR and release this as patch version in near future |
/cc @HoldYourWaffle @gewisser Please provide more information. We can't merge PR above because it is break other use cases. Maybe you can will do deeply debug, it is not difficult, just add I think it is bug in chokidar (https://github.com/paulmillr/chokidar). |
@evilebottnawi в коммите #355 только 3 файла были модифицированы? У меня ещё изменён и index.js |
I'm not sure the failing of the test is related to the PR, the failing test fails on the master branch too.
|
@HoldYourWaffle @gewisser problem not in plugin, so we don't fix it here, windows support |
Download https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/ any machines and try to reproduce problem (i can't, all works as expected) |
The problem still persist. Changes made by d808657 didn't help. Chokidar exonerationSurprisingly, chokidar (v2.1.2) is working well for me. It detects all changes made to desired files. I'm using a non-standard web-server configuration which utilizes webpack's nodejs api The obvious solution is to attempt to combine chokidar with webpack's const sources = chokidar.watch(`./src/folder_with_files_to_watch/**.*`)
sources.on(`ready`, function() {
sources.on(`all`, function() {
// ...
webpackWatch.invalidate();
})
}) But it turns out it doesn't force plugin to re-emit files once bundle is invalidated so I have concluded that the problem is somewhere between chokidar and webpack itself. Platform and setup: |
@hinell maybe you can create minimum reproducible test repo? |
@evilebottnawi I think I have narrowed down the problem. It turns out that it derives from difference in treatment of folders and files in patterns. Here is an example. I have configured the plugin approximately in the following way: new CopyPlugin([
{ from: `./src/public/`, },
...
]) It fails to see any changes and here is why The ProblemAs you can see in the example above the directory if (pattern.fromType === 'glob') {
fileDependencies.add(file.absoluteFrom);
} If you follow the source code up and find pattern.fromType = 'glob'; assignment you can see that it is primarily assigned for glob-patterns only. Checkout the sources here and here (mentions are found only in new CopyPlugin([
{ from: `./path/to/myfile.json`, to: `myfile.json` },
]) Run webpack in watchmode and then edit the file. Webpack will not rebuild. The SolutionJust add glob pattern like new CopyPlugin([
{ from: `./src/public/**.*`, to: `subFolder/`, flatten: true },
]) Additionally it would be nice if docs clarify how exactly files are watched and how to configure it properly until problem with non-glob files and directories is fixed. |
@evilebottnawi Скачал по указанной тобой ссылке: https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/ образ виртуальной машины. Перенес проект, |
@gewisser очень интересно, можете ли вы создать минимальный вопроизводимый репозиторий, может быть чтото в конфигурации webpack? Или какой то другой плагин все ломает? Также укажите какой конкретно образ скачали (IE10/IE11) ? |
@gewisser Будет отлично, посмотрю сегодня вечером в чем же проблема |
@evilebottnawi Отправил на почту she......@gmail.com |
Find a bug https://github.com/webpack/watchpack/blob/v1.6.0/lib/DirectoryWatcher.js#L260, webpack stores watching files in |
To solve this you'd simply need to add path normalization right? |
And yes and no, WIP on this |
Done in #359, feel free to test and feedback |
In my tests the PR solved the issue perfectly 😄 |
I can also report that the PR fixes the instance I reported in the duplicate issue #358. |
Great, release today |
Expected Behavior
copy-and-watch
npm module does this already by watching the parent directory and copying any files that match the glob. (Linking to a specific commit in my own fork because it actually works there, and in my opinion it's more readable before I had to reformat because of lint settings.)Actual Behavior
At first I thought copied files weren't watched at all, but after some headaches I found out that it's just files without a webpack loader.
json
files are copied,ejs
files aren't.To add salt to injury, in my own project these "no-loader" files got copied sometimes when I modified another file that did have a loader first and if they were copied by a glob, and then it still only worked once for some reason. However I wasn't able to reproduce this behavior in my reproducing-repository (it might have something to do with the
context
option). For now I think we should focus on making it work in a not-complicated environment, if the issue persists after that I'll look into it more extensively.As far as I can tell the
copyUnmodified
option doesn't change anything.Code
I've created a reproducing repository here, for my own project is private.
How Do We Reproduce?
npx webpack --watch
ejs
files or create a new file in theassets
directoryThe text was updated successfully, but these errors were encountered: