You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
start Webpack file watcher by running npm run watch
change the file in ./package/Logger (you could try changing the message getter for example, this way the changes are easy to see)
What is the expected behavior?
The changes made in Logger module should appear on the page (e.g. Logger should append a different message). Instead Webpack doesn't re-build the Logger module.
You need webpack-dev-server if you want to see changes on the page, please update webpack-cli to the latest version, install webpack-dev-server and use webpack serve command to run dev server, --watch only watch files (it can be useful for developers which develop library and other rare cases), it is not include client code for reloading and hot module replacement
@alexander-akaitwatch doesn't re-build ../package/Logger.js is it really expected behavior? watch is supposed to re-build files if any is changed, does it include packages as well? If so, then it is a bug.
Because you need dev server to reload page as I described above, webpack only bundle files and nothing to know when you need reload page, so you need webpack-dev-server and webpack to see changes on the page
The problem that I am experiencing is that the dist/package.[hash].js does not include changes made in watch mode, it is only possible if i change symlinks to true
I added it blindly to my config but everything got even worse:
/Users/ilyakortasov/Documents/sandbox/webpack-aliases/project/node_modules/watchpack/lib/LinkResolver.js:94
throw e;
^
Error: ENOENT: no such file or directory, readlink '/Users/ilyakortasov/Documents/sandbox/webpack-aliases/project/Users'
at Object.readlinkSync (fs.js:1035:3)
at LinkResolver.resolve (/Users/ilyakortasov/Documents/sandbox/webpack-aliases/project/node_modules/watchpack/lib/LinkResolver.js:47:27)
at LinkResolver.resolve (/Users/ilyakortasov/Documents/sandbox/webpack-aliases/project/node_modules/watchpack/lib/LinkResolver.js:36:31)
at LinkResolver.resolve (/Users/ilyakortasov/Documents/sandbox/webpack-aliases/project/node_modules/watchpack/lib/LinkResolver.js:36:31)
at LinkResolver.resolve (/Users/ilyakortasov/Documents/sandbox/webpack-aliases/project/node_modules/watchpack/lib/LinkResolver.js:36:31)
at LinkResolver.resolve (/Users/ilyakortasov/Documents/sandbox/webpack-aliases/project/node_modules/watchpack/lib/LinkResolver.js:36:31)
at LinkResolver.resolve (/Users/ilyakortasov/Documents/sandbox/webpack-aliases/project/node_modules/watchpack/lib/LinkResolver.js:36:31)
at LinkResolver.resolve (/Users/ilyakortasov/Documents/sandbox/webpack-aliases/project/node_modules/watchpack/lib/LinkResolver.js:36:31)
at LinkResolver.resolve (/Users/ilyakortasov/Documents/sandbox/webpack-aliases/project/node_modules/watchpack/lib/LinkResolver.js:36:31)
at LinkResolver.resolve (/Users/ilyakortasov/Documents/sandbox/webpack-aliases/project/node_modules/watchpack/lib/LinkResolver.js:36:31) {
errno: -2,
syscall: 'readlink',
code: 'ENOENT',
path: '/Users/ilyakortasov/Documents/sandbox/webpack-aliases/project/Users'
}
But you can't do it, you need resolve symlinks, because ./node_modules/package is link, even followSymlinks will not help, because you use import { Logger } from 'package/Logger'; and package/Logger is link, so resolving impossible
You see we use Webpack aliases in our project, these aliases need to work not only in the project directory but also in the symlinked package directories. If we resolve symlinks, then Webpack aliases don't work inside symlinked packages and everything crashes. Is there any other workaround?
The best way to explain is with code: go to the minimal reproducible repo and switch to aliases branch, then run npm run watch, Webpack will not be able to resolve generated because of symlinks: true option. If you set symlinks to false, then everything works. Note: I just updated my repo, make sure to pull it first
Activity
alexander-akait commentedon Jan 25, 2021
Can't reproduce, watch works as expected
alexander-akait commentedon Jan 25, 2021
You need
webpack-dev-serverif you want to see changes on the page, please updatewebpack-clito the latest version, installwebpack-dev-serverand usewebpack servecommand to run dev server,--watchonly watch files (it can be useful for developers which develop library and other rare cases), it is not include client code for reloading and hot module replacementTomSssM commentedon Jan 25, 2021
@alexander-akait
watchdoesn't re-build../package/Logger.jsis it really expected behavior?watchis supposed to re-build files if any is changed, does it include packages as well? If so, then it is a bug.alexander-akait commentedon Jan 25, 2021
It re-build files, look at console
alexander-akait commentedon Jan 25, 2021
No, changes will not be appeared, because nobody reload the page
alexander-akait commentedon Jan 25, 2021
Changes works on each change on
Logger.js:TomSssM commentedon Jan 25, 2021
Changes are still missing after full page reload, bundle containing the code from
packagelikewise doesn't update though Webpack writes logsalexander-akait commentedon Jan 25, 2021
Because you need dev server to reload page as I described above, webpack only bundle files and nothing to know when you need reload page, so you need webpack-dev-server and webpack to see changes on the page
alexander-akait commentedon Jan 25, 2021
Oh, I see the problem
TomSssM commentedon Jan 25, 2021
The problem that I am experiencing is that the
dist/package.[hash].jsdoes not include changes made in watch mode, it is only possible if i changesymlinkstotrueTomSssM commentedon Jan 25, 2021
I wonder if it is a good idea to add something like
followSymlinkstowatchOptionsso that the file watcher will resolve symlinks in watch mode1 remaining item
alexander-akait commentedon Jan 25, 2021
followSymlinksalready inwatchOptionsTomSssM commentedon Jan 25, 2021
I can't find it here https://webpack.js.org/configuration/watch/ Is it somewhere else?
TomSssM commentedon Jan 25, 2021
Let's just say in the project I am working on it is necessary to disable symlinks =)
alexander-akait commentedon Jan 25, 2021
webpack/webpack.js.org#4483
TomSssM commentedon Jan 25, 2021
I added it blindly to my config but everything got even worse:
alexander-akait commentedon Jan 25, 2021
But you can't do it, you need resolve
symlinks, because./node_modules/packageis link, evenfollowSymlinkswill not help, because you useimport { Logger } from 'package/Logger';andpackage/Loggeris link, so resolving impossibleTomSssM commentedon Jan 25, 2021
You see we use Webpack aliases in our project, these aliases need to work not only in the project directory but also in the symlinked package directories. If we resolve symlinks, then Webpack aliases don't work inside symlinked packages and everything crashes. Is there any other workaround?
alexander-akait commentedon Jan 25, 2021
I don't see, inpackage.jsonPlease clarify, aliases work everywhere
No workarounds, you disable symlinks, but wait they will work 😕WrongTomSssM commentedon Jan 25, 2021
The best way to explain is with code: go to the minimal reproducible repo and switch to
aliasesbranch, then runnpm run watch, Webpack will not be able to resolvegeneratedbecause ofsymlinks: trueoption. If you setsymlinkstofalse, then everything works.Note: I just updated my repo, make sure to pull it first
alexander-akait commentedon Jan 25, 2021
Bug in cache, set
cache: false,and all works finealexander-akait commentedon Jan 25, 2021
Original issue - #12246
PR - #12254
TomSssM commentedon Jan 25, 2021
Horray! Everything works now, thanks 🎉
alexander-akait commentedon Jan 25, 2021
Some things were a little unclear, I thought you were expecting an automatic reload and want fully disable symlinks, let's close because duplicate
TomSssM commentedon Jan 25, 2021
Oh I see now why you thought this way, gotta be clearer next time =)